• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of version 2 of the GNU General Public License as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * You should have received a copy of the GNU General Public License along
13  * with this program; if not, write the Free Software Foundation, Inc.,
14  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  */
17 /**********************************************************
18  *
19  *    TEST IDENTIFIER	: sched_get_priority_max01
20  *
21  *    EXECUTED BY	: anyone
22  *
23  *    TEST TITLE	: Basic test for sched_get_priority_max(2)
24  *
25  *    TEST CASE TOTAL	: 3
26  *
27  *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
28  *
29  *    SIGNALS
30  * 	Uses SIGUSR1 to pause before test if option set.
31  * 	(See the parse_opts(3) man page).
32  *
33  *    DESCRIPTION
34  *	This is a Phase I test for the sched_get_priority_max(2) system call.
35  *	It is intended to provide a limited exposure of the system call.
36  *
37  * 	Setup:
38  * 	  Setup signal handling.
39  *	  Pause for SIGUSR1 if option specified.
40  *
41  * 	Test:
42  *	 Loop if the proper options are given.
43  * 	  Execute system call
44  *	  Check return code, if system call failed (return=-1)
45  *		Log the errno and Issue a FAIL message.
46  *	  Otherwise, Issue a PASS message.
47  *
48  * 	Cleanup:
49  * 	  Print errno log and/or timing stats if options given
50  *
51  * USAGE:  <for command-line>
52  *  sched_get_priority_max01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f]
53  * 			     [-p]
54  *			where,  -c n : Run n copies concurrently.
55  *				-e   : Turn on errno logging.
56  *				-h   : Show help screen
57  *				-f   : Turn off functional testing
58  *				-i n : Execute test n times.
59  *				-I x : Execute test for x seconds.
60  *				-p   : Pause for SIGUSR1 before starting
61  *				-P x : Pause for x seconds between iterations.
62  *				-t   : Turn on syscall timing.
63  *
64  ****************************************************************/
65 
66 #include <errno.h>
67 #include <sched.h>
68 #include "test.h"
69 
70 static void setup();
71 static void cleanup();
72 
73 char *TCID = "sched_get_priority_max01";
74 
75 static struct test_case_t {
76 	char *desc;
77 	int policy;
78 	int retval;
79 } test_cases[] = {
80 	{
81 	"Test for SCHED_OTHER", SCHED_OTHER, 0}, {
82 	"Test for SCHED_FIFO", SCHED_FIFO, 99}, {
83 	"Test for SCHED_RR", SCHED_RR, 99}
84 };
85 
86 int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
87 
main(int ac,char ** av)88 int main(int ac, char **av)
89 {
90 
91 	int lc, ind;
92 
93 	tst_parse_opts(ac, av, NULL, NULL);
94 
95 	setup();
96 
97 	for (lc = 0; TEST_LOOPING(lc); lc++) {
98 
99 		tst_count = 0;
100 
101 		for (ind = 0; ind < TST_TOTAL; ind++) {
102 			/*
103 			 * Call sched_get_priority_max(2)
104 			 */
105 			TEST(sched_get_priority_max(test_cases[ind].policy));
106 
107 			if (TEST_RETURN == test_cases[ind].retval) {
108 				tst_resm(TPASS, "%s Passed",
109 					 test_cases[ind].desc);
110 			} else {
111 				tst_resm(TFAIL | TTERRNO, "%s Failed,"
112 					 "sched_get_priority_max() returned %ld",
113 					 test_cases[ind].desc, TEST_RETURN);
114 			}
115 		}
116 	}
117 
118 	/* cleanup and exit */
119 	cleanup();
120 
121 	tst_exit();
122 
123 }
124 
125 /* setup() - performs all ONE TIME setup for this test */
setup(void)126 void setup(void)
127 {
128 
129 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
130 
131 	TEST_PAUSE;
132 
133 }
134 
135 /*
136  *cleanup() -  performs all ONE TIME cleanup for this test at
137  *		completion or premature exit.
138  */
cleanup(void)139 void cleanup(void)
140 {
141 
142 }
143