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 | |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 46 | #include "test.h" |
| 47 | #include "usctest.h" |
| 48 | #include "linux_syscall_numbers.h" |
| 49 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 50 | char *TCID = "ssetmask01"; |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 51 | int testno; |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 52 | int TST_TOTAL = 2; |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 53 | |
| 54 | /* Extern Global Functions */ |
| 55 | /******************************************************************************/ |
| 56 | /* */ |
| 57 | /* Function: cleanup */ |
| 58 | /* */ |
| 59 | /* Description: Performs all one time clean up for this test on successful */ |
| 60 | /* completion, premature exit or failure. Closes all temporary */ |
| 61 | /* files, removes all temporary directories exits the test with */ |
| 62 | /* appropriate return code by calling tst_exit() function. */ |
| 63 | /* */ |
| 64 | /* Input: None. */ |
| 65 | /* */ |
| 66 | /* Output: None. */ |
| 67 | /* */ |
| 68 | /* Return: On failure - Exits calling tst_exit(). Non '0' return code. */ |
| 69 | /* On success - Exits calling tst_exit(). With '0' return code. */ |
| 70 | /* */ |
| 71 | /******************************************************************************/ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 72 | void cleanup(void) |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 73 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 74 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 75 | TEST_CLEANUP; |
| 76 | tst_rmdir(); |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 77 | |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /* Local Functions */ |
| 81 | /******************************************************************************/ |
| 82 | /* */ |
| 83 | /* Function: setup */ |
| 84 | /* */ |
| 85 | /* Description: Performs all one time setup for this test. This function is */ |
| 86 | /* typically used to capture signals, create temporary dirs */ |
| 87 | /* and temporary files that may be used in the course of this */ |
| 88 | /* test. */ |
| 89 | /* */ |
| 90 | /* Input: None. */ |
| 91 | /* */ |
| 92 | /* Output: None. */ |
| 93 | /* */ |
| 94 | /* Return: On failure - Exits by calling cleanup(). */ |
| 95 | /* On success - returns 0. */ |
| 96 | /* */ |
| 97 | /******************************************************************************/ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 98 | void setup(void) |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 99 | { |
| 100 | /* Capture signals if any */ |
| 101 | /* Create temporary directories */ |
| 102 | TEST_PAUSE; |
| 103 | tst_tmpdir(); |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 104 | } |
| 105 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 106 | int main(int ac, char **av) |
| 107 | { |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 108 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 109 | const char *msg; |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 110 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 111 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 112 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 113 | } |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 114 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 115 | setup(); |
| 116 | |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 117 | for (lc = 0; TEST_LOOPING(lc); ++lc) { |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 118 | tst_count = 0; |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 119 | for (testno = 0; testno < TST_TOTAL; ++testno) { |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 120 | ltp_syscall(__NR_ssetmask, SIGALRM); |
| 121 | TEST(ltp_syscall(__NR_sgetmask)); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 122 | if (TEST_RETURN != SIGALRM) { |
Cyril Hrubis | 9fa8ad0 | 2014-12-16 13:20:49 +0100 | [diff] [blame^] | 123 | tst_brkm(TFAIL | TTERRNO, cleanup, |
| 124 | "sgetmask() failed"); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 125 | } |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 126 | TEST(ltp_syscall(__NR_ssetmask, SIGUSR1)); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 127 | if (TEST_RETURN != SIGALRM) { |
Cyril Hrubis | 9fa8ad0 | 2014-12-16 13:20:49 +0100 | [diff] [blame^] | 128 | tst_brkm(TFAIL | TTERRNO, cleanup, |
| 129 | "ssetmask() failed"); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 130 | } |
| 131 | tst_resm(TPASS, "Got SIGALRM--Test PASS "); |
| 132 | } |
| 133 | } |
subrata_modak | e70e2b4 | 2009-05-21 18:39:52 +0000 | [diff] [blame] | 134 | cleanup(); |
vapier | 80a715a | 2009-08-28 14:11:58 +0000 | [diff] [blame] | 135 | tst_exit(); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 136 | } |