• 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	: sysfs02
20  *
21  *    EXECUTED BY	: anyone
22  *
23  *    TEST TITLE	: Basic test for sysfs(2)
24  *
25  *    TEST CASE TOTAL	: 1
26  *
27  *    AUTHOR		: Aniruddha Marathe <aniruddha.marathe@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 sysfs(2) system call.
35  *    It is intended to provide a limited exposure of the system call.
36  *    This test is run for option 2 for sysfs(2)
37  *
38  *	Setup:
39  *	  Setup signal handling.
40  *	  Pause for SIGUSR1 if option specified.
41  *
42  *	Test:
43  *	 Loop if the proper options are given.
44  *	  Execute system call
45  *	  Check return code, if system call failed (return=-1)
46  *		Log the errno and Issue a FAIL message.
47  *	  Otherwise, Issue a PASS message.
48  *
49  *	Cleanup:
50  *	  Print errno log and/or timing stats if options given
51  *
52  * USAGE:  <for command-line>
53  * sysfs02  [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-t] [-p] [-f]
54  * where:
55  *	-c n : run n copies simultaneously
56  *	-e   : Turn on errno logging.
57  *	-i n : Execute test n times.
58  *	-I x : Execute test for x seconds.
59  *	-p   : Pause for SIGUSR1 before starting
60  *	-P x : Pause for x seconds between iterations.
61  *	-t   : Turn on syscall timing.
62  *
63  *RESTRICTIONS:
64  *There is no glibc or libc support
65  *****************************************************************************/
66 
67 #include <errno.h>
68 #include <unistd.h>
69 #include <sys/syscall.h>
70 #include "test.h"
71 #include "lapi/syscalls.h"
72 
73 static void setup();
74 static void cleanup();
75 
76 char *TCID = "sysfs02";
77 int TST_TOTAL = 1;
78 
main(int ac,char ** av)79 int main(int ac, char **av)
80 {
81 	int lc;
82 	char buf[40];		/* 40 bytes suffice to store fs name */
83 
84 	tst_parse_opts(ac, av, NULL, NULL);
85 
86 	setup();
87 
88 	for (lc = 0; TEST_LOOPING(lc); lc++) {
89 
90 		tst_count = 0;
91 
92 		/*option 2 buf holds fs name */
93 		TEST(ltp_syscall(__NR_sysfs, 2, 0, buf));
94 
95 		/* check return code */
96 		if (TEST_RETURN == -1) {
97 			tst_resm(TFAIL, "sysfs(2) Failed for "
98 				 "option 2 and returned"
99 				 " %d as error number", TEST_ERRNO);
100 		} else {
101 			tst_resm(TPASS, "sysfs(2) Passed for option 2");
102 		}
103 	}			/*End of TEST_LOOPING */
104 
105 	/*Clean up and exit */
106 	cleanup();
107 
108 	tst_exit();
109 }
110 
111 /* setup() - performs all ONE TIME setup for this test */
setup(void)112 void setup(void)
113 {
114 
115 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
116 
117 	TEST_PAUSE;
118 }
119 
120 /*
121  * cleanup() - Performs one time cleanup for this test at
122  * completion or premature exit
123  */
cleanup(void)124 void cleanup(void)
125 {
126 
127 }
128