subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 1 | /******************************************************************************/ |
| 2 | /* Copyright (c) Crackerjack Project., 2007 */ |
| 3 | /* */ |
| 4 | /* This program is free software; you can redistribute it and/or modify */ |
| 5 | /* it under the terms of the GNU General Public License as published by */ |
| 6 | /* the Free Software Foundation; either version 2 of the License, or */ |
| 7 | /* (at your option) any later version. */ |
| 8 | /* */ |
| 9 | /* This program is distributed in the hope that it will be useful, */ |
| 10 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 11 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ |
| 12 | /* the GNU General Public License for more details. */ |
| 13 | /* */ |
| 14 | /* You should have received a copy of the GNU General Public License */ |
| 15 | /* along with this program; if not, write to the Free Software */ |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 16 | /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 17 | /* */ |
| 18 | /******************************************************************************/ |
| 19 | /******************************************************************************/ |
| 20 | /* */ |
| 21 | /* File: ssetmask01.c */ |
| 22 | /* */ |
| 23 | /* Description: This tests the ssetmask() syscall */ |
| 24 | /* */ |
| 25 | /* Usage: <for command-line> */ |
| 26 | /* ssetmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t] */ |
| 27 | /* where, -c n : Run n copies concurrently. */ |
| 28 | /* -e : Turn on errno logging. */ |
| 29 | /* -i n : Execute test n times. */ |
| 30 | /* -I x : Execute test for x seconds. */ |
| 31 | /* -P x : Pause for x seconds between iterations. */ |
| 32 | /* -t : Turn on syscall timing. */ |
| 33 | /* */ |
| 34 | /* Total Tests: 2 */ |
| 35 | /* */ |
| 36 | /* Test Name: ssetmask01 */ |
| 37 | /* History: Porting from Crackerjack to LTP is done by */ |
| 38 | /* Manas Kumar Nayak maknayak@in.ibm.com> */ |
| 39 | /******************************************************************************/ |
| 40 | |
| 41 | #include <stdio.h> |
| 42 | #include <errno.h> |
| 43 | #include <stdlib.h> |
| 44 | #include <signal.h> |
| 45 | |
| 46 | /* Harness Specific Include Files. */ |
| 47 | #include "test.h" |
| 48 | #include "usctest.h" |
| 49 | #include "linux_syscall_numbers.h" |
| 50 | |
| 51 | /* Extern Global Variables */ |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 52 | |
| 53 | /* Global Variables */ |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 54 | char *TCID = "ssetmask01"; /* Test program identifier. */ |
| 55 | int testno; |
| 56 | int TST_TOTAL = 2; /* total number of tests in this file. */ |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 57 | |
| 58 | /* Extern Global Functions */ |
| 59 | /******************************************************************************/ |
| 60 | /* */ |
| 61 | /* Function: cleanup */ |
| 62 | /* */ |
| 63 | /* Description: Performs all one time clean up for this test on successful */ |
| 64 | /* completion, premature exit or failure. Closes all temporary */ |
| 65 | /* files, removes all temporary directories exits the test with */ |
| 66 | /* appropriate return code by calling tst_exit() function. */ |
| 67 | /* */ |
| 68 | /* Input: None. */ |
| 69 | /* */ |
| 70 | /* Output: None. */ |
| 71 | /* */ |
| 72 | /* Return: On failure - Exits calling tst_exit(). Non '0' return code. */ |
| 73 | /* On success - Exits calling tst_exit(). With '0' return code. */ |
| 74 | /* */ |
| 75 | /******************************************************************************/ |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 76 | extern void cleanup() |
| 77 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 78 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 79 | TEST_CLEANUP; |
| 80 | tst_rmdir(); |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 81 | |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | /* Local Functions */ |
| 85 | /******************************************************************************/ |
| 86 | /* */ |
| 87 | /* Function: setup */ |
| 88 | /* */ |
| 89 | /* Description: Performs all one time setup for this test. This function is */ |
| 90 | /* typically used to capture signals, create temporary dirs */ |
| 91 | /* and temporary files that may be used in the course of this */ |
| 92 | /* test. */ |
| 93 | /* */ |
| 94 | /* Input: None. */ |
| 95 | /* */ |
| 96 | /* Output: None. */ |
| 97 | /* */ |
| 98 | /* Return: On failure - Exits by calling cleanup(). */ |
| 99 | /* On success - returns 0. */ |
| 100 | /* */ |
| 101 | /******************************************************************************/ |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 102 | void setup() |
| 103 | { |
| 104 | /* Capture signals if any */ |
| 105 | /* Create temporary directories */ |
| 106 | TEST_PAUSE; |
| 107 | tst_tmpdir(); |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 108 | } |
| 109 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 110 | int main(int ac, char **av) |
| 111 | { |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 112 | int lc; |
| 113 | char *msg; |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 114 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 115 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 116 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 117 | tst_exit(); |
| 118 | } |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 119 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 120 | setup(); |
| 121 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 122 | for (lc = 0; TEST_LOOPING(lc); ++lc) { |
| 123 | Tst_count = 0; |
| 124 | for (testno = 0; testno < TST_TOTAL; ++testno) { |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame^] | 125 | ltp_syscall(__NR_ssetmask, SIGALRM); |
| 126 | TEST(ltp_syscall(__NR_sgetmask)); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 127 | if (TEST_RETURN != SIGALRM) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 128 | tst_resm(TFAIL | TTERRNO, "sgetmask() failed"); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 129 | cleanup(); |
| 130 | tst_exit(); |
| 131 | } |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame^] | 132 | TEST(ltp_syscall(__NR_ssetmask, SIGUSR1)); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 133 | if (TEST_RETURN != SIGALRM) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 134 | tst_resm(TFAIL | TTERRNO, "ssetmask() failed"); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 135 | cleanup(); |
| 136 | tst_exit(); |
| 137 | } |
| 138 | tst_resm(TPASS, "Got SIGALRM--Test PASS "); |
| 139 | } |
| 140 | } |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 141 | cleanup(); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 142 | tst_exit(); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 143 | } |