summaryrefslogtreecommitdiff
path: root/Tests/LibC/TestAbort.cpp
blob: c2580f7c885cb3f717dc0f0b5f55b0a598aa3a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * 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;
    });
    EXPECT_CRASH_WITH_SIGNAL("This should _abort with SIGILL signal", SIGILL, [] {
        _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;
    });
}