blob: 066d315133dd722332c8146a191ed2dfa307cf01 [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#include "test.h"
subrata_modakb02ce842009-05-21 18:25:58 +000052#include "linux_syscall_numbers.h"
53
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020054char *TCID = "rt_sigqueueinfo01";
subrata_modakdde67282009-08-07 12:03:22 +000055int testno;
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020056int TST_TOTAL = 2;
subrata_modakb02ce842009-05-21 18:25:58 +000057
Mike Frysingerc57fba52014-04-09 18:56:30 -040058void cleanup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080059{
Garrett Cooper2c282152010-12-16 00:55:50 -080060
subrata_modakdde67282009-08-07 12:03:22 +000061 tst_rmdir();
subrata_modakb02ce842009-05-21 18:25:58 +000062
subrata_modakb02ce842009-05-21 18:25:58 +000063}
64
Mike Frysingerc57fba52014-04-09 18:56:30 -040065void setup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080066{
subrata_modakdde67282009-08-07 12:03:22 +000067 TEST_PAUSE;
68 tst_tmpdir();
subrata_modakb02ce842009-05-21 18:25:58 +000069}
70
Wanlong Gao354ebb42012-12-07 10:10:04 +080071int main(int ac, char **av)
72{
Garrett Cooper80894732010-12-19 08:54:00 -080073 int status;
74 pid_t pid;
subrata_modakdde67282009-08-07 12:03:22 +000075 pid = getpid();
76 siginfo_t uinfo;
subrata_modakb02ce842009-05-21 18:25:58 +000077
Caspar Zhangd59a6592013-03-07 14:59:12 +080078 tst_count = 0;
Garrett Cooper80894732010-12-19 08:54:00 -080079 for (testno = 0; testno < TST_TOTAL; ++testno) {
80 TEST(pid = fork());
81 setup();
82 if (TEST_RETURN < 0)
Wanlong Gao354ebb42012-12-07 10:10:04 +080083 tst_brkm(TFAIL | TTERRNO, cleanup, "fork failed");
Garrett Cooper80894732010-12-19 08:54:00 -080084 else if (TEST_RETURN == 0) {
85 uinfo.si_errno = 0;
86 uinfo.si_code = SI_QUEUE;
Jan Stancek359980f2013-02-15 10:16:05 +010087 TEST(ltp_syscall(__NR_rt_sigqueueinfo, getpid(),
88 SIGCHLD, &uinfo));
Garrett Cooper80894732010-12-19 08:54:00 -080089 if (TEST_RETURN != 0)
90 err(1, "rt_sigqueueinfo");
91 exit(0);
Yi Zhao068a65d2011-09-01 13:53:27 +080092 } else {
Garrett Cooper80894732010-12-19 08:54:00 -080093 wait(&status);
94 if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
95 tst_resm(TPASS, "Test Succeeded");
96 else
97 tst_resm(TFAIL, "Test Failed");
Yi Zhao068a65d2011-09-01 13:53:27 +080098 }
Garrett Cooper80894732010-12-19 08:54:00 -080099 cleanup();
subrata_modakdde67282009-08-07 12:03:22 +0000100 }
Garrett Cooper80894732010-12-19 08:54:00 -0800101 tst_exit();
Yi Zhao068a65d2011-09-01 13:53:27 +0800102}