1 /*
2 * Copyright (c) 2016-2023 The strace developers.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #include "tests.h"
9 #include "scno.h"
10
11 #ifdef __NR_sched_rr_get_interval
12
13 # include <stdint.h>
14 # include <stdio.h>
15 # include <sched.h>
16 # include <unistd.h>
17
18 int
19 main(void)
20 {
21 TAIL_ALLOC_OBJECT_CONST_PTR(kernel_old_timespec_t, tp);
22 long rc;
23
24 rc = syscall(__NR_sched_rr_get_interval, 0, NULL);
25 printf("sched_rr_get_interval(0, NULL) = %s\n", sprintrc(rc));
26
27 rc = syscall(__NR_sched_rr_get_interval, 0, tp + 1);
28 printf("sched_rr_get_interval(0, %p) = %s\n", tp + 1, sprintrc(rc));
29
30 rc = syscall(__NR_sched_rr_get_interval, -1, tp);
31 printf("sched_rr_get_interval(-1, %p) = %s\n", tp, sprintrc(rc));
32
33 rc = syscall(__NR_sched_rr_get_interval, 0, tp);
34 if (rc == 0)
35 printf("sched_rr_get_interval(0, {tv_sec=%lld, tv_nsec=%llu})"
36 " = 0\n",
37 (long long) tp->tv_sec,
38 zero_extend_signed_to_ull(tp->tv_nsec));
39 else
40 printf("sched_rr_get_interval(-1, %p) = %s\n", tp,
41 sprintrc(rc));
42
43 puts("+++ exited with 0 +++");
44 return 0;
45 }
46
47 #else
48
49 SKIP_MAIN_UNDEFINED("__NR_sched_rr_get_interval")
50
51 #endif