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 Foundation, */ 16 /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 17 /* */ 18 /* History: Porting from Crackerjack to LTP is done by */ 19 /* Manas Kumar Nayak maknayak (at) in.ibm.com> */ 20 /******************************************************************************/ 21 22 /******************************************************************************/ 23 /* Description: This tests the rt_sigaction() syscall */ 24 /* rt_sigaction Expected EFAULT error check */ 25 /******************************************************************************/ 26 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <unistd.h> 30 #include <signal.h> 31 #include <errno.h> 32 #include <sys/syscall.h> 33 #include <string.h> 34 35 #include "test.h" 36 #include "linux_syscall_numbers.h" 37 #include "lapi/rt_sigaction.h" 38 39 char *TCID = "rt_sigaction02"; 40 static int testno; 41 int TST_TOTAL = 1; 42 43 void cleanup(void) 44 { 45 tst_rmdir(); 46 47 tst_exit(); 48 } 49 50 void setup(void) 51 { 52 TEST_PAUSE; 53 tst_tmpdir(); 54 } 55 56 static int test_flags[] = 57 { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO, 58 SA_RESETHAND | SA_SIGINFO, SA_NOMASK }; 59 char *test_flags_list[] = 60 { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO", 61 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" }; 62 63 static struct test_case_t { 64 int exp_errno; 65 char *errdesc; 66 } test_cases[] = { 67 { 68 EFAULT, "EFAULT"} 69 }; 70 71 int main(int ac, char **av) 72 { 73 unsigned int flag; 74 int signal; 75 int lc; 76 77 tst_parse_opts(ac, av, NULL, NULL); 78 79 setup(); 80 81 for (lc = 0; TEST_LOOPING(lc); ++lc) { 82 tst_count = 0; 83 for (testno = 0; testno < TST_TOTAL; ++testno) { 84 for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) { 85 tst_resm(TINFO, "Signal %d", signal); 86 87 for (flag = 0; flag < ARRAY_SIZE(test_flags); flag++) { 88 89 /* * 90 * long sys_rt_sigaction (int sig, const struct sigaction *act, * 91 * truct sigaction *oact, size_t sigsetsize); * 92 * EFAULT: * 93 * An invalid act or oact value was specified * 94 */ 95 96 TEST(ltp_rt_sigaction(signal, 97 INVAL_SA_PTR, NULL, SIGSETSIZE)); 98 if ((TEST_RETURN == -1) 99 && (TEST_ERRNO == 100 test_cases[0].exp_errno)) { 101 tst_resm(TINFO, 102 "sa.sa_flags = %s ", 103 test_flags_list[flag]); 104 tst_resm(TPASS, 105 "%s failure with sig: %d as expected errno = %s : %s", 106 TCID, signal, 107 test_cases[0].errdesc, 108 strerror(TEST_ERRNO)); 109 } else { 110 tst_resm(TFAIL, 111 "rt_sigaction call succeeded: result = %ld got error %d:but expected %d", 112 TEST_RETURN, 113 TEST_ERRNO, 114 test_cases[0]. 115 exp_errno); 116 tst_resm(TINFO, 117 "sa.sa_flags = %s ", 118 test_flags_list[flag]); 119 } 120 } 121 } 122 123 } 124 } 125 cleanup(); 126 tst_exit(); 127 } 128