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 * shmdt02 - check for EINVAL error
28 * loop if that option was specified
29 * call shmdt() using an invalid shared memory address
30 * check the errno value
31 * issue a PASS message if we get EINVAL
32 * otherwise, the tests fails
33 * issue a FAIL message
36 * USAGE: <for command-line>
37 * shmdt02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
38 * where, -c n : Run n copies concurrently.
39 * -e : Turn on errno logging.
40 * -i n : Execute test n times.
41 * -I x : Execute test for x seconds.
42 * -P x : Pause for x seconds between iterations.
43 * -t : Turn on syscall timing.
46 * 03/2001 - Written by Wayne Boyer
54 char *TCID
= "shmdt02";
58 int exp_enos
[] = {EINVAL
, 0}; /* 0 terminated list of expected errnos */
60 int main(int ac
, char **av
)
62 int lc
; /* loop counter */
63 char *msg
; /* message returned from parse_opts */
64 int unshared
; /* a local variable to use to produce */ /* the error in the shmdt() call */
66 /* parse standard options */
67 if ((msg
= parse_opts(ac
, av
, (option_t
*)NULL
, NULL
)) != (char *)NULL
){
68 tst_brkm(TBROK
, cleanup
, "OPTION PARSING ERROR - %s", msg
);
71 setup(); /* global setup */
73 /* The following loop checks looping state if -i option given */
75 for (lc
= 0; TEST_LOOPING(lc
); lc
++) {
76 /* reset Tst_count in case we are looping */
80 * make the call using the TEST() macro - attempt to
81 * remove an invalid shared memory address
84 TEST(shmdt(&unshared
));
86 if (TEST_RETURN
!= -1) {
87 tst_brkm(TFAIL
, cleanup
, "call succeeded unexpectedly");
90 TEST_ERROR_LOG(TEST_ERRNO
);
94 tst_resm(TPASS
, "expected failure - errno = %d : %s",
95 TEST_ERRNO
, strerror(TEST_ERRNO
));
98 tst_resm(TFAIL
, "call failed with an unexpected error "
99 "- %d : %s", TEST_ERRNO
, strerror(TEST_ERRNO
));
111 * setup() - performs all the ONE TIME setup for this test.
116 /* capture signals */
117 tst_sig(NOFORK
, DEF_HANDLER
, cleanup
);
119 /* Set up the expected error numbers for -e option */
120 TEST_EXP_ENOS(exp_enos
);
122 /* Pause if that option was specified */
127 * cleanup() - performs all the ONE TIME cleanup for this test at completion
134 * print timing stats if that option was specified.
135 * print errno log if that option was specified.
139 /* exit with return code appropriate for results */