1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
4  * Copyright (c) 2021 sujiaxun <[email protected]>
5  * Copyright (c) Linux Test Project, 2009-2022
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Basic test for the sched_get_priority_max(2) system call.
12  *
13  * Obtain different maximum priority for different schedulling policies and
14  * compare them with the expected value.
15  */
16 
17 #define _GNU_SOURCE
18 
19 #include <sched.h>
20 #include "tst_test.h"
21 #include "lapi/sched.h"
22 
23 #define POLICY_DESC(x) .desc = #x, .policy = x
24 
25 static struct test_case {
26 	char *desc;
27 	int policy;
28 	int retval;
29 } tcases[] = {
30 	{POLICY_DESC(SCHED_BATCH), 0},
31 	{POLICY_DESC(SCHED_DEADLINE), 0},
32 	{POLICY_DESC(SCHED_FIFO), 99},
33 	{POLICY_DESC(SCHED_IDLE), 0},
34 	{POLICY_DESC(SCHED_OTHER), 0},
35 	{POLICY_DESC(SCHED_RR), 99},
36 };
37 
run_test(unsigned int nr)38 static void run_test(unsigned int nr)
39 {
40 	struct test_case *tc = &tcases[nr];
41 
42 	TST_EXP_VAL(tst_syscall(__NR_sched_get_priority_max, tc->policy),
43 			tc->retval, "%s", tc->desc);
44 }
45 
46 static struct tst_test test = {
47 	.tcnt = ARRAY_SIZE(tcases),
48 	.test = run_test,
49 };
50