Skip to content

Commit

Permalink
test fork failure in aborts(...) (#18)
Browse files Browse the repository at this point in the history
Change-Id: Ib254785f7904c5a8d6d04d599e482a4602818a37
  • Loading branch information
oliverlee authored Dec 25, 2023
1 parent 5ebbea2 commit 447bd9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ skytest_test(
],
)

skytest_test(
name = "aborts_with_failed_fork_test",
srcs = [
"aborts_with_failed_fork_test.cpp",
"failing_fork.cpp",
],
return_code = 1,
stdout = [
"unable to fork process",
"0 tests passed.*1 test failed",
],
)

cc_library(
name = "no_malloc",
srcs = ["no_malloc.cpp"],
Expand Down
10 changes: 10 additions & 0 deletions test/aborts_with_failed_fork_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "skytest/skytest.hpp"

auto main() -> int
{
using namespace ::skytest::literals;
using ::skytest::aborts;
using ::skytest::expect;

"fork fails"_test = [] { return expect(aborts([] {})); };
}
8 changes: 8 additions & 0 deletions test/failing_fork.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <unistd.h>

extern "C" {
auto fork() -> pid_t
{
return -1;
}
}

0 comments on commit 447bd9c

Please sign in to comment.