TestAbort.cpp 848 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibTest/TestCase.h>
  7. #include <assert.h> // FIXME: Remove when `_abort` is moved to <stdlib.h>
  8. #include <signal.h>
  9. #include <stdlib.h>
  10. TEST_CASE(_abort)
  11. {
  12. EXPECT_CRASH("This should _abort", [] {
  13. _abort();
  14. return Test::Crash::Failure::DidNotCrash;
  15. });
  16. EXPECT_CRASH_WITH_SIGNAL("This should _abort with SIGILL signal", SIGILL, [] {
  17. _abort();
  18. return Test::Crash::Failure::DidNotCrash;
  19. });
  20. }
  21. TEST_CASE(abort)
  22. {
  23. EXPECT_CRASH("This should abort", [] {
  24. abort();
  25. return Test::Crash::Failure::DidNotCrash;
  26. });
  27. EXPECT_CRASH_WITH_SIGNAL("This should abort with SIGABRT signal", SIGABRT, [] {
  28. abort();
  29. return Test::Crash::Failure::DidNotCrash;
  30. });
  31. }