| 1 |
/* COVERAGE: sched_getattr sched_setattr */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE |
| 4 |
#include <sched.h> |
| 5 |
#include <unistd.h> |
| 6 |
#include <sys/syscall.h> |
| 7 |
#include <sys/types.h> |
| 8 |
#include <unistd.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <malloc.h> |
| 11 |
|
| 12 |
#if defined __NR_sched_getattr && defined __NR_sched_setattr |
| 13 |
|
| 14 |
static inline int __sched_getattr(pid_t pid, void *attr, unsigned int size, |
| 15 |
unsigned int flags) |
| 16 |
{ |
| 17 |
return syscall(__NR_sched_getattr, pid, attr, size, flags); |
| 18 |
} |
| 19 |
|
| 20 |
static inline int __sched_setattr(pid_t pid, void *attr, unsigned int flags) |
| 21 |
{ |
| 22 |
return syscall(__NR_sched_setattr, pid, attr, flags); |
| 23 |
} |
| 24 |
|
| 25 |
int main() |
| 26 |
{ |
| 27 |
int mypid = getpid(); |
| 28 |
|
| 29 |
// Declaration of struct sched_attr not in available in 4.1.0-0 kernel headers. |
| 30 |
// Following avoids declaring the structure within this test program. |
| 31 |
int sas = 1024; |
| 32 |
int sal = 8; /* __alignof__ (struct sched_attr) */ |
| 33 |
void *sa = memalign(sal, sas); |
| 34 |
|
| 35 |
__sched_getattr(mypid, sa, sas, 0); |
| 36 |
//staptest// [[[[sched_getattr (NNNN, {size=NNNN, sched_policy=NNNN, sched_flags=NNNN, sched_nice=NNNN, sched_priority=NNNN, sched_runtime=NNNN, sched_deadline=NNNN, sched_period=NNNN}, NNNN, NNNN)!!!!ni_syscall ()]]]] = NNNN |
| 37 |
|
| 38 |
__sched_setattr(mypid, sa, 0); |
| 39 |
//staptest// [[[[sched_setattr (NNNN, {size=NNNN, sched_policy=NNNN, sched_flags=NNNN, sched_nice=NNNN, sched_priority=NNNN, sched_runtime=NNNN, sched_deadline=NNNN, sched_period=NNNN}, 0)!!!!ni_syscall ()]]]] = NNNN |
| 40 |
|
| 41 |
// Limit testing |
| 42 |
|
| 43 |
__sched_getattr(-1, 0, 0, 0); |
| 44 |
//staptest// [[[[sched_getattr (-1, NULL, 0, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 45 |
|
| 46 |
__sched_getattr(0, (void *)-1, 0, 0); |
| 47 |
#ifdef __s390__ |
| 48 |
//staptest// [[[[sched_getattr (0, 0x[7]?[f]+, 0, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 49 |
#else |
| 50 |
//staptest// [[[[sched_getattr (0, 0x[f]+, 0, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 51 |
#endif |
| 52 |
|
| 53 |
__sched_getattr(0, 0, -1, 0); |
| 54 |
//staptest// [[[[sched_getattr (0, NULL, 4294967295, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 55 |
|
| 56 |
__sched_getattr(0, 0, 0, -1); |
| 57 |
//staptest// [[[[sched_getattr (0, NULL, 0, 4294967295)!!!!ni_syscall ()]]]] = -NNNN |
| 58 |
|
| 59 |
__sched_setattr(-1, NULL, 0); |
| 60 |
//staptest// [[[[sched_setattr (-1, NULL, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 61 |
|
| 62 |
__sched_setattr(0, (void *)-1, 0); |
| 63 |
#ifdef __s390__ |
| 64 |
//staptest// [[[[sched_setattr (0, 0x[7]?[f]+, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 65 |
#else |
| 66 |
//staptest// [[[[sched_setattr (0, 0x[f]+, 0)!!!!ni_syscall ()]]]] = -NNNN |
| 67 |
#endif |
| 68 |
|
| 69 |
__sched_setattr(0, NULL, -1); |
| 70 |
//staptest// [[[[sched_setattr (0, NULL, 4294967295)!!!!ni_syscall ()]]]] = -NNNN |
| 71 |
|
| 72 |
free(sa); |
| 73 |
|
| 74 |
return 0; |
| 75 |
} |
| 76 |
#else |
| 77 |
int main() |
| 78 |
{ |
| 79 |
return 0; |
| 80 |
} |
| 81 |
#endif |