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 <unistd.h>
29#include <sys/time.h>
30#include <sys/timex.h>
31#include <time.h>
32#include <sys/types.h>
33#include <sys/stat.h>
34#include <fcntl.h>
35#include <stdlib.h>
36#include <string.h>
37#include <sys/wait.h>
38#ifdef KTEST
39#include "../kselftest.h"
40#else
41static inline int ksft_exit_pass(void)
42{
43 exit(0);
44}
45static inline int ksft_exit_fail(void)
46{
47 exit(1);
48}
49#endif
50
51#define NSEC_PER_SEC 1000000000LL
52
53int main(int argv, char **argc)
54{
55 struct timex tx;
56 int ret, ppm;
57 pid_t pid;
58
59
60 printf("Running Asyncrhonous Frequency Changing Tests...\n");
61
62 pid = fork();
63 if (!pid)
64 return system("./inconsistency-check -c 1 -t 600");
65
66 ppm = 500;
67 ret = 0;
68
69 while (pid != waitpid(pid, &ret, WNOHANG)) {
70 ppm = -ppm;
71 tx.modes = ADJ_FREQUENCY;
72 tx.freq = ppm << 16;
73 adjtimex(&tx);
74 usleep(500000);
75 }
76
77
78 tx.modes = ADJ_FREQUENCY;
79 tx.offset = 0;
80 adjtimex(&tx);
81
82
83 if (ret) {
84 printf("[FAILED]\n");
85 return ksft_exit_fail();
86 }
87 printf("[OK]\n");
88 return ksft_exit_pass();
89}
90