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 T_META_TAG_VM_PREFERRED 14 ); 15 16 #if ENTITLED 17 T_DECL(can_use_internal_bands_with_entitlement, "Can move process into internal bands with entitlement") 18 #else 19 T_DECL(can_not_use_internal_bands_without_entitlement, "Can not move process into internal bands with entitlement") 20 #endif 21 { 22 for (int32_t band = JETSAM_PRIORITY_IDLE + 1; band <= JETSAM_PRIORITY_ENTITLED_MAX; band++) { 23 int ret = set_priority(getpid(), band, 0, false); 24 T_QUIET; T_ASSERT_POSIX_SUCCESS(ret, "set_priority"); 25 26 int32_t set_band, limit; 27 uint64_t user_data; 28 uint32_t state; 29 bool success = get_priority_props(getpid(), false, &set_band, &limit, &user_data, &state); 30 T_QUIET; T_ASSERT_TRUE(success, "get_priority_props"); 31 #if ENTITLED 32 T_QUIET; T_ASSERT_EQ(set_band, band, "Able to use entitled band"); 33 #else 34 T_QUIET; T_ASSERT_EQ(set_band, JETSAM_PRIORITY_IDLE, "Fell through to idle band"); 35 #endif 36 } 37 } 38