mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
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:
parent
dc707e6ed8
commit
744fd91d0b
Notes:
github-actions[bot]
2025-05-16 19:24:44 +00:00
Author: https://github.com/ayeteadoe
Commit: 744fd91d0b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4698
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/R-Goc
13 changed files with 133 additions and 101 deletions
|
@ -206,10 +206,7 @@ TEST_CASE(from_code_points)
|
|||
auto string = String::from_code_point(0x10ffff);
|
||||
EXPECT_EQ(string, "\xF4\x8F\xBF\xBF"sv);
|
||||
|
||||
EXPECT_CRASH("Creating a string from an invalid code point", [] {
|
||||
String::from_code_point(0xffffffff);
|
||||
return Test::Crash::Failure::DidNotCrash;
|
||||
});
|
||||
EXPECT_DEATH("Creating a string from an invalid code point", (void)String::from_code_point(0xffffffff));
|
||||
}
|
||||
|
||||
TEST_CASE(substring)
|
||||
|
@ -1147,10 +1144,7 @@ TEST_CASE(repeated)
|
|||
EXPECT_EQ(string3, "𐌀𐌀𐌀𐌀𐌀𐌀𐌀𐌀𐌀𐌀"sv);
|
||||
}
|
||||
|
||||
EXPECT_CRASH("Creating a string from an invalid code point", [] {
|
||||
(void)String::repeated(0xffffffff, 1);
|
||||
return Test::Crash::Failure::DidNotCrash;
|
||||
});
|
||||
EXPECT_DEATH("Creating a string from an invalid code point", (void)String::repeated(0xffffffff, 1));
|
||||
}
|
||||
|
||||
TEST_CASE(join)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue