blob: a174a67acd9b35658bb77c3e3f4423c34d36f112 [file] [log] [blame]
vapierd13d74b2006-02-11 07:24:00 +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.
vapierd13d74b2006-02-11 07:24:00 +000015 *
16 */
17/**********************************************************
subrata_modak4bb656a2009-02-26 12:02:09 +000018 *
vapierd13d74b2006-02-11 07:24:00 +000019 * TEST IDENTIFIER : sched_setparam01
subrata_modak4bb656a2009-02-26 12:02:09 +000020 *
vapierd13d74b2006-02-11 07:24:00 +000021 * EXECUTED BY : anyone
subrata_modak4bb656a2009-02-26 12:02:09 +000022 *
vapierd13d74b2006-02-11 07:24:00 +000023 * TEST TITLE : Basic test for sched_setparam(2)
subrata_modak4bb656a2009-02-26 12:02:09 +000024 *
vapierd13d74b2006-02-11 07:24:00 +000025 * TEST CASE TOTAL : 1
subrata_modak4bb656a2009-02-26 12:02:09 +000026 *
vapierd13d74b2006-02-11 07:24:00 +000027 * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
subrata_modak4bb656a2009-02-26 12:02:09 +000028 *
vapierd13d74b2006-02-11 07:24:00 +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_setparam(2) system call.
35 * It is intended to provide a limited exposure of the system call.
subrata_modak4bb656a2009-02-26 12:02:09 +000036 *
vapierd13d74b2006-02-11 07:24:00 +000037 * Setup:
38 * Setup signal handling.
39 * Pause for SIGUSR1 if option specified.
subrata_modak4bb656a2009-02-26 12:02:09 +000040 *
vapierd13d74b2006-02-11 07:24:00 +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 *
vapierd13d74b2006-02-11 07:24:00 +000048 * Cleanup:
49 * Print errno log and/or timing stats if options given
subrata_modak4bb656a2009-02-26 12:02:09 +000050 *
vapierd13d74b2006-02-11 07:24:00 +000051 * USAGE: <for command-line>
52 * sched_setparam01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
53 * where, -c n : Run n copies concurrently.
54 * -e : Turn on errno logging.
55 * -h : Show help screen
56 * -f : Turn off functional testing
57 * -i n : Execute test n times.
58 * -I x : Execute test for x seconds.
59 * -p : Pause for SIGUSR1 before starting
60 * -P x : Pause for x seconds between iterations.
61 * -t : Turn on syscall timing.
62 *
63 ****************************************************************/
64
65#include <errno.h>
66#include <sched.h>
67#include "test.h"
vapierd13d74b2006-02-11 07:24:00 +000068
69static void setup();
70static void cleanup();
71
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020072char *TCID = "sched_setparam01";
73int TST_TOTAL = 1;
vapierd13d74b2006-02-11 07:24:00 +000074
75static struct sched_param param;
76
subrata_modak56207ce2009-03-23 13:35:39 +000077int main(int ac, char **av)
vapierd13d74b2006-02-11 07:24:00 +000078{
79
Cyril Hrubis89af32a2012-10-24 16:39:11 +020080 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020081 const char *msg;
vapierd13d74b2006-02-11 07:24:00 +000082
Garrett Cooper53740502010-12-16 00:04:01 -080083 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080084 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
vapierd13d74b2006-02-11 07:24:00 +000085
vapierd13d74b2006-02-11 07:24:00 +000086 setup();
87
vapierd13d74b2006-02-11 07:24:00 +000088 for (lc = 0; TEST_LOOPING(lc); lc++) {
89
Caspar Zhangd59a6592013-03-07 14:59:12 +080090 tst_count = 0;
vapierd13d74b2006-02-11 07:24:00 +000091
92 /*
93 * Call sched_setparam(2) with pid=0 sothat it will
94 * set the scheduling parameters for the calling process
95 */
96 TEST(sched_setparam(0, &param));
subrata_modakbdbaec52009-02-26 12:14:51 +000097
vapierd13d74b2006-02-11 07:24:00 +000098 if (TEST_RETURN == 0) {
subrata_modak923b23f2009-11-02 13:57:16 +000099 tst_resm(TPASS, "sched_setparam() returned %ld",
vapierd13d74b2006-02-11 07:24:00 +0000100 TEST_RETURN);
101 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800102 tst_resm(TFAIL | TTERRNO,
103 "Test Failed, sched_setparam()" "returned %ld",
104 TEST_RETURN);
subrata_modak4bb656a2009-02-26 12:02:09 +0000105 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800106 }
vapierd13d74b2006-02-11 07:24:00 +0000107
vapierd13d74b2006-02-11 07:24:00 +0000108 cleanup();
Garrett Coopere57b3f72010-12-19 08:46:29 -0800109 tst_exit();
Garrett Cooper2c282152010-12-16 00:55:50 -0800110}
vapierd13d74b2006-02-11 07:24:00 +0000111
112/* setup() - performs all ONE TIME setup for this test */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400113void setup(void)
vapierd13d74b2006-02-11 07:24:00 +0000114{
subrata_modakbdbaec52009-02-26 12:14:51 +0000115
vapierd13d74b2006-02-11 07:24:00 +0000116 tst_sig(NOFORK, DEF_HANDLER, cleanup);
117
vapierd13d74b2006-02-11 07:24:00 +0000118 TEST_PAUSE;
119
120 param.sched_priority = 0;
subrata_modakbdbaec52009-02-26 12:14:51 +0000121
Garrett Cooper2c282152010-12-16 00:55:50 -0800122}
vapierd13d74b2006-02-11 07:24:00 +0000123
124/*
125 *cleanup() - performs all ONE TIME cleanup for this test at
126 * completion or premature exit.
127 */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400128void cleanup(void)
vapierd13d74b2006-02-11 07:24:00 +0000129{
Chris Dearmanec6edca2012-10-17 19:54:01 -0700130}