subrata_modak | b02ce84 | 2009-05-21 18:25:58 +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 | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 17 | /* */ |
| 18 | /******************************************************************************/ |
| 19 | /******************************************************************************/ |
| 20 | /* */ |
| 21 | /* File: rt_sigqueueinfo01.c */ |
| 22 | /* */ |
| 23 | /* Description: This tests the rt_sigqueueinfo() syscall. */ |
| 24 | /* rt_sigqueueinfo() Send signal information to a signal */ |
| 25 | /* */ |
| 26 | /* Usage: <for command-line> */ |
| 27 | /* rt_sigqueueinfo01 [-c n] [-e][-i n] [-I x] [-p x] [-t] */ |
| 28 | /* where, -c n : Run n copies concurrently. */ |
| 29 | /* -e : Turn on errno logging. */ |
| 30 | /* -i n : Execute test n times. */ |
| 31 | /* -I x : Execute test for x seconds. */ |
| 32 | /* -P x : Pause for x seconds between iterations. */ |
| 33 | /* -t : Turn on syscall timing. */ |
| 34 | /* */ |
| 35 | /* Total Tests: 2 */ |
| 36 | /* */ |
| 37 | /* Test Name: rt_sigqueueinfo01 */ |
| 38 | /* History: Porting from Crackerjack to LTP is done by */ |
| 39 | /* Manas Kumar Nayak maknayak@in.ibm.com> */ |
| 40 | /******************************************************************************/ |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 41 | #include <sys/wait.h> |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 42 | #include <stdio.h> |
| 43 | #include <signal.h> |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 44 | #include <err.h> |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 45 | #include <errno.h> |
| 46 | #include <stdlib.h> |
| 47 | #include <unistd.h> |
| 48 | #include <sys/syscall.h> |
| 49 | #include <string.h> |
| 50 | |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 51 | /* Harness Specific Include Files. */ |
| 52 | #include "test.h" |
| 53 | #include "usctest.h" |
| 54 | #include "linux_syscall_numbers.h" |
| 55 | |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 56 | /* Global Variables */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 57 | char *TCID = "rt_sigqueueinfo01"; /* Test program identifier. */ |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 58 | int testno; |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 59 | int TST_TOTAL = 2; /* total number of tests in this file. */ |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 60 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 61 | extern void cleanup() |
| 62 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 63 | |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 64 | TEST_CLEANUP; |
| 65 | tst_rmdir(); |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 66 | |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 69 | void setup() |
| 70 | { |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 71 | TEST_PAUSE; |
| 72 | tst_tmpdir(); |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 75 | int main(int ac, char **av) |
| 76 | { |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 77 | int status; |
| 78 | pid_t pid; |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 79 | pid = getpid(); |
| 80 | siginfo_t uinfo; |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 81 | |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 82 | Tst_count = 0; |
| 83 | for (testno = 0; testno < TST_TOTAL; ++testno) { |
| 84 | TEST(pid = fork()); |
| 85 | setup(); |
| 86 | if (TEST_RETURN < 0) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 87 | tst_brkm(TFAIL | TTERRNO, cleanup, "fork failed"); |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 88 | else if (TEST_RETURN == 0) { |
| 89 | uinfo.si_errno = 0; |
| 90 | uinfo.si_code = SI_QUEUE; |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame^] | 91 | TEST(ltp_syscall(__NR_rt_sigqueueinfo, getpid(), |
| 92 | SIGCHLD, &uinfo)); |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 93 | if (TEST_RETURN != 0) |
| 94 | err(1, "rt_sigqueueinfo"); |
| 95 | exit(0); |
Yi Zhao | 068a65d | 2011-09-01 13:53:27 +0800 | [diff] [blame] | 96 | } else { |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 97 | wait(&status); |
| 98 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) |
| 99 | tst_resm(TPASS, "Test Succeeded"); |
| 100 | else |
| 101 | tst_resm(TFAIL, "Test Failed"); |
Yi Zhao | 068a65d | 2011-09-01 13:53:27 +0800 | [diff] [blame] | 102 | } |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 103 | cleanup(); |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 104 | } |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 105 | tst_exit(); |
Yi Zhao | 068a65d | 2011-09-01 13:53:27 +0800 | [diff] [blame] | 106 | } |