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