sort: add -x hex sort feature back
[minix.git] / test / ipc / shmctl / shmctl04.c
blobefeaf6ff1100cec917c762b3612ea5581cb923d6
1 /*
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
21 * NAME
22 * shmctl04.c
24 * DESCRIPTION
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.
37 * HISTORY
38 * 09/2002 - Written by Mingming Cao
40 * RESTRICTIONS
41 * none
44 #include "ipcshm.h"
46 char *TCID = "shmctl04";
47 int TST_TOTAL = 1;
48 extern int Tst_count;
50 struct shm_info shm_info;
51 int max_ids;
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);
68 setup();
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 */
74 Tst_count = 0;
75 TEST(shmctl(0, SHM_INFO, (struct shmid_ds *)&shm_info));
77 if (TEST_RETURN != -1) {
78 tst_resm(TPASS, "SHM_INFO call succeeded");
79 continue;
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));
89 cleanup();
91 /*NOTREACHED*/
92 return(0);
96 * setup() - performs all the ONE TIME setup for this test.
98 void
99 setup(void)
101 /* capture signals */
102 tst_sig(NOFORK, DEF_HANDLER, cleanup);
104 /* Pause if that option was specified */
105 TEST_PAUSE;
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.
112 tst_tmpdir();
117 * cleanup() - performs all the ONE TIME cleanup for this test at completion
118 * or premature exit.
120 void
121 cleanup(void)
124 /* Remove the temporary directory */
125 tst_rmdir();
128 * print timing stats if that option was specified.
129 * print errno log if that option was specified.
131 TEST_CLEANUP;
133 /* exit with return code appropriate for results */
134 tst_exit();