• 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_yield01.C
23  *
24  * DESCRIPTION
25  *	Testcase to check that sched_yield returns correct values.
26  *
27  * ALGORITHM
28  *	Call sched_yield(), check its return value. If it is 0, then pass,
29  *	otherwise fail with proper errno!
30  *
31  * USAGE:  <for command-line>
32  * sched_yield01 [-c n] [-i n] [-I x] [-P x] [-t]
33  *     where,  -c n : Run n copies concurrently.
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  * HISTORY
40  *	07/2001 Ported by Wayne Boyer
41  *
42  * RESTRICTIONS
43  *	None
44  */
45 #include <stdio.h>
46 #include <sched.h>
47 #include <errno.h>
48 #include "test.h"
49 
50 char *TCID = "sched_yield01";
51 int TST_TOTAL = 1;
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 
66 		/* reset tst_count in case we are looping */
67 		tst_count = 0;
68 
69 		TEST(sched_yield());
70 
71 		if (TEST_RETURN != 0) {
72 			tst_resm(TFAIL, "call failed - errno %d : %s",
73 				 TEST_ERRNO, strerror(TEST_ERRNO));
74 		} else {
75 			tst_resm(TPASS, "sched_yield() call succeeded");
76 		}
77 	}
78 	cleanup();
79 	tst_exit();
80 
81 }
82 
83 /*
84  * setup() - performs all ONE TIME setup for this test.
85  */
setup(void)86 void setup(void)
87 {
88 
89 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
90 
91 	TEST_PAUSE;
92 }
93 
94 /*
95  * cleanup() - performs all ONE TIME cleanup for this test at
96  *	       completion or premature exit.
97  */
cleanup(void)98 void cleanup(void)
99 {
100 
101 }
102