1 /*
2 *
3 * Copyright (c) International Business Machines Corp., 2001
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /*
21 * NAME
22 * shmctl04.c
23 *
24 * DESCRIPTION
25 * shmctl04 - test the SHM_INFO command
26 * they are used with shmctl() in ipcs
27 *
28 * USAGE: <for command-line>
29 * shmctl04 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
30 * where, -c n : Run n copies concurrently.
31 * -f : Turn off functionality Testing.
32 * -i n : Execute test n times.
33 * -I x : Execute test for x seconds.
34 * -P x : Pause for x seconds between iterations.
35 * -t : Turn on syscall timing.
36 *
37 * HISTORY
38 * 09/2002 - Written by Mingming Cao
39 *
40 * RESTRICTIONS
41 * none
42 */
43
44 #include "ipcshm.h"
45
46 char *TCID = "shmctl04";
47 int TST_TOTAL = 1;
48
49 struct shm_info shm_info;
50 int max_ids;
51
52 /*
53 * These are the various setup and check functions for the commands
54 * that we are checking.
55 */
56
main(int ac,char ** av)57 int main(int ac, char **av)
58 {
59 int lc;
60
61 tst_parse_opts(ac, av, NULL, NULL);
62
63 setup();
64
65 /* The following loop checks looping state if -i option given */
66
67 for (lc = 0; TEST_LOOPING(lc); lc++) {
68 /* reset tst_count in case we are looping */
69 tst_count = 0;
70 TEST(shmctl(0, SHM_INFO, (struct shmid_ds *)&shm_info));
71
72 if (TEST_RETURN != -1) {
73 tst_resm(TPASS, "SHM_INFO call succeeded");
74 continue;
75 }
76
77 tst_resm(TFAIL, "SHM_INFO call failed with an unexpected error"
78 " - %d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
79
80 }
81
82 cleanup();
83
84 tst_exit();
85 }
86
87 /*
88 * setup() - performs all the ONE TIME setup for this test.
89 */
setup(void)90 void setup(void)
91 {
92
93 tst_sig(NOFORK, DEF_HANDLER, cleanup);
94
95 TEST_PAUSE;
96
97 /*
98 * Create a temporary directory and cd into it.
99 * This helps to ensure that a unique msgkey is created.
100 * See ../lib/libipc.c for more information.
101 */
102 tst_tmpdir();
103
104 }
105
106 /*
107 * cleanup() - performs all the ONE TIME cleanup for this test at completion
108 * or premature exit.
109 */
cleanup(void)110 void cleanup(void)
111 {
112
113 tst_rmdir();
114
115 }
116