Skip to contentSkip to conversation

Add timekeeping tests to kernel selftest

RFC PATCH Superseded John Stultz 3 participants 28 messages Feb 25, 2015 – Mar 2, 2015

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Add timekeeping tests to kernel selftest

I've hosted my timekeeping tests on github for the last few years:
https://github.com/johnstultz-work/timetests

but I suspect not too many folks have actually used them.

I've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time until recently. So I wanted to send this out and get any feedback to see if they might be able to get into shape for the 4.1 merge window.

I've added both the non-desctructive and destructive tests (which set the time, possibly to strange values, or tries to trigger historical issues that could crash the machine). The destructive tests are run (as root, or with proper privledge) via:

	# make run_destructive_tests

Thoughts or comments here would be greatly appreciated!

thanks!
-john

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>

John Stultz (19):
selftests/timers: Cleanup Makefile to make it easier to add future
tests
selftests/timers: Quiet warning due to lack of return check on brk selftests/timers: Add nanosleep test from timetest suite selftests/timers: Add inconsistency-check test from timetests selftests/timers: Add nsleep-lat test from timetest suite selftests/timers: Add clock skew estimation test from timetest suite selftests/timers: Add set-timer-lat test from timetest suite selftests/timers: Add threaded time inconsistency test from timetest
suite
selftests/timers: Add mqueue latency test from the timetest suite selftests/timers: Add adjtimex validation test from timetest suite selftests/timers: Add alarmtimer-suspend test from timetests suite selftests/timers: Add change_skew test from timetest suite selftests/timers: Add skew_consistency test from the timetests suite selftests/timers: Add clocksource-switch test from timetest suite selftests/timers: Add leap-a-day test from timetest suite selftests/timers: Add leapcrash test from the timetest suite selftests/timers: Add set-tai from the timetest suite selftests/timers: Add set-2038 test from timetest suite
MAINTAINERS: Add selftests/timers to the timekeeping maintainance list

 MAINTAINERS                                        |   1 +
 tools/testing/selftests/timers/Makefile            |  35 ++-
 .../testing/selftests/timers/alarmtimer-suspend.c  | 172 ++++++++++++
 tools/testing/selftests/timers/change_skew.c       |  93 +++++++
 .../testing/selftests/timers/clocksource-switch.c  | 165 +++++++++++
 .../testing/selftests/timers/inconsistency-check.c | 199 ++++++++++++++
 tools/testing/selftests/timers/leap-a-day.c        | 306 +++++++++++++++++++++
 tools/testing/selftests/timers/leapcrash.c         | 106 +++++++
 tools/testing/selftests/timers/mqueue-lat.c        | 113 ++++++++
 tools/testing/selftests/timers/nanosleep.c         | 162 +++++++++++
 tools/testing/selftests/timers/nsleep-lat.c        | 178 ++++++++++++
 tools/testing/selftests/timers/posix_timers.c      |   5 +-
 tools/testing/selftests/timers/raw_skew.c          | 139 ++++++++++
 tools/testing/selftests/timers/set-2038.c          | 131 +++++++++
 tools/testing/selftests/timers/set-tai.c           |  67 +++++
 tools/testing/selftests/timers/set-timer-lat.c     | 198 +++++++++++++
 tools/testing/selftests/timers/skew_consistency.c  |  75 +++++
 tools/testing/selftests/timers/threadtest.c        | 182 ++++++++++++
 tools/testing/selftests/timers/valid-adjtimex.c    | 188 +++++++++++++
 19 files changed, 2510 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/timers/alarmtimer-suspend.c
 create mode 100644 tools/testing/selftests/timers/change_skew.c
 create mode 100644 tools/testing/selftests/timers/clocksource-switch.c
 create mode 100644 tools/testing/selftests/timers/inconsistency-check.c
 create mode 100644 tools/testing/selftests/timers/leap-a-day.c
 create mode 100644 tools/testing/selftests/timers/leapcrash.c
 create mode 100644 tools/testing/selftests/timers/mqueue-lat.c
 create mode 100644 tools/testing/selftests/timers/nanosleep.c
 create mode 100644 tools/testing/selftests/timers/nsleep-lat.c
 create mode 100644 tools/testing/selftests/timers/raw_skew.c
 create mode 100644 tools/testing/selftests/timers/set-2038.c
 create mode 100644 tools/testing/selftests/timers/set-tai.c
 create mode 100644 tools/testing/selftests/timers/set-timer-lat.c
 create mode 100644 tools/testing/selftests/timers/skew_consistency.c
 create mode 100644 tools/testing/selftests/timers/threadtest.c
 create mode 100644 tools/testing/selftests/timers/valid-adjtimex.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/19 selftests/timers: Cleanup Makefile to make it easier to add future tests

Try to streamline the makefile so its easier to add timer/timekeeping tests.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/timers/Makefile +6 -3
index eb2859f..90a37b3 100644
@@ -1,8 +1,11 @@
-all:
-	gcc posix_timers.c -o posix_timers -lrt
+CFLAGS += -O3 -Wl,-no-as-needed
+LDFLAGS += -lrt -lpthread
+bins = posix_timers
+
+all: ${bins}
 
 run_tests: all
 	./posix_timers
 
 clean:
-	rm -f ./posix_timers
+	rm -f ${bins}
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 01/19] selftests/timers: Cleanup Makefile to make it easier to add future tests

Quoted 17 lines · John Stultz

Try to streamline the makefile so its easier to add timer/timekeeping tests.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/timers/Makefile +0 -0
index eb2859f..90a37b3 100644

tools/testing/selftests/timers/Makefile line 8

Quoted 10 lines
tools/testing/selftests/timers/Makefile +5 -2
@@ -1,8 +1,11 @@
-all:
-	gcc posix_timers.c -o posix_timers -lrt
+CFLAGS += -O3 -Wl,-no-as-needed
+LDFLAGS += -lrt -lpthread
+bins = posix_timers
+
+all: ${bins}
 
 run_tests: all
 	./posix_timers

Please add another target for running destructive tests. You might have to classify tests so posix_timers doesn't run all of them by default.

thanks,
-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
#3 lore raw

PATCH 2/19 selftests/timers: Quiet warning due to lack of return check on brk

In reply to John Stultz

The posix_timers.c test has a loop that tries to keep it in kernel space, repeatedly calling brk(). Since its noise, and a failure won't change what the test would do, add a unused value to quiet the warning.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/posix_timers.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/posix_timers.c +3 -2
index f87d970..3e04cc0 100644
@@ -35,10 +35,11 @@ static void user_loop(void)
 static void kernel_loop(void)
 {
 	void *addr = sbrk(0);
+	int unused;
 
 	while (!done) {
-		brk(addr + 4096);
-		brk(addr);
+		unused = brk(addr + 4096);
+		unused = brk(addr);
 	}
 }
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 3/19 selftests/timers: Add nanosleep test from timetest suite

In reply to John Stultz

Add my basic nanosleep test from my timetest suite. This test validates that nanosleep dosen't return early against a number of clockids.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile    |   3 +-
 tools/testing/selftests/timers/nanosleep.c | 162 +++++++++++++++++++++++++++++
 2 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/nanosleep.c
tools/testing/selftests/timers/Makefile +2 -1
index 90a37b3..469aaa6 100644
@@ -1,11 +1,12 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
-bins = posix_timers
+bins = posix_timers nanosleep
 
 all: ${bins}
 
 run_tests: all
 	./posix_timers
+	./nanosleep
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/nanosleep.c new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

PATCH 4/19 selftests/timers: Add inconsistency-check test from timetests

In reply to John Stultz

This adds my inconsistency-test from my timetests suite, which checks for (single threaded) time inconsistencies across the various clockids.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile            |   4 +-
 .../testing/selftests/timers/inconsistency-check.c | 199 +++++++++++++++++++++
 2 files changed, 201 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/timers/inconsistency-check.c
tools/testing/selftests/timers/Makefile +2 -2
index 469aaa6..b202888 100644
@@ -1,12 +1,12 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
-bins = posix_timers nanosleep
+bins = posix_timers nanosleep inconsistency-check
 
 all: ${bins}
 
 run_tests: all
 	./posix_timers
 	./nanosleep
-
+	./inconsistency-check
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/inconsistency-check.c new file +199 -0

199 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

PATCH 5/19 selftests/timers: Add nsleep-lat test from timetest suite

In reply to John Stultz

Adds my nanosleep latency test from the timetest suite. This checks to make sure we don't see "unreasonable" latencies (> 40ms) when calling nanosleep.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile     |   3 +-
 tools/testing/selftests/timers/nsleep-lat.c | 178 ++++++++++++++++++++++++++++
 2 files changed, 180 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/nsleep-lat.c
tools/testing/selftests/timers/Makefile +2 -1
index b202888..28c2184 100644
@@ -1,12 +1,13 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
-bins = posix_timers nanosleep inconsistency-check
+bins = posix_timers nanosleep inconsistency-check nsleep-lat
 
 all: ${bins}
 
 run_tests: all
 	./posix_timers
 	./nanosleep
+	./nsleep-lat
 	./inconsistency-check
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/nsleep-lat.c new file +178 -0

178 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

PATCH 6/19 selftests/timers: Add clock skew estimation test from timetest suite

In reply to John Stultz

This adds my clock skew estimation test from the timetest suite. It measures the drift between CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW and compares it with the current frequency value from adjtimex.

It sometimes can trigger false failures when ntpd isn't in a steady state, but its a useful too when doing adjtimex testing.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile   |   3 +-
 tools/testing/selftests/timers/raw_skew.c | 139 ++++++++++++++++++++++++++++++
 2 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/raw_skew.c
tools/testing/selftests/timers/Makefile +2 -1
index 28c2184..3f41d18 100644
@@ -1,6 +1,6 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
-bins = posix_timers nanosleep inconsistency-check nsleep-lat
+bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew
 
 all: ${bins}
 
@@ -9,5 +9,6 @@ run_tests: all
 	./nanosleep
 	./nsleep-lat
 	./inconsistency-check
+	./raw_skew
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/raw_skew.c new file +139 -0

139 lines not on this page · raw message

Signature · 1 line
1.9.1
#8 lore raw

PATCH 7/19 selftests/timers: Add set-timer-lat test from timetest suite

In reply to John Stultz

Add my set-timer-lat test from the timetest suite. This test checks the latency from set_timer and reports if any are unreasonable (>40ms).

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile        |   5 +-
 tools/testing/selftests/timers/set-timer-lat.c | 198 +++++++++++++++++++++++++
 2 files changed, 202 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/set-timer-lat.c
tools/testing/selftests/timers/Makefile +4 -1
index 3f41d18..a1236cc 100644
@@ -1,6 +1,7 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
-bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew
+bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
+	set-timer-lat
 
 all: ${bins}
 
@@ -8,7 +9,9 @@ run_tests: all
 	./posix_timers
 	./nanosleep
 	./nsleep-lat
+	./set-timer-lat
 	./inconsistency-check
 	./raw_skew
+
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/set-timer-lat.c new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

PATCH 8/19 selftests/timers: Add threaded time inconsistency test from timetest suite

In reply to John Stultz

Add the threaded time inconsistency test from the timetest suite. This checks for time inconsistencies between cpus, usually associated with clock skew as sometimes found w/ TSCs.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile     |   4 +-
 tools/testing/selftests/timers/threadtest.c | 182 ++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/timers/threadtest.c
tools/testing/selftests/timers/Makefile +2 -2
index a1236cc..f8458c8 100644
@@ -1,7 +1,7 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
-	set-timer-lat
+	set-timer-lat threadtest
 
 all: ${bins}
 
@@ -12,6 +12,6 @@ run_tests: all
 	./set-timer-lat
 	./inconsistency-check
 	./raw_skew
-
+	./threadtest -t 30 -n 8
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/threadtest.c new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
1.9.1
#10 lore raw

PATCH 9/19 selftests/timers: Add mqueue latency test from the timetest suite

In reply to John Stultz

Add test to validate mqueue timeout latency from the timetest suite

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile     |   3 +-
 tools/testing/selftests/timers/mqueue-lat.c | 113 ++++++++++++++++++++++++++++
 2 files changed, 115 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/mqueue-lat.c
tools/testing/selftests/timers/Makefile +2 -1
index f8458c8..8ce28b4 100644
@@ -1,7 +1,7 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
-	set-timer-lat threadtest
+	set-timer-lat threadtest mqueue-lat
 
 all: ${bins}
 
@@ -10,6 +10,7 @@ run_tests: all
 	./nanosleep
 	./nsleep-lat
 	./set-timer-lat
+	./mqueue-lat
 	./inconsistency-check
 	./raw_skew
 	./threadtest -t 30 -n 8
tools/testing/selftests/timers/mqueue-lat.c new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
1.9.1
#11 lore raw

PATCH 10/19 selftests/timers: Add adjtimex validation test from timetest suite

In reply to John Stultz

This adds a adjtimex validation test which checks the behavior for a set of valida and invalid inputs. So far this only tests ADJ_FREQUENCY, but hopefully will grow.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile         |  11 +-
 tools/testing/selftests/timers/valid-adjtimex.c | 188 ++++++++++++++++++++++++
 2 files changed, 198 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/valid-adjtimex.c
tools/testing/selftests/timers/Makefile +10 -1
index 8ce28b4..49ac0cf 100644
@@ -1,10 +1,12 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
-	set-timer-lat threadtest mqueue-lat
+	set-timer-lat threadtest mqueue-lat valid-adjtimex
 
 all: ${bins}
 
+# these are all "safe" tests that don't modify
+# system time or require escalated privledges
 run_tests: all
 	./posix_timers
 	./nanosleep
@@ -14,5 +16,12 @@ run_tests: all
 	./inconsistency-check
 	./raw_skew
 	./threadtest -t 30 -n 8
+
+# these tests require escalated privledges
+# and may modify the system time or trigger
+# other behavior like suspend
+run_destructive_tests: all
+	./valid-adjtimex
+
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/valid-adjtimex.c new file +188 -0

188 lines not on this page · raw message

Signature · 1 line
1.9.1
#12 lore raw

PATCH 11/19 selftests/timers: Add alarmtimer-suspend test from timetests suite

In reply to John Stultz

This adds the alarmtimer-suspend test from the timetests suite, which tests that the alarmtimers wake the system up from suspend shortly after the time they were set to fire.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile            |   6 +-
 .../testing/selftests/timers/alarmtimer-suspend.c  | 172 +++++++++++++++++++++
 2 files changed, 176 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/timers/alarmtimer-suspend.c
tools/testing/selftests/timers/Makefile +4 -2
index 49ac0cf..4e3eef6 100644
@@ -1,7 +1,8 @@
 CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
-	set-timer-lat threadtest mqueue-lat valid-adjtimex
+	set-timer-lat threadtest mqueue-lat valid-adjtimex \
+	alarmtimer-suspend
 
 all: ${bins}
 
@@ -20,7 +21,8 @@ run_tests: all
 # these tests require escalated privledges
 # and may modify the system time or trigger
 # other behavior like suspend
-run_destructive_tests: all
+run_destructive_tests: run_tests
+	./alarmtimer-suspend
 	./valid-adjtimex
 
 clean:
tools/testing/selftests/timers/alarmtimer-suspend.c new file +172 -0

172 lines not on this page · raw message

Signature · 1 line
1.9.1
#13 lore raw

PATCH 12/19 selftests/timers: Add change_skew test from timetest suite

In reply to John Stultz

This patch adds the change_skew test which validates the adjtimex freq can be set to various values and then using the inconsistency-check, raw_skew, and nanosleep tests ensures time behaves properly.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile      |  3 +-
 tools/testing/selftests/timers/change_skew.c | 93 ++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/change_skew.c
tools/testing/selftests/timers/Makefile +2 -1
index 4e3eef6..c3e32f1 100644
@@ -2,7 +2,7 @@ CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
-	alarmtimer-suspend
+	alarmtimer-suspend change_skew
 
 all: ${bins}
 
@@ -24,6 +24,7 @@ run_tests: all
 run_destructive_tests: run_tests
 	./alarmtimer-suspend
 	./valid-adjtimex
+	./change_skew
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/change_skew.c new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH 13/19 selftests/timers: Add skew_consistency test from the timetests suite

In reply to John Stultz

This change adds the skew_consistency test, which twists the ADJ_FREQUENCY knob back and forth and watches for timekeeping inconsistencies.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile           |  3 +-
 tools/testing/selftests/timers/skew_consistency.c | 75 +++++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/skew_consistency.c
tools/testing/selftests/timers/Makefile +2 -1
index c3e32f1..68b5253 100644
@@ -2,7 +2,7 @@ CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
-	alarmtimer-suspend change_skew
+	alarmtimer-suspend change_skew skew_consistency
 
 all: ${bins}
 
@@ -25,6 +25,7 @@ run_destructive_tests: run_tests
 	./alarmtimer-suspend
 	./valid-adjtimex
 	./change_skew
+	./skew_consistency
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/skew_consistency.c new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
1.9.1
#15 lore raw

PATCH 14/19 selftests/timers: Add clocksource-switch test from timetest suite

In reply to John Stultz

Adds the clocksource-switch tests which continually switches the current clocksource between all the available ones, watching for any timekeeping inconsistencies.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile            |   3 +-
 .../testing/selftests/timers/clocksource-switch.c  | 165 +++++++++++++++++++++
 2 files changed, 167 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/clocksource-switch.c
tools/testing/selftests/timers/Makefile +2 -1
index 68b5253..d50a1ef 100644
@@ -2,7 +2,7 @@ CFLAGS += -O3 -Wl,-no-as-needed
 LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
-	alarmtimer-suspend change_skew skew_consistency
+	alarmtimer-suspend change_skew skew_consistency clocksource-switch \
 
 all: ${bins}
 
@@ -26,6 +26,7 @@ run_destructive_tests: run_tests
 	./valid-adjtimex
 	./change_skew
 	./skew_consistency
+	./clocksource-switch
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/clocksource-switch.c new file +165 -0

165 lines not on this page · raw message

Signature · 1 line
1.9.1
#16 lore raw

PATCH 15/19 selftests/timers: Add leap-a-day test from timetest suite

In reply to John Stultz

This change adds the leap-a-day test which sets STA_INS and STA_DEL each day to trigger leapseconds each day. It also has a mode to jump the time to right before the end of the day each iteration.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile     |   2 +
 tools/testing/selftests/timers/leap-a-day.c | 306 ++++++++++++++++++++++++++++
 2 files changed, 308 insertions(+)
 create mode 100644 tools/testing/selftests/timers/leap-a-day.c
tools/testing/selftests/timers/Makefile +2 -0
index d50a1ef..6acc920 100644
@@ -3,6 +3,7 @@ LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
 	alarmtimer-suspend change_skew skew_consistency clocksource-switch \
+	leap-a-day
 
 all: ${bins}
 
@@ -27,6 +28,7 @@ run_destructive_tests: run_tests
 	./change_skew
 	./skew_consistency
 	./clocksource-switch
+	./leap-a-day -s -i 10
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/leap-a-day.c new file +306 -0

306 lines not on this page · raw message

Signature · 1 line
1.9.1
#17 lore raw

PATCH 16/19 selftests/timers: Add leapcrash test from the timetest suite

In reply to John Stultz

This change adds the leapcrash test which tests to see if a leapsecond deadlock which was observed from 2.6.26 to 3.3 is present on this system.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile    |   3 +-
 tools/testing/selftests/timers/leapcrash.c | 106 +++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/leapcrash.c
tools/testing/selftests/timers/Makefile +2 -1
index 6acc920..e9486cd 100644
@@ -3,7 +3,7 @@ LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
 	alarmtimer-suspend change_skew skew_consistency clocksource-switch \
-	leap-a-day
+	leap-a-day leapcrash
 
 all: ${bins}
 
@@ -29,6 +29,7 @@ run_destructive_tests: run_tests
 	./skew_consistency
 	./clocksource-switch
 	./leap-a-day -s -i 10
+	./leapcrash
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/leapcrash.c new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
1.9.1
#18 lore raw

PATCH 17/19 selftests/timers: Add set-tai from the timetest suite

In reply to John Stultz

This patch adds the set-tai test which ensures the tai offset can be set properly from adjtimex.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile  |  3 +-
 tools/testing/selftests/timers/set-tai.c | 67 ++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/set-tai.c
tools/testing/selftests/timers/Makefile +2 -1
index e9486cd..3538d08 100644
@@ -3,7 +3,7 @@ LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
 	alarmtimer-suspend change_skew skew_consistency clocksource-switch \
-	leap-a-day leapcrash
+	leap-a-day leapcrash set-tai
 
 all: ${bins}
 
@@ -30,6 +30,7 @@ run_destructive_tests: run_tests
 	./clocksource-switch
 	./leap-a-day -s -i 10
 	./leapcrash
+	./set-tai
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/set-tai.c new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.9.1
#19 lore raw

PATCH 18/19 selftests/timers: Add set-2038 test from timetest suite

In reply to John Stultz

Adds the set-2038 test which sets the time to near-edge cases like the start and end of the 32 bit epoch and checks that time behaves properly. There is also a dangerous mode, which lets the clock roll over past 2038 on 32bit systems, which on some older kernels will cause system hangs.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 tools/testing/selftests/timers/Makefile   |   3 +-
 tools/testing/selftests/timers/set-2038.c | 131 ++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/timers/set-2038.c
tools/testing/selftests/timers/Makefile +2 -1
index 3538d08..d771c0c 100644
@@ -3,7 +3,7 @@ LDFLAGS += -lrt -lpthread
 bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \
 	set-timer-lat threadtest mqueue-lat valid-adjtimex \
 	alarmtimer-suspend change_skew skew_consistency clocksource-switch \
-	leap-a-day leapcrash set-tai
+	leap-a-day leapcrash set-tai set-2038
 
 all: ${bins}
 
@@ -31,6 +31,7 @@ run_destructive_tests: run_tests
 	./leap-a-day -s -i 10
 	./leapcrash
 	./set-tai
+	./set-2038
 
 clean:
 	rm -f ${bins}
tools/testing/selftests/timers/set-2038.c new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
1.9.1
#20 lore raw

PATCH 19/19 MAINTAINERS: Add selftests/timers to the timekeeping maintainance list

In reply to John Stultz

Since I'm adding a bunch of tests to selftests/timers, put me on the hook in the maintainers file.

Cc Shuah Khan <[email protected]>
Cc Prarit Bhargava <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Richard Cochran <[email protected]>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index ddc5a8c..369f42e 100644
@@ -8535,6 +8535,7 @@ F:	include/uapi/linux/timex.h
 F:	kernel/time/clocksource.c
 F:	kernel/time/time*.c
 F:	kernel/time/ntp.c
+F:	tools/testing/selftests/timers/
 
 SC1200 WDT DRIVER
 M:	Zwane Mwaikambo <[email protected]>
Signature · 1 line
1.9.1
#21 lore raw
In reply to John Stultz
Quoted 1 line · John Stultz

Thoughts or comments here would be greatly appreciated!

I only browsed through just to get an idea of the various tests, and the series looks good to me.

Thanks,
Richard

#22 lore raw
Quoted 5 lines · Richard Cochran
Quoted 1 line · John Stultz

Thoughts or comments here would be greatly appreciated!

I only browsed through just to get an idea of the various tests, and the series looks good to me.

Thanks for the look-over. There's still more coverage I'd like to have, but I'm eager to have a wider set of folks running what I've got now. Do let me know if you have any thoughts for additional tests to add.

thanks
-john

#23 lore raw
In reply to John Stultz
Quoted 11 lines · John Stultz

I've hosted my timekeeping tests on github for the last few years:
https://github.com/johnstultz-work/timetests

but I suspect not too many folks have actually used them.

I've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time until recently. So I wanted to send this out and get any feedback to see if they might be able to get into shape for the 4.1 merge window.

Quoted 7 lines

I've added both the non-desctructive and destructive tests (which set the time, possibly to strange values, or tries to trigger historical issues that could crash the machine). The destructive tests are run (as root, or with proper privledge) via:

	# make run_destructive_tests

I quickly browsed through the tests. Looks good to me. One comment on test run scope. Since timers now include destructive tests, run_tests target should only run the non-destructive by default and destructive tests.

I didn't see the run_destructive_tests in this set of changes in the timers/Makefile.

Please see cpu-hotplug and memory-hotplug as examples that support default and full range tests.

thanks,
-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
#24 lore raw
Quoted 20 lines · Shuah Khan
Quoted 11 lines · John Stultz

I've hosted my timekeeping tests on github for the last few years:
https://github.com/johnstultz-work/timetests

but I suspect not too many folks have actually used them.

I've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time until recently. So I wanted to send this out and get any feedback to see if they might be able to get into shape for the 4.1 merge window.

Quoted 7 lines

I've added both the non-desctructive and destructive tests (which set the time, possibly to strange values, or tries to trigger historical issues that could crash the machine). The destructive tests are run (as root, or with proper privledge) via:

      # make run_destructive_tests
Quoted 4 lines

I quickly browsed through the tests. Looks good to me. One comment on test run scope. Since timers now include destructive tests, run_tests target should only run the non-destructive by default and destructive tests.

Yes, agreed. That's why they are separated.

Quoted 2 lines

I didn't see the run_destructive_tests in this set of changes in the timers/Makefile.

? See patch 10/19 for where run_destructive_tests gets introduced.

Quoted 2 lines

Please see cpu-hotplug and memory-hotplug as examples that support default and full range tests.

Would you rather the destructive tests be included in run_full_tests?

Other then that, I've got a few compiler warning cleanup and a fix for CROSS_COMPILE, so I'll resbumit the set tomorrow or later this week. So let me know if there are any other changes you'd like and I'll roll those in.

thanks
-john

#25 lore raw
Quoted 26 lines · John Stultz
Quoted 20 lines · Shuah Khan
Quoted 11 lines · John Stultz

I've hosted my timekeeping tests on github for the last few years:
https://github.com/johnstultz-work/timetests

but I suspect not too many folks have actually used them.

I've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time until recently. So I wanted to send this out and get any feedback to see if they might be able to get into shape for the 4.1 merge window.

Quoted 7 lines

I've added both the non-desctructive and destructive tests (which set the time, possibly to strange values, or tries to trigger historical issues that could crash the machine). The destructive tests are run (as root, or with proper privledge) via:

      # make run_destructive_tests
Quoted 4 lines

I quickly browsed through the tests. Looks good to me. One comment on test run scope. Since timers now include destructive tests, run_tests target should only run the non-destructive by default and destructive tests.

Quoted 6 lines

Yes, agreed. That's why they are separated.

Quoted 2 lines

I didn't see the run_destructive_tests in this set of changes in the timers/Makefile.

? See patch 10/19 for where run_destructive_tests gets introduced.

Sorry missed that one.

Quoted 5 lines
Quoted 3 lines

Please see cpu-hotplug and memory-hotplug as examples that support default and full range tests.

Would you rather the destructive tests be included in run_full_tests?

run_destructive_tests is just fine and appropriate for these tests.

Quoted 5 lines

Other then that, I've got a few compiler warning cleanup and a fix for CROSS_COMPILE, so I'll resbumit the set tomorrow or later this week. So let me know if there are any other changes you'd like and I'll roll those in.

Please use kselftest.h reporting mechanism for new tests. posix_timers.c is updated to use it and it would make sense use it for new tests as well.

thanks,
-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
#26 lore raw
Quoted 9 lines · Shuah Khan
Quoted 4 lines · John Stultz

Other then that, I've got a few compiler warning cleanup and a fix for CROSS_COMPILE, so I'll resbumit the set tomorrow or later this week. So let me know if there are any other changes you'd like and I'll roll those in.

Please use kselftest.h reporting mechanism for new tests. posix_timers.c is updated to use it and it would make sense use it for new tests as well.

Hrm.. I'm not objecting to this, but one thing I've tried to do with my test suite is minimize any sort of test-infrastructure dependencies, so as much as possible, single test files can be plucked out, built and run by themselves. Not sure if this concern is something I'm just crazy about or if others see value in this as well. :)

The kselftest.h calls are simple enough, so I'll try to integrate the changes in and see if there's a nice way to keep the test files functioning externally too.

thanks
-john

#27 lore raw
Quoted 11 lines · John Stultz
Quoted 9 lines · Shuah Khan
Quoted 4 lines · John Stultz

Other then that, I've got a few compiler warning cleanup and a fix for CROSS_COMPILE, so I'll resbumit the set tomorrow or later this week. So let me know if there are any other changes you'd like and I'll roll those in.

Please use kselftest.h reporting mechanism for new tests. posix_timers.c is updated to use it and it would make sense use it for new tests as well.

Quoted 6 lines

Hrm.. I'm not objecting to this, but one thing I've tried to do with my test suite is minimize any sort of test-infrastructure dependencies, so as much as possible, single test files can be plucked out, built and run by themselves. Not sure if this concern is something I'm just crazy about or if others see value in this as well. :)

Ah I see see your point. Dependency on a framework would take away the flexibility.

Quoted 4 lines

The kselftest.h calls are simple enough, so I'll try to integrate the changes in and see if there's a nice way to keep the test files functioning externally too.

See you if you can, if it does become hard, I an not going to make it a requirement to use it. :)

-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978