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 AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com>
19 EXECUTED BY: root / superuser
20
21 TEST ITEMS:
22 1. Check to see if adjtimex succeed with mode combination :
23 ADJ_OFFSET | ADJ_FREQUENCY | ADJ_MAXERROR | ADJ_ESTERROR |
24 ADJ_STATUS | ADJ_TIMECONST | ADJ_TICK
25 2. Check to see if adjtimex succeed with mode ADJ_OFFSET_SINGLESHOT
26 */
27
28 #if defined UCLINUX && !__THROW
29 /* workaround for libc bug causing failure in sys/timex.h */
30 #define __THROW
31 #endif
32
33 #include <errno.h>
34 #include <sys/timex.h>
35 #include "test.h"
36
37 #define SET_MODE (ADJ_OFFSET | ADJ_FREQUENCY | ADJ_MAXERROR | ADJ_ESTERROR | \
38 ADJ_STATUS | ADJ_TIMECONST | ADJ_TICK)
39
40 static void setup(void);
41 static void cleanup(void);
42
43 char *TCID = "adjtimex01";
44 int TST_TOTAL = 2;
45
46 static struct timex tim_save;
47
main(int ac,char ** av)48 int main(int ac, char **av)
49 {
50 int lc;
51
52 tst_parse_opts(ac, av, NULL, NULL);
53
54 setup();
55
56 for (lc = 0; TEST_LOOPING(lc); lc++) {
57
58 tst_count = 0;
59
60 /* Call adjtimex(2) */
61 tim_save.modes = SET_MODE;
62
63 TEST(adjtimex(&tim_save));
64
65 if ((TEST_RETURN >= 0) && (TEST_RETURN <= 5)) {
66 tst_resm(TPASS, "adjtimex() with mode %u returned %ld",
67 SET_MODE, TEST_RETURN);
68 } else {
69 tst_resm(TFAIL | TTERRNO,
70 "Test Failed, adjtimex() with mode %u "
71 "returned %ld", SET_MODE, TEST_RETURN);
72 }
73
74 /* Call adjtimex(2) */
75 tim_save.modes = ADJ_OFFSET_SINGLESHOT;
76
77 TEST(adjtimex(&tim_save));
78
79 if ((TEST_RETURN >= 0) && (TEST_RETURN <= 5)) {
80 tst_resm(TPASS, "adjtimex() with mode %u returned %ld",
81 ADJ_OFFSET_SINGLESHOT, TEST_RETURN);
82 } else {
83 tst_resm(TFAIL | TTERRNO,
84 "Test Failed, adjtimex() with mode %u returned "
85 "%ld", ADJ_OFFSET_SINGLESHOT, TEST_RETURN);
86 }
87 }
88
89 cleanup();
90
91 tst_exit();
92 }
93
setup(void)94 static void setup(void)
95 {
96 tst_require_root();
97
98 tim_save.modes = 0;
99
100 tst_sig(NOFORK, DEF_HANDLER, cleanup);
101
102 TEST_PAUSE;
103
104 /* Save current parameters in tim_save */
105 if ((adjtimex(&tim_save)) == -1)
106 tst_brkm(TBROK | TERRNO, cleanup,
107 "failed to save current parameters");
108 }
109
cleanup(void)110 static void cleanup(void)
111 {
112 }
113