Fix some broken tests
Subsystems (5)
v2 cover Fix some broken tests
This series fixes some self-tests that are broken, unreliable or produce compiler warnings in 4.3.
Ben.
Ben Hutchings (6):
selftests: Add missing #include directives
selftests: memfd: Stop unnecessary rebuilds
selftests: kprobe: Choose an always-defined function to probe
selftests: Make scripts executable
selftests: vm: Try harder to allocate huge pages
selftests: breakpoint: Actually build it
tools/testing/selftests/breakpoints/Makefile | 2 +- .../selftests/ftrace/test.d/kprobe/add_and_remove.tc | 2 +- .../testing/selftests/ftrace/test.d/kprobe/busy_check.tc | 2 +- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc | 2 +- .../selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | 14 +++++++------- .../selftests/ftrace/test.d/kprobe/kretprobe_args.tc | 2 +- tools/testing/selftests/memfd/Makefile | 12 ++++++------ tools/testing/selftests/memfd/memfd_test.c | 1 + tools/testing/selftests/memfd/run_fuse_test.sh | 0 tools/testing/selftests/mqueue/mq_open_tests.c | 1 + tools/testing/selftests/mqueue/mq_perf_tests.c | 1 + tools/testing/selftests/static_keys/test_static_keys.sh | 0 tools/testing/selftests/timers/nanosleep.c | 1 + tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++- 14 files changed, 36 insertions(+), 19 deletions(-) mode change 100644 => 100755 tools/testing/selftests/memfd/run_fuse_test.sh mode change 100644 => 100755 tools/testing/selftests/static_keys/test_static_keys.sh
A message that is not in the archive (sent off-list or not yet received): 20151102122048.GA17015-/[email protected]
PATCH v2 1/6 selftests: Add missing #include directives
Several C programs fail to include the headers declaring all the functions they call, resulting in warnings or errors.
After this, memfd_test.c is still missing some function declarations but can't easily get them because of a conflict between <linux/fcntl.h> and <sys/fcntl.h>.
--- tools/testing/selftests/memfd/memfd_test.c | 1 + tools/testing/selftests/mqueue/mq_open_tests.c | 1 + tools/testing/selftests/mqueue/mq_perf_tests.c | 1 + tools/testing/selftests/timers/nanosleep.c | 1 + 4 files changed, 4 insertions(+)
tools/testing/selftests/memfd/memfd_test.c +1 -0
@@ -15,6 +15,7 @@#include <sys/mman.h> #include <sys/stat.h> #include <sys/syscall.h> +#include <sys/wait.h> #include <unistd.h> #define MFD_DEF_SIZE 8192
tools/testing/selftests/mqueue/mq_open_tests.c +1 -0
@@ -31,6 +31,7 @@#include <sys/resource.h> #include <sys/stat.h> #include <mqueue.h> +#include <error.h> static char *usage ="Usage:\n"
tools/testing/selftests/mqueue/mq_perf_tests.c +1 -0
@@ -37,6 +37,7 @@#include <sys/stat.h> #include <mqueue.h> #include <popt.h> +#include <error.h> static char *usage ="Usage:\n"
tools/testing/selftests/timers/nanosleep.c +1 -0
@@ -19,6 +19,7 @@* GNU General Public License for more details. */ +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <time.h>
PATCH v2 2/6 selftests: memfd: Stop unnecessary rebuilds
In reply to a message not in the archiveInstead of explicitly running the compiler, add dependencies and take advantage of implicit rules to build only as necessary.
--- tools/testing/selftests/memfd/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/memfd/Makefile +6 -6
@@ -4,16 +4,16 @@ CFLAGS += -I../../../../include/uapi/ CFLAGS += -I../../../../include/ CFLAGS += -I../../../../usr/include/ -all: - $(CC) $(CFLAGS) memfd_test.c -o memfd_test - TEST_PROGS := memfd_test +all: $(TEST_PROGS) + include ../lib.mk -build_fuse: - $(CC) $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt - $(CC) $(CFLAGS) fuse_test.c -o fuse_test +build_fuse: fuse_mnt fuse_test + +fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) +fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs) run_fuse: build_fuse @./run_fuse_test.sh || echo "fuse_test: [FAIL]"
PATCH v2 3/6 selftests: kprobe: Choose an always-defined function to probe
In reply to a message not in the archivedo_fork() is no longer defined on x86, so probe _do_fork() instead.
--- .../selftests/ftrace/test.d/kprobe/add_and_remove.tc | 2 +- tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc | 2 +- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc | 2 +- .../selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | 14 +++++++------- .../selftests/ftrace/test.d/kprobe/kretprobe_args.tc | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)
tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc +1 -1
@@ -5,7 +5,7 @@ echo 0 > events/enable echo > kprobe_events -echo p:myevent do_fork > kprobe_events +echo p:myevent _do_fork > kprobe_events grep myevent kprobe_events test -d events/kprobes/myevent echo > kprobe_events
tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc +1 -1
@@ -5,7 +5,7 @@ echo 0 > events/enable echo > kprobe_events -echo p:myevent do_fork > kprobe_events +echo p:myevent _do_fork > kprobe_events test -d events/kprobes/myevent echo 1 > events/kprobes/myevent/enable echo > kprobe_events && exit 1 # this must fail
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc +1 -1
@@ -5,7 +5,7 @@ echo 0 > events/enable echo > kprobe_events -echo 'p:testprobe do_fork $stack $stack0 +0($stack)' > kprobe_events +echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events grep testprobe kprobe_events test -d events/kprobes/testprobe echo 1 > events/kprobes/testprobe/enable
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc +7 -7
@@ -6,31 +6,31 @@ grep function available_tracers || exit_unsupported # this is configurable # prepare echo nop > current_tracer -echo do_fork > set_ftrace_filter +echo _do_fork > set_ftrace_filter echo 0 > events/enable echo > kprobe_events -echo 'p:testprobe do_fork' > kprobe_events +echo 'p:testprobe _do_fork' > kprobe_events # kprobe on / ftrace off echo 1 > events/kprobes/testprobe/enable echo > trace ( echo "forked") grep testprobe trace -! grep 'do_fork <-' trace +! grep '_do_fork <-' trace # kprobe on / ftrace on echo function > current_tracer echo > trace ( echo "forked") grep testprobe trace -grep 'do_fork <-' trace +grep '_do_fork <-' trace # kprobe off / ftrace on echo 0 > events/kprobes/testprobe/enable echo > trace ( echo "forked") ! grep testprobe trace -grep 'do_fork <-' trace +grep '_do_fork <-' trace # kprobe on / ftrace on echo 1 > events/kprobes/testprobe/enable
@@ -38,14 +38,14 @@ echo function > current_tracer echo > trace ( echo "forked") grep testprobe trace -grep 'do_fork <-' trace +grep '_do_fork <-' trace # kprobe on / ftrace off echo nop > current_tracer echo > trace ( echo "forked") grep testprobe trace -! grep 'do_fork <-' trace +! grep '_do_fork <-' trace # cleanup echo nop > current_tracer
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc +1 -1
@@ -5,7 +5,7 @@ echo 0 > events/enable echo > kprobe_events -echo 'r:testprobe2 do_fork $retval' > kprobe_events +echo 'r:testprobe2 _do_fork $retval' > kprobe_events grep testprobe2 kprobe_events test -d events/kprobes/testprobe2 echo 1 > events/kprobes/testprobe2/enable
PATCH v2 4/6 selftests: Make scripts executable
In reply to a message not in the archive--- tools/testing/selftests/memfd/run_fuse_test.sh | 0 tools/testing/selftests/static_keys/test_static_keys.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/testing/selftests/memfd/run_fuse_test.sh mode change 100644 => 100755 tools/testing/selftests/static_keys/test_static_keys.sh
tools/testing/selftests/memfd/run_fuse_test.sh +0 -0
tools/testing/selftests/static_keys/test_static_keys.sh +0 -0
PATCH v2 5/6 selftests: vm: Try harder to allocate huge pages
In reply to a message not in the archiveIf we need to increase the number of huge pages, drop caches first to reduce fragmentation and then check that we actually allocated as many as we wanted. Retry once if that doesn't work.
--- tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
tools/testing/selftests/vm/run_vmtests +14 -1
@@ -20,13 +20,26 @@ done < /proc/meminfo if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` needpgs=`expr $needmem / $pgsize` - if [ $freepgs -lt $needpgs ]; then + tries=2 + while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do lackpgs=$(( $needpgs - $freepgs )) + echo 3 > /proc/sys/vm/drop_caches echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages if [ $? -ne 0 ]; then echo "Please run this test as root" exit 1 fi + while read name size unit; do + if [ "$name" = "HugePages_Free:" ]; then + freepgs=$size + fi + done < /proc/meminfo + tries=$((tries - 1)) + done + if [ $freepgs -lt $needpgs ]; then + printf "Not enough huge pages available (%d < %d)\n" \ + $freepgs $needpgs + exit 1 fi else echo "no hugetlbfs support in kernel?"
PATCH v2 6/6 selftests: breakpoint: Actually build it
In reply to a message not in the archive--- tools/testing/selftests/breakpoints/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/breakpoints/Makefile +1 -1
@@ -6,7 +6,7 @@ ifeq ($(ARCH),x86) TEST_PROGS := breakpoint_test endif -all: +all: $(TEST_PROGS) include ../lib.mk
Quoted 25 lines · Ben Hutchings
This series fixes some self-tests that are broken, unreliable or produce compiler warnings in 4.3.
Ben.
Ben Hutchings (6): selftests: Add missing #include directives
selftests: memfd: Stop unnecessary rebuilds selftests: kprobe:
Choose an always-defined function to probe selftests: Make scripts executable selftests: vm: Try harder to allocate huge pages
selftests: breakpoint: Actually build ittools/testing/selftests/breakpoints/Makefile | 2 +- .../selftests/ftrace/test.d/kprobe/add_and_remove.tc | 2 +- .../testing/selftests/ftrace/test.d/kprobe/busy_check.tc | 2 +- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc | 2 +- .../selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | 14 +++++++------- .../selftests/ftrace/test.d/kprobe/kretprobe_args.tc | 2 +- tools/testing/selftests/memfd/Makefile | 12 ++++++------ tools/testing/selftests/memfd/memfd_test.c | 1 + tools/testing/selftests/memfd/run_fuse_test.sh | 0 tools/testing/selftests/mqueue/mq_open_tests.c | 1 + tools/testing/selftests/mqueue/mq_perf_tests.c | 1 + tools/testing/selftests/static_keys/test_static_keys.sh | 0 tools/testing/selftests/timers/nanosleep.c | 1 + tools/testing/selftests/vm/run_vmtests | 15
Quoted 5 lines
++++++++++++++- 14 files changed, 36 insertions(+), 19 deletions(-) mode change 100644 => 100755
tools/testing/selftests/memfd/run_fuse_test.shmode change 100644 => 100755tools/testing/selftests/static_keys/test_static_keys.sh
Ben,
Thanks for doing this. Several tests pass now with your patches. All 6 patches applied to linux-kselftest next for 4.4
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