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 : sysfs01
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 * This test is carried out for option 1 for sysfs(2).
36 * It is intended to provide a limited exposure of the system call.
37 *
38 *
39 * Setup:
40 * Setup signal handling.
41 * Pause for SIGUSR1 if option specified.
42 *
43 * Test:
44 * Loop if the proper options are given.
45 * Execute system call
46 * Check return code, if system call failed (return=-1)
47 * Log the errno and Issue a FAIL message.
48 * Otherwise, Issue a PASS message.
49 *
50 * Cleanup:
51 * Print errno log and/or timing stats if options given
52 *
53 * USAGE: <for command-line>
54 * sysfs01 [-c n] [-e] [-i n] [-I x] [-p x] [-t] [-h] [-f] [-p]
55 * where:
56 * -c n : run n copies simultaneously.
57 * -e : Turn on errno logging.
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 *RESTRICTIONS:
65 *There is no glibc or libc support
66 *Kernel should be compiled with proc filesystem support
67 ******************************************************************************/
68
69 #include <errno.h>
70 #include <unistd.h>
71 #include <sys/syscall.h>
72 #include "test.h"
73 #include "lapi/syscalls.h"
74
75 static void setup();
76 static void cleanup();
77
78 char *TCID = "sysfs01";
79 int TST_TOTAL = 1;
80
main(int ac,char ** av)81 int main(int ac, char **av)
82 {
83 int lc;
84
85 tst_parse_opts(ac, av, NULL, NULL);
86
87 setup();
88
89 for (lc = 0; TEST_LOOPING(lc); lc++) {
90
91 tst_count = 0;
92
93 /* option 1, buf holds fs name */
94 TEST(ltp_syscall(__NR_sysfs, 1, "proc"));
95
96 /* check return code */
97 if (TEST_RETURN == -1) {
98 tst_resm(TFAIL, "sysfs(2) Failed for "
99 "option 1 and set errno to %d", TEST_ERRNO);
100 } else {
101 tst_resm(TPASS, "sysfs(2) Passed for " "option 1");
102 }
103 } /*End of TEST_LOOPING */
104
105 /*Clean up and exit */
106 cleanup();
107 tst_exit();
108
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 /*
122 * cleanup() - Performs one time cleanup for this test at
123 * completion or premature exit
124 */
125
cleanup(void)126 void cleanup(void)
127 {
128
129 }
130