blob: e8f7fbcc97a7acf6c4d5eb0142ed9decb971b0ea [file] [log] [blame]
robbiew0e9d4582002-12-24 17:06:57 +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.
robbiew0e9d4582002-12-24 17:06:57 +000015 *
16 */
17/**************************************************************************
subrata_modak4bb656a2009-02-26 12:02:09 +000018 *
robbiew0e9d4582002-12-24 17:06:57 +000019 * TEST IDENTIFIER : munlockall01
subrata_modak4bb656a2009-02-26 12:02:09 +000020 *
robbiew0e9d4582002-12-24 17:06:57 +000021 * EXECUTED BY : root / superuser
subrata_modak4bb656a2009-02-26 12:02:09 +000022 *
robbiew0e9d4582002-12-24 17:06:57 +000023 * TEST TITLE : Basic test for munlockall(2)
subrata_modak4bb656a2009-02-26 12:02:09 +000024 *
robbiew0e9d4582002-12-24 17:06:57 +000025 * TEST CASE TOTAL : 1
subrata_modak4bb656a2009-02-26 12:02:09 +000026 *
robbiew0e9d4582002-12-24 17:06:57 +000027 * AUTHOR : sowmya adiga<sowmya.adiga@wipro.com>
subrata_modak4bb656a2009-02-26 12:02:09 +000028 *
robbiew0e9d4582002-12-24 17:06:57 +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 munlockall(2) system call.
35 * It is intended to provide a limited exposure of the system call.
subrata_modakbdbaec52009-02-26 12:14:51 +000036 *
robbiew0e9d4582002-12-24 17:06:57 +000037 * Setup:
38 * Setup signal handling.
39 * Pause for SIGUSR1 if option specified.
subrata_modak4bb656a2009-02-26 12:02:09 +000040 *
robbiew0e9d4582002-12-24 17:06:57 +000041 * 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_modak4bb656a2009-02-26 12:02:09 +000046 *
robbiew0e9d4582002-12-24 17:06:57 +000047 * Cleanup:
48 * Print errno log and/or timing stats if options given
subrata_modak4bb656a2009-02-26 12:02:09 +000049 *
robbiew0e9d4582002-12-24 17:06:57 +000050 * 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"
robbiew0e9d4582002-12-24 17:06:57 +000067
68void setup();
69void cleanup();
70
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020071char *TCID = "munlockall01";
72int TST_TOTAL = 1;
robbiew0e9d4582002-12-24 17:06:57 +000073
robbiewd34d5812005-07-11 22:28:09 +000074#if !defined(UCLINUX)
75
robbiew0e9d4582002-12-24 17:06:57 +000076int main(int ac, char **av)
77{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020078 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020079 const char *msg;
robbiew0e9d4582002-12-24 17:06:57 +000080
Garrett Cooper45e285d2010-11-22 12:19:25 -080081 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
robbiew0e9d4582002-12-24 17:06:57 +000082 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Garrett Cooper2c282152010-12-16 00:55:50 -080083
robbiew0e9d4582002-12-24 17:06:57 +000084 }
85
robbiew0e9d4582002-12-24 17:06:57 +000086 setup();
87
88 /* check looping state */
89 for (lc = 0; TEST_LOOPING(lc); lc++) {
90
Caspar Zhangd59a6592013-03-07 14:59:12 +080091 tst_count = 0;
subrata_modak56207ce2009-03-23 13:35:39 +000092
robbiew0e9d4582002-12-24 17:06:57 +000093 TEST(munlockall());
subrata_modak56207ce2009-03-23 13:35:39 +000094
robbiew0e9d4582002-12-24 17:06:57 +000095 /* check return code */
96 if (TEST_RETURN == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +080097 tst_resm(TFAIL | TTERRNO, "munlockall() Failed with"
98 " return=%ld", TEST_RETURN);
robbiew0e9d4582002-12-24 17:06:57 +000099 } else {
100 tst_resm(TPASS, "munlockall() passed with"
subrata_modak923b23f2009-11-02 13:57:16 +0000101 " return=%ld ", TEST_RETURN);
subrata_modak56207ce2009-03-23 13:35:39 +0000102
robbiew0e9d4582002-12-24 17:06:57 +0000103 }
subrata_modak56207ce2009-03-23 13:35:39 +0000104 }
robbiew0e9d4582002-12-24 17:06:57 +0000105
106 /* cleanup and exit */
107 cleanup();
Garrett Cooper1e6f5a62010-12-19 09:58:10 -0800108 tst_exit();
subrata_modakbdbaec52009-02-26 12:14:51 +0000109
Garrett Cooper2c282152010-12-16 00:55:50 -0800110}
robbiew0e9d4582002-12-24 17:06:57 +0000111
robbiewd34d5812005-07-11 22:28:09 +0000112#else
113
Mike Frysingerc57fba52014-04-09 18:56:30 -0400114int main(void)
robbiewd34d5812005-07-11 22:28:09 +0000115{
vapier81a63072006-02-27 04:29:21 +0000116 tst_resm(TINFO, "test is not available on uClinux");
Garrett Cooper2c282152010-12-16 00:55:50 -0800117 tst_exit();
robbiewd34d5812005-07-11 22:28:09 +0000118}
119
120#endif /* if !defined(UCLINUX) */
121
robbiew0e9d4582002-12-24 17:06:57 +0000122/* setup() - performs all ONE TIME setup for this test. */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400123void setup(void)
robbiew0e9d4582002-12-24 17:06:57 +0000124{
Nicolas Jolyd4ceb372014-06-22 17:03:57 +0200125 tst_require_root(NULL);
subrata_modakbdbaec52009-02-26 12:14:51 +0000126
robbiew0e9d4582002-12-24 17:06:57 +0000127 tst_sig(NOFORK, DEF_HANDLER, cleanup);
128
robbiew0e9d4582002-12-24 17:06:57 +0000129 TEST_PAUSE;
130}
131
132/*
133 * cleanup() - performs all ONE TIME cleanup for this test at
134 * completion or premature exit.
135 */
Mike Frysingerc57fba52014-04-09 18:56:30 -0400136void cleanup(void)
robbiew0e9d4582002-12-24 17:06:57 +0000137{
Chris Dearmanec6edca2012-10-17 19:54:01 -0700138}