blob: 299e021670f96fea63a57a6e98579ae3ef613732 [file] [log] [blame]
subrata_modak8afc2fa2009-05-21 18:35:31 +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_modak8afc2fa2009-05-21 18:35:31 +000017/* */
18/******************************************************************************/
19/******************************************************************************/
20/* */
21/* File: sgetmask01.c */
22/* */
23/* Description: This tests the sgetmask() syscall */
24/* */
25/* Usage: <for command-line> */
26/* sgetmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t] */
27/* where, -c n : Run n copies concurrently. */
28/* -e : Turn on errno logging. */
29/* -i n : Execute test n times. */
30/* -I x : Execute test for x seconds. */
31/* -P x : Pause for x seconds between iterations. */
32/* -t : Turn on syscall timing. */
33/* */
34/* Total Tests: 1 */
35/* */
36/* Test Name: sgetmask01 */
37/* History: Porting from Crackerjack to LTP is done by */
38/* Manas Kumar Nayak maknayak@in.ibm.com> */
39/******************************************************************************/
40
subrata_modak8afc2fa2009-05-21 18:35:31 +000041/* NOTE: This case test the behavior of sgetmask
42# Sometime the returned "Oops"in this case don't mean anything for
43# correct or error, we check the result between different kernel and
44# try to find if there exist different returned code in different kernel
45#
46*/
47
subrata_modak8afc2fa2009-05-21 18:35:31 +000048#include <stdio.h>
49#include <signal.h>
50#include <sys/syscall.h>
51#include <unistd.h>
52#include <stdio.h>
53#include <errno.h>
54
subrata_modak8afc2fa2009-05-21 18:35:31 +000055#include "test.h"
56#include "usctest.h"
57#include "linux_syscall_numbers.h"
58
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020059char *TCID = "sgetmask01";
Wanlong Gao354ebb42012-12-07 10:10:04 +080060int testno;
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020061int TST_TOTAL = 2;
subrata_modak8afc2fa2009-05-21 18:35:31 +000062
63/* Extern Global Functions */
64/******************************************************************************/
65/* */
66/* Function: cleanup */
67/* */
68/* Description: Performs all one time clean up for this test on successful */
69/* completion, premature exit or failure. Closes all temporary */
70/* files, removes all temporary directories exits the test with */
71/* appropriate return code by calling tst_exit() function. */
72/* */
73/* Input: None. */
74/* */
75/* Output: None. */
76/* */
77/* Return: On failure - Exits calling tst_exit(). Non '0' return code. */
78/* On success - Exits calling tst_exit(). With '0' return code. */
79/* */
80/******************************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -040081void cleanup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080082{
Garrett Cooper2c282152010-12-16 00:55:50 -080083
Wanlong Gao354ebb42012-12-07 10:10:04 +080084 TEST_CLEANUP;
85 tst_rmdir();
subrata_modak8afc2fa2009-05-21 18:35:31 +000086
Wanlong Gao354ebb42012-12-07 10:10:04 +080087 tst_exit();
subrata_modak8afc2fa2009-05-21 18:35:31 +000088}
89
90/* Local Functions */
91/******************************************************************************/
92/* */
93/* Function: setup */
94/* */
95/* Description: Performs all one time setup for this test. This function is */
96/* typically used to capture signals, create temporary dirs */
97/* and temporary files that may be used in the course of this */
98/* test. */
99/* */
100/* Input: None. */
101/* */
102/* Output: None. */
103/* */
104/* Return: On failure - Exits by calling cleanup(). */
105/* On success - returns 0. */
106/* */
107/******************************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -0400108void setup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +0800109{
110 /* Capture signals if any */
111 /* Create temporary directories */
112 TEST_PAUSE;
113 tst_tmpdir();
subrata_modak8afc2fa2009-05-21 18:35:31 +0000114}
115
Wanlong Gao354ebb42012-12-07 10:10:04 +0800116int main(int ac, char **av)
117{
118 int sig;
Cyril Hrubis89af32a2012-10-24 16:39:11 +0200119 int lc;
120 char *msg;
Garrett Cooper2c282152010-12-16 00:55:50 -0800121
Wanlong Gao354ebb42012-12-07 10:10:04 +0800122 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
123 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
124 tst_exit();
125 }
subrata_modak8afc2fa2009-05-21 18:35:31 +0000126
Wanlong Gao354ebb42012-12-07 10:10:04 +0800127 setup();
subrata_modak8afc2fa2009-05-21 18:35:31 +0000128
Wanlong Gao354ebb42012-12-07 10:10:04 +0800129 for (lc = 0; TEST_LOOPING(lc); ++lc) {
Caspar Zhangd59a6592013-03-07 14:59:12 +0800130 tst_count = 0;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800131 for (testno = 0; testno < TST_TOTAL; ++testno) {
subrata_modak8afc2fa2009-05-21 18:35:31 +0000132
Garrett Cooperdf3eb162010-11-28 22:44:32 -0800133 for (sig = -3; sig <= SIGRTMAX + 1; sig++) {
Jan Stancek359980f2013-02-15 10:16:05 +0100134 TEST(ltp_syscall(__NR_ssetmask, sig));
135 tst_resm(TINFO, "Setting signal : %d -- "
136 "return of setmask : %ld",
137 sig, TEST_RETURN);
138 TEST(ltp_syscall(__NR_sgetmask));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800139 if (TEST_RETURN != sig) {
140 tst_resm(TINFO,
141 "Oops,setting sig %d, got %ld",
142 sig, TEST_RETURN);
143 } else
144 tst_resm(TPASS,
145 "OK,setting sig %d, got %ld",
146 sig, TEST_RETURN);
147 if (sig == SIGRTMAX + 1) {
subrata_modak8afc2fa2009-05-21 18:35:31 +0000148 cleanup();
149 tst_exit();
150 }
Wanlong Gao354ebb42012-12-07 10:10:04 +0800151 }
subrata_modak8afc2fa2009-05-21 18:35:31 +0000152 }
Wanlong Gao354ebb42012-12-07 10:10:04 +0800153 }
subrata_modak8afc2fa2009-05-21 18:35:31 +0000154 cleanup();
Wanlong Gao354ebb42012-12-07 10:10:04 +0800155 tst_exit();
Chris Dearmanec6edca2012-10-17 19:54:01 -0700156}