• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Wipro Technologies Ltd, 2002.  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  * You should have received a copy of the GNU General Public License along
13  * with this program; if not, write the Free Software Foundation, Inc.,
14  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  */
17 /**********************************************************
18  *
19  *    TEST IDENTIFIER	: capget01
20  *
21  *    EXECUTED BY	: anyone
22  *
23  *    TEST TITLE	: Basic test for capget(2)
24  *
25  *    TEST CASE TOTAL	: 1
26  *
27  *    AUTHOR		: Saji Kumar.V.R <saji.kumar@wipro.com>
28  *
29  *    SIGNALS
30  * 	Uses SIGUSR1 to pause before test if option set.
31  * 	(See the parse_opts(3) man page).
32  *
33  *    DESCRIPTION
34  *	This is a Phase I test for the capget(2) system call.
35  *	It is intended to provide a limited exposure of the system call.
36  *
37  * 	Setup:
38  * 	  Setup signal handling.
39  *	  Pause for SIGUSR1 if option specified.
40  *
41  * 	Test:
42  *	 Loop if the proper options are given.
43  * 	  call capget()
44  *	  if return value == 0
45  *		Test passed
46  *	  Otherwise
47  *		Test failed
48  *
49  * 	Cleanup:
50  * 	  Print errno log and/or timing stats if options given
51  *
52  * USAGE:  <for command-line>
53  * capget01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
54  *			where,  -c n : Run n copies concurrently.
55  *				-e   : Turn on errno logging.
56  *				-h   : Show help screen
57  *				-f   : Turn off functional testing
58  *				-i n : Execute test n times.
59  *				-I x : Execute test for x seconds.
60  *				-p   : Pause for SIGUSR1 before starting
61  *				-P x : Pause for x seconds between iterations.
62  *				-t   : Turn on syscall timing.
63  ****************************************************************/
64 
65 #include <errno.h>
66 #include <unistd.h>
67 #include "test.h"
68 #include "lapi/syscalls.h"
69 
70 #include <linux/capability.h>
71 
72 static void setup();
73 static void cleanup();
74 
75 char *TCID = "capget01";
76 int TST_TOTAL = 1;
77 
78 static struct __user_cap_header_struct header;	/* cap_user_header_t is a pointer
79 						   to __user_cap_header_struct */
80 
81 static struct __user_cap_data_struct data;	/* cap_user_data_t is a pointer to
82 						   __user_cap_data_struct */
83 
main(int ac,char ** av)84 int main(int ac, char **av)
85 {
86 
87 	int lc;
88 
89 	tst_parse_opts(ac, av, NULL, NULL);
90 
91 	setup();
92 
93 	/* header.version must be _LINUX_CAPABILITY_VERSION */
94 	header.version = _LINUX_CAPABILITY_VERSION;
95 
96 	for (lc = 0; TEST_LOOPING(lc); lc++) {
97 
98 		tst_count = 0;
99 
100 		TEST(ltp_syscall(__NR_capget, &header, &data));
101 
102 		if (TEST_RETURN == 0) {
103 			tst_resm(TPASS, "capget() returned %ld", TEST_RETURN);
104 		} else {
105 			tst_resm(TFAIL | TTERRNO,
106 				 "Test Failed, capget() returned %ld",
107 				 TEST_RETURN);
108 		}
109 	}
110 
111 	cleanup();
112 
113 	tst_exit();
114 }
115 
setup(void)116 void setup(void)
117 {
118 
119 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
120 
121 	TEST_PAUSE;
122 
123 }
124 
cleanup(void)125 void cleanup(void)
126 {
127 }
128