1 /*
2 * Copyright (c) International Business Machines Corp., 2001
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 HISTORY
21 03/2001 - Written by Wayne Boyer
22
23 TEST ITEMS:
24 Check that a correct call to getitimer() succeeds.
25 */
26
27 #include "test.h"
28
29 #include <errno.h>
30 #include <sys/time.h>
31
32 static void cleanup(void);
33 static void setup(void);
34
35 char *TCID = "getitimer01";
36 int TST_TOTAL = 3;
37
38 static int itimer_name[] = {
39 ITIMER_REAL,
40 ITIMER_VIRTUAL,
41 ITIMER_PROF,
42 };
43
main(int ac,char ** av)44 int main(int ac, char **av)
45 {
46 int lc;
47 int i;
48 struct itimerval value;
49
50 tst_parse_opts(ac, av, NULL, NULL);
51
52 setup();
53
54 for (lc = 0; TEST_LOOPING(lc); lc++) {
55 tst_count = 0;
56
57 for (i = 0; i < 3; i++) {
58
59 TEST(getitimer(itimer_name[i], &value));
60
61 if (TEST_RETURN != 0)
62 tst_resm(TFAIL, "call failed - errno = %d - %s",
63 TEST_ERRNO, strerror(TEST_ERRNO));
64
65 /*
66 * Since ITIMER is effectively disabled (we did
67 * not set it before the getitimer call), the
68 * elements in it_value should be zero.
69 */
70 if ((value.it_value.tv_sec == 0) &&
71 (value.it_value.tv_usec == 0)) {
72 tst_resm(TPASS, "functionality is ok");
73 } else {
74 tst_resm(TFAIL, "timer are non zero");
75 }
76 }
77 }
78
79 cleanup();
80 tst_exit();
81 }
82
setup(void)83 static void setup(void)
84 {
85 tst_sig(NOFORK, DEF_HANDLER, cleanup);
86
87 TEST_PAUSE;
88 }
89
cleanup(void)90 static void cleanup(void)
91 {
92 }
93