• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *   Copyright (c) International Business Machines  Corp., 2001
4  *
5  *   This program is free software;  you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13  *   the GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program;  if not, write to the Free Software
17  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /*
21  * NAME
22  *	sched_getscheduler02.C
23  *
24  * DESCRIPTION
25  *	To check for the errno ESRCH
26  *
27  * ALGORITHM
28  *	Pass an invalid pid to sched_getscheduler() and test for ESRCH.
29  *
30  * USAGE:  <for command-line>
31  *  sched_getscheduler02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
32  *     where,  -c n : Run n copies concurrently.
33  *             -e   : Turn on errno logging.
34  *             -i n : Execute test n times.
35  *             -I x : Execute test for x seconds.
36  *             -P x : Pause for x seconds between iterations.
37  *             -t   : Turn on syscall timing.
38  *
39  * RESTRICTION
40  *	None
41  */
42 
43 #include <stdio.h>
44 #include <sched.h>
45 #include <errno.h>
46 #include "test.h"
47 
48 char *TCID = "sched_getscheduler02";
49 int TST_TOTAL = 1;
50 
51 static pid_t unused_pid;
52 
53 void setup(void);
54 void cleanup(void);
55 
main(int ac,char ** av)56 int main(int ac, char **av)
57 {
58 	int lc;
59 
60 	tst_parse_opts(ac, av, NULL, NULL);
61 
62 	setup();
63 
64 	for (lc = 0; TEST_LOOPING(lc); lc++) {
65 		/* reset tst_count in case we are looping */
66 		tst_count = 0;
67 
68 		TEST(sched_getscheduler(unused_pid));
69 
70 		if (TEST_RETURN != -1) {
71 			tst_resm(TFAIL, "sched_getscheduler(2) passed "
72 				 "unexpectedly");
73 			continue;
74 		}
75 
76 		if (errno != ESRCH) {
77 			tst_resm(TFAIL, "Expected ESRCH, got %d", errno);
78 		} else {
79 			tst_resm(TPASS, "call failed with ESRCH");
80 		}
81 	}
82 	cleanup();
83 	tst_exit();
84 
85 }
86 
87 /*
88  * setup() - performs all ONE TIME setup for this test.
89  */
setup(void)90 void setup(void)
91 {
92 	unused_pid = tst_get_unused_pid(cleanup);
93 
94 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
95 
96 	TEST_PAUSE;
97 }
98 
99 /*
100  * cleanup() - performs all ONE TIME cleanup for this test at
101  *	       completion or premature exit.
102  */
cleanup(void)103 void cleanup(void)
104 {
105 
106 }
107