3 * Copyright (c) International Business Machines Corp., 2001
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * shmctl04 - test the SHM_INFO command
26 * they are used with shmctl() in ipcs
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.
38 * 09/2002 - Written by Mingming Cao
46 char *TCID
= "shmctl04";
50 struct shm_info shm_info
;
54 * These are the various setup and check functions for the commands
55 * that we are checking.
58 int main(int ac
, char **av
)
60 int lc
; /* loop counter */
61 char *msg
; /* message returned from parse_opts */
63 /* parse standard options */
64 if ((msg
= parse_opts(ac
, av
, (option_t
*)NULL
, NULL
)) != (char *)NULL
){
65 tst_brkm(TBROK
, cleanup
, "OPTION PARSING ERROR - %s", msg
);
70 /* The following loop checks looping state if -i option given */
72 for (lc
= 0; TEST_LOOPING(lc
); lc
++) {
73 /* reset Tst_count in case we are looping */
75 TEST(shmctl(0, SHM_INFO
, (struct shmid_ds
*)&shm_info
));
77 if (TEST_RETURN
!= -1) {
78 tst_resm(TPASS
, "SHM_INFO call succeeded");
82 TEST_ERROR_LOG(TEST_ERRNO
);
84 tst_resm(TFAIL
, "SHM_INFO call failed with an unexpected error"
85 " - %d : %s",TEST_ERRNO
, strerror(TEST_ERRNO
));
96 * setup() - performs all the ONE TIME setup for this test.
101 /* capture signals */
102 tst_sig(NOFORK
, DEF_HANDLER
, cleanup
);
104 /* Pause if that option was specified */
108 * Create a temporary directory and cd into it.
109 * This helps to ensure that a unique msgkey is created.
110 * See ../lib/libipc.c for more information.
117 * cleanup() - performs all the ONE TIME cleanup for this test at completion
124 /* Remove the temporary directory */
128 * print timing stats if that option was specified.
129 * print errno log if that option was specified.
133 /* exit with return code appropriate for results */