]>
git.saurik.com Git - apple/xnu.git/blob - tests/text_corruption.c
4 #include <darwintest.h>
5 #include <darwintest_utils.h>
7 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(false));
10 * No system(3c) on watchOS, so provide our own.
11 * returns -1 if fails to run
12 * returns 0 if process exits normally.
13 * returns +n if process exits due to signal N
16 my_system(const char *command
)
22 const char *argv
[] = {
29 if (dt_launch_tool(&pid
, (char **)(void *)argv
, FALSE
, NULL
, NULL
)) {
33 err
= dt_waitpid(pid
, &status
, &signal
, 30);
43 * The tests are run in the following order:
46 * - corrupt foo, then call foo
50 * - corrupt atan, then call atan
53 * The first and last of each should exit normally. The middle one should exit with SIGILL.
55 * atan() was picked as a shared region function that isn't likely used by any normal daemons.
57 T_DECL(text_corruption_recovery
, "test detection/recovery of text corruption",
58 T_META_IGNORECRASHES(".*text_corruption_helper.*"),
63 ret
= my_system("./text_corruption_helper foo");
64 T_QUIET
; T_ASSERT_EQ(ret
, 0, "First call of foo");
66 ret
= my_system("./text_corruption_helper Xfoo");
67 T_QUIET
; T_ASSERT_EQ(ret
, SIGILL
, "Call of corrupted foo");
69 ret
= my_system("./text_corruption_helper foo");
70 T_QUIET
; T_ASSERT_EQ(ret
, 0, "Fixed call of foo");
72 ret
= my_system("./text_corruption_helper atan");
73 T_QUIET
; T_ASSERT_EQ(ret
, 0, "First call of atan");
75 ret
= my_system("./text_corruption_helper Xatan");
76 T_QUIET
; T_ASSERT_EQ(ret
, SIGILL
, "Call of corrupted atan");
78 ret
= my_system("./text_corruption_helper atan");
79 T_QUIET
; T_ASSERT_EQ(ret
, 0, "Fixed call of atan");