• 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_min02
20  *
21  *    EXECUTED BY	: anyone
22  *
23  *    TEST TITLE	: Test for error conditions
24  *
25  *    TEST CASE TOTAL	: 1
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  *	Verify that given an invalid scheduling policy,
35  *	sched_get_priority_min() returns -1 with errno EINVAL
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) & errno=EINVAL
45  *		Test Passed
46  *	  Otherwise
47  *		Test Failed
48  *
49  * 	Cleanup:
50  * 	  Print errno log and/or timing stats if options given
51  *
52  * USAGE:  <for command-line>
53  *  sched_get_priority_min02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f]
54  * 			     [-p]
55  *			where,  -c n : Run n copies concurrently.
56  *				-e   : Turn on errno logging.
57  *				-h   : Show help screen
58  *				-f   : Turn off functional testing
59  *				-i n : Execute test n times.
60  *				-I x : Execute test for x seconds.
61  *				-p   : Pause for SIGUSR1 before starting
62  *				-P x : Pause for x seconds between iterations.
63  *				-t   : Turn on syscall timing.
64  *
65  ****************************************************************/
66 
67 #include <errno.h>
68 #include <sched.h>
69 #include "test.h"
70 
71 #define SCHED_INVALID 1000
72 
73 static void setup();
74 static void cleanup();
75 
76 char *TCID = "sched_get_priority_min02";
77 
78 int TST_TOTAL = 1;
79 
main(int ac,char ** av)80 int main(int ac, char **av)
81 {
82 
83 	int lc;
84 
85 	tst_parse_opts(ac, av, NULL, NULL);
86 
87 	setup();
88 
89 	for (lc = 0; TEST_LOOPING(lc); lc++) {
90 
91 		tst_count = 0;
92 
93 		/*
94 		 * Call sched_get_priority_min(2)
95 		 */
96 		TEST(sched_get_priority_min(SCHED_INVALID));
97 
98 		if ((TEST_RETURN == -1) && (TEST_ERRNO == EINVAL)) {
99 			tst_resm(TPASS, "Test Passed, Got EINVAL");
100 		} else {
101 			tst_resm(TFAIL | TTERRNO,
102 				 "Test Failed, sched_get_priority_min()"
103 				 " returned %ld", TEST_RETURN);
104 		}
105 	}
106 
107 	/* cleanup and exit */
108 	cleanup();
109 	tst_exit();
110 
111 }
112 
113 /* setup() - performs all ONE TIME setup for this test */
setup(void)114 void setup(void)
115 {
116 
117 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
118 
119 	TEST_PAUSE;
120 
121 }
122 
123 /*
124  *cleanup() -  performs all ONE TIME cleanup for this test at
125  *		completion or premature exit.
126  */
cleanup(void)127 void cleanup(void)
128 {
129 
130 }
131