blob: 62dccbf5bed51de72830989b0f6d1a5e9c249974 [file] [log] [blame]
plars37568272002-12-05 22:01:29 +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.
plars37568272002-12-05 22:01:29 +000015 *
16 */
17/**********************************************************
subrata_modak4bb656a2009-02-26 12:02:09 +000018 *
plars37568272002-12-05 22:01:29 +000019 * TEST IDENTIFIER : sched_get_priority_max01
subrata_modak4bb656a2009-02-26 12:02:09 +000020 *
plars37568272002-12-05 22:01:29 +000021 * EXECUTED BY : anyone
subrata_modak4bb656a2009-02-26 12:02:09 +000022 *
plars37568272002-12-05 22:01:29 +000023 * TEST TITLE : Basic test for sched_get_priority_max(2)
subrata_modak4bb656a2009-02-26 12:02:09 +000024 *
plars37568272002-12-05 22:01:29 +000025 * TEST CASE TOTAL : 3
subrata_modak4bb656a2009-02-26 12:02:09 +000026 *
plars37568272002-12-05 22:01:29 +000027 * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
subrata_modak4bb656a2009-02-26 12:02:09 +000028 *
plars37568272002-12-05 22:01:29 +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_max(2) system call.
35 * It is intended to provide a limited exposure of the system call.
subrata_modak4bb656a2009-02-26 12:02:09 +000036 *
plars37568272002-12-05 22:01:29 +000037 * Setup:
38 * Setup signal handling.
39 * Pause for SIGUSR1 if option specified.
subrata_modak4bb656a2009-02-26 12:02:09 +000040 *
plars37568272002-12-05 22:01:29 +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 *
plars37568272002-12-05 22:01:29 +000048 * Cleanup:
49 * Print errno log and/or timing stats if options given
subrata_modak4bb656a2009-02-26 12:02:09 +000050 *
plars37568272002-12-05 22:01:29 +000051 * 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"
plars37568272002-12-05 22:01:29 +000069
70static void setup();
71static void cleanup();
72
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020073char *TCID = "sched_get_priority_max01";
plars37568272002-12-05 22:01:29 +000074
75static struct test_case_t {
subrata_modak56207ce2009-03-23 13:35:39 +000076 char *desc;
plars37568272002-12-05 22:01:29 +000077 int policy;
78 int retval;
79} test_cases[] = {
subrata_modak56207ce2009-03-23 13:35:39 +000080 {
81 "Test for SCHED_OTHER", SCHED_OTHER, 0}, {
82 "Test for SCHED_FIFO", SCHED_FIFO, 99}, {
83 "Test for SCHED_RR", SCHED_RR, 99}
plars37568272002-12-05 22:01:29 +000084};
85
subrata_modak4bb656a2009-02-26 12:02:09 +000086int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
plars37568272002-12-05 22:01:29 +000087
subrata_modak56207ce2009-03-23 13:35:39 +000088int main(int ac, char **av)
plars37568272002-12-05 22:01:29 +000089{
90
91 int lc, ind; /* loop counter */
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020092 const char *msg;
subrata_modak56207ce2009-03-23 13:35:39 +000093
Garrett Cooper7d0a4a52010-12-16 10:05:08 -080094 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080095 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
plars37568272002-12-05 22:01:29 +000096
plars37568272002-12-05 22:01:29 +000097 setup();
98
plars37568272002-12-05 22:01:29 +000099 for (lc = 0; TEST_LOOPING(lc); lc++) {
100
Caspar Zhangd59a6592013-03-07 14:59:12 +0800101 tst_count = 0;
plars37568272002-12-05 22:01:29 +0000102
subrata_modak56207ce2009-03-23 13:35:39 +0000103 for (ind = 0; ind < TST_TOTAL; ind++) {
subrata_modak4bb656a2009-02-26 12:02:09 +0000104 /*
plars37568272002-12-05 22:01:29 +0000105 * Call sched_get_priority_max(2)
subrata_modak56207ce2009-03-23 13:35:39 +0000106 */
plars37568272002-12-05 22:01:29 +0000107 TEST(sched_get_priority_max(test_cases[ind].policy));
subrata_modakbdbaec52009-02-26 12:14:51 +0000108
plars37568272002-12-05 22:01:29 +0000109 if (TEST_RETURN == test_cases[ind].retval) {
110 tst_resm(TPASS, "%s Passed",
111 test_cases[ind].desc);
112 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800113 tst_resm(TFAIL | TTERRNO, "%s Failed,"
subrata_modak923b23f2009-11-02 13:57:16 +0000114 "sched_get_priority_max() returned %ld",
115 test_cases[ind].desc, TEST_RETURN);
plars37568272002-12-05 22:01:29 +0000116 }
subrata_modak4bb656a2009-02-26 12:02:09 +0000117 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800118 }
plars37568272002-12-05 22:01:29 +0000119
120 /* cleanup and exit */
121 cleanup();
122
Garrett Cooper53740502010-12-16 00:04:01 -0800123 tst_exit();
plars37568272002-12-05 22:01:29 +0000124
Garrett Cooper2c282152010-12-16 00:55:50 -0800125}
plars37568272002-12-05 22:01:29 +0000126
127/* setup() - performs all ONE TIME setup for this test */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400128void setup(void)
plars37568272002-12-05 22:01:29 +0000129{
subrata_modakbdbaec52009-02-26 12:14:51 +0000130
plars37568272002-12-05 22:01:29 +0000131 tst_sig(NOFORK, DEF_HANDLER, cleanup);
132
plars37568272002-12-05 22:01:29 +0000133 TEST_PAUSE;
134
Garrett Cooper2c282152010-12-16 00:55:50 -0800135}
plars37568272002-12-05 22:01:29 +0000136
subrata_modak4bb656a2009-02-26 12:02:09 +0000137/*
plars37568272002-12-05 22:01:29 +0000138 *cleanup() - performs all ONE TIME cleanup for this test at
139 * completion or premature exit.
140 */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400141void cleanup(void)
plars37568272002-12-05 22:01:29 +0000142{
143
Chris Dearmanec6edca2012-10-17 19:54:01 -0700144}