]> git.saurik.com Git - apple/xnu.git/blob - tests/vm/page_size_globals.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / vm / page_size_globals.c
1 #include <darwintest.h>
2 #include <mach/vm_page_size.h>
3
4 T_GLOBAL_META(
5 T_META_NAMESPACE("vm_page_size_overrides")
6 );
7
8 static void
9 verify_page_size(
10 int expected_shift,
11 int page_shift,
12 vm_size_t page_size,
13 vm_size_t page_mask)
14 {
15 T_ASSERT_EQ(page_shift, expected_shift, "page_shift");
16 T_ASSERT_EQ(page_size, 1UL << expected_shift, "page_size");
17 T_ASSERT_EQ(page_mask, page_size - 1, "page_mask");
18 }
19
20
21 T_DECL(kernel_4k,
22 "Can override vm_kernel_page_size",
23 T_META_ENVVAR("VM_KERNEL_PAGE_SIZE_4K=1"),
24 T_META_ENVVAR("MallocGuardEdges=0"),
25 T_META_ENVVAR("MallocDoNotProtectPrelude=1"),
26 T_META_ENVVAR("MallocDoNotProtectPostlude=1"))
27 {
28 verify_page_size(12, vm_kernel_page_shift, vm_kernel_page_size, vm_kernel_page_mask);
29 }
30
31 T_DECL(invalid,
32 "Invalid overrides",
33 T_META_ENVVAR("VM_KERNEL_PAGE_SIZE_4K=2"),
34 T_META_ENVVAR("VM_KERNEL_PAGE_SIZE=4K"),
35 T_META_ENVVAR("VM_KERNEL_PAGE_SIZE="))
36 {
37 /*
38 * This test just verifies that libkernel_init doesn't
39 * crash when handling invalid overrides.
40 * So if we got here, we can pass the test.
41 */
42 T_PASS("Test process spawned");
43 }