serenity/Tests/LibC/TestAbort.cpp
Sönke Holz eabf37da29 Tests/LibC+LibC: Don't assume __builtin_trap causes SIGILL
__builtin_trap() gets compiled to a breakpoint instruction on
riscv64 GCC, aarch64 GCC, and aarch64 Clang.
2024-10-04 12:06:40 -06:00

30 lines
615 B
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <signal.h>
#include <stdlib.h>
TEST_CASE(_abort)
{
EXPECT_CRASH("This should _abort", [] {
_abort();
return Test::Crash::Failure::DidNotCrash;
});
}
TEST_CASE(abort)
{
EXPECT_CRASH("This should abort", [] {
abort();
return Test::Crash::Failure::DidNotCrash;
});
EXPECT_CRASH_WITH_SIGNAL("This should abort with SIGABRT signal", SIGABRT, [] {
abort();
return Test::Crash::Failure::DidNotCrash;
});
}