]>
Commit | Line | Data |
---|---|---|
a39ff7e2 A |
1 | #include <darwintest.h> |
2 | ||
3 | #include <stdlib.h> | |
4 | #include <unistd.h> | |
5 | #include <sys/stat.h> | |
6 | #include <sys/wait.h> | |
7 | ||
cb323159 A |
8 | T_GLOBAL_META( |
9 | T_META_NAMESPACE("xnu.quicktest"), | |
10 | T_META_CHECK_LEAKS(false), | |
11 | T_META_RUN_CONCURRENTLY(true) | |
12 | ); | |
a39ff7e2 A |
13 | |
14 | T_DECL(getpriority_setpriority, "Tests getpriority and setpriority system calls", T_META_ASROOT(true)) | |
15 | { | |
16 | int my_priority; | |
17 | int my_new_priority; | |
18 | ||
19 | /* getpriority returns scheduling priority so -1 is a valid value */ | |
20 | errno = 0; | |
21 | my_priority = getpriority(PRIO_PROCESS, 0); | |
22 | ||
23 | T_WITH_ERRNO; | |
24 | T_ASSERT_FALSE(my_priority == -1 && errno != 0, "Verify getpriority is successful", NULL); | |
25 | ||
26 | /* change scheduling priority*/ | |
27 | my_new_priority = (my_priority == PRIO_MIN) ? (my_priority + 10) : (PRIO_MIN); | |
28 | ||
29 | T_WITH_ERRNO; | |
30 | T_ASSERT_POSIX_SUCCESS(setpriority(PRIO_PROCESS, 0, my_new_priority), "Change scheduling priority", NULL); | |
31 | ||
32 | /* verify change */ | |
33 | errno = 0; | |
34 | my_priority = getpriority(PRIO_PROCESS, 0); | |
35 | T_WITH_ERRNO; | |
36 | T_ASSERT_FALSE(my_priority == -1 && errno != 0, "Verify getpriority change is successful", NULL); | |
37 | ||
38 | T_WITH_ERRNO; | |
39 | T_ASSERT_EQ(my_priority, my_new_priority, "Verify setpriority correctly set scheduling priority", NULL); | |
40 | ||
41 | /* reset scheduling priority */ | |
42 | T_WITH_ERRNO; | |
43 | T_ASSERT_POSIX_SUCCESS(setpriority(PRIO_PROCESS, 0, 0), "Reset scheduling priority", NULL); | |
44 | } |