1 /*
2 * Check decoding of sched_getparam and sched_setparam syscalls.
3 *
4 * Copyright (c) 2016-2021 The strace developers.
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10 #include "tests.h"
11 #include "scno.h"
12 #include "pidns.h"
13
14 #include <sched.h>
15 #include <stdio.h>
16 #include <unistd.h>
17
18 int
19 main(void)
20 {
21 PIDNS_TEST_INIT;
22
23 struct sched_param *const param =
24 tail_alloc(sizeof(struct sched_param));
25
26 const int pid = getpid();
27 const char *pid_str = pidns_pid2str(PT_TGID);
28
29 long rc = syscall(__NR_sched_getparam, pid, param);
30 pidns_print_leader();
31 printf("sched_getparam(%d%s, [%d]) = %ld\n",
32 pid, pid_str, param->sched_priority, rc);
33
34 param->sched_priority = -1;
35 rc = syscall(__NR_sched_setparam, pid, param);
36 pidns_print_leader();
37 printf("sched_setparam(%d%s, [%d]) = %ld %s (%m)\n",
38 pid, pid_str,
39 param->sched_priority, rc, errno2name());
40
41 pidns_print_leader();
42 puts("+++ exited with 0 +++");
43 return 0;
44 }