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_min01 |
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 : Basic test for sched_get_priority_min(2) |
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 : 3 |
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 | * 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_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) |
| 45 | * Log the errno and Issue a FAIL message. |
| 46 | * Otherwise, Issue a PASS message. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 47 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 48 | * Cleanup: |
| 49 | * Print errno log and/or timing stats if options given |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 50 | * |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 51 | * 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 | |
| 71 | static void setup(); |
| 72 | static void cleanup(); |
| 73 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 74 | char *TCID = "sched_get_priority_min01"; /* Test program identifier. */ |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 75 | |
| 76 | static struct test_case_t { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 77 | char *desc; |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 78 | int policy; |
| 79 | int retval; |
| 80 | } test_cases[] = { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 81 | { |
| 82 | "Test for SCHED_OTHER", SCHED_OTHER, 0}, { |
| 83 | "Test for SCHED_FIFO", SCHED_FIFO, 1}, { |
| 84 | "Test for SCHED_RR", SCHED_RR, 1} |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 87 | int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 88 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 89 | int main(int ac, char **av) |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 90 | { |
| 91 | |
| 92 | int lc, ind; /* loop counter */ |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 93 | char *msg; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 94 | |
Garrett Cooper | a9e49f1 | 2010-12-16 10:54:03 -0800 | [diff] [blame] | 95 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 96 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 97 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 98 | setup(); |
| 99 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 100 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
| 101 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 102 | tst_count = 0; |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 103 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 104 | for (ind = 0; ind < TST_TOTAL; ind++) { |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 105 | /* |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 106 | * Call sched_get_priority_min(2) |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 107 | */ |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 108 | TEST(sched_get_priority_min(test_cases[ind].policy)); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 109 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 110 | if (TEST_RETURN == test_cases[ind].retval) { |
| 111 | tst_resm(TPASS, "%s Passed", |
| 112 | test_cases[ind].desc); |
| 113 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 114 | tst_resm(TFAIL | TTERRNO, "%s Failed," |
subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 115 | "sched_get_priority_min() returned %ld", |
| 116 | test_cases[ind].desc, TEST_RETURN); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 117 | } |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 118 | } |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 119 | } |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 120 | |
| 121 | /* cleanup and exit */ |
| 122 | cleanup(); |
| 123 | |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 124 | tst_exit(); |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 125 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 126 | } |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 127 | |
| 128 | /* setup() - performs all ONE TIME setup for this test */ |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 129 | void setup() |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 130 | { |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 131 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 132 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
| 133 | |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 134 | TEST_PAUSE; |
| 135 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 136 | } |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 137 | |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 138 | /* |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 139 | *cleanup() - performs all ONE TIME cleanup for this test at |
| 140 | * completion or premature exit. |
| 141 | */ |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 142 | void cleanup() |
plars | 96eefcf | 2002-12-05 22:02:10 +0000 | [diff] [blame] | 143 | { |
| 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 Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 151 | } |