Home | History | Annotate | Download | only in sgetmask
      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               */
     16 /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
     17 /*                                                                            */
     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 (at) in.ibm.com>                        */
     39 /******************************************************************************/
     40 
     41 /* 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 
     48 #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 
     55 #include "test.h"
     56 #include "lapi/syscalls.h"
     57 
     58 char *TCID = "sgetmask01";
     59 int testno;
     60 int TST_TOTAL = 2;
     61 
     62 /* Extern Global Functions */
     63 /******************************************************************************/
     64 /*                                                                            */
     65 /* Function:    cleanup                                                       */
     66 /*                                                                            */
     67 /* Description: Performs all one time clean up for this test on successful    */
     68 /*              completion,  premature exit or  failure. Closes all temporary */
     69 /*              files, removes all temporary directories exits the test with  */
     70 /*              appropriate return code by calling tst_exit() function.       */
     71 /*                                                                            */
     72 /* Input:       None.                                                         */
     73 /*                                                                            */
     74 /* Output:      None.                                                         */
     75 /*                                                                            */
     76 /* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
     77 /*              On success - Exits calling tst_exit(). With '0' return code.  */
     78 /*                                                                            */
     79 /******************************************************************************/
     80 void cleanup(void)
     81 {
     82 
     83 	tst_rmdir();
     84 
     85 	tst_exit();
     86 }
     87 
     88 /* Local  Functions */
     89 /******************************************************************************/
     90 /*                                                                            */
     91 /* Function:    setup                                                         */
     92 /*                                                                            */
     93 /* Description: Performs all one time setup for this test. This function is   */
     94 /*              typically used to capture signals, create temporary dirs      */
     95 /*              and temporary files that may be used in the course of this    */
     96 /*              test.                                                         */
     97 /*                                                                            */
     98 /* Input:       None.                                                         */
     99 /*                                                                            */
    100 /* Output:      None.                                                         */
    101 /*                                                                            */
    102 /* Return:      On failure - Exits by calling cleanup().                      */
    103 /*              On success - returns 0.                                       */
    104 /*                                                                            */
    105 /******************************************************************************/
    106 void setup(void)
    107 {
    108 	/* Capture signals if any */
    109 	/* Create temporary directories */
    110 	TEST_PAUSE;
    111 	tst_tmpdir();
    112 }
    113 
    114 int main(int ac, char **av)
    115 {
    116 	int sig;
    117 	int lc;
    118 
    119 	tst_parse_opts(ac, av, NULL, NULL);
    120 
    121 	setup();
    122 
    123 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
    124 		tst_count = 0;
    125 		for (testno = 0; testno < TST_TOTAL; ++testno) {
    126 
    127 			for (sig = -3; sig <= SIGRTMAX + 1; sig++) {
    128 				TEST(ltp_syscall(__NR_ssetmask, sig));
    129 				tst_resm(TINFO, "Setting signal : %d -- "
    130 					"return of setmask : %ld",
    131 					sig, TEST_RETURN);
    132 				TEST(ltp_syscall(__NR_sgetmask));
    133 				if (TEST_RETURN != sig) {
    134 					tst_resm(TINFO,
    135 						 "Oops,setting sig %d, got %ld",
    136 						 sig, TEST_RETURN);
    137 				} else
    138 					tst_resm(TPASS,
    139 						 "OK,setting sig %d, got %ld",
    140 						 sig, TEST_RETURN);
    141 				if (sig == SIGRTMAX + 1) {
    142 					cleanup();
    143 					tst_exit();
    144 				}
    145 			}
    146 		}
    147 	}
    148 	cleanup();
    149 	tst_exit();
    150 }
    151