blob: f063077713a352835e1db301bd21f4dedf271638 [file] [log] [blame]
subrata_modakb02ce842009-05-21 18:25:58 +00001/******************************************************************************/
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 Gao4548c6c2012-10-19 18:03:36 +080016/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
subrata_modakb02ce842009-05-21 18:25:58 +000017/* */
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 Cooper80894732010-12-19 08:54:00 -080041#include <sys/wait.h>
subrata_modakb02ce842009-05-21 18:25:58 +000042#include <stdio.h>
43#include <signal.h>
Garrett Cooper80894732010-12-19 08:54:00 -080044#include <err.h>
subrata_modakb02ce842009-05-21 18:25:58 +000045#include <errno.h>
46#include <stdlib.h>
47#include <unistd.h>
48#include <sys/syscall.h>
49#include <string.h>
50
subrata_modakb02ce842009-05-21 18:25:58 +000051/* Harness Specific Include Files. */
52#include "test.h"
53#include "usctest.h"
54#include "linux_syscall_numbers.h"
55
subrata_modakb02ce842009-05-21 18:25:58 +000056/* Global Variables */
Wanlong Gao354ebb42012-12-07 10:10:04 +080057char *TCID = "rt_sigqueueinfo01"; /* Test program identifier. */
subrata_modakdde67282009-08-07 12:03:22 +000058int testno;
Wanlong Gao354ebb42012-12-07 10:10:04 +080059int TST_TOTAL = 2; /* total number of tests in this file. */
subrata_modakb02ce842009-05-21 18:25:58 +000060
Wanlong Gao354ebb42012-12-07 10:10:04 +080061extern void cleanup()
62{
Garrett Cooper2c282152010-12-16 00:55:50 -080063
subrata_modakdde67282009-08-07 12:03:22 +000064 TEST_CLEANUP;
65 tst_rmdir();
subrata_modakb02ce842009-05-21 18:25:58 +000066
subrata_modakb02ce842009-05-21 18:25:58 +000067}
68
Wanlong Gao354ebb42012-12-07 10:10:04 +080069void setup()
70{
subrata_modakdde67282009-08-07 12:03:22 +000071 TEST_PAUSE;
72 tst_tmpdir();
subrata_modakb02ce842009-05-21 18:25:58 +000073}
74
Wanlong Gao354ebb42012-12-07 10:10:04 +080075int main(int ac, char **av)
76{
Garrett Cooper80894732010-12-19 08:54:00 -080077 int status;
78 pid_t pid;
subrata_modakdde67282009-08-07 12:03:22 +000079 pid = getpid();
80 siginfo_t uinfo;
subrata_modakb02ce842009-05-21 18:25:58 +000081
Garrett Cooper80894732010-12-19 08:54:00 -080082 Tst_count = 0;
83 for (testno = 0; testno < TST_TOTAL; ++testno) {
84 TEST(pid = fork());
85 setup();
86 if (TEST_RETURN < 0)
Wanlong Gao354ebb42012-12-07 10:10:04 +080087 tst_brkm(TFAIL | TTERRNO, cleanup, "fork failed");
Garrett Cooper80894732010-12-19 08:54:00 -080088 else if (TEST_RETURN == 0) {
89 uinfo.si_errno = 0;
90 uinfo.si_code = SI_QUEUE;
Jan Stancek359980f2013-02-15 10:16:05 +010091 TEST(ltp_syscall(__NR_rt_sigqueueinfo, getpid(),
92 SIGCHLD, &uinfo));
Garrett Cooper80894732010-12-19 08:54:00 -080093 if (TEST_RETURN != 0)
94 err(1, "rt_sigqueueinfo");
95 exit(0);
Yi Zhao068a65d2011-09-01 13:53:27 +080096 } else {
Garrett Cooper80894732010-12-19 08:54:00 -080097 wait(&status);
98 if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
99 tst_resm(TPASS, "Test Succeeded");
100 else
101 tst_resm(TFAIL, "Test Failed");
Yi Zhao068a65d2011-09-01 13:53:27 +0800102 }
Garrett Cooper80894732010-12-19 08:54:00 -0800103 cleanup();
subrata_modakdde67282009-08-07 12:03:22 +0000104 }
Garrett Cooper80894732010-12-19 08:54:00 -0800105 tst_exit();
Yi Zhao068a65d2011-09-01 13:53:27 +0800106}