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 * Testcase to check the basic functionality of getgid().
29 * loop if that option was specified
30 * Execute getgid() call using TEST macro
31 * if not expected value
32 * break remaining tests and cleanup
33 * if STD_FUNCTIONAL_TEST
34 * Execute getuid() call
35 * Execute getpwduid() call
36 * if the passwd entry is NULL
37 * break the remaining tests and cleanup
38 * else if pwent->pw_gid != TEST_RETURN
39 * print failure message
46 * USAGE: <for command-line>
47 * getgid03 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
48 * where, -c n : Run n copies concurrently.
49 * -f : Turn off functionality Testing.
50 * -i n : Execute test n times.
51 * -I x : Execute test for x seconds.
52 * -P x : Pause for x seconds between iterations.
53 * -t : Turn on syscall timing.
56 * 07/2001 Ported by Wayne Boyer
68 #include "compat_16.h"
73 TCID_DEFINE(getgid03
);
77 int main(int ac
, char **av
)
79 int lc
; /* loop counter */
80 char *msg
; /* message returned from parse_opts */
84 /* parse standard options */
85 if ((msg
= parse_opts(ac
, av
, (option_t
*) NULL
, NULL
)) != (char *)NULL
) {
86 tst_brkm(TBROK
, cleanup
, "OPTION PARSING ERROR - %s", msg
);
89 setup(); /* global setup */
91 /* The following loop checks looping state if -i option given */
92 for (lc
= 0; TEST_LOOPING(lc
); lc
++) {
94 /* reset Tst_count in case we are looping */
99 if (TEST_RETURN
< 0) {
100 tst_brkm(TBROK
, cleanup
, "This should never happen");
103 if (STD_FUNCTIONAL_TEST
) {
105 pwent
= getpwuid(uid
);
108 tst_brkm(TBROK
, cleanup
, "getuid() returned "
109 "unexpected value %d", uid
);
110 } else if (!GID_SIZE_CHECK(pwent
->pw_gid
)) {
113 "gid for uid %d is too large for testing getgid16",
116 if (pwent
->pw_gid
!= TEST_RETURN
) {
117 tst_resm(TFAIL
, "getgid() return value "
118 "%ld unexpected - expected %d",
119 TEST_RETURN
, pwent
->pw_gid
);
121 tst_resm(TPASS
, "group id %ld returned "
122 "correctly", TEST_RETURN
);
126 tst_resm(TPASS
, "call succeeded");
131 /*NOTREACHED*/ return 0;
135 * setup() - performs all ONE TIME setup for this test
139 /* capture signals */
140 tst_sig(NOFORK
, DEF_HANDLER
, cleanup
);
142 /* Pause if that option was specified */
147 * cleanup() - performs all the ONE TIME cleanup for this test at completion
153 * print timing status if that option was specified.
154 * print errno log if that option was specified
158 /* exit with return code appropriate for results */