This source file includes following definitions.
- change_skew_test
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <sys/time.h>
29 #include <sys/timex.h>
30 #include <time.h>
31 #include "../kselftest.h"
32
33 #define NSEC_PER_SEC 1000000000LL
34
35
36 int change_skew_test(int ppm)
37 {
38 struct timex tx;
39 int ret;
40
41 tx.modes = ADJ_FREQUENCY;
42 tx.freq = ppm << 16;
43
44 ret = adjtimex(&tx);
45 if (ret < 0) {
46 printf("Error adjusting freq\n");
47 return ret;
48 }
49
50 ret = system("./raw_skew");
51 ret |= system("./inconsistency-check");
52 ret |= system("./nanosleep");
53
54 return ret;
55 }
56
57
58 int main(int argv, char **argc)
59 {
60 struct timex tx;
61 int i, ret;
62
63 int ppm[5] = {0, 250, 500, -250, -500};
64
65
66 ret = system("killall -9 ntpd");
67
68
69 tx.modes = ADJ_OFFSET;
70 tx.offset = 0;
71 ret = adjtimex(&tx);
72
73 if (ret < 0) {
74 printf("Maybe you're not running as root?\n");
75 return -1;
76 }
77
78 for (i = 0; i < 5; i++) {
79 printf("Using %i ppm adjustment\n", ppm[i]);
80 ret = change_skew_test(ppm[i]);
81 if (ret)
82 break;
83 }
84
85
86 tx.modes = ADJ_FREQUENCY;
87 tx.offset = 0;
88 adjtimex(&tx);
89
90 if (ret) {
91 printf("[FAIL]");
92 return ksft_exit_fail();
93 }
94 printf("[OK]");
95 return ksft_exit_pass();
96 }