X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/15de9d6b4ab2de27ae24b13b7b6c4d55fffe4aef..974e388456677d82eb6d10d4fd72390641a5bdfe:/tests/nxheap.c diff --git a/tests/nxheap.c b/tests/nxheap.c index eb521e8..d75dc48 100644 --- a/tests/nxheap.c +++ b/tests/nxheap.c @@ -1,53 +1,41 @@ -#include #include #include +#include +#include -char *heap; -volatile int pass; -sigjmp_buf jbuf; +#include -void +static char *heap; +static volatile int pass; +static sigjmp_buf jbuf; + +static void __dead2 action(int signo, struct __siginfo *info, void *uap __attribute__((unused))) { if (info) { pass = (signo == SIGBUS && info->si_addr == heap); } - return siglongjmp(jbuf, 0); + siglongjmp(jbuf, 0); } -int -main(void) +T_DECL(nxheap, "Non-executable heap", T_META_CHECK_LEAKS(NO)) { - int ret; - struct sigaction sa = { .__sigaction_u.__sa_sigaction = action, .sa_flags = SA_SIGINFO, }; - test_start("Non-executable heap"); - - ret = sigaction(SIGBUS, &sa, NULL); - assert(ret == 0); - test_long("sigaction", ret, 0); + T_ASSERT_POSIX_ZERO(sigaction(SIGBUS, &sa, NULL), NULL); if (sigsetjmp(jbuf, 0)) { - // PASS - test_long("SIGBUS", 1, 1); - test_stop(); - return EXIT_FAILURE; + T_PASS("SIGBUS"); + T_END; } - heap = malloc(1); - test_ptr_notnull("malloc", heap); + T_QUIET; T_ASSERT_NOTNULL((heap = malloc(1)), NULL); - *heap = 0xc3; // retq + *heap = (char)0xc3; // retq ((void (*)(void))heap)(); // call *%eax - // FAIL - test_long("SIGBUS", 0, 1); - - test_stop(); - - return EXIT_SUCCESS; + T_FAIL("SIGBUS"); }