]>
git.saurik.com Git - apple/xnu.git/blob - tests/xnu_quick_test_getsetpriority.c
1 #include <darwintest.h>
9 T_META_NAMESPACE("xnu.quicktest"),
10 T_META_CHECK_LEAKS(false),
11 T_META_RUN_CONCURRENTLY(true)
14 T_DECL(getpriority_setpriority
, "Tests getpriority and setpriority system calls", T_META_ASROOT(true))
19 /* getpriority returns scheduling priority so -1 is a valid value */
21 my_priority
= getpriority(PRIO_PROCESS
, 0);
24 T_ASSERT_FALSE(my_priority
== -1 && errno
!= 0, "Verify getpriority is successful", NULL
);
26 /* change scheduling priority*/
27 my_new_priority
= (my_priority
== PRIO_MIN
) ? (my_priority
+ 10) : (PRIO_MIN
);
30 T_ASSERT_POSIX_SUCCESS(setpriority(PRIO_PROCESS
, 0, my_new_priority
), "Change scheduling priority", NULL
);
34 my_priority
= getpriority(PRIO_PROCESS
, 0);
36 T_ASSERT_FALSE(my_priority
== -1 && errno
!= 0, "Verify getpriority change is successful", NULL
);
39 T_ASSERT_EQ(my_priority
, my_new_priority
, "Verify setpriority correctly set scheduling priority", NULL
);
41 /* reset scheduling priority */
43 T_ASSERT_POSIX_SUCCESS(setpriority(PRIO_PROCESS
, 0, 0), "Reset scheduling priority", NULL
);