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 | #include "test.h" |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 52 | #include "linux_syscall_numbers.h" |
| 53 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 54 | char *TCID = "rt_sigqueueinfo01"; |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 55 | int testno; |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 56 | int TST_TOTAL = 2; |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 57 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 58 | void cleanup(void) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 59 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 60 | |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 61 | tst_rmdir(); |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 62 | |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 65 | void setup(void) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 66 | { |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 67 | TEST_PAUSE; |
| 68 | tst_tmpdir(); |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 71 | int main(int ac, char **av) |
| 72 | { |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 73 | int status; |
| 74 | pid_t pid; |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 75 | pid = getpid(); |
| 76 | siginfo_t uinfo; |
subrata_modak | b02ce84 | 2009-05-21 18:25:58 +0000 | [diff] [blame] | 77 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 78 | tst_count = 0; |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 79 | for (testno = 0; testno < TST_TOTAL; ++testno) { |
| 80 | TEST(pid = fork()); |
| 81 | setup(); |
| 82 | if (TEST_RETURN < 0) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 83 | tst_brkm(TFAIL | TTERRNO, cleanup, "fork failed"); |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 84 | else if (TEST_RETURN == 0) { |
| 85 | uinfo.si_errno = 0; |
| 86 | uinfo.si_code = SI_QUEUE; |
Jan Stancek | 359980f | 2013-02-15 10:16:05 +0100 | [diff] [blame] | 87 | TEST(ltp_syscall(__NR_rt_sigqueueinfo, getpid(), |
| 88 | SIGCHLD, &uinfo)); |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 89 | if (TEST_RETURN != 0) |
| 90 | err(1, "rt_sigqueueinfo"); |
| 91 | exit(0); |
Yi Zhao | 068a65d | 2011-09-01 13:53:27 +0800 | [diff] [blame] | 92 | } else { |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 93 | wait(&status); |
| 94 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) |
| 95 | tst_resm(TPASS, "Test Succeeded"); |
| 96 | else |
| 97 | tst_resm(TFAIL, "Test Failed"); |
Yi Zhao | 068a65d | 2011-09-01 13:53:27 +0800 | [diff] [blame] | 98 | } |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 99 | cleanup(); |
subrata_modak | dde6728 | 2009-08-07 12:03:22 +0000 | [diff] [blame] | 100 | } |
Garrett Cooper | 8089473 | 2010-12-19 08:54:00 -0800 | [diff] [blame] | 101 | tst_exit(); |
Yi Zhao | 068a65d | 2011-09-01 13:53:27 +0800 | [diff] [blame] | 102 | } |