plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 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 |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 13 | * with this program; if not, write the Free Software Foundation, Inc., |
| 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 15 | * |
| 16 | */ |
| 17 | /********************************************************** |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 18 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 19 | * TEST IDENTIFIER : sched_get_priority_min02 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 20 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 21 | * EXECUTED BY : anyone |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 22 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 23 | * TEST TITLE : Test for error conditions |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 24 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 25 | * TEST CASE TOTAL : 1 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 26 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 27 | * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com> |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 28 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 29 | * 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 36 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 37 | * Setup: |
| 38 | * Setup signal handling. |
| 39 | * Pause for SIGUSR1 if option specified. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 40 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 41 | * 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 48 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 49 | * Cleanup: |
| 50 | * Print errno log and/or timing stats if options given |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 51 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 52 | * 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" |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 70 | |
| 71 | #define SCHED_INVALID 1000 |
| 72 | |
| 73 | static void setup(); |
| 74 | static void cleanup(); |
| 75 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 76 | char *TCID = "sched_get_priority_min02"; |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 77 | |
| 78 | int TST_TOTAL = 1; |
| 79 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 80 | int main(int ac, char **av) |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 81 | { |
| 82 | |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 83 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 84 | const char *msg; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 85 | |
Garrett Cooper | a9e49f1 | 2010-12-16 10:54:03 -0800 | [diff] [blame] | 86 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 87 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 88 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 89 | setup(); |
| 90 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 91 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
| 92 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 93 | tst_count = 0; |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 94 | |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 95 | /* |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 96 | * Call sched_get_priority_min(2) |
| 97 | */ |
| 98 | TEST(sched_get_priority_min(SCHED_INVALID)); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 99 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 100 | if ((TEST_RETURN == -1) && (TEST_ERRNO == EINVAL)) { |
| 101 | tst_resm(TPASS, "Test Passed, Got EINVAL"); |
| 102 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 103 | tst_resm(TFAIL | TTERRNO, |
| 104 | "Test Failed, sched_get_priority_min()" |
| 105 | " returned %ld", TEST_RETURN); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 106 | } |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 107 | } |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 108 | |
| 109 | /* cleanup and exit */ |
| 110 | cleanup(); |
Garrett Cooper | 1e6f5a6 | 2010-12-19 09:58:10 -0800 | [diff] [blame] | 111 | tst_exit(); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 112 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 113 | } |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 114 | |
| 115 | /* setup() - performs all ONE TIME setup for this test */ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 116 | void setup(void) |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 117 | { |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 118 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 119 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
| 120 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 121 | TEST_PAUSE; |
| 122 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 123 | } |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 124 | |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 125 | /* |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 126 | *cleanup() - performs all ONE TIME cleanup for this test at |
| 127 | * completion or premature exit. |
| 128 | */ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 129 | void cleanup(void) |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 130 | { |
| 131 | |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 132 | } |