]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/xnu_quick_test/helpers/launch.c
c9b1357890012a66d4aa22b7f7680e4d970e977c
2 * Part of the execve tests. This program should not be compiled fat. xnu_quick_test
3 * will call the various single-architecture builds of this program as helpers to test
4 * the exec() transitions it cannot test itself.
6 * When running on a 64-bit machine (x86_64 or PPC64), the 32-bit version of
7 * xnu_quick_test will fork and exec a 64-bit helper process that performs
9 * 1. 64 bit process forking() 64-bit child, child execing() 64-bit file(4GB pagezero)
10 * 2. 64 bit process forking() 64-bit child, child execing() 64-bit file (4KB pagezero)
11 * 3. 64 bit process forking() 64-bit child, child execing() 32-bit file
13 * The 64-bit version of xnu_quick_test will fork and exec a 32-bit process
14 * that performs the following tests.
15 * 4. 32 bit process forking() 32-bit child, child execing() 32-bit file
16 * 5. 32 bit process forking() 32-bit child, child execing() 64 bit file (4GB pagezero)
17 * 6. 32 bit process forking() 32-bit child, child execing() 64 bit file (4KB pagezero)
22 #include <sys/types.h>
23 #include <sys/syscall.h>
25 extern int do_execve_test(char * path
, char * argv
[], void * envp
, int killwait
);
26 extern int get_bits(void);
29 int main(int argc
, const char * argv
[])
31 int my_err
, my_status
;
32 pid_t my_pid
, my_wait_pid
;
34 char * argvs
[2] = {"", NULL
};
35 int bits
= get_bits(); /* Gets actual processor bit-ness. */
39 * This is the helper binary for the x86_64 version of xnu_quick_test. xnu_quick_test
40 * forks and execs this code to test exec()ing from a 32-bit binary.
42 errmsg
= "execve failed: from i386 forking and exec()ing i386 process.\n";
43 argvs
[0] = "sleep-i386";
44 if (do_execve_test("helpers/sleep-i386", argvs
, NULL
, 0)) goto test_failed_exit
;
46 errmsg
= "execve failed: from i386 forking and exec()ing x86_64 process w/ 4G pagezero.\n";
47 argvs
[0] = "sleep-x86_64-4G";
48 if (do_execve_test("helpers/sleep-x86_64-4G", argvs
, NULL
, 0)) goto test_failed_exit
;
50 errmsg
= "execve failed: from i386 forking and exec()ing x86_64 process w/ 4K pagezero.\n";
51 argvs
[0] = "sleep-x86_64-4K";
52 if (do_execve_test("helpers/sleep-x86_64-4K", argvs
, NULL
, 0)) goto test_failed_exit
;
56 #if defined(__x86_64__)
58 * This is the helper binary for the i386 version of xnu_quick_test. xnu_quick_test
59 * forks and execs this code to test exec()ing from a 64-bit binary.
61 errmsg
= "execve failed: from x86_64 forking and exec()ing 64-bit x86_64 process w/ 4G pagezero.\n";
62 argvs
[0] = "sleep-x86_64-4G";
63 if (do_execve_test("helpers/sleep-x86_64-4G", argvs
, NULL
, 1)) goto test_failed_exit
;
65 errmsg
= "execve failed: from x86_64 forking and exec()ing 64-bit x86_64 process w/ 4K Pagezero.\n";
66 argvs
[0] = "sleep-x86_64-4K";
67 if (do_execve_test("helpers/sleep-x86_64-4K", argvs
, NULL
, 1)) goto test_failed_exit
;
69 errmsg
= "execve failed: from x64_64 forking and exec()ing 32-bit i386 process.\n";
70 argvs
[0] = "sleep-i386";
71 if (do_execve_test("helpers/sleep-i386", argvs
, NULL
, 1)) goto test_failed_exit
;
76 * We are ourselves launched with do_execve_test, which wants a chance to