Start adding timetests to selftest
Subsystems (3)
cover Start adding timetests to selftest
I've maintained a suite of timekeeping and timer tests for awhile
here: https://github.com/johnstultz-work/timetests
I've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time recently.
I'm going to have a long flight coming up so I figured I'd get started and get some initial feedback.
This series adds all the non-destructive tests from my timetests suite. The suite has more tests which actually tweak time state and validate things behave as expected, but I wasn't sure how to integrate that into the selftest infrastructure as I'm not sure everyone would want the tests to be mucking with their system time. (Currently my plan is to add a script similar to the runall.sh in timetests, so folks can go in and manually run it if they're feeling daring)
Thoughts or comments here would be greatly appreciated!
thanks!
-john
John Stultz (7):
selftests/timers: Cleanup Makefile to make it easier to add future
tests
selftest/timers: Quiet warning due to lack of return check on brk selftest/timers: Add nanosleep test from timetest suite selftest/timers: Add inconsistency-check test from timetests selftest/timers: Add nsleep-lat test from timetest suite selftests/timers: Add clock skew estimation test from timetest suite selftest/timers: Add set-timer-lat test from timetest suite
tools/testing/selftests/timers/Makefile | 15 +- .../testing/selftests/timers/inconsistency-check.c | 198 +++++++++++++++++++++ tools/testing/selftests/timers/nanosleep.c | 161 +++++++++++++++++ tools/testing/selftests/timers/nsleep-lat.c | 176 ++++++++++++++++++ tools/testing/selftests/timers/posix_timers.c | 5 +- tools/testing/selftests/timers/raw_skew.c | 137 ++++++++++++++ tools/testing/selftests/timers/set-timer-lat.c | 198 +++++++++++++++++++++ 7 files changed, 885 insertions(+), 5 deletions(-) create mode 100644 tools/testing/selftests/timers/inconsistency-check.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-timer-lat.c
Signature · 1 line
1.9.1
PATCH 1/7 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.
--- tools/testing/selftests/timers/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/timers/Makefile +6 -3
@@ -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
Re: [PATCH 1/7] selftests/timers: Cleanup Makefile to make it easier to add future tests
Quoted 4 lines · John Stultz
Try to streamline the makefile so its easier to add timer/timekeeping tests.
Cc Shuah Khan <[email protected]>
Drat.. I forgot to refresh the patchset after adding to the CC list. Hopefully folks can/will find the thread, but I'll resend next week sometime if I don't hear any feedback.
thanks
-john
PATCH 2/7 selftest/timers: Quiet warning due to lack of return check on brk
In reply to John StultzThe 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.
--- tools/testing/selftests/timers/posix_timers.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/posix_timers.c +3 -2
@@ -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
PATCH 3/7 selftest/timers: Add nanosleep test from timetest suite
In reply to John StultzAdd my basic nanosleep test from my timetest suite. This test validates that nanosleep dosen't return early against a number of clockids.
--- tools/testing/selftests/timers/Makefile | 3 +- tools/testing/selftests/timers/nanosleep.c | 161 +++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/timers/nanosleep.c
tools/testing/selftests/timers/Makefile +2 -1
@@ -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 +161 -0
161 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 4/7 selftest/timers: Add inconsistency-check test from timetests
In reply to John StultzThis adds my inconsistency-test from my timetests suite, which checks for (single threaded) time inconsistencies across the various clockids.
--- tools/testing/selftests/timers/Makefile | 4 +- .../testing/selftests/timers/inconsistency-check.c | 198 +++++++++++++++++++++ 2 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/timers/inconsistency-check.c
tools/testing/selftests/timers/Makefile +2 -2
@@ -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 +198 -0
198 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 5/7 selftest/timers: Add nsleep-lat test from timetest suite
In reply to John StultzAdds my nanosleep latency test from the timetest suite. This checks to make sure we don't see "unreasonable" latencies (> 40ms) when calling nanosleep.
--- tools/testing/selftests/timers/Makefile | 3 +- tools/testing/selftests/timers/nsleep-lat.c | 176 ++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/timers/nsleep-lat.c
tools/testing/selftests/timers/Makefile +2 -1
@@ -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 +176 -0
176 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 6/7 selftests/timers: Add clock skew estimation test from timetest suite
In reply to John StultzThis 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.
--- tools/testing/selftests/timers/Makefile | 3 +- tools/testing/selftests/timers/raw_skew.c | 137 ++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/timers/raw_skew.c
tools/testing/selftests/timers/Makefile +2 -1
@@ -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 +137 -0
137 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 7/7 selftest/timers: Add set-timer-lat test from timetest suite
In reply to John StultzAdd my set-timer-lat test from the timetest suite. This test checks the latency from set_timer and reports if any are unreasonable (>40ms).
--- 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
@@ -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
Quoted 9 lines · John Stultz
I've maintained a suite of timekeeping and timer tests for awhile
here: https://github.com/johnstultz-work/timetestsI've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time recently.
I'm going to have a long flight coming up so I figured I'd get started and get some initial feedback.
Quoted 8 lines
This series adds all the non-destructive tests from my timetests suite. The suite has more tests which actually tweak time state and validate things behave as expected, but I wasn't sure how to integrate that into the selftest infrastructure as I'm not sure everyone would want the tests to be mucking with their system time. (Currently my plan is to add a script similar to the
runall.shin timetests, so folks can go in and manually run it if they're feeling daring)
Providing a way to run destructive tests as a special option is great. Non-destructive tests can be run in default mode.
Thanks for the tests. Looks good to me. I am in the middle of review at the moment, will send you comments if any.
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
Quoted 19 lines · Shuah Khan
Quoted 9 lines · John Stultz
I've maintained a suite of timekeeping and timer tests for awhile
here: https://github.com/johnstultz-work/timetestsI've been meaning to get them reworked and submitted into the selftest infrastructure, but haven't had much time recently.
I'm going to have a long flight coming up so I figured I'd get started and get some initial feedback.
Quoted 8 lines
This series adds all the non-destructive tests from my timetests suite. The suite has more tests which actually tweak time state and validate things behave as expected, but I wasn't sure how to integrate that into the selftest infrastructure as I'm not sure everyone would want the tests to be mucking with their system time. (Currently my plan is to add a script similar to the
runall.shin timetests, so folks can go in and manually run it if they're feeling daring)
Quoted 6 lines
Providing a way to run destructive tests as a special option is great. Non-destructive tests can be run in default mode.
Thanks for the tests. Looks good to me. I am in the middle of review at the moment, will send you comments if any.
Yea, I realized after sending it that I didn't checkpatch things and there's a bunch of style issues to be resolved. I've already fixed up most of those, and will re-submit next week.
If you have any other feedback (other then white-space/style quirks), do let me know and I'll also try to add that in.
I know its close to the merge window, and I'm in no rush to get these in for 3.20, but wanted to send them out for initial thoughts now because doing this has been on my list since kernel summit and was finally able to steal a few evening hours to start and hopefully get some momentum going on it. :)
thanks
-john