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 : sysfs03 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 testcase tests sysfs(2) for option 3 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 * sysfs03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-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 = "sysfs03"; 77 int TST_TOTAL = 1; 78 79 int main(int ac, char **av) 80 { 81 int lc; 82 83 tst_parse_opts(ac, av, NULL, NULL); 84 85 setup(); 86 87 for (lc = 0; TEST_LOOPING(lc); lc++) { 88 89 tst_count = 0; 90 91 TEST(ltp_syscall(__NR_sysfs, 3)); 92 93 /* check return code */ 94 if (TEST_RETURN == -1) { 95 tst_resm(TFAIL, "sysfs(2) Failed for" 96 " option 3 and returned" 97 " %d as error number", TEST_ERRNO); 98 } else { 99 tst_resm(TPASS, "sysfs(2) Passed for option 3"); 100 } 101 } /*End of TEST_LOOPING */ 102 103 /*Clean up and exit */ 104 cleanup(); 105 tst_exit(); 106 107 } 108 109 /* setup() - performs all ONE TIME setup for this test */ 110 void setup(void) 111 { 112 113 tst_sig(NOFORK, DEF_HANDLER, cleanup); 114 115 TEST_PAUSE; 116 } 117 118 /* 119 * cleanup() - Performs one time cleanup for this test at 120 * completion or premature exit 121 */ 122 void cleanup(void) 123 { 124 125 } 126