Commit graph

3 commits

Author SHA1 Message Date
Johan Dahlin
29355a0e33 LibTest: Prevent -dead_strip from removing assertion handler
The ak_assertion_handler symbol is referenced only through a weak
symbol in AK/Assertions.cpp. With -dead_strip on macOS, the linker
strips the strong definition, breaking EXPECT_DEATH tests which rely
on the handler to longjmp back instead of crashing.

Add retain and used attributes to prevent the linker from removing it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 18:36:27 +01:00
Undefine
5b5a881992 LibTest: Fix custom assertion handler on FreeBSD and OpenBSD
Those systems expect sigjmp_buf to be passed to sigsetjmp / siglongjmp
instead of jmp_buf.
2026-01-12 20:58:21 +01:00
ayeteadoe
744fd91d0b 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.
2025-05-16 13:23:32 -06:00