blob: 12e3fd89e9fdb29003d78124fc4393631fc694fe [file] [log] [blame]
plars96eefcf2002-12-05 22:02:10 +00001/*
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
Wanlong Gaofed96412012-10-24 10:10:29 +080013 * with this program; if not, write the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
plars96eefcf2002-12-05 22:02:10 +000015 *
16 */
17/**********************************************************
subrata_modak4bb656a2009-02-26 12:02:09 +000018 *
plars96eefcf2002-12-05 22:02:10 +000019 * TEST IDENTIFIER : sched_get_priority_min02
subrata_modak4bb656a2009-02-26 12:02:09 +000020 *
plars96eefcf2002-12-05 22:02:10 +000021 * EXECUTED BY : anyone
subrata_modak4bb656a2009-02-26 12:02:09 +000022 *
plars96eefcf2002-12-05 22:02:10 +000023 * TEST TITLE : Test for error conditions
subrata_modak4bb656a2009-02-26 12:02:09 +000024 *
plars96eefcf2002-12-05 22:02:10 +000025 * TEST CASE TOTAL : 1
subrata_modak4bb656a2009-02-26 12:02:09 +000026 *
plars96eefcf2002-12-05 22:02:10 +000027 * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
subrata_modak4bb656a2009-02-26 12:02:09 +000028 *
plars96eefcf2002-12-05 22:02:10 +000029 * 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
subrata_modak4bb656a2009-02-26 12:02:09 +000036 *
plars96eefcf2002-12-05 22:02:10 +000037 * Setup:
38 * Setup signal handling.
39 * Pause for SIGUSR1 if option specified.
subrata_modak4bb656a2009-02-26 12:02:09 +000040 *
plars96eefcf2002-12-05 22:02:10 +000041 * 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
subrata_modak4bb656a2009-02-26 12:02:09 +000048 *
plars96eefcf2002-12-05 22:02:10 +000049 * Cleanup:
50 * Print errno log and/or timing stats if options given
subrata_modak4bb656a2009-02-26 12:02:09 +000051 *
plars96eefcf2002-12-05 22:02:10 +000052 * 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"
plars96eefcf2002-12-05 22:02:10 +000070
71#define SCHED_INVALID 1000
72
73static void setup();
74static void cleanup();
75
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020076char *TCID = "sched_get_priority_min02";
plars96eefcf2002-12-05 22:02:10 +000077
78int TST_TOTAL = 1;
79
subrata_modak56207ce2009-03-23 13:35:39 +000080int main(int ac, char **av)
plars96eefcf2002-12-05 22:02:10 +000081{
82
Cyril Hrubis89af32a2012-10-24 16:39:11 +020083 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020084 const char *msg;
subrata_modak56207ce2009-03-23 13:35:39 +000085
Garrett Coopera9e49f12010-12-16 10:54:03 -080086 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080087 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
plars96eefcf2002-12-05 22:02:10 +000088
plars96eefcf2002-12-05 22:02:10 +000089 setup();
90
plars96eefcf2002-12-05 22:02:10 +000091 for (lc = 0; TEST_LOOPING(lc); lc++) {
92
Caspar Zhangd59a6592013-03-07 14:59:12 +080093 tst_count = 0;
plars96eefcf2002-12-05 22:02:10 +000094
subrata_modak4bb656a2009-02-26 12:02:09 +000095 /*
plars96eefcf2002-12-05 22:02:10 +000096 * Call sched_get_priority_min(2)
97 */
98 TEST(sched_get_priority_min(SCHED_INVALID));
subrata_modakbdbaec52009-02-26 12:14:51 +000099
plars96eefcf2002-12-05 22:02:10 +0000100 if ((TEST_RETURN == -1) && (TEST_ERRNO == EINVAL)) {
101 tst_resm(TPASS, "Test Passed, Got EINVAL");
102 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800103 tst_resm(TFAIL | TTERRNO,
104 "Test Failed, sched_get_priority_min()"
105 " returned %ld", TEST_RETURN);
plars96eefcf2002-12-05 22:02:10 +0000106 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800107 }
plars96eefcf2002-12-05 22:02:10 +0000108
109 /* cleanup and exit */
110 cleanup();
Garrett Cooper1e6f5a62010-12-19 09:58:10 -0800111 tst_exit();
plars96eefcf2002-12-05 22:02:10 +0000112
Garrett Cooper2c282152010-12-16 00:55:50 -0800113}
plars96eefcf2002-12-05 22:02:10 +0000114
115/* setup() - performs all ONE TIME setup for this test */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400116void setup(void)
plars96eefcf2002-12-05 22:02:10 +0000117{
subrata_modakbdbaec52009-02-26 12:14:51 +0000118
plars96eefcf2002-12-05 22:02:10 +0000119 tst_sig(NOFORK, DEF_HANDLER, cleanup);
120
plars96eefcf2002-12-05 22:02:10 +0000121 TEST_PAUSE;
122
Garrett Cooper2c282152010-12-16 00:55:50 -0800123}
plars96eefcf2002-12-05 22:02:10 +0000124
subrata_modak4bb656a2009-02-26 12:02:09 +0000125/*
plars96eefcf2002-12-05 22:02:10 +0000126 *cleanup() - performs all ONE TIME cleanup for this test at
127 * completion or premature exit.
128 */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400129void cleanup(void)
plars96eefcf2002-12-05 22:02:10 +0000130{
131
Chris Dearmanec6edca2012-10-17 19:54:01 -0700132}