selftests: New very basic kernel selftests directory
PATCH 1/2 selftests: New very basic kernel selftests directory
Bring a new kernel selftests directory in tools/testing/selftests. To add a new selftest, create a subdirectory with the sources and a makefile that creates a target named "run_test" then add the subdirectory name to the TARGET var in tools/testing/selftests/Makefile and tools/testing/selftests/run_tests script.
This can help centralizing and maintaining any useful selftest that developers usually tend to let rust in peace on some random server.
--- tools/testing/selftests/Makefile | 11 +++++++++++ tools/testing/selftests/run_tests | 8 ++++++++ 2 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 tools/testing/selftests/Makefile create mode 100755 tools/testing/selftests/run_tests
tools/testing/selftests/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +TARGETS = + +all: + for TARGET in $(TARGETS); do \ + make -C $$TARGET; \ + done; + +clean: + for TARGET in $(TARGETS); do \ + make -C $$TARGET clean; \ + done;
tools/testing/selftests/run_tests new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/bash + +TARGETS= + +for TARGET in $TARGETS +do + $TARGET/run_test +done
Signature · 1 line
1.7.5.4
PATCH 2/2 selftests: New x86 breakpoints selftest
Bring a first selftest in the relevant directory. This tests several combinations of breakpoints and watchpoints in x86, as well as icebp traps and int3 traps. Given the amount of breakpoint regressions we raised after we merged the generic breakpoint infrastructure, such selftest became necessary and can still serve today as a basis for new patches that touch the do_debug() path.
--- tools/testing/selftests/Makefile | 2 +- tools/testing/selftests/breakpoints/Makefile | 20 + .../selftests/breakpoints/breakpoint_test.c | 394 ++++++++++++++++++++ tools/testing/selftests/run_tests | 2 +- 4 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/breakpoints/Makefile create mode 100644 tools/testing/selftests/breakpoints/breakpoint_test.c
tools/testing/selftests/Makefile +1 -1
@@ -1,4 +1,4 @@ -TARGETS = +TARGETS = breakpoints all: for TARGET in $(TARGETS); do \
tools/testing/selftests/breakpoints/Makefile new file +20 -0
@@ -0,0 +1,20 @@ +# Taken from perf makefile +uname_M := $(shell uname -m 2>/dev/null || echo not) +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/) +ifeq ($(ARCH),i386) + ARCH := x86 +endif +ifeq ($(ARCH),x86_64) + ARCH := x86 +endif + + +all: +ifeq ($(ARCH),x86) + gcc breakpoint_test.c -o run_test +else + echo "Not an x86 target, can't build breakpoints selftests" +endif + +clean: + rm -fr run_test
tools/testing/selftests/breakpoints/breakpoint_test.c new file +394 -0
394 lines not on this page · raw message
tools/testing/selftests/run_tests +1 -1
@@ -1,6 +1,6 @@ #!/bin/bash -TARGETS= +TARGETS=breakpoints for TARGET in $TARGETS do
Signature · 1 line
1.7.5.4
Re: [PATCH 2/2] selftests: New x86 breakpoints selftest
Quoted 1 line · On Fri, 2 Dec 2011 16:41:15 +0100 Frederic Weisbecker <[email protected]>…
Bring a first selftest in the relevant directory.
That all looks nice and simple, thanks. Unless I get suitably shouted at I think I'll send all this Linuswards. Then I can hassle people to add their little test snippets as they add userspace-visible features.
I don't think we'd ever want to turn this into some huge kernel verification suite. My thinking here is that I frequently see that people have written little test cases for their new feature, but those test cases just die after the feature is merged. It would be better to maintain and grow these tests as the relevant features are augmented or bugfixed.
All these features are Linux-specific. Standard interface features (eg POSIX) are and should be tested via other externally-maintained test suites.
If the whole idea ends up not working out, we can just delete it all.
Re: [PATCH 2/2] selftests: New x86 breakpoints selftest
Quoted 9 lines · Andrew Morton
Quoted 1 line · On Fri, 2 Dec 2011 16:41:15 +0100 Frederic Weisbecker <[email protected]>…
Bring a first selftest in the relevant directory.
That all looks nice and simple, thanks. Unless I get suitably shouted at I think I'll send all this Linuswards. Then I can hassle people to add their little test snippets as they add userspace-visible features.
Quoted 6 lines
I don't think we'd ever want to turn this into some huge kernel verification suite. My thinking here is that I frequently see that people have written little test cases for their new feature, but those test cases just die after the feature is merged. It would be better to maintain and grow these tests as the relevant features are augmented or bugfixed.
Exactly. And I also think this is no good place for background long running stress-tests but rather for correctness tests (Unless we find situations where short stress-tests are enough to trigger correctness problems). That's really targeted to spot ABI breakages or alike.
My selftest for the cgroup task counter subsystem is also a good candidate for that (if that subsystem ever get merged but that's a separate debate ;)
Quoted 6 lines
All these features are Linux-specific. Standard interface features (eg POSIX) are and should be tested via other externally-maintained test suites.
If the whole idea ends up not working out, we can just delete it all.
Agreed, let the selftest subsystem selftest itself for a while and we'll figure out.
Thanks.
Re: [PATCH 2/2] selftests: New x86 breakpoints selftest
In reply to Frederic WeisbeckerQuoted 7 lines · Frederic Weisbecker
Bring a first selftest in the relevant directory. This tests several combinations of breakpoints and watchpoints in x86, as well as icebp traps and int3 traps. Given the amount of breakpoint regressions we raised after we merged the generic breakpoint infrastructure, such selftest became necessary and can still serve today as a basis for new patches that touch the
do_debug()path.
Hi Frederic,
Can we also including testing of watchpoints over kernel variables?
We could do this using the perf syscall or (in a convoluted way) use a kernel module that works in tandem with this user-space testcase.
Thanks,
K.Prasad
Quoted 1 line · Frederic Weisbecker
Bring a new kernel selftests directory in
tools/testing/selftests.
Interesting ... but why to invent a test framework from scratch while there already exists stuff like googletest or TAP::Harness ?
Fubo.
Quoted 5 lines · Fubo Chen
Quoted 1 line · Frederic Weisbecker
Bring a new kernel selftests directory in
tools/testing/selftests.Interesting ... but why to invent a test framework from scratch while there already exists stuff like googletest or
TAP::Harness?
We wanted to start with something very simple that just launch selftests in batch.
Let's see first where this goes, if this becomes a useful subsystem that grows up, then if it makes sense to rely on some more elaborated selftest framework we can think about it.