blob: ed0b2d17448d910f68dee401c49b5a4cce15c767 [file] [log] [blame]
plarsb6a1d252002-02-12 16:03:54 +00001
2/*
3 *
4 * Copyright (c) International Business Machines Corp., 2002
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14 * the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Wanlong Gao4548c6c2012-10-19 18:03:36 +080018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
plarsb6a1d252002-02-12 16:03:54 +000019 */
20
21/*
22 * NAME
23 * sigpending02.c
24 *
25 * DESCRIPTION
26 * Test to see the the proper errors are returned by sigpending
subrata_modak56207ce2009-03-23 13:35:39 +000027 *$
plarsb6a1d252002-02-12 16:03:54 +000028 * ALGORITHM
29 * test 1:
30 * Call sigpending(sigset_t*=-1), it should return -1 with errno EFAULT
31 *
32 * USAGE: <for command-line>
33 * -c n Run n copies concurrently
34 * -e Turn on errno logging
35 * -f Turn off functional testing
36 * -h Show this help screen
37 * -i n Execute test n times
38 * -I x Execute test for x seconds
39 * -p Pause for SIGUSR1 before starting
40 * -P x Pause for x seconds between iterations
41 * -t Turn on syscall timing
42 *
43 * HISTORY
44 * 02/2002 Written by Paul Larson
45 *
46 * RESTRICTIONS
47 * None
48 */
49#include <sys/types.h>
50#include <sys/fcntl.h>
51#include <sys/stat.h>
52#include <errno.h>
53#include <string.h>
54#include <signal.h>
55#include "test.h"
plarsb6a1d252002-02-12 16:03:54 +000056
subrata_modak4bb656a2009-02-26 12:02:09 +000057void setup();
plarsb6a1d252002-02-12 16:03:54 +000058void help();
59void cleanup();
60
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020061char *TCID = "sigpending02";
62int TST_TOTAL = 1;
plarsb6a1d252002-02-12 16:03:54 +000063
plarsb6a1d252002-02-12 16:03:54 +000064/***********************************************************************
65 * Main
66 ***********************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +000067int main(int ac, char **av)
plarsb6a1d252002-02-12 16:03:54 +000068{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020069 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020070 const char *msg;
subrata_modak56207ce2009-03-23 13:35:39 +000071 sigset_t *sigset;
plarsb6a1d252002-02-12 16:03:54 +000072
Garrett Cooper45e285d2010-11-22 12:19:25 -080073 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
subrata_modak56207ce2009-03-23 13:35:39 +000074 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Garrett Cooper2c282152010-12-16 00:55:50 -080075
subrata_modak56207ce2009-03-23 13:35:39 +000076 }
plarsb6a1d252002-02-12 16:03:54 +000077
78 /***************************************************************
79 * perform global setup for test
80 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +000081 setup();
plarsb6a1d252002-02-12 16:03:54 +000082
subrata_modak56207ce2009-03-23 13:35:39 +000083 /* set sigset to point to an invalid location */
84 sigset = (sigset_t *) - 1;
plarsb6a1d252002-02-12 16:03:54 +000085
plarsb6a1d252002-02-12 16:03:54 +000086 /***************************************************************
subrata_modak4bb656a2009-02-26 12:02:09 +000087 * check looping state
plarsb6a1d252002-02-12 16:03:54 +000088 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +000089 /* TEST_LOOPING() is a macro that will make sure the test continues
90 * looping according to the standard command line args.
91 */
92 for (lc = 0; TEST_LOOPING(lc); lc++) {
plarsb6a1d252002-02-12 16:03:54 +000093
Caspar Zhangd59a6592013-03-07 14:59:12 +080094 tst_count = 0;
plarsb6a1d252002-02-12 16:03:54 +000095
subrata_modak56207ce2009-03-23 13:35:39 +000096 TEST(sigpending(sigset));
plarsb6a1d252002-02-12 16:03:54 +000097
subrata_modak56207ce2009-03-23 13:35:39 +000098 /* check return code */
99 if (TEST_RETURN == -1) {
subrata_modak56207ce2009-03-23 13:35:39 +0000100 if (TEST_ERRNO != EFAULT)
101 tst_brkm(TFAIL, cleanup,
102 "sigpending() Failed with wrong "
103 "errno, expected errno=%d, got errno=%d : %s",
104 EFAULT, TEST_ERRNO,
105 strerror(TEST_ERRNO));
106 else
107 tst_resm(TPASS,
108 "expected failure - errno = %d : %s",
109 TEST_ERRNO, strerror(TEST_ERRNO));
110 } else {
111 tst_brkm(TFAIL, cleanup,
112 "sigpending() Failed, expected "
subrata_modak923b23f2009-11-02 13:57:16 +0000113 "return value=-1, got %ld", TEST_RETURN);
subrata_modak56207ce2009-03-23 13:35:39 +0000114 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800115 }
plarsb6a1d252002-02-12 16:03:54 +0000116
117 /***************************************************************
118 * cleanup and exit
119 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +0000120 cleanup();
Garrett Cooper1e6f5a62010-12-19 09:58:10 -0800121 tst_exit();
plarsb6a1d252002-02-12 16:03:54 +0000122
Garrett Cooper2c282152010-12-16 00:55:50 -0800123}
plarsb6a1d252002-02-12 16:03:54 +0000124
125/***************************************************************
126 * help
127 ***************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -0400128void help(void)
plarsb6a1d252002-02-12 16:03:54 +0000129{
subrata_modak56207ce2009-03-23 13:35:39 +0000130 printf("test\n");
plarsb6a1d252002-02-12 16:03:54 +0000131}
132
133/***************************************************************
134 * setup() - performs all ONE TIME setup for this test.
135 ***************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -0400136void setup(void)
plarsb6a1d252002-02-12 16:03:54 +0000137{
subrata_modak56207ce2009-03-23 13:35:39 +0000138 TEST_PAUSE;
plarsb6a1d252002-02-12 16:03:54 +0000139}
140
141/***************************************************************
142 * cleanup() - performs all ONE TIME cleanup for this test at
143 * completion or premature exit.
144 ***************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -0400145void cleanup(void)
plarsb6a1d252002-02-12 16:03:54 +0000146{
Chris Dearmanec6edca2012-10-17 19:54:01 -0700147}