diff options
author | John Stultz <john.stultz@linaro.org> | 2015-03-11 20:40:09 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2015-03-12 15:22:15 -0400 |
commit | 6e8b285bcdd1834a18fd264c88a15418091c4015 (patch) | |
tree | f944d8d7725221797c4a0e04b6071b6e0109ec91 /tools/testing/selftests | |
parent | d869424558419a4a34a12bd5187b5d6d06ee132f (diff) |
selftests/timers: Add skew_consistency test from the timetests suite
This change adds the skew_consistency test, which twists the
ADJ_FREQUENCY knob back and forth and watches for timekeeping
inconsistencies.
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Tested-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/timers/Makefile | 3 | ||||
-rw-r--r-- | tools/testing/selftests/timers/skew_consistency.c | 89 |
2 files changed, 91 insertions, 1 deletions
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile index 55b74ccd37ae..4b6b5c3cedaf 100644 --- a/tools/testing/selftests/timers/Makefile +++ b/tools/testing/selftests/timers/Makefile | |||
@@ -4,7 +4,7 @@ CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS) | |||
4 | LDFLAGS += -lrt -lpthread | 4 | LDFLAGS += -lrt -lpthread |
5 | bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \ | 5 | bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \ |
6 | set-timer-lat threadtest mqueue-lat valid-adjtimex \ | 6 | set-timer-lat threadtest mqueue-lat valid-adjtimex \ |
7 | alarmtimer-suspend change_skew | 7 | alarmtimer-suspend change_skew skew_consistency |
8 | 8 | ||
9 | all: ${bins} | 9 | all: ${bins} |
10 | 10 | ||
@@ -27,6 +27,7 @@ run_destructive_tests: run_tests | |||
27 | ./alarmtimer-suspend | 27 | ./alarmtimer-suspend |
28 | ./valid-adjtimex | 28 | ./valid-adjtimex |
29 | ./change_skew | 29 | ./change_skew |
30 | ./skew_consistency | ||
30 | 31 | ||
31 | clean: | 32 | clean: |
32 | rm -f ${bins} | 33 | rm -f ${bins} |
diff --git a/tools/testing/selftests/timers/skew_consistency.c b/tools/testing/selftests/timers/skew_consistency.c new file mode 100644 index 000000000000..5562f84ee07c --- /dev/null +++ b/tools/testing/selftests/timers/skew_consistency.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /* ADJ_FREQ Skew consistency test | ||
2 | * by: john stultz (johnstul@us.ibm.com) | ||
3 | * (C) Copyright IBM 2012 | ||
4 | * Licensed under the GPLv2 | ||
5 | * | ||
6 | * NOTE: This is a meta-test which cranks the ADJ_FREQ knob back | ||
7 | * and forth and watches for consistency problems. Thus this test requires | ||
8 | * that the inconsistency-check tests be present in the same directory it | ||
9 | * is run from. | ||
10 | * | ||
11 | * To build: | ||
12 | * $ gcc skew_consistency.c -o skew_consistency -lrt | ||
13 | * | ||
14 | * This program is free software: you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation, either version 2 of the License, or | ||
17 | * (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
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 | ||
41 | static inline int ksft_exit_pass(void) | ||
42 | { | ||
43 | exit(0); | ||
44 | } | ||
45 | static inline int ksft_exit_fail(void) | ||
46 | { | ||
47 | exit(1); | ||
48 | } | ||
49 | #endif | ||
50 | |||
51 | #define NSEC_PER_SEC 1000000000LL | ||
52 | |||
53 | int 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 | /* Set things back */ | ||
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 | } | ||