diff options
author | Andrew Kaster <akaster@serenityos.org> | 2021-06-30 22:40:03 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-06 17:22:45 +0200 |
commit | d0447f23b851b8e13052a35f1cd7de5f4ab44a03 (patch) | |
tree | 020360e7c435a60a6756c1e746746ff0d3ebf968 /Tests/LibC | |
parent | f0d562131ffcb2d84f9f0cc32b86ab244b82d1e5 (diff) | |
download | serenity-d0447f23b851b8e13052a35f1cd7de5f4ab44a03.zip |
Tests+Base: Convert stack-smash to be LibTest based and stop skipping it
Now that the test is converted to be LibTest based, we can remove it
from the exclude list in /home/anon/.config/Tests.ini.
Prior to this it would crash and fail because it was signaled instead of
returning normally with exit code 0.
Diffstat (limited to 'Tests/LibC')
-rw-r--r-- | Tests/LibC/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/LibC/TestStackSmash.cpp (renamed from Tests/LibC/stack-smash.cpp) | 16 |
2 files changed, 10 insertions, 7 deletions
diff --git a/Tests/LibC/CMakeLists.txt b/Tests/LibC/CMakeLists.txt index a4f8a4ce0b..3c5dc09d43 100644 --- a/Tests/LibC/CMakeLists.txt +++ b/Tests/LibC/CMakeLists.txt @@ -7,6 +7,7 @@ set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCDirEnt.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCInodeWatcher.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCString.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TestStackSmash.cpp ) file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") diff --git a/Tests/LibC/stack-smash.cpp b/Tests/LibC/TestStackSmash.cpp index 6a2a303951..bcea97d501 100644 --- a/Tests/LibC/stack-smash.cpp +++ b/Tests/LibC/TestStackSmash.cpp @@ -4,7 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <cstdio> +#include <AK/Format.h> +#include <LibTest/TestCase.h> // Note: Needs to be 'noline' so stack canary isn't optimized out. static void __attribute__((noinline)) smasher(char* string) @@ -24,11 +25,12 @@ static void __attribute__((noinline)) stack_to_smash() smasher(string); } -int main() +TEST_CASE(stack_smash) { - puts("[+] Starting the stack smash..."); - stack_to_smash(); - puts("[+] Stack smash wasn't detected!"); - - return 0; + EXPECT_CRASH("Smash the stack and trigger __stack_chk_fail", [] { + outln("[+] Starting the stack smash..."); + stack_to_smash(); + outln("[+] Stack smash wasn't detected!"); + return Test::Crash::Failure::DidNotCrash; + }); } |