Home | History | Annotate | Download | only in getdomainname
      1 /*
      2  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
      3  *
      4  * This program is free software; you can redistribute it and/or modify it
      5  * under the terms of version 2 of the GNU General Public License as
      6  * published by the Free Software Foundation.
      7  *
      8  * This program is distributed in the hope that it would be useful, but
      9  * WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     11  *
     12  * You should have received a copy of the GNU General Public License along
     13  * with this program; if not, write the Free Software Foundation, Inc.,
     14  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     15  *
     16  */
     17 /**********************************************************
     18  *
     19  *    TEST IDENTIFIER	: getdomainname01
     20  *
     21  *    EXECUTED BY	: anyone
     22  *
     23  *    TEST TITLE	: Basic test for getdomainname(2)
     24  *
     25  *    TEST CASE TOTAL	: 1
     26  *
     27  *    AUTHOR		: Saji Kumar.V.R <saji.kumar (at) wipro.com>
     28  *
     29  *    SIGNALS
     30  *	Uses SIGUSR1 to pause before test if option set.
     31  *	(See the parse_opts(3) man page).
     32  *
     33  *    DESCRIPTION
     34  *	This is a Phase I test for the getdomainname(2) system call.
     35  *	It is intended to provide a limited exposure of the system call.
     36  *
     37  *	Setup:
     38  *	  Setup signal handling.
     39  *	  Pause for SIGUSR1 if option specified.
     40  *
     41  *	Test:
     42  *	 Loop if the proper options are given.
     43  *	  Execute system call
     44  *	  Check return code, if system call failed (return=-1)
     45  *		Log the errno and Issue a FAIL message.
     46  *	  Otherwise, Issue a PASS message.
     47  *
     48  *	Cleanup:
     49  *	  Print errno log and/or timing stats if options given
     50  *
     51  * USAGE:  <for command-line>
     52  *  getdomainname01  [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
     53  *			where,  -c n : Run n copies concurrently.
     54  *				-e   : Turn on errno logging.
     55  *				-h   : Show help screen
     56  *				-f   : Turn off functional testing
     57  *				-i n : Execute test n times.
     58  *				-I x : Execute test for x seconds.
     59  *				-p   : Pause for SIGUSR1 before starting
     60  *				-P x : Pause for x seconds between iterations.
     61  *				-t   : Turn on syscall timing.
     62  *
     63  ****************************************************************/
     64 
     65 #include <errno.h>
     66 #include <linux/utsname.h>
     67 #include "test.h"
     68 
     69 #define MAX_NAME_LEN __NEW_UTS_LEN
     70 
     71 static void setup();
     72 static void cleanup();
     73 
     74 char *TCID = "getdomainname01";
     75 int TST_TOTAL = 1;
     76 
     77 static char domain_name[MAX_NAME_LEN];
     78 
     79 int main(int ac, char **av)
     80 {
     81 
     82 	int lc;
     83 
     84 	tst_parse_opts(ac, av, NULL, NULL);
     85 
     86 	setup();
     87 
     88 	for (lc = 0; TEST_LOOPING(lc); lc++) {
     89 
     90 		tst_count = 0;
     91 
     92 		/*
     93 		 * Call getdomainname(2)
     94 		 */
     95 		TEST(getdomainname(domain_name, sizeof(domain_name)));
     96 
     97 		/* check return code */
     98 		if (TEST_RETURN == -1) {
     99 			tst_resm(TFAIL, "getdomainname() Failed, errno = %d :"
    100 				 " %s", TEST_ERRNO, strerror(TEST_ERRNO));
    101 		} else {
    102 			tst_resm(TPASS, "getdomainname() returned %ld ",
    103 				 TEST_RETURN);
    104 		}
    105 
    106 	}
    107 
    108 	/* cleanup and exit */
    109 	cleanup();
    110 
    111 	tst_exit();
    112 
    113 }
    114 
    115 /* setup() - performs all ONE TIME setup for this test */
    116 void setup(void)
    117 {
    118 
    119 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
    120 
    121 	TEST_PAUSE;
    122 
    123 }
    124 
    125 /*
    126  *cleanup() -  performs all ONE TIME cleanup for this test at
    127  *		completion or premature exit.
    128  */
    129 void cleanup(void)
    130 {
    131 
    132 }
    133