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 : munlockall01
20 *
21 * EXECUTED BY : root / superuser
22 *
23 * TEST TITLE : Basic test for munlockall(2)
24 *
25 * TEST CASE TOTAL : 1
26 *
27 * AUTHOR : sowmya adiga<sowmya.adiga@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 munlockall(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 * 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.
46 *
47 * Cleanup:
48 * Print errno log and/or timing stats if options given
49 *
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"
67
68 void setup();
69 void cleanup();
70
71 char *TCID = "munlockall01";
72 int TST_TOTAL = 1;
73
74 #if !defined(UCLINUX)
75
main(int ac,char ** av)76 int main(int ac, char **av)
77 {
78 int lc;
79
80 tst_parse_opts(ac, av, NULL, NULL);
81
82 setup();
83
84 /* check looping state */
85 for (lc = 0; TEST_LOOPING(lc); lc++) {
86
87 tst_count = 0;
88
89 TEST(munlockall());
90
91 /* check return code */
92 if (TEST_RETURN == -1) {
93 tst_resm(TFAIL | TTERRNO, "munlockall() Failed with"
94 " return=%ld", TEST_RETURN);
95 } else {
96 tst_resm(TPASS, "munlockall() passed with"
97 " return=%ld ", TEST_RETURN);
98
99 }
100 }
101
102 /* cleanup and exit */
103 cleanup();
104 tst_exit();
105
106 }
107
108 #else
109
main(void)110 int main(void)
111 {
112 tst_resm(TINFO, "test is not available on uClinux");
113 tst_exit();
114 }
115
116 #endif /* if !defined(UCLINUX) */
117
118 /* setup() - performs all ONE TIME setup for this test. */
setup(void)119 void setup(void)
120 {
121 tst_require_root();
122
123 tst_sig(NOFORK, DEF_HANDLER, cleanup);
124
125 TEST_PAUSE;
126 }
127
128 /*
129 * cleanup() - performs all ONE TIME cleanup for this test at
130 * completion or premature exit.
131 */
cleanup(void)132 void cleanup(void)
133 {
134 }
135