]>
git.saurik.com Git - apple/xnu.git/blob - tests/vm_set_max_addr_test.c
3 #include <spawn_private.h>
5 #include <mach/mach_init.h>
6 #include <mach/mach_vm.h>
8 #include <darwintest.h>
9 #include <darwintest_utils.h>
11 extern char * testpath
;
15 T_META_NAMESPACE("xnu.vm"),
16 T_META_CHECK_LEAKS(false))
18 #if (defined(__arm64__) && defined(__LP64__))
23 char * command_path
= "./vm_set_max_addr_helper";
24 char * command_args
[] = { command_path
, NULL
};
25 posix_spawnattr_t attrp
;
27 result
= posix_spawnattr_init(&attrp
);
28 T_ASSERT_POSIX_SUCCESS(result
, "posix_spawnattr_init");
30 result
= posix_spawn(&child_pid
, command_path
, NULL
, &attrp
, command_args
, NULL
);
31 T_ASSERT_POSIX_SUCCESS(result
, "posix_spawn");
33 result
= waitpid(child_pid
, &status
, 0);
34 T_ASSERT_POSIX_SUCCESS(result
, "waitpid");
36 code
= WEXITSTATUS(status
);
37 T_ASSERT_NE_INT(code
, 0, "Child should have failed");
39 result
= posix_spawnattr_set_max_addr_np(&attrp
, ~0ULL);
40 T_ASSERT_POSIX_SUCCESS(result
, "posix_spawnattr_set_max_addr_np");
42 result
= posix_spawn(&child_pid
, command_path
, NULL
, &attrp
, command_args
, NULL
);
43 T_ASSERT_POSIX_SUCCESS(result
, "posix_spawn");
45 result
= waitpid(child_pid
, &status
, 0);
46 T_ASSERT_POSIX_SUCCESS(result
, "waitpid");
48 code
= WEXITSTATUS(status
);
49 T_ASSERT_EQ_INT(code
, 0, "Child should have succeeded");
51 posix_spawnattr_destroy(&attrp
);
52 T_ASSERT_POSIX_SUCCESS(result
, "posix_spawnattr_destroy");
53 #else /* !defined(__arm64__) || !defined(__LP64__) */
54 T_SKIP("Not supported on this architecture");
55 #endif /* (defined(__arm64__) && defined(__LP64__)) */