blob: 224ca0e5b2db067c01b1286b1a66159ffd136443 [file] [log] [blame]
plars865695b2001-08-27 22:15:12 +00001/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
Wanlong Gaofed96412012-10-24 10:10:29 +080020 * with this program; if not, write the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
plars865695b2001-08-27 22:15:12 +000022 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
plars865695b2001-08-27 22:15:12 +000031 */
Cyril Hrubis7dc42c92013-09-12 14:55:55 +020032/*
plars865695b2001-08-27 22:15:12 +000033 * AUTHOR : William Roske
plars865695b2001-08-27 22:15:12 +000034 * CO-PILOT : Dave Fenner
Cyril Hrubis7dc42c92013-09-12 14:55:55 +020035 */
plars865695b2001-08-27 22:15:12 +000036#include <sys/types.h>
37#include <sys/fcntl.h>
38#include <errno.h>
39#include <string.h>
40#include <signal.h>
Stanislav Kholmanskikh1c442442013-09-11 13:25:43 +040041
plars865695b2001-08-27 22:15:12 +000042#include "test.h"
subrata_modak493f24f2009-10-15 14:30:34 +000043#include "compat_16.h"
plars865695b2001-08-27 22:15:12 +000044
Cyril Hrubis7dc42c92013-09-12 14:55:55 +020045static void setup(void);
46static void cleanup(void);
plars865695b2001-08-27 22:15:12 +000047
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020048TCID_DEFINE(getuid01);
49int TST_TOTAL = 1;
plars865695b2001-08-27 22:15:12 +000050
subrata_modak56207ce2009-03-23 13:35:39 +000051int main(int ac, char **av)
plars865695b2001-08-27 22:15:12 +000052{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020053 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020054 const char *msg;
subrata_modak56207ce2009-03-23 13:35:39 +000055
Garrett Cooper45e285d2010-11-22 12:19:25 -080056 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080057 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
plars865695b2001-08-27 22:15:12 +000058
subrata_modak56207ce2009-03-23 13:35:39 +000059 setup();
plars865695b2001-08-27 22:15:12 +000060
subrata_modak56207ce2009-03-23 13:35:39 +000061 for (lc = 0; TEST_LOOPING(lc); lc++) {
plars865695b2001-08-27 22:15:12 +000062
Caspar Zhangd59a6592013-03-07 14:59:12 +080063 tst_count = 0;
plars865695b2001-08-27 22:15:12 +000064
Stanislav Kholmanskikh1c442442013-09-11 13:25:43 +040065 TEST(GETUID(cleanup));
subrata_modakbdbaec52009-02-26 12:14:51 +000066
Garrett Cooper27408da2010-12-19 02:31:31 -080067 if (TEST_RETURN == -1)
Wanlong Gao354ebb42012-12-07 10:10:04 +080068 tst_resm(TFAIL | TTERRNO, "getuid failed");
Cyril Hrubise38b9612014-06-02 17:20:57 +020069 else
Wanlong Gao354ebb42012-12-07 10:10:04 +080070 tst_resm(TPASS, "getuid returned %ld", TEST_RETURN);
plars865695b2001-08-27 22:15:12 +000071
Garrett Cooper2c282152010-12-16 00:55:50 -080072 }
plars865695b2001-08-27 22:15:12 +000073
subrata_modak56207ce2009-03-23 13:35:39 +000074 cleanup();
Garrett Cooper27408da2010-12-19 02:31:31 -080075 tst_exit();
Garrett Cooper2c282152010-12-16 00:55:50 -080076}
plars865695b2001-08-27 22:15:12 +000077
Cyril Hrubis7dc42c92013-09-12 14:55:55 +020078static void setup(void)
plars865695b2001-08-27 22:15:12 +000079{
subrata_modak56207ce2009-03-23 13:35:39 +000080 tst_sig(NOFORK, DEF_HANDLER, cleanup);
subrata_modak56207ce2009-03-23 13:35:39 +000081 TEST_PAUSE;
Garrett Cooper2c282152010-12-16 00:55:50 -080082}
plars865695b2001-08-27 22:15:12 +000083
Cyril Hrubis7dc42c92013-09-12 14:55:55 +020084static void cleanup(void)
plars865695b2001-08-27 22:15:12 +000085{
Chris Dearmanec6edca2012-10-17 19:54:01 -070086}