xref: /xnu-10063.141.1/tests/vm/vm_compressor.c (revision d8b80295118ef25ac3a784134bcf95cd8e88109f)
1 /*
2  * Created by Jarrad Cisco on 09/28/2022.
3  * Copyright © 2022 Apple. All rights reserved.
4  *
5  * Functional tests for VM compressor/swap.
6  */
7 #include <sys/sysctl.h>
8 #include <darwintest.h>
9 #include <darwintest_utils.h>
10 #include <TargetConditionals.h>
11 
12 T_GLOBAL_META(
13 	T_META_NAMESPACE("xnu.vm"),
14 	T_META_RADAR_COMPONENT_NAME("xnu"),
15 	T_META_RADAR_COMPONENT_VERSION("VM"),
16 	T_META_ASROOT(YES),
17 	T_META_RUN_CONCURRENTLY(true));
18 
19 T_DECL(swap_enabled,
20     "Check that Swap is successfully enabled",
21     T_META_ENABLED(TARGET_OS_OSX))
22 {
23 	int swap_enabled;
24 	size_t len = sizeof(swap_enabled);
25 	int rc = sysctlbyname("vm.swap_enabled", &swap_enabled, &len, NULL, 0);
26 	T_QUIET; T_ASSERT_POSIX_SUCCESS(rc, "Failed to query sysctl `vm.swap_enabled`");
27 	T_EXPECT_EQ(swap_enabled, 1, "Check that vm.swap_enabled is set");
28 }
29