• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2021, BELLSOFT. All rights reserved.
4  * Copyright (c) International Business Machines  Corp., 2001
5  */
6 
7 /*\
8  * [Description]
9  *
10  * Pass an unused pid to sched_getscheduler() and test for ESRCH.
11  */
12 
13 #include <stdio.h>
14 #include <errno.h>
15 
16 #include "tst_test.h"
17 #include "tst_sched.h"
18 
19 static pid_t unused_pid;
20 
setup(void)21 static void setup(void)
22 {
23 	tst_res(TINFO, "Testing %s variant", sched_variants[tst_variant].desc);
24 
25 	unused_pid = tst_get_unused_pid();
26 }
27 
run(void)28 static void run(void)
29 {
30 	struct sched_variant *tv = &sched_variants[tst_variant];
31 
32 	TST_EXP_FAIL(tv->sched_getscheduler(unused_pid), ESRCH,
33 		     "sched_getscheduler(%d)", unused_pid);
34 }
35 
36 static struct tst_test test = {
37 	.setup = setup,
38 	.test_variants = ARRAY_SIZE(sched_variants),
39 	.test_all = run,
40 };
41