robbiew | 0e9d458 | 2002-12-24 17:06:57 +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. |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 15 | * |
| 16 | */ |
| 17 | /************************************************************************** |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 18 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 19 | * TEST IDENTIFIER : munlockall01 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 20 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 21 | * EXECUTED BY : root / superuser |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 22 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 23 | * TEST TITLE : Basic test for munlockall(2) |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 24 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 25 | * TEST CASE TOTAL : 1 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 26 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 27 | * AUTHOR : sowmya adiga<sowmya.adiga@wipro.com> |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 28 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +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 munlockall(2) system call. |
| 35 | * It is intended to provide a limited exposure of the system call. |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 36 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +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 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 41 | * Test: |
| 42 | * Execute system call |
| 43 | * Check return code, if system call failed (return=-1) |
| 44 | * Log the errno and Issue a FAIL message. |
| 45 | * Otherwise, Issue a PASS message. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 46 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 47 | * Cleanup: |
| 48 | * Print errno log and/or timing stats if options given |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 49 | * |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 50 | * USAGE: <for command-line> |
| 51 | * munlockall01 [-c n] [-e] [-i n] [-I x] [-p x] [-t] |
| 52 | * where, -c n : Run n copies concurrently |
| 53 | * -e : Turn on errno logging. |
| 54 | * -h : Show this help screen |
| 55 | * -i n : Execute test n times. |
| 56 | * -I x : Execute test for x seconds. |
| 57 | * -p : Pause for SIGUSR1 before starting |
| 58 | * -P x : Pause for x seconds between iterations. |
| 59 | * t : Turn on syscall timing. |
| 60 | * |
| 61 | * RESTRICTIONS |
| 62 | * Must be root/superuser to run it. |
| 63 | *****************************************************************************/ |
| 64 | #include <errno.h> |
| 65 | #include <sys/mman.h> |
| 66 | #include "test.h" |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 67 | |
| 68 | void setup(); |
| 69 | void cleanup(); |
| 70 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 71 | char *TCID = "munlockall01"; |
| 72 | int TST_TOTAL = 1; |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 73 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 74 | #if !defined(UCLINUX) |
| 75 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 76 | int main(int ac, char **av) |
| 77 | { |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 78 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 79 | const char *msg; |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 80 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 81 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 82 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 83 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 84 | } |
| 85 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 86 | setup(); |
| 87 | |
| 88 | /* check looping state */ |
| 89 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
| 90 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 91 | tst_count = 0; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 92 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 93 | TEST(munlockall()); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 94 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 95 | /* check return code */ |
| 96 | if (TEST_RETURN == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 97 | tst_resm(TFAIL | TTERRNO, "munlockall() Failed with" |
| 98 | " return=%ld", TEST_RETURN); |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 99 | } else { |
| 100 | tst_resm(TPASS, "munlockall() passed with" |
subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 101 | " return=%ld ", TEST_RETURN); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 102 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 103 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 104 | } |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 105 | |
| 106 | /* cleanup and exit */ |
| 107 | cleanup(); |
Garrett Cooper | 1e6f5a6 | 2010-12-19 09:58:10 -0800 | [diff] [blame] | 108 | tst_exit(); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 109 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 110 | } |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 111 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 112 | #else |
| 113 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 114 | int main(void) |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 115 | { |
vapier | 81a6307 | 2006-02-27 04:29:21 +0000 | [diff] [blame] | 116 | tst_resm(TINFO, "test is not available on uClinux"); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 117 | tst_exit(); |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | #endif /* if !defined(UCLINUX) */ |
| 121 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 122 | /* setup() - performs all ONE TIME setup for this test. */ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 123 | void setup(void) |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 124 | { |
Nicolas Joly | d4ceb37 | 2014-06-22 17:03:57 +0200 | [diff] [blame] | 125 | tst_require_root(NULL); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 126 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 127 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
| 128 | |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 129 | TEST_PAUSE; |
| 130 | } |
| 131 | |
| 132 | /* |
| 133 | * cleanup() - performs all ONE TIME cleanup for this test at |
| 134 | * completion or premature exit. |
| 135 | */ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 136 | void cleanup(void) |
robbiew | 0e9d458 | 2002-12-24 17:06:57 +0000 | [diff] [blame] | 137 | { |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 138 | } |