]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/xnu_quick_test/helpers/launch.c
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)
21 #include <sys/types.h>
22 #include <sys/syscall.h>
24 extern int do_execve_test(char * path
, char * argv
[], void * envp
, int killwait
);
25 extern int get_bits(void);
28 int main(int argc
, const char * argv
[])
30 int my_err
, my_status
;
31 pid_t my_pid
, my_wait_pid
;
33 char * argvs
[2] = {"", NULL
};
34 int bits
= get_bits(); /* Gets actual processor bit-ness. */
38 * This is the helper binary for the x86_64 version of xnu_quick_test. xnu_quick_test
39 * forks and execs this code to test exec()ing from a 32-bit binary.
41 errmsg
= "execve failed: from i386 forking and exec()ing i386 process.\n";
42 argvs
[0] = "sleep-i386";
43 if (do_execve_test("helpers/sleep-i386", argvs
, NULL
, 0)) goto test_failed_exit
;
45 errmsg
= "execve failed: from i386 forking and exec()ing x86_64 process w/ 4G pagezero.\n";
46 argvs
[0] = "sleep-x86_64-4G";
47 if (do_execve_test("helpers/sleep-x86_64-4G", argvs
, NULL
, 0)) goto test_failed_exit
;
49 errmsg
= "execve failed: from i386 forking and exec()ing x86_64 process w/ 4K pagezero.\n";
50 argvs
[0] = "sleep-x86_64-4K";
51 if (do_execve_test("helpers/sleep-x86_64-4K", argvs
, NULL
, 0)) goto test_failed_exit
;
55 #if defined(__x86_64__)
57 * This is the helper binary for the i386 version of xnu_quick_test. xnu_quick_test
58 * forks and execs this code to test exec()ing from a 64-bit binary.
60 errmsg
= "execve failed: from x86_64 forking and exec()ing 64-bit x86_64 process w/ 4G pagezero.\n";
61 argvs
[0] = "sleep-x86_64-4G";
62 if (do_execve_test("helpers/sleep-x86_64-4G", argvs
, NULL
, 1)) goto test_failed_exit
;
64 errmsg
= "execve failed: from x86_64 forking and exec()ing 64-bit x86_64 process w/ 4K Pagezero.\n";
65 argvs
[0] = "sleep-x86_64-4K";
66 if (do_execve_test("helpers/sleep-x86_64-4K", argvs
, NULL
, 1)) goto test_failed_exit
;
68 errmsg
= "execve failed: from x64_64 forking and exec()ing 32-bit i386 process.\n";
69 argvs
[0] = "sleep-i386";
70 if (do_execve_test("helpers/sleep-i386", argvs
, NULL
, 1)) goto test_failed_exit
;
75 * We are ourselves launched with do_execve_test, which wants a chance to