2 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
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.
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.
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., 59
14 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 /**********************************************************
19 * TEST IDENTIFIER : getrusage01
21 * EXECUTED BY : anyone
23 * TEST TITLE : Basic test for getrusage(2)
27 * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
30 * Uses SIGUSR1 to pause before test if option set.
31 * (See the parse_opts(3) man page).
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.
38 * Setup signal handling.
39 * Pause for SIGUSR1 if option specified.
42 * Loop if the proper options are given.
50 * Print errno log and/or timing stats if options given
52 * USAGE: <for command-line>
53 * getrusage01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f]
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.
65 ****************************************************************/
69 #include <sys/resource.h>
74 static void cleanup();
76 char *TCID
= "getrusage01"; /* Test program identifier. */
77 extern int Tst_count
; /* Test Case counter for tst_* routines */
78 int who
[2] = { RUSAGE_SELF
, RUSAGE_CHILDREN
};
81 int main(int ac
, char **av
)
84 int lc
, ind
; /* loop counter */
85 char *msg
; /* message returned from parse_opts */
88 /* parse standard options */
89 if ((msg
= parse_opts(ac
, av
, (option_t
*) NULL
, NULL
))
91 tst_brkm(TBROK
, tst_exit
, "OPTION PARSING ERROR - %s", msg
);
94 /* perform global setup for test */
97 /* check looping state if -i option given */
98 for (lc
= 0; TEST_LOOPING(lc
); lc
++) {
100 /* reset Tst_count in case we are looping. */
103 for (ind
= 0; ind
< TST_TOTAL
; ind
++) {
107 TEST(getrusage(who
[ind
], &usage
));
109 if (TEST_RETURN
== 0) {
110 tst_resm(TPASS
, "TEST Passed");
112 tst_resm(TFAIL
, "test Failed,"
113 "getrusage() returned %ld"
114 " errno = %d : %s", TEST_RETURN
,
115 TEST_ERRNO
, strerror(TEST_ERRNO
));
118 } /* End for TEST_LOOPING */
120 /* cleanup and exit */
123 /*NOTREACHED*/ return 0;
127 /* setup() - performs all ONE TIME setup for this test */
131 /* capture signals */
132 tst_sig(NOFORK
, DEF_HANDLER
, cleanup
);
134 /* Pause if that option was specified */
140 *cleanup() - performs all ONE TIME cleanup for this test at
141 * completion or premature exit.
147 * print timing stats if that option was specified.
148 * print errno log if that option was specified.
152 /* exit with return code appropriate for results */
154 } /* End cleanup() */