All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/9] kbuild: Don't pass -rR to selftest makefiles
@ 2015-03-11  4:05 ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:05 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

The makefiles under tools/testing/selftests are not real kbuild
makefiles, they are regular stand alone makefiles. As such they *do*
want all the standard implicit rules and variables defined.

So before calling those makefiles, filter -rR out of MAKEFLAGS.

Without this not all the selftests are built correctly when called via
the top-level Makefile.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 1100ff3c77e3..0836e9d628f0 100644
--- a/Makefile
+++ b/Makefile
@@ -1085,7 +1085,7 @@ headers_check: headers_install
 
 PHONY += kselftest
 kselftest:
-	$(Q)$(MAKE) -C tools/testing/selftests run_tests
+	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
 
 # ---------------------------------------------------------------------------
 # Modules
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 1/9] kbuild: Don't pass -rR to selftest makefiles
@ 2015-03-11  4:05 ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:05 UTC (permalink / raw)
  To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

The makefiles under tools/testing/selftests are not real kbuild
makefiles, they are regular stand alone makefiles. As such they *do*
want all the standard implicit rules and variables defined.

So before calling those makefiles, filter -rR out of MAKEFLAGS.

Without this not all the selftests are built correctly when called via
the top-level Makefile.

Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 1100ff3c77e3..0836e9d628f0 100644
--- a/Makefile
+++ b/Makefile
@@ -1085,7 +1085,7 @@ headers_check: headers_install
 
 PHONY += kselftest
 kselftest:
-	$(Q)$(MAKE) -C tools/testing/selftests run_tests
+	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
 
 # ---------------------------------------------------------------------------
 # Modules
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile
@ 2015-03-11  4:05   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:05 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

The makefile in arch/x86/Makefile.um sets LDFLAGS and exports it, which
is then propagated to the selftest Makefiles and leads to build errors
there. The build errors occur because we are passing LDFLAGS to CC, but
the option set in Makefile.um (-m elf_x86_64) is not understood by CC.
We could fix that by using -Wl, but that might break the UM build if
it's actually passing that option to LD directly.

We don't actually want the LDFLAGS from kbuild in the selftest Makefile,
so the simplest fix seems to be to clear LDFLAGS before invoking the
selftest Makefile.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 0836e9d628f0..5cef1d4c2ea0 100644
--- a/Makefile
+++ b/Makefile
@@ -1085,7 +1085,7 @@ headers_check: headers_install
 
 PHONY += kselftest
 kselftest:
-	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
+	$(Q)$(MAKE) LDFLAGS= -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
 
 # ---------------------------------------------------------------------------
 # Modules
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile
@ 2015-03-11  4:05   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:05 UTC (permalink / raw)
  To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

The makefile in arch/x86/Makefile.um sets LDFLAGS and exports it, which
is then propagated to the selftest Makefiles and leads to build errors
there. The build errors occur because we are passing LDFLAGS to CC, but
the option set in Makefile.um (-m elf_x86_64) is not understood by CC.
We could fix that by using -Wl, but that might break the UM build if
it's actually passing that option to LD directly.

We don't actually want the LDFLAGS from kbuild in the selftest Makefile,
so the simplest fix seems to be to clear LDFLAGS before invoking the
selftest Makefile.

Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 0836e9d628f0..5cef1d4c2ea0 100644
--- a/Makefile
+++ b/Makefile
@@ -1085,7 +1085,7 @@ headers_check: headers_install
 
 PHONY += kselftest
 kselftest:
-	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
+	$(Q)$(MAKE) LDFLAGS= -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
 
 # ---------------------------------------------------------------------------
 # Modules
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests
  2015-03-11  4:05 ` Michael Ellerman
@ 2015-03-11  4:05   ` Michael Ellerman
  -1 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:05 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

This adds a Make include file which most selftests can then include to
get the run_tests logic.

On its own this has the advantage of some reduction in repetition, and
also means the pass/fail message is defined in fewer places.

However the key advantage is it will allow us to implement install very
simply in a subsequent patch.

The default implementation just executes each program in $(TEST_PROGS).

We use a variable to hold the default implementation of $(RUN_TESTS)
because that gives us a clean way to override it if necessary, ie. using
override. The mount, memory-hotplug and mqueue tests use that to provide
a different implementation.

Tests are not run via /bin/bash, so if they are scripts they must be
executable, we add a+x to several.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---

v3: Rebase onto 4.0-rc2, add +x to more scripts that need it.
v4: Rebase onto 4.0-rc3.

 tools/testing/selftests/breakpoints/Makefile         |  5 +++--
 tools/testing/selftests/cpu-hotplug/Makefile         |  5 +++--
 tools/testing/selftests/cpu-hotplug/on-off-test.sh   |  0
 tools/testing/selftests/efivarfs/Makefile            |  5 +++--
 tools/testing/selftests/efivarfs/efivarfs.sh         |  0
 tools/testing/selftests/exec/Makefile                |  5 +++--
 tools/testing/selftests/firmware/Makefile            | 20 ++------------------
 tools/testing/selftests/firmware/fw_filesystem.sh    |  0
 tools/testing/selftests/firmware/fw_userhelper.sh    |  0
 tools/testing/selftests/ftrace/Makefile              |  5 +++--
 tools/testing/selftests/ipc/Makefile                 |  5 +++--
 tools/testing/selftests/kcmp/Makefile                |  5 +++--
 tools/testing/selftests/lib.mk                       | 10 ++++++++++
 tools/testing/selftests/memfd/Makefile               |  6 +++---
 tools/testing/selftests/memory-hotplug/Makefile      |  5 +++--
 .../testing/selftests/memory-hotplug/on-off-test.sh  |  0
 tools/testing/selftests/mount/Makefile               |  8 ++------
 tools/testing/selftests/mqueue/Makefile              |  9 ++++++---
 tools/testing/selftests/net/Makefile                 |  8 ++++----
 tools/testing/selftests/net/run_afpackettests        |  0
 tools/testing/selftests/net/run_netsocktests         |  0
 tools/testing/selftests/ptrace/Makefile              |  5 +++--
 tools/testing/selftests/size/Makefile                |  5 +++--
 tools/testing/selftests/sysctl/Makefile              | 11 ++---------
 tools/testing/selftests/sysctl/run_numerictests      |  0
 tools/testing/selftests/sysctl/run_stringtests       |  0
 tools/testing/selftests/timers/Makefile              |  5 +++--
 tools/testing/selftests/user/Makefile                |  5 +++--
 tools/testing/selftests/vm/Makefile                  |  5 +++--
 tools/testing/selftests/vm/run_vmtests               |  0
 30 files changed, 68 insertions(+), 69 deletions(-)
 mode change 100644 => 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh
 mode change 100644 => 100755 tools/testing/selftests/efivarfs/efivarfs.sh
 mode change 100644 => 100755 tools/testing/selftests/firmware/fw_filesystem.sh
 mode change 100644 => 100755 tools/testing/selftests/firmware/fw_userhelper.sh
 create mode 100644 tools/testing/selftests/lib.mk
 mode change 100644 => 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh
 mode change 100644 => 100755 tools/testing/selftests/net/run_afpackettests
 mode change 100644 => 100755 tools/testing/selftests/net/run_netsocktests
 mode change 100644 => 100755 tools/testing/selftests/sysctl/run_numerictests
 mode change 100644 => 100755 tools/testing/selftests/sysctl/run_stringtests
 mode change 100644 => 100755 tools/testing/selftests/vm/run_vmtests

diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index e18b42b254af..182235640209 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -16,8 +16,9 @@ else
 	echo "Not an x86 target, can't build breakpoints selftests"
 endif
 
-run_tests:
-	@./breakpoint_test || echo "breakpoints selftests: [FAIL]"
+TEST_PROGS := breakpoint_test
+
+include ../lib.mk
 
 clean:
 	rm -fr breakpoint_test
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index e9c28d8dc84b..15f02591d22c 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -1,7 +1,8 @@
 all:
 
-run_tests:
-	@/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
+TEST_PROGS := on-off-test.sh
+
+include ../lib.mk
 
 run_full_test:
 	@/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 29e8c6bc81b0..3052d0bda24b 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -5,8 +5,9 @@ test_objs = open-unlink create-read
 
 all: $(test_objs)
 
-run_tests: all
-	@/bin/bash ./efivarfs.sh || echo "efivarfs selftests: [FAIL]"
+TEST_PROGS := efivarfs.sh
+
+include ../lib.mk
 
 clean:
 	rm -f $(test_objs)
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 66dfc2ce1788..a0098daeb73d 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -18,8 +18,9 @@ execveat.denatured: execveat
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
 
-run_tests: all
-	./execveat
+TEST_PROGS := execveat
+
+include ../lib.mk
 
 clean:
 	rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/selftests/firmware/Makefile
index e23cce0bbc3a..9bf82234855b 100644
--- a/tools/testing/selftests/firmware/Makefile
+++ b/tools/testing/selftests/firmware/Makefile
@@ -3,25 +3,9 @@
 # No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
 all:
 
-fw_filesystem:
-	@if /bin/sh ./fw_filesystem.sh ; then \
-                echo "fw_filesystem: ok"; \
-        else \
-                echo "fw_filesystem: [FAIL]"; \
-                exit 1; \
-        fi
+TEST_PROGS := fw_filesystem.sh fw_userhelper.sh
 
-fw_userhelper:
-	@if /bin/sh ./fw_userhelper.sh ; then \
-                echo "fw_userhelper: ok"; \
-        else \
-                echo "fw_userhelper: [FAIL]"; \
-                exit 1; \
-        fi
-
-run_tests: all fw_filesystem fw_userhelper
+include ../lib.mk
 
 # Nothing to clean up.
 clean:
-
-.PHONY: all clean run_tests fw_filesystem fw_userhelper
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 76cc9f156267..346720639d1d 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -1,7 +1,8 @@
 all:
 
-run_tests:
-	@/bin/sh ./ftracetest || echo "ftrace selftests: [FAIL]"
+TEST_PROGS := ftracetest
+
+include ../lib.mk
 
 clean:
 	rm -rf logs/*
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 74bbefdeaf4c..3b6013da4f59 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -18,8 +18,9 @@ else
 	echo "Not an x86 target, can't build msgque selftest"
 endif
 
-run_tests: all
-	./msgque_test
+TEST_PROGS := msgque_test
+
+include ../lib.mk
 
 clean:
 	rm -fr ./msgque_test
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index ff0eefdc6ceb..0eecd183058c 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -3,8 +3,9 @@ CFLAGS += -I../../../../usr/include/
 
 all: kcmp_test
 
-run_tests: all
-	@./kcmp_test || echo "kcmp_test: [FAIL]"
+TEST_PROGS := kcmp_test
+
+include ../lib.mk
 
 clean:
 	$(RM) kcmp_test kcmp-test-file
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
new file mode 100644
index 000000000000..b30c5a49cb61
--- /dev/null
+++ b/tools/testing/selftests/lib.mk
@@ -0,0 +1,10 @@
+define RUN_TESTS
+	@for TEST in $(TEST_PROGS); do \
+		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
+	done;
+endef
+
+run_tests: all
+	$(RUN_TESTS)
+
+.PHONY: run_tests all clean
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index b80cd10d53ba..191dee9d6fd3 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -5,9 +5,9 @@ CFLAGS += -I../../../../include/
 all:
 	gcc $(CFLAGS) memfd_test.c -o memfd_test
 
-run_tests: all
-	gcc $(CFLAGS) memfd_test.c -o memfd_test
-	@./memfd_test || echo "memfd_test: [FAIL]"
+TEST_PROGS := memfd_test
+
+include ../lib.mk
 
 build_fuse:
 	gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index d46b8d489cd2..8f7dea66ecac 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -1,7 +1,8 @@
 all:
 
-run_tests:
-	@/bin/bash ./on-off-test.sh -r 2 || echo "memory-hotplug selftests: [FAIL]"
+include ../lib.mk
+
+override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
 
 run_full_test:
 	@/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 337d853c2b72..06931dfd3ef0 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -5,13 +5,9 @@ all: unprivileged-remount-test
 unprivileged-remount-test: unprivileged-remount-test.c
 	gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test
 
-# Allow specific tests to be selected.
-test_unprivileged_remount: unprivileged-remount-test
-	@if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
+include ../lib.mk
 
-run_tests: all test_unprivileged_remount
+override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
 
 clean:
 	rm -f unprivileged-remount-test
-
-.PHONY: all test_unprivileged_remount
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 8056e2e68fa4..cbc300ef11bf 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -2,9 +2,12 @@ all:
 	gcc -O2 mq_open_tests.c -o mq_open_tests -lrt
 	gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt
 
-run_tests:
-	@./mq_open_tests /test1 || echo "mq_open_tests: [FAIL]"
-	@./mq_perf_tests || echo "mq_perf_tests: [FAIL]"
+include ../lib.mk
+
+override define RUN_TESTS
+	@./mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]"
+	@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
+endef
 
 clean:
 	rm -f mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 62f22cc9941c..fa8187ff15e6 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -11,9 +11,9 @@ all: $(NET_PROGS)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
 
-run_tests: all
-	@/bin/sh ./run_netsocktests || echo "sockettests: [FAIL]"
-	@/bin/sh ./run_afpackettests || echo "afpackettests: [FAIL]"
-	./test_bpf.sh
+TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
+
+include ../lib.mk
+
 clean:
 	$(RM) $(NET_PROGS)
diff --git a/tools/testing/selftests/net/run_afpackettests b/tools/testing/selftests/net/run_afpackettests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/net/run_netsocktests b/tools/testing/selftests/net/run_netsocktests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
index 47ae2d385ce8..453927fea90c 100644
--- a/tools/testing/selftests/ptrace/Makefile
+++ b/tools/testing/selftests/ptrace/Makefile
@@ -6,5 +6,6 @@ all: peeksiginfo
 clean:
 	rm -f peeksiginfo
 
-run_tests: all
-	@./peeksiginfo || echo "peeksiginfo selftests: [FAIL]"
+TEST_PROGS := peeksiginfo
+
+include ../lib.mk
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index 04dc25e4fa92..e4353d74ea6e 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -5,8 +5,9 @@ all: get_size
 get_size: get_size.c
 	$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
 
-run_tests: all
-	./get_size
+TEST_PROGS := get_size
+
+include ../lib.mk
 
 clean:
 	$(RM) get_size
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile
index 0a92adaf0865..c9660f5ef9f9 100644
--- a/tools/testing/selftests/sysctl/Makefile
+++ b/tools/testing/selftests/sysctl/Makefile
@@ -4,16 +4,9 @@
 # No binaries, but make sure arg-less "make" doesn't trigger "run_tests".
 all:
 
-# Allow specific tests to be selected.
-test_num:
-	@/bin/sh ./run_numerictests
+TEST_PROGS := run_numerictests run_stringtests
 
-test_string:
-	@/bin/sh ./run_stringtests
-
-run_tests: all test_num test_string
+include ../lib.mk
 
 # Nothing to clean up.
 clean:
-
-.PHONY: all run_tests clean test_num test_string
diff --git a/tools/testing/selftests/sysctl/run_numerictests b/tools/testing/selftests/sysctl/run_numerictests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/sysctl/run_stringtests b/tools/testing/selftests/sysctl/run_stringtests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index eb2859f4ad21..149cee3b7b8a 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,8 +1,9 @@
 all:
 	gcc posix_timers.c -o posix_timers -lrt
 
-run_tests: all
-	./posix_timers
+TEST_PROGS := posix_timers
+
+include ../lib.mk
 
 clean:
 	rm -f ./posix_timers
diff --git a/tools/testing/selftests/user/Makefile b/tools/testing/selftests/user/Makefile
index 12c9d15bab07..d401b63c5b1a 100644
--- a/tools/testing/selftests/user/Makefile
+++ b/tools/testing/selftests/user/Makefile
@@ -3,5 +3,6 @@
 # No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
 all:
 
-run_tests: all
-	./test_user_copy.sh
+TEST_PROGS := test_user_copy.sh
+
+include ../lib.mk
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 077828c889f1..90e56090b0ed 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -9,8 +9,9 @@ all: $(BINARIES)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^ -lrt
 
-run_tests: all
-	@/bin/sh ./run_vmtests || (echo "vmtests: [FAIL]"; exit 1)
+TEST_PROGS := run_vmtests
+
+include ../lib.mk
 
 clean:
 	$(RM) $(BINARIES)
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
old mode 100644
new mode 100755
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests
@ 2015-03-11  4:05   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:05 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

This adds a Make include file which most selftests can then include to
get the run_tests logic.

On its own this has the advantage of some reduction in repetition, and
also means the pass/fail message is defined in fewer places.

However the key advantage is it will allow us to implement install very
simply in a subsequent patch.

The default implementation just executes each program in $(TEST_PROGS).

We use a variable to hold the default implementation of $(RUN_TESTS)
because that gives us a clean way to override it if necessary, ie. using
override. The mount, memory-hotplug and mqueue tests use that to provide
a different implementation.

Tests are not run via /bin/bash, so if they are scripts they must be
executable, we add a+x to several.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---

v3: Rebase onto 4.0-rc2, add +x to more scripts that need it.
v4: Rebase onto 4.0-rc3.

 tools/testing/selftests/breakpoints/Makefile         |  5 +++--
 tools/testing/selftests/cpu-hotplug/Makefile         |  5 +++--
 tools/testing/selftests/cpu-hotplug/on-off-test.sh   |  0
 tools/testing/selftests/efivarfs/Makefile            |  5 +++--
 tools/testing/selftests/efivarfs/efivarfs.sh         |  0
 tools/testing/selftests/exec/Makefile                |  5 +++--
 tools/testing/selftests/firmware/Makefile            | 20 ++------------------
 tools/testing/selftests/firmware/fw_filesystem.sh    |  0
 tools/testing/selftests/firmware/fw_userhelper.sh    |  0
 tools/testing/selftests/ftrace/Makefile              |  5 +++--
 tools/testing/selftests/ipc/Makefile                 |  5 +++--
 tools/testing/selftests/kcmp/Makefile                |  5 +++--
 tools/testing/selftests/lib.mk                       | 10 ++++++++++
 tools/testing/selftests/memfd/Makefile               |  6 +++---
 tools/testing/selftests/memory-hotplug/Makefile      |  5 +++--
 .../testing/selftests/memory-hotplug/on-off-test.sh  |  0
 tools/testing/selftests/mount/Makefile               |  8 ++------
 tools/testing/selftests/mqueue/Makefile              |  9 ++++++---
 tools/testing/selftests/net/Makefile                 |  8 ++++----
 tools/testing/selftests/net/run_afpackettests        |  0
 tools/testing/selftests/net/run_netsocktests         |  0
 tools/testing/selftests/ptrace/Makefile              |  5 +++--
 tools/testing/selftests/size/Makefile                |  5 +++--
 tools/testing/selftests/sysctl/Makefile              | 11 ++---------
 tools/testing/selftests/sysctl/run_numerictests      |  0
 tools/testing/selftests/sysctl/run_stringtests       |  0
 tools/testing/selftests/timers/Makefile              |  5 +++--
 tools/testing/selftests/user/Makefile                |  5 +++--
 tools/testing/selftests/vm/Makefile                  |  5 +++--
 tools/testing/selftests/vm/run_vmtests               |  0
 30 files changed, 68 insertions(+), 69 deletions(-)
 mode change 100644 => 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh
 mode change 100644 => 100755 tools/testing/selftests/efivarfs/efivarfs.sh
 mode change 100644 => 100755 tools/testing/selftests/firmware/fw_filesystem.sh
 mode change 100644 => 100755 tools/testing/selftests/firmware/fw_userhelper.sh
 create mode 100644 tools/testing/selftests/lib.mk
 mode change 100644 => 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh
 mode change 100644 => 100755 tools/testing/selftests/net/run_afpackettests
 mode change 100644 => 100755 tools/testing/selftests/net/run_netsocktests
 mode change 100644 => 100755 tools/testing/selftests/sysctl/run_numerictests
 mode change 100644 => 100755 tools/testing/selftests/sysctl/run_stringtests
 mode change 100644 => 100755 tools/testing/selftests/vm/run_vmtests

diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index e18b42b254af..182235640209 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -16,8 +16,9 @@ else
 	echo "Not an x86 target, can't build breakpoints selftests"
 endif
 
-run_tests:
-	@./breakpoint_test || echo "breakpoints selftests: [FAIL]"
+TEST_PROGS := breakpoint_test
+
+include ../lib.mk
 
 clean:
 	rm -fr breakpoint_test
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index e9c28d8dc84b..15f02591d22c 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -1,7 +1,8 @@
 all:
 
-run_tests:
-	@/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
+TEST_PROGS := on-off-test.sh
+
+include ../lib.mk
 
 run_full_test:
 	@/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 29e8c6bc81b0..3052d0bda24b 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -5,8 +5,9 @@ test_objs = open-unlink create-read
 
 all: $(test_objs)
 
-run_tests: all
-	@/bin/bash ./efivarfs.sh || echo "efivarfs selftests: [FAIL]"
+TEST_PROGS := efivarfs.sh
+
+include ../lib.mk
 
 clean:
 	rm -f $(test_objs)
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 66dfc2ce1788..a0098daeb73d 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -18,8 +18,9 @@ execveat.denatured: execveat
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
 
-run_tests: all
-	./execveat
+TEST_PROGS := execveat
+
+include ../lib.mk
 
 clean:
 	rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/selftests/firmware/Makefile
index e23cce0bbc3a..9bf82234855b 100644
--- a/tools/testing/selftests/firmware/Makefile
+++ b/tools/testing/selftests/firmware/Makefile
@@ -3,25 +3,9 @@
 # No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
 all:
 
-fw_filesystem:
-	@if /bin/sh ./fw_filesystem.sh ; then \
-                echo "fw_filesystem: ok"; \
-        else \
-                echo "fw_filesystem: [FAIL]"; \
-                exit 1; \
-        fi
+TEST_PROGS := fw_filesystem.sh fw_userhelper.sh
 
-fw_userhelper:
-	@if /bin/sh ./fw_userhelper.sh ; then \
-                echo "fw_userhelper: ok"; \
-        else \
-                echo "fw_userhelper: [FAIL]"; \
-                exit 1; \
-        fi
-
-run_tests: all fw_filesystem fw_userhelper
+include ../lib.mk
 
 # Nothing to clean up.
 clean:
-
-.PHONY: all clean run_tests fw_filesystem fw_userhelper
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/firmware/fw_userhelper.sh b/tools/testing/selftests/firmware/fw_userhelper.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 76cc9f156267..346720639d1d 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -1,7 +1,8 @@
 all:
 
-run_tests:
-	@/bin/sh ./ftracetest || echo "ftrace selftests: [FAIL]"
+TEST_PROGS := ftracetest
+
+include ../lib.mk
 
 clean:
 	rm -rf logs/*
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 74bbefdeaf4c..3b6013da4f59 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -18,8 +18,9 @@ else
 	echo "Not an x86 target, can't build msgque selftest"
 endif
 
-run_tests: all
-	./msgque_test
+TEST_PROGS := msgque_test
+
+include ../lib.mk
 
 clean:
 	rm -fr ./msgque_test
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index ff0eefdc6ceb..0eecd183058c 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -3,8 +3,9 @@ CFLAGS += -I../../../../usr/include/
 
 all: kcmp_test
 
-run_tests: all
-	@./kcmp_test || echo "kcmp_test: [FAIL]"
+TEST_PROGS := kcmp_test
+
+include ../lib.mk
 
 clean:
 	$(RM) kcmp_test kcmp-test-file
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
new file mode 100644
index 000000000000..b30c5a49cb61
--- /dev/null
+++ b/tools/testing/selftests/lib.mk
@@ -0,0 +1,10 @@
+define RUN_TESTS
+	@for TEST in $(TEST_PROGS); do \
+		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
+	done;
+endef
+
+run_tests: all
+	$(RUN_TESTS)
+
+.PHONY: run_tests all clean
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index b80cd10d53ba..191dee9d6fd3 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -5,9 +5,9 @@ CFLAGS += -I../../../../include/
 all:
 	gcc $(CFLAGS) memfd_test.c -o memfd_test
 
-run_tests: all
-	gcc $(CFLAGS) memfd_test.c -o memfd_test
-	@./memfd_test || echo "memfd_test: [FAIL]"
+TEST_PROGS := memfd_test
+
+include ../lib.mk
 
 build_fuse:
 	gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index d46b8d489cd2..8f7dea66ecac 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -1,7 +1,8 @@
 all:
 
-run_tests:
-	@/bin/bash ./on-off-test.sh -r 2 || echo "memory-hotplug selftests: [FAIL]"
+include ../lib.mk
+
+override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
 
 run_full_test:
 	@/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 337d853c2b72..06931dfd3ef0 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -5,13 +5,9 @@ all: unprivileged-remount-test
 unprivileged-remount-test: unprivileged-remount-test.c
 	gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test
 
-# Allow specific tests to be selected.
-test_unprivileged_remount: unprivileged-remount-test
-	@if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
+include ../lib.mk
 
-run_tests: all test_unprivileged_remount
+override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
 
 clean:
 	rm -f unprivileged-remount-test
-
-.PHONY: all test_unprivileged_remount
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 8056e2e68fa4..cbc300ef11bf 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -2,9 +2,12 @@ all:
 	gcc -O2 mq_open_tests.c -o mq_open_tests -lrt
 	gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt
 
-run_tests:
-	@./mq_open_tests /test1 || echo "mq_open_tests: [FAIL]"
-	@./mq_perf_tests || echo "mq_perf_tests: [FAIL]"
+include ../lib.mk
+
+override define RUN_TESTS
+	@./mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]"
+	@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
+endef
 
 clean:
 	rm -f mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 62f22cc9941c..fa8187ff15e6 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -11,9 +11,9 @@ all: $(NET_PROGS)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
 
-run_tests: all
-	@/bin/sh ./run_netsocktests || echo "sockettests: [FAIL]"
-	@/bin/sh ./run_afpackettests || echo "afpackettests: [FAIL]"
-	./test_bpf.sh
+TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
+
+include ../lib.mk
+
 clean:
 	$(RM) $(NET_PROGS)
diff --git a/tools/testing/selftests/net/run_afpackettests b/tools/testing/selftests/net/run_afpackettests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/net/run_netsocktests b/tools/testing/selftests/net/run_netsocktests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
index 47ae2d385ce8..453927fea90c 100644
--- a/tools/testing/selftests/ptrace/Makefile
+++ b/tools/testing/selftests/ptrace/Makefile
@@ -6,5 +6,6 @@ all: peeksiginfo
 clean:
 	rm -f peeksiginfo
 
-run_tests: all
-	@./peeksiginfo || echo "peeksiginfo selftests: [FAIL]"
+TEST_PROGS := peeksiginfo
+
+include ../lib.mk
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index 04dc25e4fa92..e4353d74ea6e 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -5,8 +5,9 @@ all: get_size
 get_size: get_size.c
 	$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
 
-run_tests: all
-	./get_size
+TEST_PROGS := get_size
+
+include ../lib.mk
 
 clean:
 	$(RM) get_size
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile
index 0a92adaf0865..c9660f5ef9f9 100644
--- a/tools/testing/selftests/sysctl/Makefile
+++ b/tools/testing/selftests/sysctl/Makefile
@@ -4,16 +4,9 @@
 # No binaries, but make sure arg-less "make" doesn't trigger "run_tests".
 all:
 
-# Allow specific tests to be selected.
-test_num:
-	@/bin/sh ./run_numerictests
+TEST_PROGS := run_numerictests run_stringtests
 
-test_string:
-	@/bin/sh ./run_stringtests
-
-run_tests: all test_num test_string
+include ../lib.mk
 
 # Nothing to clean up.
 clean:
-
-.PHONY: all run_tests clean test_num test_string
diff --git a/tools/testing/selftests/sysctl/run_numerictests b/tools/testing/selftests/sysctl/run_numerictests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/sysctl/run_stringtests b/tools/testing/selftests/sysctl/run_stringtests
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index eb2859f4ad21..149cee3b7b8a 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,8 +1,9 @@
 all:
 	gcc posix_timers.c -o posix_timers -lrt
 
-run_tests: all
-	./posix_timers
+TEST_PROGS := posix_timers
+
+include ../lib.mk
 
 clean:
 	rm -f ./posix_timers
diff --git a/tools/testing/selftests/user/Makefile b/tools/testing/selftests/user/Makefile
index 12c9d15bab07..d401b63c5b1a 100644
--- a/tools/testing/selftests/user/Makefile
+++ b/tools/testing/selftests/user/Makefile
@@ -3,5 +3,6 @@
 # No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
 all:
 
-run_tests: all
-	./test_user_copy.sh
+TEST_PROGS := test_user_copy.sh
+
+include ../lib.mk
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 077828c889f1..90e56090b0ed 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -9,8 +9,9 @@ all: $(BINARIES)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^ -lrt
 
-run_tests: all
-	@/bin/sh ./run_vmtests || (echo "vmtests: [FAIL]"; exit 1)
+TEST_PROGS := run_vmtests
+
+include ../lib.mk
 
 clean:
 	$(RM) $(BINARIES)
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
old mode 100644
new mode 100755
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 4/9] selftests: Add install target
  2015-03-11  4:05 ` Michael Ellerman
@ 2015-03-11  4:06   ` Michael Ellerman
  -1 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

This adds make install support to selftests. The basic usage is:

$ cd tools/testing/selftests
$ make install

That installs into tools/testing/selftests/install, which can then be
copied where ever necessary.

The install destination is also configurable using eg:

$ INSTALL_PATH=/mnt/selftests make install

The implementation uses two targets in the child makefiles. The first
"install" is expected to install all files into $(INSTALL_PATH).

The second, "emit_tests", is expected to emit the test instructions (ie.
bash script) on stdout. Separating this from install means the child
makefiles need no knowledge of the location of the test script.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---

v3: Rebase onto 4.0-rc2.
    Rename all.sh to run_kselftest.sh.
    Add --no-print-directory to emit_tests invocation.
v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
    newlines from echoes.

 tools/testing/selftests/Makefile                | 33 +++++++++++++++++++++++++
 tools/testing/selftests/efivarfs/Makefile       |  1 +
 tools/testing/selftests/exec/Makefile           |  3 +++
 tools/testing/selftests/lib.mk                  | 23 ++++++++++++++++-
 tools/testing/selftests/memory-hotplug/Makefile |  2 ++
 tools/testing/selftests/mount/Makefile          |  2 ++
 tools/testing/selftests/mqueue/Makefile         |  7 ++++++
 tools/testing/selftests/net/Makefile            |  1 +
 tools/testing/selftests/sysctl/Makefile         |  1 +
 tools/testing/selftests/vm/Makefile             |  1 +
 10 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 4e511221a0c1..9af1df28bb26 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -47,7 +47,40 @@ clean_hotplug:
 		make -C $$TARGET clean; \
 	done;
 
+INSTALL_PATH ?= install
+INSTALL_PATH := $(abspath $(INSTALL_PATH))
+ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
+
+install:
+ifdef INSTALL_PATH
+	@# Ask all targets to install their files
+	mkdir -p $(INSTALL_PATH)
+	for TARGET in $(TARGETS); do \
+		mkdir -p $(INSTALL_PATH)/$$TARGET ; \
+		make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
+	done;
+
+	@# Ask all targets to emit their test scripts
+	echo "#!/bin/bash" > $(ALL_SCRIPT)
+	echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
+	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
+
+	for TARGET in $(TARGETS); do \
+		echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
+		echo "echo ========================================" >> $(ALL_SCRIPT); \
+		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
+		make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
+		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
+	done;
+
+	chmod u+x $(ALL_SCRIPT)
+else
+	$(error Error: set INSTALL_PATH to use install)
+endif
+
 clean:
 	for TARGET in $(TARGETS); do \
 		make -C $$TARGET clean; \
 	done;
+
+.PHONY: install
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 3052d0bda24b..9ff04f154bd5 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -6,6 +6,7 @@ test_objs = open-unlink create-read
 all: $(test_objs)
 
 TEST_PROGS := efivarfs.sh
+TEST_FILES := $(test_objs)
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index a0098daeb73d..886cabe307b1 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -19,8 +19,11 @@ execveat.denatured: execveat
 	$(CC) $(CFLAGS) -o $@ $^
 
 TEST_PROGS := execveat
+TEST_FILES := $(DEPS)
 
 include ../lib.mk
 
+override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
+
 clean:
 	rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index b30c5a49cb61..7bd3dabe2846 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -7,4 +7,25 @@ endef
 run_tests: all
 	$(RUN_TESTS)
 
-.PHONY: run_tests all clean
+define INSTALL_RULE
+	mkdir -p $(INSTALL_PATH)
+	install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_FILES)
+endef
+
+install: all
+ifdef INSTALL_PATH
+	$(INSTALL_RULE)
+else
+	$(error Error: set INSTALL_PATH to use install)
+endif
+
+define EMIT_TESTS
+	@for TEST in $(TEST_PROGS); do \
+		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
+	done;
+endef
+
+emit_tests:
+	$(EMIT_TESTS)
+
+.PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index 8f7dea66ecac..598a1f68f534 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -2,7 +2,9 @@ all:
 
 include ../lib.mk
 
+TEST_PROGS := on-off-test.sh
 override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
+override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 run_full_test:
 	@/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 06931dfd3ef0..a5b367f032ba 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -7,7 +7,9 @@ unprivileged-remount-test: unprivileged-remount-test.c
 
 include ../lib.mk
 
+TEST_PROGS := unprivileged-remount-test
 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
+override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 clean:
 	rm -f unprivileged-remount-test
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index cbc300ef11bf..6ca7261b55dc 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -9,5 +9,12 @@ override define RUN_TESTS
 	@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
 endef
 
+TEST_PROGS := mq_open_tests mq_perf_tests
+
+override define EMIT_TESTS
+	echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
+	echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
+endef
+
 clean:
 	rm -f mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index fa8187ff15e6..6ba2ac7bbb0d 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -12,6 +12,7 @@ all: $(NET_PROGS)
 	$(CC) $(CFLAGS) -o $@ $^
 
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
+TEST_FILES := $(NET_PROGS)
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile
index c9660f5ef9f9..b3c33e071f10 100644
--- a/tools/testing/selftests/sysctl/Makefile
+++ b/tools/testing/selftests/sysctl/Makefile
@@ -5,6 +5,7 @@
 all:
 
 TEST_PROGS := run_numerictests run_stringtests
+TEST_FILES := common_tests
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 90e56090b0ed..1a49761df6ed 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -10,6 +10,7 @@ all: $(BINARIES)
 	$(CC) $(CFLAGS) -o $@ $^ -lrt
 
 TEST_PROGS := run_vmtests
+TEST_FILES := $(BINARIES)
 
 include ../lib.mk
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 4/9] selftests: Add install target
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

This adds make install support to selftests. The basic usage is:

$ cd tools/testing/selftests
$ make install

That installs into tools/testing/selftests/install, which can then be
copied where ever necessary.

The install destination is also configurable using eg:

$ INSTALL_PATH=/mnt/selftests make install

The implementation uses two targets in the child makefiles. The first
"install" is expected to install all files into $(INSTALL_PATH).

The second, "emit_tests", is expected to emit the test instructions (ie.
bash script) on stdout. Separating this from install means the child
makefiles need no knowledge of the location of the test script.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---

v3: Rebase onto 4.0-rc2.
    Rename all.sh to run_kselftest.sh.
    Add --no-print-directory to emit_tests invocation.
v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
    newlines from echoes.

 tools/testing/selftests/Makefile                | 33 +++++++++++++++++++++++++
 tools/testing/selftests/efivarfs/Makefile       |  1 +
 tools/testing/selftests/exec/Makefile           |  3 +++
 tools/testing/selftests/lib.mk                  | 23 ++++++++++++++++-
 tools/testing/selftests/memory-hotplug/Makefile |  2 ++
 tools/testing/selftests/mount/Makefile          |  2 ++
 tools/testing/selftests/mqueue/Makefile         |  7 ++++++
 tools/testing/selftests/net/Makefile            |  1 +
 tools/testing/selftests/sysctl/Makefile         |  1 +
 tools/testing/selftests/vm/Makefile             |  1 +
 10 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 4e511221a0c1..9af1df28bb26 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -47,7 +47,40 @@ clean_hotplug:
 		make -C $$TARGET clean; \
 	done;
 
+INSTALL_PATH ?= install
+INSTALL_PATH := $(abspath $(INSTALL_PATH))
+ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh
+
+install:
+ifdef INSTALL_PATH
+	@# Ask all targets to install their files
+	mkdir -p $(INSTALL_PATH)
+	for TARGET in $(TARGETS); do \
+		mkdir -p $(INSTALL_PATH)/$$TARGET ; \
+		make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
+	done;
+
+	@# Ask all targets to emit their test scripts
+	echo "#!/bin/bash" > $(ALL_SCRIPT)
+	echo "cd \$$(dirname \$$0)" >> $(ALL_SCRIPT)
+	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
+
+	for TARGET in $(TARGETS); do \
+		echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
+		echo "echo ========================================" >> $(ALL_SCRIPT); \
+		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
+		make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
+		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
+	done;
+
+	chmod u+x $(ALL_SCRIPT)
+else
+	$(error Error: set INSTALL_PATH to use install)
+endif
+
 clean:
 	for TARGET in $(TARGETS); do \
 		make -C $$TARGET clean; \
 	done;
+
+.PHONY: install
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 3052d0bda24b..9ff04f154bd5 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -6,6 +6,7 @@ test_objs = open-unlink create-read
 all: $(test_objs)
 
 TEST_PROGS := efivarfs.sh
+TEST_FILES := $(test_objs)
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index a0098daeb73d..886cabe307b1 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -19,8 +19,11 @@ execveat.denatured: execveat
 	$(CC) $(CFLAGS) -o $@ $^
 
 TEST_PROGS := execveat
+TEST_FILES := $(DEPS)
 
 include ../lib.mk
 
+override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
+
 clean:
 	rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index b30c5a49cb61..7bd3dabe2846 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -7,4 +7,25 @@ endef
 run_tests: all
 	$(RUN_TESTS)
 
-.PHONY: run_tests all clean
+define INSTALL_RULE
+	mkdir -p $(INSTALL_PATH)
+	install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_FILES)
+endef
+
+install: all
+ifdef INSTALL_PATH
+	$(INSTALL_RULE)
+else
+	$(error Error: set INSTALL_PATH to use install)
+endif
+
+define EMIT_TESTS
+	@for TEST in $(TEST_PROGS); do \
+		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
+	done;
+endef
+
+emit_tests:
+	$(EMIT_TESTS)
+
+.PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index 8f7dea66ecac..598a1f68f534 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -2,7 +2,9 @@ all:
 
 include ../lib.mk
 
+TEST_PROGS := on-off-test.sh
 override RUN_TESTS := ./on-off-test.sh -r 2 || echo "selftests: memory-hotplug [FAIL]"
+override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 run_full_test:
 	@/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 06931dfd3ef0..a5b367f032ba 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -7,7 +7,9 @@ unprivileged-remount-test: unprivileged-remount-test.c
 
 include ../lib.mk
 
+TEST_PROGS := unprivileged-remount-test
 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
+override EMIT_TESTS := echo "$(RUN_TESTS)"
 
 clean:
 	rm -f unprivileged-remount-test
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index cbc300ef11bf..6ca7261b55dc 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -9,5 +9,12 @@ override define RUN_TESTS
 	@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
 endef
 
+TEST_PROGS := mq_open_tests mq_perf_tests
+
+override define EMIT_TESTS
+	echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
+	echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
+endef
+
 clean:
 	rm -f mq_open_tests mq_perf_tests
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index fa8187ff15e6..6ba2ac7bbb0d 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -12,6 +12,7 @@ all: $(NET_PROGS)
 	$(CC) $(CFLAGS) -o $@ $^
 
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
+TEST_FILES := $(NET_PROGS)
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile
index c9660f5ef9f9..b3c33e071f10 100644
--- a/tools/testing/selftests/sysctl/Makefile
+++ b/tools/testing/selftests/sysctl/Makefile
@@ -5,6 +5,7 @@
 all:
 
 TEST_PROGS := run_numerictests run_stringtests
+TEST_FILES := common_tests
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 90e56090b0ed..1a49761df6ed 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -10,6 +10,7 @@ all: $(BINARIES)
 	$(CC) $(CFLAGS) -o $@ $^ -lrt
 
 TEST_PROGS := run_vmtests
+TEST_FILES := $(BINARIES)
 
 include ../lib.mk
 
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 5/9] selftests: Add install support for the powerpc tests
  2015-03-11  4:05 ` Michael Ellerman
@ 2015-03-11  4:06   ` Michael Ellerman
  -1 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

The bulk of the selftests are actually below the powerpc sub directory.

This adds support for installing them, when on a powerpc machine, or if
ARCH and CROSS_COMPILE are set appropriately.

This is a little more complicated because of the sub directory structure
under powerpc, but much of the common logic in lib.mk is still used. The
net effect of the patch is still a reduction in code.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/Makefile           | 19 ++++++++-
 tools/testing/selftests/powerpc/copyloops/Makefile | 15 +++----
 tools/testing/selftests/powerpc/mm/Makefile        | 15 +++----
 tools/testing/selftests/powerpc/pmu/Makefile       | 48 ++++++++++++----------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 13 +++---
 .../testing/selftests/powerpc/primitives/Makefile  | 15 +++----
 .../testing/selftests/powerpc/stringloops/Makefile | 15 +++----
 tools/testing/selftests/powerpc/tm/Makefile        | 15 +++----
 8 files changed, 73 insertions(+), 82 deletions(-)

diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 1d5e7ad2c460..22c4f8ffa422 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -22,10 +22,25 @@ all: $(TARGETS)
 $(TARGETS):
 	$(MAKE) -k -C $@ all
 
-run_tests: all
+include ../lib.mk
+
+override define RUN_TESTS
 	@for TARGET in $(TARGETS); do \
 		$(MAKE) -C $$TARGET run_tests; \
 	done;
+endef
+
+override define INSTALL_RULE
+	@for TARGET in $(TARGETS); do \
+		$(MAKE) -C $$TARGET install; \
+	done;
+endef
+
+override define EMIT_TESTS
+	@for TARGET in $(TARGETS); do \
+		$(MAKE) -s -C $$TARGET emit_tests; \
+	done;
+endef
 
 clean:
 	@for TARGET in $(TARGETS); do \
@@ -36,4 +51,4 @@ clean:
 tags:
 	find . -name '*.c' -o -name '*.h' | xargs ctags
 
-.PHONY: all run_tests clean tags $(TARGETS)
+.PHONY: tags $(TARGETS)
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index 6f2d3be227f9..c05023514ce8 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -6,24 +6,19 @@ CFLAGS += -D SELFTEST
 # Use our CFLAGS for the implicit .S rule
 ASFLAGS = $(CFLAGS)
 
-PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
+TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
 copyuser_64:     CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base
 copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7
 memcpy_64:       CPPFLAGS += -D COPY_LOOP=test_memcpy
 memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
 
-$(PROGS): $(EXTRA_SOURCES)
+$(TEST_PROGS): $(EXTRA_SOURCES)
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
index a14c538dd7f8..41cc3ed66818 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+++ b/tools/testing/selftests/powerpc/mm/Makefile
@@ -1,21 +1,16 @@
 noarg:
 	$(MAKE) -C ../
 
-PROGS := hugetlb_vs_thp_test subpage_prot
+TEST_PROGS := hugetlb_vs_thp_test subpage_prot
 
-all: $(PROGS) tempfile
+all: $(TEST_PROGS) tempfile
 
-$(PROGS): ../harness.c
+$(TEST_PROGS): ../harness.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 tempfile:
 	dd if=/dev/zero of=tempfile bs=64k count=1
 
 clean:
-	rm -f $(PROGS) tempfile
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) tempfile
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index c9f4263906a5..5a161175bbd4 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -1,38 +1,42 @@
 noarg:
 	$(MAKE) -C ../
 
-PROGS := count_instructions l3_bank_test per_event_excludes
+TEST_PROGS := count_instructions l3_bank_test per_event_excludes
 EXTRA_SOURCES := ../harness.c event.c lib.c
 
-SUB_TARGETS = ebb
+all: $(TEST_PROGS) ebb
 
-all: $(PROGS) $(SUB_TARGETS)
-
-$(PROGS): $(EXTRA_SOURCES)
+$(TEST_PROGS): $(EXTRA_SOURCES)
 
 # loop.S can only be built 64-bit
 count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
 	$(CC) $(CFLAGS) -m64 -o $@ $^
 
-run_tests: all sub_run_tests
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
-clean: sub_clean
-	rm -f $(PROGS) loop.o
+DEFAULT_RUN_TESTS := $(RUN_TESTS)
+override define RUN_TESTS
+	$(DEFAULT_RUN_TESTS)
+	$(MAKE) -C ebb run_tests
+endef
 
-$(SUB_TARGETS):
-	$(MAKE) -k -C $@ all
+DEFAULT_EMIT_TESTS := $(EMIT_TESTS)
+override define EMIT_TESTS
+	$(DEFAULT_EMIT_TESTS)
+	$(MAKE) -s -C ebb emit_tests
+endef
 
-sub_run_tests: all
-	@for TARGET in $(SUB_TARGETS); do \
-		$(MAKE) -C $$TARGET run_tests; \
-	done;
+DEFAULT_INSTALL := $(INSTALL_RULE)
+override define INSTALL_RULE
+	$(DEFAULT_INSTALL_RULE)
+	$(MAKE) -C ebb install
+endef
 
-sub_clean:
-	@for TARGET in $(SUB_TARGETS); do \
-		$(MAKE) -C $$TARGET clean; \
-	done;
+clean:
+	rm -f $(TEST_PROGS) loop.o
+	$(MAKE) -C ebb clean
+
+ebb:
+	$(MAKE) -k -C $@ all
 
-.PHONY: all run_tests clean sub_run_tests sub_clean $(SUB_TARGETS)
+.PHONY: all run_tests clean ebb
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index 3dc4332698cb..5cdc9dbf2b27 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -4,7 +4,7 @@ noarg:
 # The EBB handler is 64-bit code and everything links against it
 CFLAGS += -m64
 
-PROGS := reg_access_test event_attributes_test cycles_test	\
+TEST_PROGS := reg_access_test event_attributes_test cycles_test	\
 	 cycles_with_freeze_test pmc56_overflow_test		\
 	 ebb_vs_cpu_event_test cpu_event_vs_ebb_test		\
 	 cpu_event_pinned_vs_ebb_test task_event_vs_ebb_test	\
@@ -16,18 +16,15 @@ PROGS := reg_access_test event_attributes_test cycles_test	\
 	 lost_exception_test no_handler_test			\
 	 cycles_with_mmcr2_test
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): ../../harness.c ../event.c ../lib.c ebb.c ebb_handler.S trace.c busy_loop.S
+$(TEST_PROGS): ../../harness.c ../event.c ../lib.c ebb.c ebb_handler.S trace.c busy_loop.S
 
 instruction_count_test: ../loop.S
 
 lost_exception_test: ../lib.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../../lib.mk
 
 clean:
-	rm -f $(PROGS)
+	rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index ea737ca01732..b68c6221d3d1 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -1,17 +1,12 @@
 CFLAGS += -I$(CURDIR)
 
-PROGS := load_unaligned_zeropad
+TEST_PROGS := load_unaligned_zeropad
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): ../harness.c
+$(TEST_PROGS): ../harness.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index 506d77346477..2a728f4d2873 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -2,19 +2,14 @@
 CFLAGS += -m64
 CFLAGS += -I$(CURDIR)
 
-PROGS := memcmp
+TEST_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): $(EXTRA_SOURCES)
+$(TEST_PROGS): $(EXTRA_SOURCES)
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 2cede239a074..34f2ec634b40 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -1,15 +1,10 @@
-PROGS := tm-resched-dscr
+TEST_PROGS := tm-resched-dscr
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): ../harness.c
+$(TEST_PROGS): ../harness.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 5/9] selftests: Add install support for the powerpc tests
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

The bulk of the selftests are actually below the powerpc sub directory.

This adds support for installing them, when on a powerpc machine, or if
ARCH and CROSS_COMPILE are set appropriately.

This is a little more complicated because of the sub directory structure
under powerpc, but much of the common logic in lib.mk is still used. The
net effect of the patch is still a reduction in code.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/Makefile           | 19 ++++++++-
 tools/testing/selftests/powerpc/copyloops/Makefile | 15 +++----
 tools/testing/selftests/powerpc/mm/Makefile        | 15 +++----
 tools/testing/selftests/powerpc/pmu/Makefile       | 48 ++++++++++++----------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 13 +++---
 .../testing/selftests/powerpc/primitives/Makefile  | 15 +++----
 .../testing/selftests/powerpc/stringloops/Makefile | 15 +++----
 tools/testing/selftests/powerpc/tm/Makefile        | 15 +++----
 8 files changed, 73 insertions(+), 82 deletions(-)

diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 1d5e7ad2c460..22c4f8ffa422 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -22,10 +22,25 @@ all: $(TARGETS)
 $(TARGETS):
 	$(MAKE) -k -C $@ all
 
-run_tests: all
+include ../lib.mk
+
+override define RUN_TESTS
 	@for TARGET in $(TARGETS); do \
 		$(MAKE) -C $$TARGET run_tests; \
 	done;
+endef
+
+override define INSTALL_RULE
+	@for TARGET in $(TARGETS); do \
+		$(MAKE) -C $$TARGET install; \
+	done;
+endef
+
+override define EMIT_TESTS
+	@for TARGET in $(TARGETS); do \
+		$(MAKE) -s -C $$TARGET emit_tests; \
+	done;
+endef
 
 clean:
 	@for TARGET in $(TARGETS); do \
@@ -36,4 +51,4 @@ clean:
 tags:
 	find . -name '*.c' -o -name '*.h' | xargs ctags
 
-.PHONY: all run_tests clean tags $(TARGETS)
+.PHONY: tags $(TARGETS)
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index 6f2d3be227f9..c05023514ce8 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -6,24 +6,19 @@ CFLAGS += -D SELFTEST
 # Use our CFLAGS for the implicit .S rule
 ASFLAGS = $(CFLAGS)
 
-PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
+TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
 copyuser_64:     CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base
 copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7
 memcpy_64:       CPPFLAGS += -D COPY_LOOP=test_memcpy
 memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
 
-$(PROGS): $(EXTRA_SOURCES)
+$(TEST_PROGS): $(EXTRA_SOURCES)
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
index a14c538dd7f8..41cc3ed66818 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+++ b/tools/testing/selftests/powerpc/mm/Makefile
@@ -1,21 +1,16 @@
 noarg:
 	$(MAKE) -C ../
 
-PROGS := hugetlb_vs_thp_test subpage_prot
+TEST_PROGS := hugetlb_vs_thp_test subpage_prot
 
-all: $(PROGS) tempfile
+all: $(TEST_PROGS) tempfile
 
-$(PROGS): ../harness.c
+$(TEST_PROGS): ../harness.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 tempfile:
 	dd if=/dev/zero of=tempfile bs=64k count=1
 
 clean:
-	rm -f $(PROGS) tempfile
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) tempfile
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index c9f4263906a5..5a161175bbd4 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -1,38 +1,42 @@
 noarg:
 	$(MAKE) -C ../
 
-PROGS := count_instructions l3_bank_test per_event_excludes
+TEST_PROGS := count_instructions l3_bank_test per_event_excludes
 EXTRA_SOURCES := ../harness.c event.c lib.c
 
-SUB_TARGETS = ebb
+all: $(TEST_PROGS) ebb
 
-all: $(PROGS) $(SUB_TARGETS)
-
-$(PROGS): $(EXTRA_SOURCES)
+$(TEST_PROGS): $(EXTRA_SOURCES)
 
 # loop.S can only be built 64-bit
 count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
 	$(CC) $(CFLAGS) -m64 -o $@ $^
 
-run_tests: all sub_run_tests
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
-clean: sub_clean
-	rm -f $(PROGS) loop.o
+DEFAULT_RUN_TESTS := $(RUN_TESTS)
+override define RUN_TESTS
+	$(DEFAULT_RUN_TESTS)
+	$(MAKE) -C ebb run_tests
+endef
 
-$(SUB_TARGETS):
-	$(MAKE) -k -C $@ all
+DEFAULT_EMIT_TESTS := $(EMIT_TESTS)
+override define EMIT_TESTS
+	$(DEFAULT_EMIT_TESTS)
+	$(MAKE) -s -C ebb emit_tests
+endef
 
-sub_run_tests: all
-	@for TARGET in $(SUB_TARGETS); do \
-		$(MAKE) -C $$TARGET run_tests; \
-	done;
+DEFAULT_INSTALL := $(INSTALL_RULE)
+override define INSTALL_RULE
+	$(DEFAULT_INSTALL_RULE)
+	$(MAKE) -C ebb install
+endef
 
-sub_clean:
-	@for TARGET in $(SUB_TARGETS); do \
-		$(MAKE) -C $$TARGET clean; \
-	done;
+clean:
+	rm -f $(TEST_PROGS) loop.o
+	$(MAKE) -C ebb clean
+
+ebb:
+	$(MAKE) -k -C $@ all
 
-.PHONY: all run_tests clean sub_run_tests sub_clean $(SUB_TARGETS)
+.PHONY: all run_tests clean ebb
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index 3dc4332698cb..5cdc9dbf2b27 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -4,7 +4,7 @@ noarg:
 # The EBB handler is 64-bit code and everything links against it
 CFLAGS += -m64
 
-PROGS := reg_access_test event_attributes_test cycles_test	\
+TEST_PROGS := reg_access_test event_attributes_test cycles_test	\
 	 cycles_with_freeze_test pmc56_overflow_test		\
 	 ebb_vs_cpu_event_test cpu_event_vs_ebb_test		\
 	 cpu_event_pinned_vs_ebb_test task_event_vs_ebb_test	\
@@ -16,18 +16,15 @@ PROGS := reg_access_test event_attributes_test cycles_test	\
 	 lost_exception_test no_handler_test			\
 	 cycles_with_mmcr2_test
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): ../../harness.c ../event.c ../lib.c ebb.c ebb_handler.S trace.c busy_loop.S
+$(TEST_PROGS): ../../harness.c ../event.c ../lib.c ebb.c ebb_handler.S trace.c busy_loop.S
 
 instruction_count_test: ../loop.S
 
 lost_exception_test: ../lib.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../../lib.mk
 
 clean:
-	rm -f $(PROGS)
+	rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index ea737ca01732..b68c6221d3d1 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -1,17 +1,12 @@
 CFLAGS += -I$(CURDIR)
 
-PROGS := load_unaligned_zeropad
+TEST_PROGS := load_unaligned_zeropad
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): ../harness.c
+$(TEST_PROGS): ../harness.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index 506d77346477..2a728f4d2873 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -2,19 +2,14 @@
 CFLAGS += -m64
 CFLAGS += -I$(CURDIR)
 
-PROGS := memcmp
+TEST_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): $(EXTRA_SOURCES)
+$(TEST_PROGS): $(EXTRA_SOURCES)
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 2cede239a074..34f2ec634b40 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -1,15 +1,10 @@
-PROGS := tm-resched-dscr
+TEST_PROGS := tm-resched-dscr
 
-all: $(PROGS)
+all: $(TEST_PROGS)
 
-$(PROGS): ../harness.c
+$(TEST_PROGS): ../harness.c
 
-run_tests: all
-	@-for PROG in $(PROGS); do \
-		./$$PROG; \
-	done;
+include ../../lib.mk
 
 clean:
-	rm -f $(PROGS) *.o
-
-.PHONY: all run_tests clean
+	rm -f $(TEST_PROGS) *.o
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 6/9] selftests: Set CC using CROSS_COMPILE once in lib.mk
  2015-03-11  4:05 ` Michael Ellerman
@ 2015-03-11  4:06   ` Michael Ellerman
  -1 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

This avoids repeating the logic in every Makefile. We mimic the
top-level Makefile and use $(CROSS_COMPILE)gcc.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/efivarfs/Makefile | 1 -
 tools/testing/selftests/exec/Makefile     | 1 -
 tools/testing/selftests/kcmp/Makefile     | 1 -
 tools/testing/selftests/lib.mk            | 4 ++++
 tools/testing/selftests/net/Makefile      | 1 -
 tools/testing/selftests/powerpc/Makefile  | 3 +--
 tools/testing/selftests/size/Makefile     | 2 --
 tools/testing/selftests/vm/Makefile       | 1 -
 8 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 9ff04f154bd5..736c3ddfc787 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall
 
 test_objs = open-unlink create-read
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 886cabe307b1..4edb7d0da29b 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall
 BINARIES = execveat
 DEPS = execveat.symlink execveat.denatured script subdir
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 0eecd183058c..2ae7450a9a89 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,4 +1,3 @@
-CC := $(CROSS_COMPILE)$(CC)
 CFLAGS += -I../../../../usr/include/
 
 all: kcmp_test
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 7bd3dabe2846..860906694a10 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -1,3 +1,7 @@
+# This mimics the top-level Makefile. We do it explicitly here so that this
+# Makefile can operate with or without the kbuild infrastructure.
+CC := $(CROSS_COMPILE)gcc
+
 define RUN_TESTS
 	@for TEST in $(TEST_PROGS); do \
 		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 6ba2ac7bbb0d..fac4782c51d8 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -1,6 +1,5 @@
 # Makefile for net selftests
 
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall -O2 -g
 
 CFLAGS += -I../../../../usr/include/
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 22c4f8ffa422..2958fe9a74e9 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -8,10 +8,9 @@ ifeq ($(ARCH),powerpc)
 
 GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
 
-CC := $(CROSS_COMPILE)$(CC)
 CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CURDIR) $(CFLAGS)
 
-export CC CFLAGS
+export CFLAGS
 
 TARGETS = pmu copyloops mm tm primitives stringloops
 
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index e4353d74ea6e..bbd0b5398b61 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,5 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
-
 all: get_size
 
 get_size: get_size.c
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 1a49761df6ed..a5ce9534eb15 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,6 +1,5 @@
 # Makefile for vm selftests
 
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall
 BINARIES = hugepage-mmap hugepage-shm map_hugetlb thuge-gen hugetlbfstest
 BINARIES += transhuge-stress
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 6/9] selftests: Set CC using CROSS_COMPILE once in lib.mk
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

This avoids repeating the logic in every Makefile. We mimic the
top-level Makefile and use $(CROSS_COMPILE)gcc.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/efivarfs/Makefile | 1 -
 tools/testing/selftests/exec/Makefile     | 1 -
 tools/testing/selftests/kcmp/Makefile     | 1 -
 tools/testing/selftests/lib.mk            | 4 ++++
 tools/testing/selftests/net/Makefile      | 1 -
 tools/testing/selftests/powerpc/Makefile  | 3 +--
 tools/testing/selftests/size/Makefile     | 2 --
 tools/testing/selftests/vm/Makefile       | 1 -
 8 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 9ff04f154bd5..736c3ddfc787 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall
 
 test_objs = open-unlink create-read
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 886cabe307b1..4edb7d0da29b 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall
 BINARIES = execveat
 DEPS = execveat.symlink execveat.denatured script subdir
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 0eecd183058c..2ae7450a9a89 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,4 +1,3 @@
-CC := $(CROSS_COMPILE)$(CC)
 CFLAGS += -I../../../../usr/include/
 
 all: kcmp_test
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 7bd3dabe2846..860906694a10 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -1,3 +1,7 @@
+# This mimics the top-level Makefile. We do it explicitly here so that this
+# Makefile can operate with or without the kbuild infrastructure.
+CC := $(CROSS_COMPILE)gcc
+
 define RUN_TESTS
 	@for TEST in $(TEST_PROGS); do \
 		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 6ba2ac7bbb0d..fac4782c51d8 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -1,6 +1,5 @@
 # Makefile for net selftests
 
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall -O2 -g
 
 CFLAGS += -I../../../../usr/include/
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 22c4f8ffa422..2958fe9a74e9 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -8,10 +8,9 @@ ifeq ($(ARCH),powerpc)
 
 GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
 
-CC := $(CROSS_COMPILE)$(CC)
 CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CURDIR) $(CFLAGS)
 
-export CC CFLAGS
+export CFLAGS
 
 TARGETS = pmu copyloops mm tm primitives stringloops
 
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index e4353d74ea6e..bbd0b5398b61 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,5 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
-
 all: get_size
 
 get_size: get_size.c
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 1a49761df6ed..a5ce9534eb15 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,6 +1,5 @@
 # Makefile for vm selftests
 
-CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall
 BINARIES = hugepage-mmap hugepage-shm map_hugetlb thuge-gen hugetlbfstest
 BINARIES += transhuge-stress
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 7/9] selftests/timers: Use implicit rules
  2015-03-11  4:05 ` Michael Ellerman
@ 2015-03-11  4:06   ` Michael Ellerman
  -1 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

There's no need to open-code the build rules, use the implicit ones.

This has the nice side effect of enabling cross compilation.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/timers/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 149cee3b7b8a..87340405e4b3 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,9 +1,9 @@
-all:
-	gcc posix_timers.c -o posix_timers -lrt
-
 TEST_PROGS := posix_timers
+LDLIBS += -lrt
+
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
 clean:
-	rm -f ./posix_timers
+	rm -f $(TEST_PROGS)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 7/9] selftests/timers: Use implicit rules
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

There's no need to open-code the build rules, use the implicit ones.

This has the nice side effect of enabling cross compilation.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/timers/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 149cee3b7b8a..87340405e4b3 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,9 +1,9 @@
-all:
-	gcc posix_timers.c -o posix_timers -lrt
-
 TEST_PROGS := posix_timers
+LDLIBS += -lrt
+
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
 clean:
-	rm -f ./posix_timers
+	rm -f $(TEST_PROGS)
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 8/9] selftests/mqueue: Use implicit rules
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

There's no need to open-code the build rules, use the implicit ones.

This has the nice side effect of enabling cross compilation.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/mqueue/Makefile | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 6ca7261b55dc..ed85a1d7ee36 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -1,6 +1,11 @@
-all:
-	gcc -O2 mq_open_tests.c -o mq_open_tests -lrt
-	gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt
+TEST_PROGS := mq_open_tests mq_perf_tests
+
+CFLAGS += -O2
+LDLIBS += -lrt
+
+mq_perf_tests: LDLIBS += -lpthread -lpopt
+
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
@@ -9,12 +14,10 @@ override define RUN_TESTS
 	@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
 endef
 
-TEST_PROGS := mq_open_tests mq_perf_tests
-
 override define EMIT_TESTS
 	echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
 	echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
 endef
 
 clean:
-	rm -f mq_open_tests mq_perf_tests
+	rm -f $(TEST_PROGS)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 8/9] selftests/mqueue: Use implicit rules
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

There's no need to open-code the build rules, use the implicit ones.

This has the nice side effect of enabling cross compilation.

Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
---
 tools/testing/selftests/mqueue/Makefile | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 6ca7261b55dc..ed85a1d7ee36 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -1,6 +1,11 @@
-all:
-	gcc -O2 mq_open_tests.c -o mq_open_tests -lrt
-	gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt
+TEST_PROGS := mq_open_tests mq_perf_tests
+
+CFLAGS += -O2
+LDLIBS += -lrt
+
+mq_perf_tests: LDLIBS += -lpthread -lpopt
+
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
@@ -9,12 +14,10 @@ override define RUN_TESTS
 	@./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]"
 endef
 
-TEST_PROGS := mq_open_tests mq_perf_tests
-
 override define EMIT_TESTS
 	echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\""
 	echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\""
 endef
 
 clean:
-	rm -f mq_open_tests mq_perf_tests
+	rm -f $(TEST_PROGS)
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 9/9] selftests/mount: Use implicit rules
  2015-03-11  4:05 ` Michael Ellerman
@ 2015-03-11  4:06   ` Michael Ellerman
  -1 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

There's no need to open-code the build rules, use the implicit ones.

This has the nice side effect of enabling cross compilation.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/mount/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index a5b367f032ba..a6c62bedb0d9 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -1,13 +1,13 @@
 # Makefile for mount selftests.
 
-all: unprivileged-remount-test
+TEST_PROGS := unprivileged-remount-test
+
+CFLAGS += -O2 -Wall
 
-unprivileged-remount-test: unprivileged-remount-test.c
-	gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
-TEST_PROGS := unprivileged-remount-test
 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
 override EMIT_TESTS := echo "$(RUN_TESTS)"
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH v4 9/9] selftests/mount: Use implicit rules
@ 2015-03-11  4:06   ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-11  4:06 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-kernel, davej, mmarek, linux-api

There's no need to open-code the build rules, use the implicit ones.

This has the nice side effect of enabling cross compilation.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/mount/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index a5b367f032ba..a6c62bedb0d9 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -1,13 +1,13 @@
 # Makefile for mount selftests.
 
-all: unprivileged-remount-test
+TEST_PROGS := unprivileged-remount-test
+
+CFLAGS += -O2 -Wall
 
-unprivileged-remount-test: unprivileged-remount-test.c
-	gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
-TEST_PROGS := unprivileged-remount-test
 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
 override EMIT_TESTS := echo "$(RUN_TESTS)"
 
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
  2015-03-11  4:06   ` Michael Ellerman
  (?)
@ 2015-03-11 13:18   ` Shuah Khan
  2015-03-11 16:03       ` Shuah Khan
  2015-03-12  3:15       ` Michael Ellerman
  -1 siblings, 2 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-11 13:18 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> This adds make install support to selftests. The basic usage is:
> 
> $ cd tools/testing/selftests
> $ make install
> 
> That installs into tools/testing/selftests/install, which can then be
> copied where ever necessary.
> 
> The install destination is also configurable using eg:
> 
> $ INSTALL_PATH=/mnt/selftests make install
> 
> The implementation uses two targets in the child makefiles. The first
> "install" is expected to install all files into $(INSTALL_PATH).
> 
> The second, "emit_tests", is expected to emit the test instructions (ie.
> bash script) on stdout. Separating this from install means the child
> makefiles need no knowledge of the location of the test script.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
> 
> v3: Rebase onto 4.0-rc2.
>     Rename all.sh to run_kselftest.sh.
>     Add --no-print-directory to emit_tests invocation.
> v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
>     newlines from echoes.

I don't see my comments addressed. If you want me to take
this work, please address the following comments:

- Name install directory kselftest. It should work with the
  the use-case.

  make INSTALL_PATH=/tmp make install
  The install directory should be /tmp/kselftest

- Flatten the directory with all tests under /tmp/kselftest

I am wasting lot of time because you don't fully address my
comments and send patches that dont' work correctly. Please
make sure your patches don't generate work for me.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-11 16:03       ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-11 16:03 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/11/2015 07:18 AM, Shuah Khan wrote:
> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>> This adds make install support to selftests. The basic usage is:
>>
>> $ cd tools/testing/selftests
>> $ make install
>>
>> That installs into tools/testing/selftests/install, which can then be
>> copied where ever necessary.
>>
>> The install destination is also configurable using eg:
>>
>> $ INSTALL_PATH=/mnt/selftests make install
>>
>> The implementation uses two targets in the child makefiles. The first
>> "install" is expected to install all files into $(INSTALL_PATH).
>>
>> The second, "emit_tests", is expected to emit the test instructions (ie.
>> bash script) on stdout. Separating this from install means the child
>> makefiles need no knowledge of the location of the test script.
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> ---
>>
>> v3: Rebase onto 4.0-rc2.
>>     Rename all.sh to run_kselftest.sh.
>>     Add --no-print-directory to emit_tests invocation.
>> v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
>>     newlines from echoes.
> 
> I don't see my comments addressed. If you want me to take
> this work, please address the following comments:
> 
> - Name install directory kselftest. It should work with the
>   the use-case.
> 
>   make INSTALL_PATH=/tmp make install
>   The install directory should be /tmp/kselftest
> 
> - Flatten the directory with all tests under /tmp/kselftest
> 

Yes. There is the issue of duplicate executable names and data
file to be concerned about. It is a name-space problem. It is
not unique to this case, example /usr/bin. This problem is better
solved without adding the complexity of hierarchical directory
structure.

1. Individual test Makefiles ensure unique names for their
   executables and data files. This can be done as a process
   when new tests are accepted.
2. Install process makes sure they are unique - this patch is
   solving the problem by creating a directory hierarchy. A simpler
   way to do it is by adding pre-fix to when there is name space
   conflict.

The problem with directory hierarchy is for one thing:

1. It is complex and way too many directories get created during
   install and this problem will mushroom as more and more tests
   get added.

2. User won't be able to define a simple path variable to invoke
   individual tests. This is a user experience problem.

Please find a way to solve the name-space problem without the
complexity of directory hierarchy.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-11 16:03       ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-11 16:03 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/11/2015 07:18 AM, Shuah Khan wrote:
> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>> This adds make install support to selftests. The basic usage is:
>>
>> $ cd tools/testing/selftests
>> $ make install
>>
>> That installs into tools/testing/selftests/install, which can then be
>> copied where ever necessary.
>>
>> The install destination is also configurable using eg:
>>
>> $ INSTALL_PATH=/mnt/selftests make install
>>
>> The implementation uses two targets in the child makefiles. The first
>> "install" is expected to install all files into $(INSTALL_PATH).
>>
>> The second, "emit_tests", is expected to emit the test instructions (ie.
>> bash script) on stdout. Separating this from install means the child
>> makefiles need no knowledge of the location of the test script.
>>
>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
>> ---
>>
>> v3: Rebase onto 4.0-rc2.
>>     Rename all.sh to run_kselftest.sh.
>>     Add --no-print-directory to emit_tests invocation.
>> v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
>>     newlines from echoes.
> 
> I don't see my comments addressed. If you want me to take
> this work, please address the following comments:
> 
> - Name install directory kselftest. It should work with the
>   the use-case.
> 
>   make INSTALL_PATH=/tmp make install
>   The install directory should be /tmp/kselftest
> 
> - Flatten the directory with all tests under /tmp/kselftest
> 

Yes. There is the issue of duplicate executable names and data
file to be concerned about. It is a name-space problem. It is
not unique to this case, example /usr/bin. This problem is better
solved without adding the complexity of hierarchical directory
structure.

1. Individual test Makefiles ensure unique names for their
   executables and data files. This can be done as a process
   when new tests are accepted.
2. Install process makes sure they are unique - this patch is
   solving the problem by creating a directory hierarchy. A simpler
   way to do it is by adding pre-fix to when there is name space
   conflict.

The problem with directory hierarchy is for one thing:

1. It is complex and way too many directories get created during
   install and this problem will mushroom as more and more tests
   get added.

2. User won't be able to define a simple path variable to invoke
   individual tests. This is a user experience problem.

Please find a way to solve the name-space problem without the
complexity of directory hierarchy.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile
@ 2015-03-11 16:08     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-11 16:08 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/10/2015 10:05 PM, Michael Ellerman wrote:
> The makefile in arch/x86/Makefile.um sets LDFLAGS and exports it, which
> is then propagated to the selftest Makefiles and leads to build errors
> there. The build errors occur because we are passing LDFLAGS to CC, but
> the option set in Makefile.um (-m elf_x86_64) is not understood by CC.
> We could fix that by using -Wl, but that might break the UM build if
> it's actually passing that option to LD directly.
> 
> We don't actually want the LDFLAGS from kbuild in the selftest Makefile,
> so the simplest fix seems to be to clear LDFLAGS before invoking the
> selftest Makefile.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 0836e9d628f0..5cef1d4c2ea0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1085,7 +1085,7 @@ headers_check: headers_install
>  
>  PHONY += kselftest
>  kselftest:
> -	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
> +	$(Q)$(MAKE) LDFLAGS= -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
>  
>  # ---------------------------------------------------------------------------
>  # Modules
> 

Does this work on x86, powerpc, and other architectures? Do all tests
with and without explicit rules build correctly?

-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile
@ 2015-03-11 16:08     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-11 16:08 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/10/2015 10:05 PM, Michael Ellerman wrote:
> The makefile in arch/x86/Makefile.um sets LDFLAGS and exports it, which
> is then propagated to the selftest Makefiles and leads to build errors
> there. The build errors occur because we are passing LDFLAGS to CC, but
> the option set in Makefile.um (-m elf_x86_64) is not understood by CC.
> We could fix that by using -Wl, but that might break the UM build if
> it's actually passing that option to LD directly.
> 
> We don't actually want the LDFLAGS from kbuild in the selftest Makefile,
> so the simplest fix seems to be to clear LDFLAGS before invoking the
> selftest Makefile.
> 
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 0836e9d628f0..5cef1d4c2ea0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1085,7 +1085,7 @@ headers_check: headers_install
>  
>  PHONY += kselftest
>  kselftest:
> -	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
> +	$(Q)$(MAKE) LDFLAGS= -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
>  
>  # ---------------------------------------------------------------------------
>  # Modules
> 

Does this work on x86, powerpc, and other architectures? Do all tests
with and without explicit rules build correctly?

-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-12  3:11         ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-12  3:11 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kernel, davej, mmarek, linux-api

On Wed, 2015-03-11 at 10:03 -0600, Shuah Khan wrote:
> On 03/11/2015 07:18 AM, Shuah Khan wrote:
> > 
> > I don't see my comments addressed. If you want me to take
> > this work, please address the following comments:
> > 
> > - Name install directory kselftest. It should work with the
> >   the use-case.
> > 
> >   make INSTALL_PATH=/tmp make install
> >   The install directory should be /tmp/kselftest
> > 
> > - Flatten the directory with all tests under /tmp/kselftest
> > 
> 
> Yes. There is the issue of duplicate executable names and data
> file to be concerned about. It is a name-space problem. It is
> not unique to this case, example /usr/bin. This problem is better
> solved without adding the complexity of hierarchical directory
> structure.
> 
> 1. Individual test Makefiles ensure unique names for their
>    executables and data files. This can be done as a process
>    when new tests are accepted.
> 2. Install process makes sure they are unique - this patch is
>    solving the problem by creating a directory hierarchy. A simpler
>    way to do it is by adding pre-fix to when there is name space
>    conflict.
> 
> The problem with directory hierarchy is for one thing:
> 
> 1. It is complex and way too many directories get created during
>    install and this problem will mushroom as more and more tests
>    get added.

One directory is created for each test directory under selftests. That's not
"way too many" directories.

Why does it make sense to have directories for the selftest sources, but not
the installed tests? Why don't we just put all the tests in one directory under
selftests? A: Because that would be stupid.

$ find tools/testing/selftests/ -maxdepth 1 -type d
tools/testing/selftests/
tools/testing/selftests/size
tools/testing/selftests/memory-hotplug
tools/testing/selftests/ipc
tools/testing/selftests/ptrace
tools/testing/selftests/timers
tools/testing/selftests/efivarfs
tools/testing/selftests/net
tools/testing/selftests/kcmp
tools/testing/selftests/mqueue
tools/testing/selftests/ftrace
tools/testing/selftests/mount
tools/testing/selftests/vm
tools/testing/selftests/firmware
tools/testing/selftests/cpu-hotplug
tools/testing/selftests/user
tools/testing/selftests/sysctl
tools/testing/selftests/powerpc
tools/testing/selftests/exec
tools/testing/selftests/memfd
tools/testing/selftests/breakpoints
tools/testing/selftests/rcutorture

Oh no directories, they're so complex!

> 2. User won't be able to define a simple path variable to invoke
>    individual tests. This is a user experience problem.

Who cares? No one does that. Many of the tests aren't just simple executables
that can be run via $PATH, they require test files in the current directory.

cheers



^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-12  3:11         ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-12  3:11 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On Wed, 2015-03-11 at 10:03 -0600, Shuah Khan wrote:
> On 03/11/2015 07:18 AM, Shuah Khan wrote:
> > 
> > I don't see my comments addressed. If you want me to take
> > this work, please address the following comments:
> > 
> > - Name install directory kselftest. It should work with the
> >   the use-case.
> > 
> >   make INSTALL_PATH=/tmp make install
> >   The install directory should be /tmp/kselftest
> > 
> > - Flatten the directory with all tests under /tmp/kselftest
> > 
> 
> Yes. There is the issue of duplicate executable names and data
> file to be concerned about. It is a name-space problem. It is
> not unique to this case, example /usr/bin. This problem is better
> solved without adding the complexity of hierarchical directory
> structure.
> 
> 1. Individual test Makefiles ensure unique names for their
>    executables and data files. This can be done as a process
>    when new tests are accepted.
> 2. Install process makes sure they are unique - this patch is
>    solving the problem by creating a directory hierarchy. A simpler
>    way to do it is by adding pre-fix to when there is name space
>    conflict.
> 
> The problem with directory hierarchy is for one thing:
> 
> 1. It is complex and way too many directories get created during
>    install and this problem will mushroom as more and more tests
>    get added.

One directory is created for each test directory under selftests. That's not
"way too many" directories.

Why does it make sense to have directories for the selftest sources, but not
the installed tests? Why don't we just put all the tests in one directory under
selftests? A: Because that would be stupid.

$ find tools/testing/selftests/ -maxdepth 1 -type d
tools/testing/selftests/
tools/testing/selftests/size
tools/testing/selftests/memory-hotplug
tools/testing/selftests/ipc
tools/testing/selftests/ptrace
tools/testing/selftests/timers
tools/testing/selftests/efivarfs
tools/testing/selftests/net
tools/testing/selftests/kcmp
tools/testing/selftests/mqueue
tools/testing/selftests/ftrace
tools/testing/selftests/mount
tools/testing/selftests/vm
tools/testing/selftests/firmware
tools/testing/selftests/cpu-hotplug
tools/testing/selftests/user
tools/testing/selftests/sysctl
tools/testing/selftests/powerpc
tools/testing/selftests/exec
tools/testing/selftests/memfd
tools/testing/selftests/breakpoints
tools/testing/selftests/rcutorture

Oh no directories, they're so complex!

> 2. User won't be able to define a simple path variable to invoke
>    individual tests. This is a user experience problem.

Who cares? No one does that. Many of the tests aren't just simple executables
that can be run via $PATH, they require test files in the current directory.

cheers

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-12  3:15       ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-12  3:15 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kernel, davej, mmarek, linux-api

On Wed, 2015-03-11 at 07:18 -0600, Shuah Khan wrote:
> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> > This adds make install support to selftests. The basic usage is:
> > 
> > $ cd tools/testing/selftests
> > $ make install
> > 
> > That installs into tools/testing/selftests/install, which can then be
> > copied where ever necessary.
> > 
> > The install destination is also configurable using eg:
> > 
> > $ INSTALL_PATH=/mnt/selftests make install
> > 
> > The implementation uses two targets in the child makefiles. The first
> > "install" is expected to install all files into $(INSTALL_PATH).
> > 
> > The second, "emit_tests", is expected to emit the test instructions (ie.
> > bash script) on stdout. Separating this from install means the child
> > makefiles need no knowledge of the location of the test script.
> > 
> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> > ---
> > 
> > v3: Rebase onto 4.0-rc2.
> >     Rename all.sh to run_kselftest.sh.
> >     Add --no-print-directory to emit_tests invocation.
> > v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
> >     newlines from echoes.
> 
> I don't see my comments addressed. If you want me to take
> this work, please address the following comments:
> 
> - Name install directory kselftest. It should work with the
>   the use-case.
> 
>   make INSTALL_PATH=/tmp make install
>   The install directory should be /tmp/kselftest
> 
> - Flatten the directory with all tests under /tmp/kselftest
> 
> I am wasting lot of time because you don't fully address my
> comments and send patches that dont' work correctly. Please
> make sure your patches don't generate work for me.

You're wasting a lot of time? You have got to be kidding me. You are wasting a
lot of *my* time.

You have my patches, they're signed off, you can do what you wish with them.
Good luck.



^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-12  3:15       ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-12  3:15 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On Wed, 2015-03-11 at 07:18 -0600, Shuah Khan wrote:
> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> > This adds make install support to selftests. The basic usage is:
> > 
> > $ cd tools/testing/selftests
> > $ make install
> > 
> > That installs into tools/testing/selftests/install, which can then be
> > copied where ever necessary.
> > 
> > The install destination is also configurable using eg:
> > 
> > $ INSTALL_PATH=/mnt/selftests make install
> > 
> > The implementation uses two targets in the child makefiles. The first
> > "install" is expected to install all files into $(INSTALL_PATH).
> > 
> > The second, "emit_tests", is expected to emit the test instructions (ie.
> > bash script) on stdout. Separating this from install means the child
> > makefiles need no knowledge of the location of the test script.
> > 
> > Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> > ---
> > 
> > v3: Rebase onto 4.0-rc2.
> >     Rename all.sh to run_kselftest.sh.
> >     Add --no-print-directory to emit_tests invocation.
> > v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
> >     newlines from echoes.
> 
> I don't see my comments addressed. If you want me to take
> this work, please address the following comments:
> 
> - Name install directory kselftest. It should work with the
>   the use-case.
> 
>   make INSTALL_PATH=/tmp make install
>   The install directory should be /tmp/kselftest
> 
> - Flatten the directory with all tests under /tmp/kselftest
> 
> I am wasting lot of time because you don't fully address my
> comments and send patches that dont' work correctly. Please
> make sure your patches don't generate work for me.

You're wasting a lot of time? You have got to be kidding me. You are wasting a
lot of *my* time.

You have my patches, they're signed off, you can do what you wish with them.
Good luck.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 16:33         ` Dave Jones
  0 siblings, 0 replies; 47+ messages in thread
From: Dave Jones @ 2015-03-13 16:33 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Shuah Khan, linux-kernel, mmarek, linux-api

On Thu, Mar 12, 2015 at 02:15:44PM +1100, Michael Ellerman wrote:
 > On Wed, 2015-03-11 at 07:18 -0600, Shuah Khan wrote:
 > > On 03/10/2015 10:06 PM, Michael Ellerman wrote:
 > > > This adds make install support to selftests. The basic usage is:
 > > > 
 > > > v3: Rebase onto 4.0-rc2.
 > > >     Rename all.sh to run_kselftest.sh.
 > > >     Add --no-print-directory to emit_tests invocation.
 > > > v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
 > > >     newlines from echoes.
 > > 
 > > I don't see my comments addressed. If you want me to take
 > > this work, please address the following comments:
 > > 
 > > - Name install directory kselftest. It should work with the
 > >   the use-case.
 > > 
 > >   make INSTALL_PATH=/tmp make install
 > >   The install directory should be /tmp/kselftest
 > > 
 > > - Flatten the directory with all tests under /tmp/kselftest
 > > 
 > > I am wasting lot of time because you don't fully address my
 > > comments and send patches that dont' work correctly. Please
 > > make sure your patches don't generate work for me.
 > 
 > You're wasting a lot of time? You have got to be kidding me. You are wasting a
 > lot of *my* time.
 > 
 > You have my patches, they're signed off, you can do what you wish with them.
 > Good luck.

This is getting silly. We've spent three months arguing over shell
scripts and makefiles for what should be a trivial feature.
We make fundamental changes to the VM code with less contention.

It's not helped that timezones are working against everyone here,
so even minor changes end up taking a while to get reposted, re-reviewed
etc, but the level of pushback because something isn't perfect is absurd,
especially when we're talking about new features.

If you want the in-kernel variant to be perfect every step of the way,
and move slowly and never introduce subtle breakage along the way that then
gets fixed up in subsequent changes, maybe a faster moving external project
that syncs up with the kernel tree is the way forward.

If kselftests is going to evolve into something useful, something has to change.

	Dave


^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 16:33         ` Dave Jones
  0 siblings, 0 replies; 47+ messages in thread
From: Dave Jones @ 2015-03-13 16:33 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	mmarek-AlSwsSmVLrQ, linux-api-u79uwXL29TY76Z2rM5mHXA

On Thu, Mar 12, 2015 at 02:15:44PM +1100, Michael Ellerman wrote:
 > On Wed, 2015-03-11 at 07:18 -0600, Shuah Khan wrote:
 > > On 03/10/2015 10:06 PM, Michael Ellerman wrote:
 > > > This adds make install support to selftests. The basic usage is:
 > > > 
 > > > v3: Rebase onto 4.0-rc2.
 > > >     Rename all.sh to run_kselftest.sh.
 > > >     Add --no-print-directory to emit_tests invocation.
 > > > v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
 > > >     newlines from echoes.
 > > 
 > > I don't see my comments addressed. If you want me to take
 > > this work, please address the following comments:
 > > 
 > > - Name install directory kselftest. It should work with the
 > >   the use-case.
 > > 
 > >   make INSTALL_PATH=/tmp make install
 > >   The install directory should be /tmp/kselftest
 > > 
 > > - Flatten the directory with all tests under /tmp/kselftest
 > > 
 > > I am wasting lot of time because you don't fully address my
 > > comments and send patches that dont' work correctly. Please
 > > make sure your patches don't generate work for me.
 > 
 > You're wasting a lot of time? You have got to be kidding me. You are wasting a
 > lot of *my* time.
 > 
 > You have my patches, they're signed off, you can do what you wish with them.
 > Good luck.

This is getting silly. We've spent three months arguing over shell
scripts and makefiles for what should be a trivial feature.
We make fundamental changes to the VM code with less contention.

It's not helped that timezones are working against everyone here,
so even minor changes end up taking a while to get reposted, re-reviewed
etc, but the level of pushback because something isn't perfect is absurd,
especially when we're talking about new features.

If you want the in-kernel variant to be perfect every step of the way,
and move slowly and never introduce subtle breakage along the way that then
gets fixed up in subsequent changes, maybe a faster moving external project
that syncs up with the kernel tree is the way forward.

If kselftests is going to evolve into something useful, something has to change.

	Dave

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
  2015-03-13 16:33         ` Dave Jones
  (?)
@ 2015-03-13 17:08         ` Shuah Khan
  -1 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 17:08 UTC (permalink / raw)
  To: Dave Jones, Michael Ellerman, linux-kernel, mmarek, linux-api,
	Shuah Khan

On 03/13/2015 10:33 AM, Dave Jones wrote:
> On Thu, Mar 12, 2015 at 02:15:44PM +1100, Michael Ellerman wrote:
>  > On Wed, 2015-03-11 at 07:18 -0600, Shuah Khan wrote:
>  > > On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>  > > > This adds make install support to selftests. The basic usage is:
>  > > > 
>  > > > v3: Rebase onto 4.0-rc2.
>  > > >     Rename all.sh to run_kselftest.sh.
>  > > >     Add --no-print-directory to emit_tests invocation.
>  > > > v4: Rebase onto 4.0-rc3, add TEST_FILES to efivars and vm tests, remove
>  > > >     newlines from echoes.
>  > > 
>  > > I don't see my comments addressed. If you want me to take
>  > > this work, please address the following comments:
>  > > 
>  > > - Name install directory kselftest. It should work with the
>  > >   the use-case.
>  > > 
>  > >   make INSTALL_PATH=/tmp make install
>  > >   The install directory should be /tmp/kselftest
>  > > 
>  > > - Flatten the directory with all tests under /tmp/kselftest
>  > > 
>  > > I am wasting lot of time because you don't fully address my
>  > > comments and send patches that dont' work correctly. Please
>  > > make sure your patches don't generate work for me.
>  > 
>  > You're wasting a lot of time? You have got to be kidding me. You are wasting a
>  > lot of *my* time.
>  > 
>  > You have my patches, they're signed off, you can do what you wish with them.
>  > Good luck.
> 
> This is getting silly. We've spent three months arguing over shell
> scripts and makefiles for what should be a trivial feature.
> We make fundamental changes to the VM code with less contention.

I really don't think this process has to this contentious. I don't
believe the changes I am asking for are unreasonable.

> 
> It's not helped that timezones are working against everyone here,
> so even minor changes end up taking a while to get reposted, re-reviewed
> etc, but the level of pushback because something isn't perfect is absurd,
> especially when we're talking about new features.

Directory structure might seem like a trivial problem, however it is
important to get the user interface right.

Since Michael doesn't have the bandwidth to make the suggested changes,
I working on applying his patches. There are some conflicts with the

selftests: Introduce minimal shared logic for running tests
selftests: Add install target

patches and timer patches. I can fix the directory hierarchy after
I get these two patches into next.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests
@ 2015-03-13 17:19     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 17:19 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/10/2015 10:05 PM, Michael Ellerman wrote:
> This adds a Make include file which most selftests can then include to
> get the run_tests logic.
> 
> On its own this has the advantage of some reduction in repetition, and
> also means the pass/fail message is defined in fewer places.
> 
> However the key advantage is it will allow us to implement install very
> simply in a subsequent patch.
> 
> The default implementation just executes each program in $(TEST_PROGS).
> 
> We use a variable to hold the default implementation of $(RUN_TESTS)
> because that gives us a clean way to override it if necessary, ie. using
> override. The mount, memory-hotplug and mqueue tests use that to provide
> a different implementation.
> 
> Tests are not run via /bin/bash, so if they are scripts they must be
> executable, we add a+x to several.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

This patch will be applied to next and queued for 4.1.

-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests
@ 2015-03-13 17:19     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 17:19 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/10/2015 10:05 PM, Michael Ellerman wrote:
> This adds a Make include file which most selftests can then include to
> get the run_tests logic.
> 
> On its own this has the advantage of some reduction in repetition, and
> also means the pass/fail message is defined in fewer places.
> 
> However the key advantage is it will allow us to implement install very
> simply in a subsequent patch.
> 
> The default implementation just executes each program in $(TEST_PROGS).
> 
> We use a variable to hold the default implementation of $(RUN_TESTS)
> because that gives us a clean way to override it if necessary, ie. using
> override. The mount, memory-hotplug and mqueue tests use that to provide
> a different implementation.
> 
> Tests are not run via /bin/bash, so if they are scripts they must be
> executable, we add a+x to several.
> 
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>

This patch will be applied to next and queued for 4.1.

-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 17:20     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 17:20 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api, Shuah Khan

On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> This adds make install support to selftests. The basic usage is:
> 
> $ cd tools/testing/selftests
> $ make install
> 
> That installs into tools/testing/selftests/install, which can then be
> copied where ever necessary.
> 
> The install destination is also configurable using eg:
> 
> $ INSTALL_PATH=/mnt/selftests make install
> 
> The implementation uses two targets in the child makefiles. The first
> "install" is expected to install all files into $(INSTALL_PATH).
> 
> The second, "emit_tests", is expected to emit the test instructions (ie.
> bash script) on stdout. Separating this from install means the child
> makefiles need no knowledge of the location of the test script.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Thanks for doing the work. This patch will be applied to next and will
be queued for 4.1

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 17:20     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 17:20 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA, Shuah Khan

On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> This adds make install support to selftests. The basic usage is:
> 
> $ cd tools/testing/selftests
> $ make install
> 
> That installs into tools/testing/selftests/install, which can then be
> copied where ever necessary.
> 
> The install destination is also configurable using eg:
> 
> $ INSTALL_PATH=/mnt/selftests make install
> 
> The implementation uses two targets in the child makefiles. The first
> "install" is expected to install all files into $(INSTALL_PATH).
> 
> The second, "emit_tests", is expected to emit the test instructions (ie.
> bash script) on stdout. Separating this from install means the child
> makefiles need no knowledge of the location of the test script.
> 
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>

Thanks for doing the work. This patch will be applied to next and will
be queued for 4.1

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile
@ 2015-03-13 18:06     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 18:06 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/10/2015 10:05 PM, Michael Ellerman wrote:
> The makefile in arch/x86/Makefile.um sets LDFLAGS and exports it, which
> is then propagated to the selftest Makefiles and leads to build errors
> there. The build errors occur because we are passing LDFLAGS to CC, but
> the option set in Makefile.um (-m elf_x86_64) is not understood by CC.
> We could fix that by using -Wl, but that might break the UM build if
> it's actually passing that option to LD directly.
> 
> We don't actually want the LDFLAGS from kbuild in the selftest Makefile,
> so the simplest fix seems to be to clear LDFLAGS before invoking the
> selftest Makefile.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 0836e9d628f0..5cef1d4c2ea0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1085,7 +1085,7 @@ headers_check: headers_install
>  
>  PHONY += kselftest
>  kselftest:
> -	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
> +	$(Q)$(MAKE) LDFLAGS= -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
>  
>  # ---------------------------------------------------------------------------
>  # Modules
> 

Thanks for finding the problem and fix. I want to handle this in
the selftests/Makefile level instead. I have a patch ready to send
out for review.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile
@ 2015-03-13 18:06     ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 18:06 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/10/2015 10:05 PM, Michael Ellerman wrote:
> The makefile in arch/x86/Makefile.um sets LDFLAGS and exports it, which
> is then propagated to the selftest Makefiles and leads to build errors
> there. The build errors occur because we are passing LDFLAGS to CC, but
> the option set in Makefile.um (-m elf_x86_64) is not understood by CC.
> We could fix that by using -Wl, but that might break the UM build if
> it's actually passing that option to LD directly.
> 
> We don't actually want the LDFLAGS from kbuild in the selftest Makefile,
> so the simplest fix seems to be to clear LDFLAGS before invoking the
> selftest Makefile.
> 
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 0836e9d628f0..5cef1d4c2ea0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1085,7 +1085,7 @@ headers_check: headers_install
>  
>  PHONY += kselftest
>  kselftest:
> -	$(Q)$(MAKE) -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
> +	$(Q)$(MAKE) LDFLAGS= -C tools/testing/selftests MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" run_tests
>  
>  # ---------------------------------------------------------------------------
>  # Modules
> 

Thanks for finding the problem and fix. I want to handle this in
the selftests/Makefile level instead. I have a patch ready to send
out for review.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests
@ 2015-03-13 20:28       ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 20:28 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/13/2015 11:19 AM, Shuah Khan wrote:
> On 03/10/2015 10:05 PM, Michael Ellerman wrote:
>> This adds a Make include file which most selftests can then include to
>> get the run_tests logic.
>>
>> On its own this has the advantage of some reduction in repetition, and
>> also means the pass/fail message is defined in fewer places.
>>
>> However the key advantage is it will allow us to implement install very
>> simply in a subsequent patch.
>>
>> The default implementation just executes each program in $(TEST_PROGS).
>>
>> We use a variable to hold the default implementation of $(RUN_TESTS)
>> because that gives us a clean way to override it if necessary, ie. using
>> override. The mount, memory-hotplug and mqueue tests use that to provide
>> a different implementation.
>>
>> Tests are not run via /bin/bash, so if they are scripts they must be
>> executable, we add a+x to several.
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> This patch will be applied to next and queued for 4.1.
> 

This patch is now in linux-kselftest next. Could you please review
to make sure, it looks right. I had to drop the shared logic from
timers Makefile because, it changed considerably with the additional
tests and it wasn't easy to resolve the conflict and keep both changes.
So at the moment, timers doesn't use the shared logic.

If lib.mk could provide a way to run additional programs that require
arguments in addition to RUN_TESTS. In the case of timers, there is one
test that requires arguments. In some cases, e.g: memory hotplug,
override works well since it is just one executable. In this case,
there is a mix.

Something that can be addressed in a separate patch. For now, I made
the decision to apply with shared logic patch minus the changes to
use lib.mk

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests
@ 2015-03-13 20:28       ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 20:28 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/13/2015 11:19 AM, Shuah Khan wrote:
> On 03/10/2015 10:05 PM, Michael Ellerman wrote:
>> This adds a Make include file which most selftests can then include to
>> get the run_tests logic.
>>
>> On its own this has the advantage of some reduction in repetition, and
>> also means the pass/fail message is defined in fewer places.
>>
>> However the key advantage is it will allow us to implement install very
>> simply in a subsequent patch.
>>
>> The default implementation just executes each program in $(TEST_PROGS).
>>
>> We use a variable to hold the default implementation of $(RUN_TESTS)
>> because that gives us a clean way to override it if necessary, ie. using
>> override. The mount, memory-hotplug and mqueue tests use that to provide
>> a different implementation.
>>
>> Tests are not run via /bin/bash, so if they are scripts they must be
>> executable, we add a+x to several.
>>
>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> 
> This patch will be applied to next and queued for 4.1.
> 

This patch is now in linux-kselftest next. Could you please review
to make sure, it looks right. I had to drop the shared logic from
timers Makefile because, it changed considerably with the additional
tests and it wasn't easy to resolve the conflict and keep both changes.
So at the moment, timers doesn't use the shared logic.

If lib.mk could provide a way to run additional programs that require
arguments in addition to RUN_TESTS. In the case of timers, there is one
test that requires arguments. In some cases, e.g: memory hotplug,
override works well since it is just one executable. In this case,
there is a mix.

Something that can be addressed in a separate patch. For now, I made
the decision to apply with shared logic patch minus the changes to
use lib.mk

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 21:32       ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 21:32 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/13/2015 11:20 AM, Shuah Khan wrote:
> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>> This adds make install support to selftests. The basic usage is:
>>
>> $ cd tools/testing/selftests
>> $ make install
>>
>> That installs into tools/testing/selftests/install, which can then be
>> copied where ever necessary.
>>
>> The install destination is also configurable using eg:
>>
>> $ INSTALL_PATH=/mnt/selftests make install
>>
>> The implementation uses two targets in the child makefiles. The first
>> "install" is expected to install all files into $(INSTALL_PATH).
>>
>> The second, "emit_tests", is expected to emit the test instructions (ie.
>> bash script) on stdout. Separating this from install means the child
>> makefiles need no knowledge of the location of the test script.
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> Thanks for doing the work. This patch will be applied to next and will
> be queued for 4.1
> 

ok. linux-kselftest next has both shared logic and install patches
now. As I mentioned in my reply to shared logic patch, I had to drop
the changes to timers Makefile to add shared logic, hence timers progs
don't get installed at the moment.

Could you please review to make sure, it looks right.

As I said in the other email, if lib.mk could provide a way to run
additional programs that require arguments in addition to RUN_TESTS.
In the case of timers, there is one test that requires arguments. In
some cases, e.g: memory hotplug, override works well since it is just
one executable. In this case, there is a mix of executables that don't
need any special handling and some that need it.

You are welcome to add shared logic and install to timers if you would
like.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 21:32       ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 21:32 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/13/2015 11:20 AM, Shuah Khan wrote:
> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>> This adds make install support to selftests. The basic usage is:
>>
>> $ cd tools/testing/selftests
>> $ make install
>>
>> That installs into tools/testing/selftests/install, which can then be
>> copied where ever necessary.
>>
>> The install destination is also configurable using eg:
>>
>> $ INSTALL_PATH=/mnt/selftests make install
>>
>> The implementation uses two targets in the child makefiles. The first
>> "install" is expected to install all files into $(INSTALL_PATH).
>>
>> The second, "emit_tests", is expected to emit the test instructions (ie.
>> bash script) on stdout. Separating this from install means the child
>> makefiles need no knowledge of the location of the test script.
>>
>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> 
> Thanks for doing the work. This patch will be applied to next and will
> be queued for 4.1
> 

ok. linux-kselftest next has both shared logic and install patches
now. As I mentioned in my reply to shared logic patch, I had to drop
the changes to timers Makefile to add shared logic, hence timers progs
don't get installed at the moment.

Could you please review to make sure, it looks right.

As I said in the other email, if lib.mk could provide a way to run
additional programs that require arguments in addition to RUN_TESTS.
In the case of timers, there is one test that requires arguments. In
some cases, e.g: memory hotplug, override works well since it is just
one executable. In this case, there is a mix of executables that don't
need any special handling and some that need it.

You are welcome to add shared logic and install to timers if you would
like.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 23:08         ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 23:08 UTC (permalink / raw)
  To: Michael Ellerman, davej; +Cc: linux-kernel, linux-api

On 03/13/2015 03:32 PM, Shuah Khan wrote:
> On 03/13/2015 11:20 AM, Shuah Khan wrote:
>> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>>> This adds make install support to selftests. The basic usage is:
>>>
>>> $ cd tools/testing/selftests
>>> $ make install
>>>
>>> That installs into tools/testing/selftests/install, which can then be
>>> copied where ever necessary.
>>>
>>> The install destination is also configurable using eg:
>>>
>>> $ INSTALL_PATH=/mnt/selftests make install
>>>
>>> The implementation uses two targets in the child makefiles. The first
>>> "install" is expected to install all files into $(INSTALL_PATH).
>>>
>>> The second, "emit_tests", is expected to emit the test instructions (ie.
>>> bash script) on stdout. Separating this from install means the child
>>> makefiles need no knowledge of the location of the test script.
>>>
>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>
>> Thanks for doing the work. This patch will be applied to next and will
>> be queued for 4.1
>>
> 
> ok. linux-kselftest next has both shared logic and install patches
> now. As I mentioned in my reply to shared logic patch, I had to drop
> the changes to timers Makefile to add shared logic, hence timers progs
> don't get installed at the moment.
> 
> Could you please review to make sure, it looks right.
> 
> As I said in the other email, if lib.mk could provide a way to run
> additional programs that require arguments in addition to RUN_TESTS.
> In the case of timers, there is one test that requires arguments. In
> some cases, e.g: memory hotplug, override works well since it is just
> one executable. In this case, there is a mix of executables that don't
> need any special handling and some that need it.
> 
> You are welcome to add shared logic and install to timers if you would
> like.
> 

I managed to get this taken care of before my weekend. You will see two
patches one with changes to lib.mk to add additional variables to avoid
overrides for cases like timers, and the other that updates timers to
use shared logic.

I did quick test running both make run_tests and make install to verify
timers programs are installed and run_tests works correctly.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-13 23:08         ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-13 23:08 UTC (permalink / raw)
  To: Michael Ellerman, davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/13/2015 03:32 PM, Shuah Khan wrote:
> On 03/13/2015 11:20 AM, Shuah Khan wrote:
>> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>>> This adds make install support to selftests. The basic usage is:
>>>
>>> $ cd tools/testing/selftests
>>> $ make install
>>>
>>> That installs into tools/testing/selftests/install, which can then be
>>> copied where ever necessary.
>>>
>>> The install destination is also configurable using eg:
>>>
>>> $ INSTALL_PATH=/mnt/selftests make install
>>>
>>> The implementation uses two targets in the child makefiles. The first
>>> "install" is expected to install all files into $(INSTALL_PATH).
>>>
>>> The second, "emit_tests", is expected to emit the test instructions (ie.
>>> bash script) on stdout. Separating this from install means the child
>>> makefiles need no knowledge of the location of the test script.
>>>
>>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
>>
>> Thanks for doing the work. This patch will be applied to next and will
>> be queued for 4.1
>>
> 
> ok. linux-kselftest next has both shared logic and install patches
> now. As I mentioned in my reply to shared logic patch, I had to drop
> the changes to timers Makefile to add shared logic, hence timers progs
> don't get installed at the moment.
> 
> Could you please review to make sure, it looks right.
> 
> As I said in the other email, if lib.mk could provide a way to run
> additional programs that require arguments in addition to RUN_TESTS.
> In the case of timers, there is one test that requires arguments. In
> some cases, e.g: memory hotplug, override works well since it is just
> one executable. In this case, there is a mix of executables that don't
> need any special handling and some that need it.
> 
> You are welcome to add shared logic and install to timers if you would
> like.
> 

I managed to get this taken care of before my weekend. You will see two
patches one with changes to lib.mk to add additional variables to avoid
overrides for cases like timers, and the other that updates timers to
use shared logic.

I did quick test running both make run_tests and make install to verify
timers programs are installed and run_tests works correctly.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
  2015-03-13 21:32       ` Shuah Khan
  (?)
  (?)
@ 2015-03-16  3:04       ` Michael Ellerman
  2015-03-16  3:12           ` Michael Ellerman
  2015-03-18 14:30           ` Shuah Khan
  -1 siblings, 2 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-16  3:04 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kernel, davej, mmarek, linux-api

On Fri, 2015-03-13 at 15:32 -0600, Shuah Khan wrote:
> On 03/13/2015 11:20 AM, Shuah Khan wrote:
> > On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> >> This adds make install support to selftests. The basic usage is:
> >>
> >> $ cd tools/testing/selftests
> >> $ make install
> >>
> >> That installs into tools/testing/selftests/install, which can then be
> >> copied where ever necessary.
> >>
> >> The install destination is also configurable using eg:
> >>
> >> $ INSTALL_PATH=/mnt/selftests make install
> >>
> >> The implementation uses two targets in the child makefiles. The first
> >> "install" is expected to install all files into $(INSTALL_PATH).
> >>
> >> The second, "emit_tests", is expected to emit the test instructions (ie.
> >> bash script) on stdout. Separating this from install means the child
> >> makefiles need no knowledge of the location of the test script.
> >>
> >> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> > 
> > Thanks for doing the work. This patch will be applied to next and will
> > be queued for 4.1
> > 
> 
> ok. linux-kselftest next has both shared logic and install patches
> now.

Thanks, looks good to me.

Can you also apply the patch to install the powerpc tests, or was there a
problem with it? It seems to apply cleanly for me.

https://lkml.org/lkml/2015/3/11/9

cheers



^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-16  3:12           ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-16  3:12 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kernel, davej, mmarek, linux-api

On Mon, 2015-03-16 at 14:04 +1100, Michael Ellerman wrote:
> On Fri, 2015-03-13 at 15:32 -0600, Shuah Khan wrote:
> > On 03/13/2015 11:20 AM, Shuah Khan wrote:
> > > On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> > >> This adds make install support to selftests. The basic usage is:
> > >>
> > >> $ cd tools/testing/selftests
> > >> $ make install
> > >>
> > >> That installs into tools/testing/selftests/install, which can then be
> > >> copied where ever necessary.
> > >>
> > >> The install destination is also configurable using eg:
> > >>
> > >> $ INSTALL_PATH=/mnt/selftests make install
> > >>
> > >> The implementation uses two targets in the child makefiles. The first
> > >> "install" is expected to install all files into $(INSTALL_PATH).
> > >>
> > >> The second, "emit_tests", is expected to emit the test instructions (ie.
> > >> bash script) on stdout. Separating this from install means the child
> > >> makefiles need no knowledge of the location of the test script.
> > >>
> > >> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> > > 
> > > Thanks for doing the work. This patch will be applied to next and will
> > > be queued for 4.1
> > > 
> > 
> > ok. linux-kselftest next has both shared logic and install patches
> > now.
> 
> Thanks, looks good to me.

And also 6/9 "selftests: Set CC using CROSS_COMPILE once in lib.mk" would be
nice and is uncontroversial, I think:

https://lkml.org/lkml/2015/3/11/5

cheers



^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-16  3:12           ` Michael Ellerman
  0 siblings, 0 replies; 47+ messages in thread
From: Michael Ellerman @ 2015-03-16  3:12 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On Mon, 2015-03-16 at 14:04 +1100, Michael Ellerman wrote:
> On Fri, 2015-03-13 at 15:32 -0600, Shuah Khan wrote:
> > On 03/13/2015 11:20 AM, Shuah Khan wrote:
> > > On 03/10/2015 10:06 PM, Michael Ellerman wrote:
> > >> This adds make install support to selftests. The basic usage is:
> > >>
> > >> $ cd tools/testing/selftests
> > >> $ make install
> > >>
> > >> That installs into tools/testing/selftests/install, which can then be
> > >> copied where ever necessary.
> > >>
> > >> The install destination is also configurable using eg:
> > >>
> > >> $ INSTALL_PATH=/mnt/selftests make install
> > >>
> > >> The implementation uses two targets in the child makefiles. The first
> > >> "install" is expected to install all files into $(INSTALL_PATH).
> > >>
> > >> The second, "emit_tests", is expected to emit the test instructions (ie.
> > >> bash script) on stdout. Separating this from install means the child
> > >> makefiles need no knowledge of the location of the test script.
> > >>
> > >> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> > > 
> > > Thanks for doing the work. This patch will be applied to next and will
> > > be queued for 4.1
> > > 
> > 
> > ok. linux-kselftest next has both shared logic and install patches
> > now.
> 
> Thanks, looks good to me.

And also 6/9 "selftests: Set CC using CROSS_COMPILE once in lib.mk" would be
nice and is uncontroversial, I think:

https://lkml.org/lkml/2015/3/11/5

cheers

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-18 14:30           ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-18 14:30 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, davej, mmarek, linux-api

On 03/15/2015 09:04 PM, Michael Ellerman wrote:
> On Fri, 2015-03-13 at 15:32 -0600, Shuah Khan wrote:
>> On 03/13/2015 11:20 AM, Shuah Khan wrote:
>>> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>>>> This adds make install support to selftests. The basic usage is:
>>>>
>>>> $ cd tools/testing/selftests
>>>> $ make install
>>>>
>>>> That installs into tools/testing/selftests/install, which can then be
>>>> copied where ever necessary.
>>>>
>>>> The install destination is also configurable using eg:
>>>>
>>>> $ INSTALL_PATH=/mnt/selftests make install
>>>>
>>>> The implementation uses two targets in the child makefiles. The first
>>>> "install" is expected to install all files into $(INSTALL_PATH).
>>>>
>>>> The second, "emit_tests", is expected to emit the test instructions (ie.
>>>> bash script) on stdout. Separating this from install means the child
>>>> makefiles need no knowledge of the location of the test script.
>>>>
>>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>>
>>> Thanks for doing the work. This patch will be applied to next and will
>>> be queued for 4.1
>>>
>>
>> ok. linux-kselftest next has both shared logic and install patches
>> now.
> 
> Thanks, looks good to me.
> 
> Can you also apply the patch to install the powerpc tests, or was there a
> problem with it? It seems to apply cleanly for me.
> 
> https://lkml.org/lkml/2015/3/11/9
> 
> cheers

It is on my todo after the install patches are squared away.
It will be applied to next.

-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH v4 4/9] selftests: Add install target
@ 2015-03-18 14:30           ` Shuah Khan
  0 siblings, 0 replies; 47+ messages in thread
From: Shuah Khan @ 2015-03-18 14:30 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL, mmarek-AlSwsSmVLrQ,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 03/15/2015 09:04 PM, Michael Ellerman wrote:
> On Fri, 2015-03-13 at 15:32 -0600, Shuah Khan wrote:
>> On 03/13/2015 11:20 AM, Shuah Khan wrote:
>>> On 03/10/2015 10:06 PM, Michael Ellerman wrote:
>>>> This adds make install support to selftests. The basic usage is:
>>>>
>>>> $ cd tools/testing/selftests
>>>> $ make install
>>>>
>>>> That installs into tools/testing/selftests/install, which can then be
>>>> copied where ever necessary.
>>>>
>>>> The install destination is also configurable using eg:
>>>>
>>>> $ INSTALL_PATH=/mnt/selftests make install
>>>>
>>>> The implementation uses two targets in the child makefiles. The first
>>>> "install" is expected to install all files into $(INSTALL_PATH).
>>>>
>>>> The second, "emit_tests", is expected to emit the test instructions (ie.
>>>> bash script) on stdout. Separating this from install means the child
>>>> makefiles need no knowledge of the location of the test script.
>>>>
>>>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
>>>
>>> Thanks for doing the work. This patch will be applied to next and will
>>> be queued for 4.1
>>>
>>
>> ok. linux-kselftest next has both shared logic and install patches
>> now.
> 
> Thanks, looks good to me.
> 
> Can you also apply the patch to install the powerpc tests, or was there a
> problem with it? It seems to apply cleanly for me.
> 
> https://lkml.org/lkml/2015/3/11/9
> 
> cheers

It is on my todo after the install patches are squared away.
It will be applied to next.

-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2015-03-18 14:30 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-11  4:05 [PATCH v4 1/9] kbuild: Don't pass -rR to selftest makefiles Michael Ellerman
2015-03-11  4:05 ` Michael Ellerman
2015-03-11  4:05 ` [PATCH v4 2/9] kbuild: Don't pass LDFLAGS to selftest Makefile Michael Ellerman
2015-03-11  4:05   ` Michael Ellerman
2015-03-11 16:08   ` Shuah Khan
2015-03-11 16:08     ` Shuah Khan
2015-03-13 18:06   ` Shuah Khan
2015-03-13 18:06     ` Shuah Khan
2015-03-11  4:05 ` [PATCH v4 3/9] selftests: Introduce minimal shared logic for running tests Michael Ellerman
2015-03-11  4:05   ` Michael Ellerman
2015-03-13 17:19   ` Shuah Khan
2015-03-13 17:19     ` Shuah Khan
2015-03-13 20:28     ` Shuah Khan
2015-03-13 20:28       ` Shuah Khan
2015-03-11  4:06 ` [PATCH v4 4/9] selftests: Add install target Michael Ellerman
2015-03-11  4:06   ` Michael Ellerman
2015-03-11 13:18   ` Shuah Khan
2015-03-11 16:03     ` Shuah Khan
2015-03-11 16:03       ` Shuah Khan
2015-03-12  3:11       ` Michael Ellerman
2015-03-12  3:11         ` Michael Ellerman
2015-03-12  3:15     ` Michael Ellerman
2015-03-12  3:15       ` Michael Ellerman
2015-03-13 16:33       ` Dave Jones
2015-03-13 16:33         ` Dave Jones
2015-03-13 17:08         ` Shuah Khan
2015-03-13 17:20   ` Shuah Khan
2015-03-13 17:20     ` Shuah Khan
2015-03-13 21:32     ` Shuah Khan
2015-03-13 21:32       ` Shuah Khan
2015-03-13 23:08       ` Shuah Khan
2015-03-13 23:08         ` Shuah Khan
2015-03-16  3:04       ` Michael Ellerman
2015-03-16  3:12         ` Michael Ellerman
2015-03-16  3:12           ` Michael Ellerman
2015-03-18 14:30         ` Shuah Khan
2015-03-18 14:30           ` Shuah Khan
2015-03-11  4:06 ` [PATCH v4 5/9] selftests: Add install support for the powerpc tests Michael Ellerman
2015-03-11  4:06   ` Michael Ellerman
2015-03-11  4:06 ` [PATCH v4 6/9] selftests: Set CC using CROSS_COMPILE once in lib.mk Michael Ellerman
2015-03-11  4:06   ` Michael Ellerman
2015-03-11  4:06 ` [PATCH v4 7/9] selftests/timers: Use implicit rules Michael Ellerman
2015-03-11  4:06   ` Michael Ellerman
2015-03-11  4:06 ` [PATCH v4 8/9] selftests/mqueue: " Michael Ellerman
2015-03-11  4:06   ` Michael Ellerman
2015-03-11  4:06 ` [PATCH v4 9/9] selftests/mount: " Michael Ellerman
2015-03-11  4:06   ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.