]>
git.saurik.com Git - apple/xnu.git/blob - tests/verify_kalloc_config.c
2c5c08727f420f4951b48e99f7c026d4e5fa7f52
4 #include <mach_debug/mach_debug.h>
5 #include <darwintest.h>
8 T_META_NAMESPACE("xnu.vm"),
9 T_META_CHECK_LEAKS(false),
10 T_META_RUN_CONCURRENTLY(true)
13 static void run_test(void);
20 mach_zone_name_t
*name
= NULL
;
21 unsigned int nameCnt
= 0;
22 mach_zone_info_t
*info
= NULL
;
23 unsigned int infoCnt
= 0;
24 mach_memory_info_t
*wiredInfo
= NULL
;
25 unsigned int wiredInfoCnt
= 0;
26 const char kalloc_str
[] = "kalloc.";
28 kr
= mach_memory_info(mach_host_self(),
29 &name
, &nameCnt
, &info
, &infoCnt
,
30 &wiredInfo
, &wiredInfoCnt
);
31 T_QUIET
; T_ASSERT_MACH_SUCCESS(kr
, "mach_memory_info");
32 T_QUIET
; T_ASSERT_EQ(nameCnt
, infoCnt
, "zone name and info counts don't match");
34 /* Match the names of the kalloc zones against their element sizes. */
35 for (i
= 0; i
< nameCnt
; i
++) {
36 if (strncmp(name
[i
].mzn_name
, kalloc_str
, strlen(kalloc_str
)) == 0) {
37 size
= strtoul(&(name
[i
].mzn_name
[strlen(kalloc_str
)]), NULL
, 10);
38 T_LOG("ZONE NAME: %-25s ELEMENT SIZE: %llu", name
[i
].mzn_name
, size
);
39 T_QUIET
; T_ASSERT_EQ(size
, info
[i
].mzi_elem_size
, "kalloc zone name and element size don't match");
43 if ((name
!= NULL
) && (nameCnt
!= 0)) {
44 kr
= vm_deallocate(mach_task_self(), (vm_address_t
) name
,
45 (vm_size_t
) (nameCnt
* sizeof *name
));
46 T_QUIET
; T_ASSERT_MACH_SUCCESS(kr
, "vm_deallocate name");
49 if ((info
!= NULL
) && (infoCnt
!= 0)) {
50 kr
= vm_deallocate(mach_task_self(), (vm_address_t
) info
,
51 (vm_size_t
) (infoCnt
* sizeof *info
));
52 T_QUIET
; T_ASSERT_MACH_SUCCESS(kr
, "vm_deallocate info");
55 if ((wiredInfo
!= NULL
) && (wiredInfoCnt
!= 0)) {
56 kr
= vm_deallocate(mach_task_self(), (vm_address_t
) wiredInfo
,
57 (vm_size_t
) (wiredInfoCnt
* sizeof *wiredInfo
));
58 T_QUIET
; T_ASSERT_MACH_SUCCESS(kr
, "vm_deallocate wiredInfo");
64 T_DECL( verify_kalloc_config
,
65 "verifies that the kalloc zones are configured correctly",