• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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	: getrusage01
20  *
21  *    EXECUTED BY	: anyone
22  *
23  *    TEST TITLE	: Basic test for getrusage(2)
24  *
25  *    TEST CASE TOTAL	: 2
26  *
27  *    AUTHOR		: Saji Kumar.V.R <saji.kumar@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 getrusage(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  *	  if return code == 0
45  *		Test Passed
46  *	  else
47  *		Test Failed
48  *
49  * 	Cleanup:
50  * 	  Print errno log and/or timing stats if options given
51  *
52  * USAGE:  <for command-line>
53  *  getrusage01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f]
54  * 			     [-p]
55  *			where,  -c n : Run n copies concurrently.
56  *				-e   : Turn on errno logging.
57  *				-h   : Show help screen
58  *				-f   : Turn off functional testing
59  *				-i n : Execute test n times.
60  *				-I x : Execute test for x seconds.
61  *				-p   : Pause for SIGUSR1 before starting
62  *				-P x : Pause for x seconds between iterations.
63  *				-t   : Turn on syscall timing.
64  *
65  ****************************************************************/
66 
67 #include <errno.h>
68 #include <sched.h>
69 #include <sys/resource.h>
70 #include "test.h"
71 
72 static void setup();
73 static void cleanup();
74 
75 char *TCID = "getrusage01";
76 int who[2] = { RUSAGE_SELF, RUSAGE_CHILDREN };
77 
78 int TST_TOTAL = 2;
79 
main(int ac,char ** av)80 int main(int ac, char **av)
81 {
82 
83 	int lc, i;
84 	struct rusage usage;
85 
86 	tst_parse_opts(ac, av, NULL, NULL);
87 
88 	setup();
89 
90 	for (lc = 0; TEST_LOOPING(lc); lc++) {
91 
92 		tst_count = 0;
93 
94 		for (i = 0; i < TST_TOTAL; i++) {
95 			TEST(getrusage(who[i], &usage));
96 
97 			if (TEST_RETURN == 0)
98 				tst_resm(TPASS, "getrusage passed");
99 			else
100 				tst_resm(TFAIL | TTERRNO, "getrusage failed");
101 		}
102 	}
103 
104 	cleanup();
105 	tst_exit();
106 
107 }
108 
setup(void)109 void setup(void)
110 {
111 
112 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
113 
114 	TEST_PAUSE;
115 
116 }
117 
cleanup(void)118 void cleanup(void)
119 {
120 }
121