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