blob: d4e9b9e4ee539d71eb2e1216a1c399f518e3a35f [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_min01
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 : Basic test for sched_get_priority_min(2)
subrata_modak4bb656a2009-02-26 12:02:09 +000024 *
plars96eefcf2002-12-05 22:02:10 +000025 * TEST CASE TOTAL : 3
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 * This is a Phase I test for the sched_get_priority_min(2) system call.
35 * It is intended to provide a limited exposure of the system call.
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)
45 * Log the errno and Issue a FAIL message.
46 * Otherwise, Issue a PASS message.
subrata_modak4bb656a2009-02-26 12:02:09 +000047 *
plars96eefcf2002-12-05 22:02:10 +000048 * Cleanup:
49 * Print errno log and/or timing stats if options given
subrata_modak4bb656a2009-02-26 12:02:09 +000050 *
plars96eefcf2002-12-05 22:02:10 +000051 * USAGE: <for command-line>
52 * sched_get_priority_min01 [-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#include "usctest.h"
70
71static void setup();
72static void cleanup();
73
subrata_modak56207ce2009-03-23 13:35:39 +000074char *TCID = "sched_get_priority_min01"; /* Test program identifier. */
plars96eefcf2002-12-05 22:02:10 +000075
76static struct test_case_t {
subrata_modak56207ce2009-03-23 13:35:39 +000077 char *desc;
plars96eefcf2002-12-05 22:02:10 +000078 int policy;
79 int retval;
80} test_cases[] = {
subrata_modak56207ce2009-03-23 13:35:39 +000081 {
82 "Test for SCHED_OTHER", SCHED_OTHER, 0}, {
83 "Test for SCHED_FIFO", SCHED_FIFO, 1}, {
84 "Test for SCHED_RR", SCHED_RR, 1}
plars96eefcf2002-12-05 22:02:10 +000085};
86
subrata_modak4bb656a2009-02-26 12:02:09 +000087int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
plars96eefcf2002-12-05 22:02:10 +000088
subrata_modak56207ce2009-03-23 13:35:39 +000089int main(int ac, char **av)
plars96eefcf2002-12-05 22:02:10 +000090{
91
92 int lc, ind; /* loop counter */
Cyril Hrubis89af32a2012-10-24 16:39:11 +020093 char *msg;
subrata_modak56207ce2009-03-23 13:35:39 +000094
Garrett Coopera9e49f12010-12-16 10:54:03 -080095 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080096 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
plars96eefcf2002-12-05 22:02:10 +000097
plars96eefcf2002-12-05 22:02:10 +000098 setup();
99
plars96eefcf2002-12-05 22:02:10 +0000100 for (lc = 0; TEST_LOOPING(lc); lc++) {
101
Caspar Zhangd59a6592013-03-07 14:59:12 +0800102 tst_count = 0;
plars96eefcf2002-12-05 22:02:10 +0000103
subrata_modak56207ce2009-03-23 13:35:39 +0000104 for (ind = 0; ind < TST_TOTAL; ind++) {
subrata_modak4bb656a2009-02-26 12:02:09 +0000105 /*
plars96eefcf2002-12-05 22:02:10 +0000106 * Call sched_get_priority_min(2)
subrata_modak56207ce2009-03-23 13:35:39 +0000107 */
plars96eefcf2002-12-05 22:02:10 +0000108 TEST(sched_get_priority_min(test_cases[ind].policy));
subrata_modakbdbaec52009-02-26 12:14:51 +0000109
plars96eefcf2002-12-05 22:02:10 +0000110 if (TEST_RETURN == test_cases[ind].retval) {
111 tst_resm(TPASS, "%s Passed",
112 test_cases[ind].desc);
113 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800114 tst_resm(TFAIL | TTERRNO, "%s Failed,"
subrata_modak923b23f2009-11-02 13:57:16 +0000115 "sched_get_priority_min() returned %ld",
116 test_cases[ind].desc, TEST_RETURN);
plars96eefcf2002-12-05 22:02:10 +0000117 }
subrata_modak4bb656a2009-02-26 12:02:09 +0000118 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800119 }
plars96eefcf2002-12-05 22:02:10 +0000120
121 /* cleanup and exit */
122 cleanup();
123
Garrett Cooper53740502010-12-16 00:04:01 -0800124 tst_exit();
plars96eefcf2002-12-05 22:02:10 +0000125
Garrett Cooper2c282152010-12-16 00:55:50 -0800126}
plars96eefcf2002-12-05 22:02:10 +0000127
128/* setup() - performs all ONE TIME setup for this test */
subrata_modak56207ce2009-03-23 13:35:39 +0000129void setup()
plars96eefcf2002-12-05 22:02:10 +0000130{
subrata_modakbdbaec52009-02-26 12:14:51 +0000131
plars96eefcf2002-12-05 22:02:10 +0000132 tst_sig(NOFORK, DEF_HANDLER, cleanup);
133
plars96eefcf2002-12-05 22:02:10 +0000134 TEST_PAUSE;
135
Garrett Cooper2c282152010-12-16 00:55:50 -0800136}
plars96eefcf2002-12-05 22:02:10 +0000137
subrata_modak4bb656a2009-02-26 12:02:09 +0000138/*
plars96eefcf2002-12-05 22:02:10 +0000139 *cleanup() - performs all ONE TIME cleanup for this test at
140 * completion or premature exit.
141 */
subrata_modak56207ce2009-03-23 13:35:39 +0000142void cleanup()
plars96eefcf2002-12-05 22:02:10 +0000143{
144
145 /*
146 * print timing stats if that option was specified.
147 * print errno log if that option was specified.
148 */
149 TEST_CLEANUP;
150
Chris Dearmanec6edca2012-10-17 19:54:01 -0700151}