Home | History | Annotate | Download | only in sched_setparam
      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_setparam01
     20  *
     21  *    EXECUTED BY	: anyone
     22  *
     23  *    TEST TITLE	: Basic test for sched_setparam(2)
     24  *
     25  *    TEST CASE TOTAL	: 1
     26  *
     27  *    AUTHOR		: Saji Kumar.V.R <saji.kumar (at) 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  *	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.
     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)
     45  *		Log the errno and Issue a FAIL message.
     46  *	  Otherwise, Issue a PASS message.
     47  *
     48  * 	Cleanup:
     49  * 	  Print errno log and/or timing stats if options given
     50  *
     51  * 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"
     68 
     69 static void setup();
     70 static void cleanup();
     71 
     72 char *TCID = "sched_setparam01";
     73 int TST_TOTAL = 1;
     74 
     75 static struct sched_param param;
     76 
     77 int main(int ac, char **av)
     78 {
     79 
     80 	int lc;
     81 
     82 	tst_parse_opts(ac, av, NULL, NULL);
     83 
     84 	setup();
     85 
     86 	for (lc = 0; TEST_LOOPING(lc); lc++) {
     87 
     88 		tst_count = 0;
     89 
     90 		/*
     91 		 * Call sched_setparam(2) with pid=0 sothat it will
     92 		 * set the scheduling parameters for the calling process
     93 		 */
     94 		TEST(sched_setparam(0, &param));
     95 
     96 		if (TEST_RETURN == 0) {
     97 			tst_resm(TPASS, "sched_setparam() returned %ld",
     98 				 TEST_RETURN);
     99 		} else {
    100 			tst_resm(TFAIL | TTERRNO,
    101 				 "Test Failed, sched_setparam()" "returned %ld",
    102 				 TEST_RETURN);
    103 		}
    104 	}
    105 
    106 	cleanup();
    107 	tst_exit();
    108 }
    109 
    110 /* setup() - performs all ONE TIME setup for this test */
    111 void setup(void)
    112 {
    113 
    114 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
    115 
    116 	TEST_PAUSE;
    117 
    118 	param.sched_priority = 0;
    119 
    120 }
    121 
    122 /*
    123  *cleanup() -  performs all ONE TIME cleanup for this test at
    124  *		completion or premature exit.
    125  */
    126 void cleanup(void)
    127 {
    128 }
    129