subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +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 | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 17 | /* */ |
| 18 | /******************************************************************************/ |
| 19 | /******************************************************************************/ |
| 20 | /* */ |
| 21 | /* File: sgetmask01.c */ |
| 22 | /* */ |
| 23 | /* Description: This tests the sgetmask() syscall */ |
| 24 | /* */ |
| 25 | /* Usage: <for command-line> */ |
| 26 | /* sgetmask01 [-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: 1 */ |
| 35 | /* */ |
| 36 | /* Test Name: sgetmask01 */ |
| 37 | /* History: Porting from Crackerjack to LTP is done by */ |
| 38 | /* Manas Kumar Nayak maknayak@in.ibm.com> */ |
| 39 | /******************************************************************************/ |
| 40 | |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 41 | /* NOTE: This case test the behavior of sgetmask |
| 42 | # Sometime the returned "Oops"in this case don't mean anything for |
| 43 | # correct or error, we check the result between different kernel and |
| 44 | # try to find if there exist different returned code in different kernel |
| 45 | # |
| 46 | */ |
| 47 | |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 48 | #include <stdio.h> |
| 49 | #include <signal.h> |
| 50 | #include <sys/syscall.h> |
| 51 | #include <unistd.h> |
| 52 | #include <stdio.h> |
| 53 | #include <errno.h> |
| 54 | |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 55 | #include "test.h" |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 56 | #include "linux_syscall_numbers.h" |
| 57 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 58 | char *TCID = "sgetmask01"; |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 59 | int testno; |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 60 | int TST_TOTAL = 2; |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 61 | |
| 62 | /* Extern Global Functions */ |
| 63 | /******************************************************************************/ |
| 64 | /* */ |
| 65 | /* Function: cleanup */ |
| 66 | /* */ |
| 67 | /* Description: Performs all one time clean up for this test on successful */ |
| 68 | /* completion, premature exit or failure. Closes all temporary */ |
| 69 | /* files, removes all temporary directories exits the test with */ |
| 70 | /* appropriate return code by calling tst_exit() function. */ |
| 71 | /* */ |
| 72 | /* Input: None. */ |
| 73 | /* */ |
| 74 | /* Output: None. */ |
| 75 | /* */ |
| 76 | /* Return: On failure - Exits calling tst_exit(). Non '0' return code. */ |
| 77 | /* On success - Exits calling tst_exit(). With '0' return code. */ |
| 78 | /* */ |
| 79 | /******************************************************************************/ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 80 | void cleanup(void) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 81 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 82 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 83 | tst_rmdir(); |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 84 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 85 | tst_exit(); |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | /* Local Functions */ |
| 89 | /******************************************************************************/ |
| 90 | /* */ |
| 91 | /* Function: setup */ |
| 92 | /* */ |
| 93 | /* Description: Performs all one time setup for this test. This function is */ |
| 94 | /* typically used to capture signals, create temporary dirs */ |
| 95 | /* and temporary files that may be used in the course of this */ |
| 96 | /* test. */ |
| 97 | /* */ |
| 98 | /* Input: None. */ |
| 99 | /* */ |
| 100 | /* Output: None. */ |
| 101 | /* */ |
| 102 | /* Return: On failure - Exits by calling cleanup(). */ |
| 103 | /* On success - returns 0. */ |
| 104 | /* */ |
| 105 | /******************************************************************************/ |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 106 | void setup(void) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 107 | { |
| 108 | /* Capture signals if any */ |
| 109 | /* Create temporary directories */ |
| 110 | TEST_PAUSE; |
| 111 | tst_tmpdir(); |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 114 | int main(int ac, char **av) |
| 115 | { |
| 116 | int sig; |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 117 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 118 | const char *msg; |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 119 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 120 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { |
| 121 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 122 | } |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 123 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 124 | setup(); |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 125 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 126 | for (lc = 0; TEST_LOOPING(lc); ++lc) { |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 127 | tst_count = 0; |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 128 | for (testno = 0; testno < TST_TOTAL; ++testno) { |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 129 | |
Garrett Cooper | df3eb16 | 2010-11-28 22:44:32 -0800 | [diff] [blame] | 130 | for (sig = -3; sig <= SIGRTMAX + 1; sig++) { |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 131 | TEST(ltp_syscall(__NR_ssetmask, sig)); |
| 132 | tst_resm(TINFO, "Setting signal : %d -- " |
| 133 | "return of setmask : %ld", |
| 134 | sig, TEST_RETURN); |
| 135 | TEST(ltp_syscall(__NR_sgetmask)); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 136 | if (TEST_RETURN != sig) { |
| 137 | tst_resm(TINFO, |
| 138 | "Oops,setting sig %d, got %ld", |
| 139 | sig, TEST_RETURN); |
| 140 | } else |
| 141 | tst_resm(TPASS, |
| 142 | "OK,setting sig %d, got %ld", |
| 143 | sig, TEST_RETURN); |
| 144 | if (sig == SIGRTMAX + 1) { |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 145 | cleanup(); |
| 146 | tst_exit(); |
| 147 | } |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 148 | } |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 149 | } |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 150 | } |
subrata_modak | 8afc2fa | 2009-05-21 18:35:31 +0000 | [diff] [blame] | 151 | cleanup(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 152 | tst_exit(); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 153 | } |