LibTest: Support death tests without child process cloning

A challenge for getting LibTest working on Windows has always
been CrashTest. It implements death tests similar to Google Test
where a child process is cloned to invoke the expression that
should abort/terminate the program. Then the exit code of the
child is used by the parent test process to verify if the
application correctly aborted/terminated due to invoking
the expression.

The problem was that finding an equivalent way to port Crash::run()
to Windows was not looking very likely as publicly exposed Win32/
Native APIs have no equivalent to fork(); however, Windows actually
does have native support for process cloning via undocumented NT
APIs that clever people reverse engineered and published, see
`NtCreateUserProcess()`.

All that being said, this `EXPECT_DEATH()` implementation avoids
needing to use a child process in general, allowing us to remove
CrashTest in favour of a single cross-platform solution for death
tests.
This commit is contained in:
ayeteadoe 2025-05-15 07:55:33 -07:00 committed by Andrew Kaster
commit 744fd91d0b
Notes: github-actions[bot] 2025-05-16 19:24:44 +00:00
13 changed files with 133 additions and 101 deletions

View file

@ -170,10 +170,8 @@ TEST_CASE(iterate_utf8)
EXPECT(iterator.done());
EXPECT(!iterator.peek(0).has_value());
EXPECT_CRASH("Dereferencing Utf8CodePointIterator which is already done.", [&iterator] {
*iterator;
return Test::Crash::Failure::DidNotCrash;
});
EXPECT_DEATH("Dereferencing Utf8CodePointIterator which is already done.", *iterator);
}
TEST_CASE(decode_invalid_ut8)