1 #include <sys/kern_memorystatus.h> 2 3 #include <darwintest.h> 4 #include <darwintest_utils.h> 5 6 #include "memorystatus_assertion_helpers.h" 7 8 T_GLOBAL_META( 9 T_META_NAMESPACE("xnu.vm"), 10 T_META_RADAR_COMPONENT_NAME("xnu"), 11 T_META_RADAR_COMPONENT_VERSION("VM"), 12 T_META_CHECK_LEAKS(false) 13 ); 14 15 #if ENTITLED 16 T_DECL(can_use_internal_bands_with_entitlement, "Can move process into internal bands with entitlement") 17 #else 18 T_DECL(can_not_use_internal_bands_without_entitlement, "Can not move process into internal bands with entitlement") 19 #endif 20 { 21 for (int32_t band = JETSAM_PRIORITY_IDLE + 1; band <= JETSAM_PRIORITY_ENTITLED_MAX; band++) { 22 int ret = set_priority(getpid(), band, 0, false); 23 T_QUIET; T_ASSERT_POSIX_SUCCESS(ret, "set_priority"); 24 25 int32_t set_band, limit; 26 uint64_t user_data; 27 uint32_t state; 28 bool success = get_priority_props(getpid(), false, &set_band, &limit, &user_data, &state); 29 T_QUIET; T_ASSERT_TRUE(success, "get_priority_props"); 30 #if ENTITLED 31 T_QUIET; T_ASSERT_EQ(set_band, band, "Able to use entitled band"); 32 #else 33 T_QUIET; T_ASSERT_EQ(set_band, JETSAM_PRIORITY_IDLE, "Fell through to idle band"); 34 #endif 35 } 36 } 37