All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-10-21 11:01 ` bamvor.zhangjian
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
I fix and test all the TARGET in tools/testing/selftest/Makefile. For
ppc, I test through fake target.

There are six patches in these series. And five of them clean up the
existing code. I split the clean up patches into five, hope it is easy
to review.

selftests: remove duplicated all and clean target
selftests: remove useless TEST_DIRS
selftests: add pattern rules
selftests: remove CROSS_COMPILE in dedicated Makefile
selftests: add EXTRA_CLEAN for clean target
selftests: enable O and KBUILD_OUTPUT

In the first patch, I split the test files into two types:
TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
means there is no need to compile before use. The main reason of this
is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
idea in the end. Because people may puzzle why copy the file before
installation.

Because of the introducing of TEST_GEN_XXX, I update the top-level
Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
could remove all the unnecessary all and clean targets.

The second patch remove TEST_DIRS variable. And third patch add the
pattern for compiling the c sourc code. The fourth patch remove the
useless CROSS_COMPILE variable as it aleady exists in
"tools/testing/selftests/lib.mk".

Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
the duplicated clean target

The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
using the existing kbuild system because user may compile kselftest
directly (make -C tools/testing/selftests).

Bamvor Jian Zhang (6):
  selftests: remove duplicated all and clean target
  selftests: remove useless TEST_DIRS
  selftests: add default rules for c source file
  selftests: remove CROSS_COMPILE in dedicated Makefile
  selftests: add EXTRA_CLEAN for clean target
  selftests: enable O and KBUILD_OUTPUT

 Documentation/kselftest.txt                        | 13 ++++++++
 tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
 tools/testing/selftests/breakpoints/Makefile       |  8 ++---
 tools/testing/selftests/capabilities/Makefile      | 11 ++----
 tools/testing/selftests/efivarfs/Makefile          |  8 +----
 tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
 tools/testing/selftests/ftrace/Makefile            |  6 ++--
 tools/testing/selftests/futex/Makefile             | 21 +++++++++---
 tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
 tools/testing/selftests/ipc/Makefile               |  7 +---
 tools/testing/selftests/kcmp/Makefile              |  6 ++--
 tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
 tools/testing/selftests/membarrier/Makefile        |  6 +---
 tools/testing/selftests/memfd/Makefile             | 15 ++-------
 tools/testing/selftests/mount/Makefile             |  7 +---
 tools/testing/selftests/mqueue/Makefile            |  6 +---
 tools/testing/selftests/net/Makefile               | 10 +-----
 tools/testing/selftests/powerpc/Makefile           | 14 +++++---
 tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
 .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
 .../selftests/powerpc/context_switch/Makefile      |  9 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
 tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
 tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
 tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
 tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
 .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
 .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
 .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
 tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
 tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
 tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
 tools/testing/selftests/pstore/Makefile            |  4 +--
 tools/testing/selftests/ptrace/Makefile            |  8 +----
 tools/testing/selftests/seccomp/Makefile           |  6 +---
 tools/testing/selftests/sigaltstack/Makefile       |  5 +--
 tools/testing/selftests/size/Makefile              | 10 ++----
 tools/testing/selftests/timers/Makefile            | 10 ++----
 tools/testing/selftests/vm/Makefile                | 29 +++++++---------
 tools/testing/selftests/x86/Makefile               | 17 ++++++----
 tools/testing/selftests/zram/Makefile              |  3 +-
 42 files changed, 250 insertions(+), 323 deletions(-)

-- 
1.8.4.5

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

* [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-10-21 11:01 ` bamvor.zhangjian
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
I fix and test all the TARGET in tools/testing/selftest/Makefile. For
ppc, I test through fake target.

There are six patches in these series. And five of them clean up the
existing code. I split the clean up patches into five, hope it is easy
to review.

selftests: remove duplicated all and clean target
selftests: remove useless TEST_DIRS
selftests: add pattern rules
selftests: remove CROSS_COMPILE in dedicated Makefile
selftests: add EXTRA_CLEAN for clean target
selftests: enable O and KBUILD_OUTPUT

In the first patch, I split the test files into two types:
TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
means there is no need to compile before use. The main reason of this
is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
idea in the end. Because people may puzzle why copy the file before
installation.

Because of the introducing of TEST_GEN_XXX, I update the top-level
Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
could remove all the unnecessary all and clean targets.

The second patch remove TEST_DIRS variable. And third patch add the
pattern for compiling the c sourc code. The fourth patch remove the
useless CROSS_COMPILE variable as it aleady exists in
"tools/testing/selftests/lib.mk".

Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
the duplicated clean target

The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
using the existing kbuild system because user may compile kselftest
directly (make -C tools/testing/selftests).

Bamvor Jian Zhang (6):
  selftests: remove duplicated all and clean target
  selftests: remove useless TEST_DIRS
  selftests: add default rules for c source file
  selftests: remove CROSS_COMPILE in dedicated Makefile
  selftests: add EXTRA_CLEAN for clean target
  selftests: enable O and KBUILD_OUTPUT

 Documentation/kselftest.txt                        | 13 ++++++++
 tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
 tools/testing/selftests/breakpoints/Makefile       |  8 ++---
 tools/testing/selftests/capabilities/Makefile      | 11 ++----
 tools/testing/selftests/efivarfs/Makefile          |  8 +----
 tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
 tools/testing/selftests/ftrace/Makefile            |  6 ++--
 tools/testing/selftests/futex/Makefile             | 21 +++++++++---
 tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
 tools/testing/selftests/ipc/Makefile               |  7 +---
 tools/testing/selftests/kcmp/Makefile              |  6 ++--
 tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
 tools/testing/selftests/membarrier/Makefile        |  6 +---
 tools/testing/selftests/memfd/Makefile             | 15 ++-------
 tools/testing/selftests/mount/Makefile             |  7 +---
 tools/testing/selftests/mqueue/Makefile            |  6 +---
 tools/testing/selftests/net/Makefile               | 10 +-----
 tools/testing/selftests/powerpc/Makefile           | 14 +++++---
 tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
 .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
 .../selftests/powerpc/context_switch/Makefile      |  9 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
 tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
 tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
 tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
 tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
 .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
 .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
 .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
 tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
 tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
 tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
 tools/testing/selftests/pstore/Makefile            |  4 +--
 tools/testing/selftests/ptrace/Makefile            |  8 +----
 tools/testing/selftests/seccomp/Makefile           |  6 +---
 tools/testing/selftests/sigaltstack/Makefile       |  5 +--
 tools/testing/selftests/size/Makefile              | 10 ++----
 tools/testing/selftests/timers/Makefile            | 10 ++----
 tools/testing/selftests/vm/Makefile                | 29 +++++++---------
 tools/testing/selftests/x86/Makefile               | 17 ++++++----
 tools/testing/selftests/zram/Makefile              |  3 +-
 42 files changed, 250 insertions(+), 323 deletions(-)

-- 
1.8.4.5

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

* [PATCH RFC 1/6] selftests: remove duplicated all and clean target
  2016-10-21 11:01 ` bamvor.zhangjian
@ 2016-10-21 11:01   ` bamvor.zhangjian
  -1 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
indicate the default test program, extended test program and test files.
These lead to duplicated all and clean targets.

In order to remove them, introduce TEST_GEN_PROGS,
TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
objected.

And add this changes to "Contributing new tests(details)" of
Documentation/kselftest.txt.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 Documentation/kselftest.txt                        | 13 ++++++++++++
 tools/testing/selftests/breakpoints/Makefile       |  8 ++------
 tools/testing/selftests/capabilities/Makefile      | 11 ++--------
 tools/testing/selftests/efivarfs/Makefile          |  8 +-------
 tools/testing/selftests/exec/Makefile              | 10 ++++-----
 tools/testing/selftests/futex/functional/Makefile  | 12 +++--------
 tools/testing/selftests/ipc/Makefile               |  7 +------
 tools/testing/selftests/kcmp/Makefile              |  6 ++----
 tools/testing/selftests/lib.mk                     | 18 ++++++++++++----
 tools/testing/selftests/membarrier/Makefile        |  6 +-----
 tools/testing/selftests/memfd/Makefile             | 14 +++----------
 tools/testing/selftests/mount/Makefile             |  6 ++----
 tools/testing/selftests/mqueue/Makefile            |  6 +-----
 tools/testing/selftests/net/Makefile               |  8 +-------
 tools/testing/selftests/powerpc/alignment/Makefile |  9 ++------
 .../testing/selftests/powerpc/benchmarks/Makefile  | 10 ++++-----
 .../selftests/powerpc/context_switch/Makefile      |  9 ++------
 tools/testing/selftests/powerpc/copyloops/Makefile | 10 ++++-----
 tools/testing/selftests/powerpc/dscr/Makefile      | 12 +++++------
 tools/testing/selftests/powerpc/math/Makefile      | 12 +++++------
 tools/testing/selftests/powerpc/mm/Makefile        | 12 ++++-------
 tools/testing/selftests/powerpc/pmu/Makefile       | 12 +++++------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 11 +++-------
 .../testing/selftests/powerpc/primitives/Makefile  | 10 ++++-----
 .../testing/selftests/powerpc/stringloops/Makefile | 10 ++++-----
 .../selftests/powerpc/switch_endian/Makefile       |  8 +++-----
 tools/testing/selftests/powerpc/syscalls/Makefile  | 10 ++++-----
 tools/testing/selftests/powerpc/tm/Makefile        | 10 ++++-----
 tools/testing/selftests/powerpc/vphn/Makefile      | 10 +++------
 tools/testing/selftests/ptrace/Makefile            |  8 +-------
 tools/testing/selftests/seccomp/Makefile           |  6 +-----
 tools/testing/selftests/sigaltstack/Makefile       |  5 +----
 tools/testing/selftests/size/Makefile              |  6 +-----
 tools/testing/selftests/timers/Makefile            |  9 ++------
 tools/testing/selftests/vm/Makefile                | 24 +++++++++-------------
 35 files changed, 123 insertions(+), 223 deletions(-)

diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
index 54bee77..11cdd06 100644
--- a/Documentation/kselftest.txt
+++ b/Documentation/kselftest.txt
@@ -84,3 +84,16 @@ In general, the rules for selftests are
 
  * Don't cause the top-level "make run_tests" to fail if your feature is
    unconfigured.
+
+Contributing new tests(details)
+===============================
+
+ * Use TEST_GEN_XXX if such binaries or files are generated during
+   compiling.
+   TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
+   default.
+   TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
+   executable which is not tested by default.
+   TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
+   test.
+
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index 74e533f..616f36a 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -3,14 +3,10 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
 ifeq ($(ARCH),x86)
-TEST_PROGS := breakpoint_test
+TEST_GEN_PROGS := breakpoint_test
 endif
 
-TEST_PROGS += step_after_suspend_test
-
-all: $(TEST_PROGS)
+TEST_GEN_PROGS += step_after_suspend_test
 
 include ../lib.mk
 
-clean:
-	rm -fr breakpoint_test step_after_suspend_test
diff --git a/tools/testing/selftests/capabilities/Makefile b/tools/testing/selftests/capabilities/Makefile
index 008602a..29b8adf 100644
--- a/tools/testing/selftests/capabilities/Makefile
+++ b/tools/testing/selftests/capabilities/Makefile
@@ -1,15 +1,8 @@
-TEST_FILES := validate_cap
-TEST_PROGS := test_execve
-
-BINARIES := $(TEST_FILES) $(TEST_PROGS)
+TEST_GEN_FILES := validate_cap
+TEST_GEN_PROGS := test_execve
 
 CFLAGS += -O2 -g -std=gnu99 -Wall
 LDLIBS += -lcap-ng -lrt -ldl
 
-all: $(BINARIES)
-
-clean:
-	$(RM) $(BINARIES)
-
 include ../lib.mk
 
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 736c3dd..c49dcea 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -1,13 +1,7 @@
 CFLAGS = -Wall
 
-test_objs = open-unlink create-read
-
-all: $(test_objs)
-
+TEST_GEN_FILES := open-unlink create-read
 TEST_PROGS := efivarfs.sh
-TEST_FILES := $(test_objs)
 
 include ../lib.mk
 
-clean:
-	rm -f $(test_objs)
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index d430060..b3bf091 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,7 +1,4 @@
 CFLAGS = -Wall
-BINARIES = execveat
-DEPS = execveat.symlink execveat.denatured script subdir
-all: $(BINARIES) $(DEPS)
 
 subdir:
 	mkdir -p $@
@@ -17,11 +14,12 @@ execveat.denatured: execveat
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
 
-TEST_PROGS := execveat
+TEST_GEN_PROGS := execveat
+TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
 # Makefile is a run-time dependency, since it's accessed by the execveat test
-TEST_FILES := $(DEPS) Makefile
+TEST_FILES := Makefile
 
 include ../lib.mk
 
 clean:
-	rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
+	rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 9d6b75e..ac35782 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -3,7 +3,7 @@ CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
 LDFLAGS := $(LDFLAGS) -pthread -lrt
 
 HEADERS := ../include/futextest.h
-TARGETS := \
+TEST_GEN_FILES := \
 	futex_wait_timeout \
 	futex_wait_wouldblock \
 	futex_requeue_pi \
@@ -12,14 +12,8 @@ TARGETS := \
 	futex_wait_uninitialized_heap \
 	futex_wait_private_mapped_file
 
-TEST_PROGS := $(TARGETS) run.sh
-
-.PHONY: all clean
-all: $(TARGETS)
-
-$(TARGETS): $(HEADERS)
+TEST_PROGS := run.sh
 
 include ../../lib.mk
 
-clean:
-	rm -f $(TARGETS)
+$(TEST_GEN_FILES): $(HEADERS)
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 25d2e70..30ef4c7 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -11,12 +11,7 @@ endif
 
 CFLAGS += -I../../../../usr/include/
 
-all:
-	$(CC) $(CFLAGS) msgque.c -o msgque_test
-
-TEST_PROGS := msgque_test
+TEST_GEN_PROGS := msgque
 
 include ../lib.mk
 
-clean:
-	rm -fr ./msgque_test
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 2ae7450..9e8b673 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,10 +1,8 @@
 CFLAGS += -I../../../../usr/include/
 
-all: kcmp_test
-
-TEST_PROGS := kcmp_test
+TEST_GEN_PROGS := kcmp_test
 
 include ../lib.mk
 
 clean:
-	$(RM) kcmp_test kcmp-test-file
+	$(RM) $(TEST_GEN_PROGS) kcmp-test-file
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 50a93f5..12edfb1f 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -3,7 +3,7 @@
 CC := $(CROSS_COMPILE)gcc
 
 define RUN_TESTS
-	@for TEST in $(TEST_PROGS); do \
+	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
 	done;
 endef
@@ -14,8 +14,13 @@ run_tests: all
 define INSTALL_RULE
 	@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then					\
 		mkdir -p ${INSTALL_PATH};										\
-		echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";	\
-		rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;		\
+		echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
+		rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
+	fi
+	@if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then					\
+		mkdir -p ${INSTALL_PATH};										\
+		echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/";	\
+		rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/;		\
 	fi
 endef
 
@@ -27,7 +32,7 @@ else
 endif
 
 define EMIT_TESTS
-	@for TEST in $(TEST_PROGS); do \
+	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
 	done;
 endef
@@ -35,4 +40,9 @@ endef
 emit_tests:
 	$(EMIT_TESTS)
 
+all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+
+clean:
+	$(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+
 .PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile
index a1a9708..0284553 100644
--- a/tools/testing/selftests/membarrier/Makefile
+++ b/tools/testing/selftests/membarrier/Makefile
@@ -1,10 +1,6 @@
 CFLAGS += -g -I../../../../usr/include/
 
-TEST_PROGS := membarrier_test
-
-all: $(TEST_PROGS)
+TEST_GEN_PROGS := membarrier_test
 
 include ../lib.mk
 
-clean:
-	$(RM) $(TEST_PROGS)
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index fd396ac..2c87f23 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -4,19 +4,11 @@ CFLAGS += -I../../../../include/uapi/
 CFLAGS += -I../../../../include/
 CFLAGS += -I../../../../usr/include/
 
-TEST_PROGS := memfd_test
-
-all: $(TEST_PROGS)
-
-include ../lib.mk
-
-build_fuse: fuse_mnt fuse_test
+TEST_PROGS := run_fuse_test.sh
+TEST_GEN_FILES := memfd_test fuse_mnt fuse_test
 
 fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
 fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
 
-run_fuse: build_fuse
-	@./run_fuse_test.sh || echo "fuse_test: [FAIL]"
+include ../lib.mk
 
-clean:
-	$(RM) memfd_test fuse_test
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 5e35c9c..e8fb15e 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -1,14 +1,14 @@
 # Makefile for mount selftests.
 CFLAGS = -Wall \
          -O2
-all: unprivileged-remount-test
 
 unprivileged-remount-test: unprivileged-remount-test.c
 	$(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
 
+TEST_GEN_PROGS := unprivileged-remount-test
+
 include ../lib.mk
 
-TEST_PROGS := unprivileged-remount-test
 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 		      then	\
 				./unprivileged-remount-test ; \
@@ -17,5 +17,3 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 		      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 eebac29..79a664a 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -1,8 +1,6 @@
 CFLAGS += -O2
 LDLIBS = -lrt -lpthread -lpopt
-TEST_PROGS := mq_open_tests mq_perf_tests
-
-all: $(TEST_PROGS)
+TEST_GEN_PROGS := mq_open_tests mq_perf_tests
 
 include ../lib.mk
 
@@ -16,5 +14,3 @@ override define EMIT_TESTS
 	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 0e53407..c976425 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -4,16 +4,10 @@ CFLAGS = -Wall -O2 -g
 
 CFLAGS += -I../../../../usr/include/
 
-NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
-
-all: $(NET_PROGS)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
-
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
-TEST_FILES := $(NET_PROGS)
+TEST_GEN_FILES := socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
 
 include ../lib.mk
 
-clean:
-	$(RM) $(NET_PROGS)
diff --git a/tools/testing/selftests/powerpc/alignment/Makefile b/tools/testing/selftests/powerpc/alignment/Makefile
index ad6a4e4..16b2200 100644
--- a/tools/testing/selftests/powerpc/alignment/Makefile
+++ b/tools/testing/selftests/powerpc/alignment/Makefile
@@ -1,10 +1,5 @@
-TEST_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
-
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
+TEST_GEN_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
 
 include ../../lib.mk
 
-clean:
-	rm -f $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index a9adfb7..985a77c 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -1,16 +1,14 @@
-TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench
+TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench
 
 CFLAGS += -O2
 
-all: $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c
 
-$(TEST_PROGS): ../harness.c
+include ../../lib.mk
 
 context_switch: ../utils.c
 context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
 context_switch: LDLIBS += -lpthread
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/context_switch/Makefile b/tools/testing/selftests/powerpc/context_switch/Makefile
index e164d14..e9351bb 100644
--- a/tools/testing/selftests/powerpc/context_switch/Makefile
+++ b/tools/testing/selftests/powerpc/context_switch/Makefile
@@ -1,10 +1,5 @@
-TEST_PROGS := cp_abort
-
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c ../utils.c
+TEST_GEN_PROGS := cp_abort
 
 include ../../lib.mk
 
-clean:
-	rm -f $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c ../utils.c
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index 384843e..eff1034 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -7,19 +7,17 @@ CFLAGS += -maltivec
 # Use our CFLAGS for the implicit .S rule
 ASFLAGS = $(CFLAGS)
 
-TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
+TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
 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
 
-$(TEST_PROGS): $(EXTRA_SOURCES)
-
-include ../../lib.mk
+$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 49327ee..96e0de0 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -1,14 +1,12 @@
-TEST_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
+TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
 	      dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test	\
 	      dscr_sysfs_thread_test
 
-dscr_default_test: LDLIBS += -lpthread
-
-all: $(TEST_PROGS)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c
+dscr_default_test: LDLIBS += -lpthread
 
-include ../../lib.mk
+$(TEST_GEN_PROGS): ../harness.c
 
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index a505b66..8a5dde5 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -1,9 +1,9 @@
-TEST_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
+TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c
-$(TEST_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
+$(TEST_GEN_PROGS): ../harness.c
+$(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
 
 fpu_syscall: fpu_asm.S
 fpu_preempt: fpu_asm.S
@@ -16,7 +16,5 @@ vmx_signal: vmx_asm.S
 vsx_preempt: CFLAGS += -mvsx
 vsx_preempt: vsx_asm.S
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
index 3bdb96e..d563378 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+++ b/tools/testing/selftests/powerpc/mm/Makefile
@@ -1,19 +1,15 @@
 noarg:
 	$(MAKE) -C ../
 
-TEST_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
-TEST_FILES := tempfile
+TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
+TEST_GEN_FILES := tempfile
 
-all: $(TEST_PROGS) $(TEST_FILES)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c
+$(TEST_GEN_PROGS): ../harness.c
 
 prot_sao: ../utils.c
 
-include ../../lib.mk
-
 tempfile:
 	dd if=/dev/zero of=tempfile bs=64k count=1
 
-clean:
-	rm -f $(TEST_PROGS) tempfile
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index ac41a71..ab0f902 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -1,12 +1,14 @@
 noarg:
 	$(MAKE) -C ../
 
-TEST_PROGS := count_instructions l3_bank_test per_event_excludes
+TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes
 EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c
 
-all: $(TEST_PROGS) ebb
+include ../../lib.mk
+
+all: $(TEST_GEN_PROGS) ebb
 
-$(TEST_PROGS): $(EXTRA_SOURCES)
+$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
 # loop.S can only be built 64-bit
 count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
@@ -14,8 +16,6 @@ count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
 
 per_event_excludes: ../utils.c
 
-include ../../lib.mk
-
 DEFAULT_RUN_TESTS := $(RUN_TESTS)
 override define RUN_TESTS
 	$(DEFAULT_RUN_TESTS)
@@ -35,7 +35,7 @@ override define INSTALL_RULE
 endef
 
 clean:
-	rm -f $(TEST_PROGS) loop.o
+	$(RM) $(TEST_PROGS) loop.o
 	$(MAKE) -C ebb clean
 
 ebb:
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index 6b0453e..8dcedc4 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
 
-TEST_PROGS := reg_access_test event_attributes_test cycles_test	\
+TEST_GEN_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,16 +16,11 @@ TEST_PROGS := reg_access_test event_attributes_test cycles_test	\
 	 lost_exception_test no_handler_test			\
 	 cycles_with_mmcr2_test ebb_lmr ebb_lmr_regs
 
-all: $(TEST_PROGS)
+include ../../../lib.mk
 
-$(TEST_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
+$(TEST_GEN_PROGS): ../../harness.c ../../utils.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
-
-include ../../../lib.mk
-
-clean:
-	rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index b68c622..32cd56c 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -1,12 +1,10 @@
 CFLAGS += -I$(CURDIR)
 
-TEST_PROGS := load_unaligned_zeropad
-
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c
+TEST_GEN_PROGS := load_unaligned_zeropad
 
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): ../harness.c
+
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index 2a728f4..c0ce663 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -2,14 +2,12 @@
 CFLAGS += -m64
 CFLAGS += -I$(CURDIR)
 
-TEST_PROGS := memcmp
+TEST_GEN_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): $(EXTRA_SOURCES)
-
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
+
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
index e21d106..bd01223 100644
--- a/tools/testing/selftests/powerpc/switch_endian/Makefile
+++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
@@ -1,8 +1,8 @@
-TEST_PROGS := switch_endian_test
+TEST_GEN_PROGS := switch_endian_test
 
 ASFLAGS += -O2 -Wall -g -nostdlib -m64
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
 switch_endian_test: check-reversed.S
 
@@ -12,7 +12,5 @@ check-reversed.o: check.o
 check-reversed.S: check-reversed.o
 	hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o check-reversed.S
+	$(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index b35c794..5bea391 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -1,12 +1,10 @@
-TEST_PROGS := ipc_unmuxed
+TEST_GEN_PROGS := ipc_unmuxed
 
 CFLAGS += -I../../../../../usr/include
 
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c
-
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): ../harness.c
+
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index c6c53c8..cad0821 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -1,12 +1,12 @@
 SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu \
 	tm-signal-context-chk-vmx tm-signal-context-chk-vsx
 
-TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
+TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
 	tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c ../utils.c
+$(TEST_GEN_PROGS): ../harness.c ../utils.c
 
 CFLAGS += -mhtm
 
@@ -17,7 +17,5 @@ tm-tmspr: CFLAGS += -pthread
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/vphn/Makefile b/tools/testing/selftests/powerpc/vphn/Makefile
index a485f2e..f8ced26 100644
--- a/tools/testing/selftests/powerpc/vphn/Makefile
+++ b/tools/testing/selftests/powerpc/vphn/Makefile
@@ -1,12 +1,8 @@
-TEST_PROGS := test-vphn
+TEST_GEN_PROGS := test-vphn
 
 CFLAGS += -m64
 
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c
-
 include ../../lib.mk
 
-clean:
-	rm -f $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c
+
diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
index 453927f..8a2bc55 100644
--- a/tools/testing/selftests/ptrace/Makefile
+++ b/tools/testing/selftests/ptrace/Makefile
@@ -1,11 +1,5 @@
 CFLAGS += -iquote../../../../include/uapi -Wall
-peeksiginfo: peeksiginfo.c
 
-all: peeksiginfo
-
-clean:
-	rm -f peeksiginfo
-
-TEST_PROGS := peeksiginfo
+TEST_GEN_PROGS := peeksiginfo
 
 include ../lib.mk
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index 8401e87..5fa6fd2 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -1,10 +1,6 @@
-TEST_PROGS := seccomp_bpf
+TEST_GEN_PROGS := seccomp_bpf
 CFLAGS += -Wl,-no-as-needed -Wall
 LDFLAGS += -lpthread
 
-all: $(TEST_PROGS)
-
 include ../lib.mk
 
-clean:
-	$(RM) $(TEST_PROGS)
diff --git a/tools/testing/selftests/sigaltstack/Makefile b/tools/testing/selftests/sigaltstack/Makefile
index 56af56e..f68fbf8 100644
--- a/tools/testing/selftests/sigaltstack/Makefile
+++ b/tools/testing/selftests/sigaltstack/Makefile
@@ -1,8 +1,5 @@
 CFLAGS = -Wall
-BINARIES = sas
-all: $(BINARIES)
+TEST_GEN_PROGS = sas
 
 include ../lib.mk
 
-clean:
-	rm -rf $(BINARIES)
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index bbd0b53..c67f357 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,11 +1,7 @@
-all: get_size
 
 get_size: get_size.c
 	$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
 
-TEST_PROGS := get_size
+TEST_GEN_PROGS := get_size
 
 include ../lib.mk
-
-clean:
-	$(RM) get_size
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 1d55568..4a3bffe 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -5,16 +5,13 @@ LDFLAGS += -lrt -lpthread
 
 # these are all "safe" tests that don't modify
 # system time or require escalated privledges
-TEST_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
+TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
 	     inconsistency-check raw_skew threadtest rtctest
 
-TEST_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
+TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
 		      skew_consistency clocksource-switch leap-a-day \
 		      leapcrash set-tai set-2038 set-tz
 
-bins = $(TEST_PROGS) $(TEST_PROGS_EXTENDED)
-
-all: ${bins}
 
 include ../lib.mk
 
@@ -34,5 +31,3 @@ run_destructive_tests: run_tests
 	./set-tai
 	./set-2038
 
-clean:
-	rm -f ${bins}
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index bbab7f4..323383a 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,18 +1,17 @@
 # Makefile for vm selftests
 
 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
-BINARIES = compaction_test
-BINARIES += hugepage-mmap
-BINARIES += hugepage-shm
-BINARIES += map_hugetlb
-BINARIES += mlock2-tests
-BINARIES += on-fault-limit
-BINARIES += thuge-gen
-BINARIES += transhuge-stress
-BINARIES += userfaultfd
-BINARIES += mlock-random-test
+TEST_GEN_FILES = compaction_test
+TEST_GEN_FILES += hugepage-mmap
+TEST_GEN_FILES += hugepage-shm
+TEST_GEN_FILES += map_hugetlb
+TEST_GEN_FILES += mlock2-tests
+TEST_GEN_FILES += on-fault-limit
+TEST_GEN_FILES += thuge-gen
+TEST_GEN_FILES += transhuge-stress
+TEST_GEN_FILES += userfaultfd
+TEST_GEN_FILES += mlock-random-test
 
-all: $(BINARIES)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^ -lrt
 userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
@@ -25,9 +24,6 @@ mlock-random-test: mlock-random-test.c
 	make -C ../../../.. headers_install
 
 TEST_PROGS := run_vmtests
-TEST_FILES := $(BINARIES)
 
 include ../lib.mk
 
-clean:
-	$(RM) $(BINARIES)
-- 
1.8.4.5

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

* [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-10-21 11:01   ` bamvor.zhangjian
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
indicate the default test program, extended test program and test files.
These lead to duplicated all and clean targets.

In order to remove them, introduce TEST_GEN_PROGS,
TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
objected.

And add this changes to "Contributing new tests(details)" of
Documentation/kselftest.txt.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 Documentation/kselftest.txt                        | 13 ++++++++++++
 tools/testing/selftests/breakpoints/Makefile       |  8 ++------
 tools/testing/selftests/capabilities/Makefile      | 11 ++--------
 tools/testing/selftests/efivarfs/Makefile          |  8 +-------
 tools/testing/selftests/exec/Makefile              | 10 ++++-----
 tools/testing/selftests/futex/functional/Makefile  | 12 +++--------
 tools/testing/selftests/ipc/Makefile               |  7 +------
 tools/testing/selftests/kcmp/Makefile              |  6 ++----
 tools/testing/selftests/lib.mk                     | 18 ++++++++++++----
 tools/testing/selftests/membarrier/Makefile        |  6 +-----
 tools/testing/selftests/memfd/Makefile             | 14 +++----------
 tools/testing/selftests/mount/Makefile             |  6 ++----
 tools/testing/selftests/mqueue/Makefile            |  6 +-----
 tools/testing/selftests/net/Makefile               |  8 +-------
 tools/testing/selftests/powerpc/alignment/Makefile |  9 ++------
 .../testing/selftests/powerpc/benchmarks/Makefile  | 10 ++++-----
 .../selftests/powerpc/context_switch/Makefile      |  9 ++------
 tools/testing/selftests/powerpc/copyloops/Makefile | 10 ++++-----
 tools/testing/selftests/powerpc/dscr/Makefile      | 12 +++++------
 tools/testing/selftests/powerpc/math/Makefile      | 12 +++++------
 tools/testing/selftests/powerpc/mm/Makefile        | 12 ++++-------
 tools/testing/selftests/powerpc/pmu/Makefile       | 12 +++++------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 11 +++-------
 .../testing/selftests/powerpc/primitives/Makefile  | 10 ++++-----
 .../testing/selftests/powerpc/stringloops/Makefile | 10 ++++-----
 .../selftests/powerpc/switch_endian/Makefile       |  8 +++-----
 tools/testing/selftests/powerpc/syscalls/Makefile  | 10 ++++-----
 tools/testing/selftests/powerpc/tm/Makefile        | 10 ++++-----
 tools/testing/selftests/powerpc/vphn/Makefile      | 10 +++------
 tools/testing/selftests/ptrace/Makefile            |  8 +-------
 tools/testing/selftests/seccomp/Makefile           |  6 +-----
 tools/testing/selftests/sigaltstack/Makefile       |  5 +----
 tools/testing/selftests/size/Makefile              |  6 +-----
 tools/testing/selftests/timers/Makefile            |  9 ++------
 tools/testing/selftests/vm/Makefile                | 24 +++++++++-------------
 35 files changed, 123 insertions(+), 223 deletions(-)

diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
index 54bee77..11cdd06 100644
--- a/Documentation/kselftest.txt
+++ b/Documentation/kselftest.txt
@@ -84,3 +84,16 @@ In general, the rules for selftests are
 
  * Don't cause the top-level "make run_tests" to fail if your feature is
    unconfigured.
+
+Contributing new tests(details)
+===============================
+
+ * Use TEST_GEN_XXX if such binaries or files are generated during
+   compiling.
+   TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
+   default.
+   TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
+   executable which is not tested by default.
+   TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
+   test.
+
diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index 74e533f..616f36a 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -3,14 +3,10 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
 ifeq ($(ARCH),x86)
-TEST_PROGS := breakpoint_test
+TEST_GEN_PROGS := breakpoint_test
 endif
 
-TEST_PROGS += step_after_suspend_test
-
-all: $(TEST_PROGS)
+TEST_GEN_PROGS += step_after_suspend_test
 
 include ../lib.mk
 
-clean:
-	rm -fr breakpoint_test step_after_suspend_test
diff --git a/tools/testing/selftests/capabilities/Makefile b/tools/testing/selftests/capabilities/Makefile
index 008602a..29b8adf 100644
--- a/tools/testing/selftests/capabilities/Makefile
+++ b/tools/testing/selftests/capabilities/Makefile
@@ -1,15 +1,8 @@
-TEST_FILES := validate_cap
-TEST_PROGS := test_execve
-
-BINARIES := $(TEST_FILES) $(TEST_PROGS)
+TEST_GEN_FILES := validate_cap
+TEST_GEN_PROGS := test_execve
 
 CFLAGS += -O2 -g -std=gnu99 -Wall
 LDLIBS += -lcap-ng -lrt -ldl
 
-all: $(BINARIES)
-
-clean:
-	$(RM) $(BINARIES)
-
 include ../lib.mk
 
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 736c3dd..c49dcea 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -1,13 +1,7 @@
 CFLAGS = -Wall
 
-test_objs = open-unlink create-read
-
-all: $(test_objs)
-
+TEST_GEN_FILES := open-unlink create-read
 TEST_PROGS := efivarfs.sh
-TEST_FILES := $(test_objs)
 
 include ../lib.mk
 
-clean:
-	rm -f $(test_objs)
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index d430060..b3bf091 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,7 +1,4 @@
 CFLAGS = -Wall
-BINARIES = execveat
-DEPS = execveat.symlink execveat.denatured script subdir
-all: $(BINARIES) $(DEPS)
 
 subdir:
 	mkdir -p $@
@@ -17,11 +14,12 @@ execveat.denatured: execveat
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
 
-TEST_PROGS := execveat
+TEST_GEN_PROGS := execveat
+TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
 # Makefile is a run-time dependency, since it's accessed by the execveat test
-TEST_FILES := $(DEPS) Makefile
+TEST_FILES := Makefile
 
 include ../lib.mk
 
 clean:
-	rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
+	rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 9d6b75e..ac35782 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -3,7 +3,7 @@ CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
 LDFLAGS := $(LDFLAGS) -pthread -lrt
 
 HEADERS := ../include/futextest.h
-TARGETS := \
+TEST_GEN_FILES := \
 	futex_wait_timeout \
 	futex_wait_wouldblock \
 	futex_requeue_pi \
@@ -12,14 +12,8 @@ TARGETS := \
 	futex_wait_uninitialized_heap \
 	futex_wait_private_mapped_file
 
-TEST_PROGS := $(TARGETS) run.sh
-
-.PHONY: all clean
-all: $(TARGETS)
-
-$(TARGETS): $(HEADERS)
+TEST_PROGS := run.sh
 
 include ../../lib.mk
 
-clean:
-	rm -f $(TARGETS)
+$(TEST_GEN_FILES): $(HEADERS)
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 25d2e70..30ef4c7 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -11,12 +11,7 @@ endif
 
 CFLAGS += -I../../../../usr/include/
 
-all:
-	$(CC) $(CFLAGS) msgque.c -o msgque_test
-
-TEST_PROGS := msgque_test
+TEST_GEN_PROGS := msgque
 
 include ../lib.mk
 
-clean:
-	rm -fr ./msgque_test
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 2ae7450..9e8b673 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,10 +1,8 @@
 CFLAGS += -I../../../../usr/include/
 
-all: kcmp_test
-
-TEST_PROGS := kcmp_test
+TEST_GEN_PROGS := kcmp_test
 
 include ../lib.mk
 
 clean:
-	$(RM) kcmp_test kcmp-test-file
+	$(RM) $(TEST_GEN_PROGS) kcmp-test-file
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 50a93f5..12edfb1f 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -3,7 +3,7 @@
 CC := $(CROSS_COMPILE)gcc
 
 define RUN_TESTS
-	@for TEST in $(TEST_PROGS); do \
+	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
 	done;
 endef
@@ -14,8 +14,13 @@ run_tests: all
 define INSTALL_RULE
 	@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then					\
 		mkdir -p ${INSTALL_PATH};										\
-		echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";	\
-		rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;		\
+		echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
+		rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
+	fi
+	@if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then					\
+		mkdir -p ${INSTALL_PATH};										\
+		echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/";	\
+		rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/;		\
 	fi
 endef
 
@@ -27,7 +32,7 @@ else
 endif
 
 define EMIT_TESTS
-	@for TEST in $(TEST_PROGS); do \
+	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
 	done;
 endef
@@ -35,4 +40,9 @@ endef
 emit_tests:
 	$(EMIT_TESTS)
 
+all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+
+clean:
+	$(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+
 .PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile
index a1a9708..0284553 100644
--- a/tools/testing/selftests/membarrier/Makefile
+++ b/tools/testing/selftests/membarrier/Makefile
@@ -1,10 +1,6 @@
 CFLAGS += -g -I../../../../usr/include/
 
-TEST_PROGS := membarrier_test
-
-all: $(TEST_PROGS)
+TEST_GEN_PROGS := membarrier_test
 
 include ../lib.mk
 
-clean:
-	$(RM) $(TEST_PROGS)
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index fd396ac..2c87f23 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -4,19 +4,11 @@ CFLAGS += -I../../../../include/uapi/
 CFLAGS += -I../../../../include/
 CFLAGS += -I../../../../usr/include/
 
-TEST_PROGS := memfd_test
-
-all: $(TEST_PROGS)
-
-include ../lib.mk
-
-build_fuse: fuse_mnt fuse_test
+TEST_PROGS := run_fuse_test.sh
+TEST_GEN_FILES := memfd_test fuse_mnt fuse_test
 
 fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
 fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
 
-run_fuse: build_fuse
-	@./run_fuse_test.sh || echo "fuse_test: [FAIL]"
+include ../lib.mk
 
-clean:
-	$(RM) memfd_test fuse_test
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 5e35c9c..e8fb15e 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -1,14 +1,14 @@
 # Makefile for mount selftests.
 CFLAGS = -Wall \
          -O2
-all: unprivileged-remount-test
 
 unprivileged-remount-test: unprivileged-remount-test.c
 	$(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
 
+TEST_GEN_PROGS := unprivileged-remount-test
+
 include ../lib.mk
 
-TEST_PROGS := unprivileged-remount-test
 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 		      then	\
 				./unprivileged-remount-test ; \
@@ -17,5 +17,3 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
 		      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 eebac29..79a664a 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -1,8 +1,6 @@
 CFLAGS += -O2
 LDLIBS = -lrt -lpthread -lpopt
-TEST_PROGS := mq_open_tests mq_perf_tests
-
-all: $(TEST_PROGS)
+TEST_GEN_PROGS := mq_open_tests mq_perf_tests
 
 include ../lib.mk
 
@@ -16,5 +14,3 @@ override define EMIT_TESTS
 	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 0e53407..c976425 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -4,16 +4,10 @@ CFLAGS = -Wall -O2 -g
 
 CFLAGS += -I../../../../usr/include/
 
-NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
-
-all: $(NET_PROGS)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^
-
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
-TEST_FILES := $(NET_PROGS)
+TEST_GEN_FILES := socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
 
 include ../lib.mk
 
-clean:
-	$(RM) $(NET_PROGS)
diff --git a/tools/testing/selftests/powerpc/alignment/Makefile b/tools/testing/selftests/powerpc/alignment/Makefile
index ad6a4e4..16b2200 100644
--- a/tools/testing/selftests/powerpc/alignment/Makefile
+++ b/tools/testing/selftests/powerpc/alignment/Makefile
@@ -1,10 +1,5 @@
-TEST_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
-
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
+TEST_GEN_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
 
 include ../../lib.mk
 
-clean:
-	rm -f $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index a9adfb7..985a77c 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -1,16 +1,14 @@
-TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench
+TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench
 
 CFLAGS += -O2
 
-all: $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c
 
-$(TEST_PROGS): ../harness.c
+include ../../lib.mk
 
 context_switch: ../utils.c
 context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
 context_switch: LDLIBS += -lpthread
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/context_switch/Makefile b/tools/testing/selftests/powerpc/context_switch/Makefile
index e164d14..e9351bb 100644
--- a/tools/testing/selftests/powerpc/context_switch/Makefile
+++ b/tools/testing/selftests/powerpc/context_switch/Makefile
@@ -1,10 +1,5 @@
-TEST_PROGS := cp_abort
-
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c ../utils.c
+TEST_GEN_PROGS := cp_abort
 
 include ../../lib.mk
 
-clean:
-	rm -f $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c ../utils.c
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index 384843e..eff1034 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -7,19 +7,17 @@ CFLAGS += -maltivec
 # Use our CFLAGS for the implicit .S rule
 ASFLAGS = $(CFLAGS)
 
-TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
+TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
 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
 
-$(TEST_PROGS): $(EXTRA_SOURCES)
-
-include ../../lib.mk
+$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 49327ee..96e0de0 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -1,14 +1,12 @@
-TEST_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
+TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
 	      dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test	\
 	      dscr_sysfs_thread_test
 
-dscr_default_test: LDLIBS += -lpthread
-
-all: $(TEST_PROGS)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c
+dscr_default_test: LDLIBS += -lpthread
 
-include ../../lib.mk
+$(TEST_GEN_PROGS): ../harness.c
 
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index a505b66..8a5dde5 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -1,9 +1,9 @@
-TEST_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
+TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c
-$(TEST_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
+$(TEST_GEN_PROGS): ../harness.c
+$(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
 
 fpu_syscall: fpu_asm.S
 fpu_preempt: fpu_asm.S
@@ -16,7 +16,5 @@ vmx_signal: vmx_asm.S
 vsx_preempt: CFLAGS += -mvsx
 vsx_preempt: vsx_asm.S
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
index 3bdb96e..d563378 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+++ b/tools/testing/selftests/powerpc/mm/Makefile
@@ -1,19 +1,15 @@
 noarg:
 	$(MAKE) -C ../
 
-TEST_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
-TEST_FILES := tempfile
+TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
+TEST_GEN_FILES := tempfile
 
-all: $(TEST_PROGS) $(TEST_FILES)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c
+$(TEST_GEN_PROGS): ../harness.c
 
 prot_sao: ../utils.c
 
-include ../../lib.mk
-
 tempfile:
 	dd if=/dev/zero of=tempfile bs=64k count=1
 
-clean:
-	rm -f $(TEST_PROGS) tempfile
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index ac41a71..ab0f902 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -1,12 +1,14 @@
 noarg:
 	$(MAKE) -C ../
 
-TEST_PROGS := count_instructions l3_bank_test per_event_excludes
+TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes
 EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c
 
-all: $(TEST_PROGS) ebb
+include ../../lib.mk
+
+all: $(TEST_GEN_PROGS) ebb
 
-$(TEST_PROGS): $(EXTRA_SOURCES)
+$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
 # loop.S can only be built 64-bit
 count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
@@ -14,8 +16,6 @@ count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
 
 per_event_excludes: ../utils.c
 
-include ../../lib.mk
-
 DEFAULT_RUN_TESTS := $(RUN_TESTS)
 override define RUN_TESTS
 	$(DEFAULT_RUN_TESTS)
@@ -35,7 +35,7 @@ override define INSTALL_RULE
 endef
 
 clean:
-	rm -f $(TEST_PROGS) loop.o
+	$(RM) $(TEST_PROGS) loop.o
 	$(MAKE) -C ebb clean
 
 ebb:
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index 6b0453e..8dcedc4 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
 
-TEST_PROGS := reg_access_test event_attributes_test cycles_test	\
+TEST_GEN_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,16 +16,11 @@ TEST_PROGS := reg_access_test event_attributes_test cycles_test	\
 	 lost_exception_test no_handler_test			\
 	 cycles_with_mmcr2_test ebb_lmr ebb_lmr_regs
 
-all: $(TEST_PROGS)
+include ../../../lib.mk
 
-$(TEST_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
+$(TEST_GEN_PROGS): ../../harness.c ../../utils.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
-
-include ../../../lib.mk
-
-clean:
-	rm -f $(TEST_PROGS)
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index b68c622..32cd56c 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -1,12 +1,10 @@
 CFLAGS += -I$(CURDIR)
 
-TEST_PROGS := load_unaligned_zeropad
-
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c
+TEST_GEN_PROGS := load_unaligned_zeropad
 
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): ../harness.c
+
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index 2a728f4..c0ce663 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -2,14 +2,12 @@
 CFLAGS += -m64
 CFLAGS += -I$(CURDIR)
 
-TEST_PROGS := memcmp
+TEST_GEN_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): $(EXTRA_SOURCES)
-
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
+
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
index e21d106..bd01223 100644
--- a/tools/testing/selftests/powerpc/switch_endian/Makefile
+++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
@@ -1,8 +1,8 @@
-TEST_PROGS := switch_endian_test
+TEST_GEN_PROGS := switch_endian_test
 
 ASFLAGS += -O2 -Wall -g -nostdlib -m64
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
 switch_endian_test: check-reversed.S
 
@@ -12,7 +12,5 @@ check-reversed.o: check.o
 check-reversed.S: check-reversed.o
 	hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o check-reversed.S
+	$(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index b35c794..5bea391 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -1,12 +1,10 @@
-TEST_PROGS := ipc_unmuxed
+TEST_GEN_PROGS := ipc_unmuxed
 
 CFLAGS += -I../../../../../usr/include
 
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c
-
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): ../harness.c
+
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index c6c53c8..cad0821 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -1,12 +1,12 @@
 SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu \
 	tm-signal-context-chk-vmx tm-signal-context-chk-vsx
 
-TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
+TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
 	tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
 
-all: $(TEST_PROGS)
+include ../../lib.mk
 
-$(TEST_PROGS): ../harness.c ../utils.c
+$(TEST_GEN_PROGS): ../harness.c ../utils.c
 
 CFLAGS += -mhtm
 
@@ -17,7 +17,5 @@ tm-tmspr: CFLAGS += -pthread
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
 
-include ../../lib.mk
-
 clean:
-	rm -f $(TEST_PROGS) *.o
+	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/vphn/Makefile b/tools/testing/selftests/powerpc/vphn/Makefile
index a485f2e..f8ced26 100644
--- a/tools/testing/selftests/powerpc/vphn/Makefile
+++ b/tools/testing/selftests/powerpc/vphn/Makefile
@@ -1,12 +1,8 @@
-TEST_PROGS := test-vphn
+TEST_GEN_PROGS := test-vphn
 
 CFLAGS += -m64
 
-all: $(TEST_PROGS)
-
-$(TEST_PROGS): ../harness.c
-
 include ../../lib.mk
 
-clean:
-	rm -f $(TEST_PROGS)
+$(TEST_GEN_PROGS): ../harness.c
+
diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
index 453927f..8a2bc55 100644
--- a/tools/testing/selftests/ptrace/Makefile
+++ b/tools/testing/selftests/ptrace/Makefile
@@ -1,11 +1,5 @@
 CFLAGS += -iquote../../../../include/uapi -Wall
-peeksiginfo: peeksiginfo.c
 
-all: peeksiginfo
-
-clean:
-	rm -f peeksiginfo
-
-TEST_PROGS := peeksiginfo
+TEST_GEN_PROGS := peeksiginfo
 
 include ../lib.mk
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index 8401e87..5fa6fd2 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -1,10 +1,6 @@
-TEST_PROGS := seccomp_bpf
+TEST_GEN_PROGS := seccomp_bpf
 CFLAGS += -Wl,-no-as-needed -Wall
 LDFLAGS += -lpthread
 
-all: $(TEST_PROGS)
-
 include ../lib.mk
 
-clean:
-	$(RM) $(TEST_PROGS)
diff --git a/tools/testing/selftests/sigaltstack/Makefile b/tools/testing/selftests/sigaltstack/Makefile
index 56af56e..f68fbf8 100644
--- a/tools/testing/selftests/sigaltstack/Makefile
+++ b/tools/testing/selftests/sigaltstack/Makefile
@@ -1,8 +1,5 @@
 CFLAGS = -Wall
-BINARIES = sas
-all: $(BINARIES)
+TEST_GEN_PROGS = sas
 
 include ../lib.mk
 
-clean:
-	rm -rf $(BINARIES)
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index bbd0b53..c67f357 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,11 +1,7 @@
-all: get_size
 
 get_size: get_size.c
 	$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
 
-TEST_PROGS := get_size
+TEST_GEN_PROGS := get_size
 
 include ../lib.mk
-
-clean:
-	$(RM) get_size
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 1d55568..4a3bffe 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -5,16 +5,13 @@ LDFLAGS += -lrt -lpthread
 
 # these are all "safe" tests that don't modify
 # system time or require escalated privledges
-TEST_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
+TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
 	     inconsistency-check raw_skew threadtest rtctest
 
-TEST_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
+TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
 		      skew_consistency clocksource-switch leap-a-day \
 		      leapcrash set-tai set-2038 set-tz
 
-bins = $(TEST_PROGS) $(TEST_PROGS_EXTENDED)
-
-all: ${bins}
 
 include ../lib.mk
 
@@ -34,5 +31,3 @@ run_destructive_tests: run_tests
 	./set-tai
 	./set-2038
 
-clean:
-	rm -f ${bins}
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index bbab7f4..323383a 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,18 +1,17 @@
 # Makefile for vm selftests
 
 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
-BINARIES = compaction_test
-BINARIES += hugepage-mmap
-BINARIES += hugepage-shm
-BINARIES += map_hugetlb
-BINARIES += mlock2-tests
-BINARIES += on-fault-limit
-BINARIES += thuge-gen
-BINARIES += transhuge-stress
-BINARIES += userfaultfd
-BINARIES += mlock-random-test
+TEST_GEN_FILES = compaction_test
+TEST_GEN_FILES += hugepage-mmap
+TEST_GEN_FILES += hugepage-shm
+TEST_GEN_FILES += map_hugetlb
+TEST_GEN_FILES += mlock2-tests
+TEST_GEN_FILES += on-fault-limit
+TEST_GEN_FILES += thuge-gen
+TEST_GEN_FILES += transhuge-stress
+TEST_GEN_FILES += userfaultfd
+TEST_GEN_FILES += mlock-random-test
 
-all: $(BINARIES)
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $^ -lrt
 userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
@@ -25,9 +24,6 @@ mlock-random-test: mlock-random-test.c
 	make -C ../../../.. headers_install
 
 TEST_PROGS := run_vmtests
-TEST_FILES := $(BINARIES)
 
 include ../lib.mk
 
-clean:
-	$(RM) $(BINARIES)
-- 
1.8.4.5

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

* [PATCH RFC 2/6] selftests: remove useless TEST_DIRS
  2016-10-21 11:01 ` bamvor.zhangjian
@ 2016-10-21 11:01   ` bamvor.zhangjian
  -1 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

The TEST_DIRS was introduced in Commit e8c1d7cdf137 ("selftests: copy
TEST_DIRS to INSTALL_PATH") for coping a whole directory in ftrace.

After rsync(with -a) is introduced by Commit 900d65ee11aa ("selftests:
change install command to rsync"). Rsync could handle the directory
without the definition of TEST_DIRS.

This patch simply replace TEST_DIRS with TEST_FILES in ftrace and remove
the TEST_DIRS in tools/testing/selftest/lib.mk

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/ftrace/Makefile | 2 +-
 tools/testing/selftests/lib.mk          | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 4e6ed13..a715300 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -1,7 +1,7 @@
 all:
 
 TEST_PROGS := ftracetest
-TEST_DIRS := test.d
+TEST_FILES := test.d
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 12edfb1f..8c0440d 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -14,8 +14,8 @@ run_tests: all
 define INSTALL_RULE
 	@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then					\
 		mkdir -p ${INSTALL_PATH};										\
-		echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
-		rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
+		echo "rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";	\
+		rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;		\
 	fi
 	@if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then					\
 		mkdir -p ${INSTALL_PATH};										\
-- 
1.8.4.5

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

* [PATCH RFC 2/6] selftests: remove useless TEST_DIRS
@ 2016-10-21 11:01   ` bamvor.zhangjian
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

The TEST_DIRS was introduced in Commit e8c1d7cdf137 ("selftests: copy
TEST_DIRS to INSTALL_PATH") for coping a whole directory in ftrace.

After rsync(with -a) is introduced by Commit 900d65ee11aa ("selftests:
change install command to rsync"). Rsync could handle the directory
without the definition of TEST_DIRS.

This patch simply replace TEST_DIRS with TEST_FILES in ftrace and remove
the TEST_DIRS in tools/testing/selftest/lib.mk

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/ftrace/Makefile | 2 +-
 tools/testing/selftests/lib.mk          | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 4e6ed13..a715300 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -1,7 +1,7 @@
 all:
 
 TEST_PROGS := ftracetest
-TEST_DIRS := test.d
+TEST_FILES := test.d
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 12edfb1f..8c0440d 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -14,8 +14,8 @@ run_tests: all
 define INSTALL_RULE
 	@if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then					\
 		mkdir -p ${INSTALL_PATH};										\
-		echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
-		rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
+		echo "rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";	\
+		rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;		\
 	fi
 	@if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then					\
 		mkdir -p ${INSTALL_PATH};										\
-- 
1.8.4.5

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

* [PATCH RFC 3/6] selftests: add default rules for c source file
@ 2016-10-21 11:01   ` bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

There are difference rules for compiling c source file in different
testcases. In order to enable KBUILD_OUTPUT support in later patch,
this patch introduce the default rules in
"tools/testing/selftest/lib.mk" and remove the existing rules in each
testcase.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/exec/Makefile  | 2 --
 tools/testing/selftests/lib.mk         | 3 +++
 tools/testing/selftests/mount/Makefile | 3 ---
 tools/testing/selftests/net/Makefile   | 2 --
 tools/testing/selftests/size/Makefile  | 4 +---
 tools/testing/selftests/vm/Makefile    | 3 +--
 6 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index b3bf091..9eb1c3e 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -11,8 +11,6 @@ execveat.symlink: execveat
 execveat.denatured: execveat
 	cp $< $@
 	chmod -x $@
-%: %.c
-	$(CC) $(CFLAGS) -o $@ $^
 
 TEST_GEN_PROGS := execveat
 TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 8c0440d..9ccec4b 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -45,4 +45,7 @@ all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 clean:
 	$(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 
+%: %.c
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
+
 .PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index e8fb15e..9093d7f 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -2,9 +2,6 @@
 CFLAGS = -Wall \
          -O2
 
-unprivileged-remount-test: unprivileged-remount-test.c
-	$(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
-
 TEST_GEN_PROGS := unprivileged-remount-test
 
 include ../lib.mk
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index c976425..d13620a 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -4,8 +4,6 @@ CFLAGS = -Wall -O2 -g
 
 CFLAGS += -I../../../../usr/include/
 
-%: %.c
-	$(CC) $(CFLAGS) -o $@ $^
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
 TEST_GEN_FILES := socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
 
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index c67f357..4685b3e 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,6 +1,4 @@
-
-get_size: get_size.c
-	$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
+CFLAGS := -static -ffreestanding -nostartfiles -s
 
 TEST_GEN_PROGS := get_size
 
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 323383a..eb0aaff 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,6 +1,7 @@
 # Makefile for vm selftests
 
 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
+LDLIBS = -lrt
 TEST_GEN_FILES = compaction_test
 TEST_GEN_FILES += hugepage-mmap
 TEST_GEN_FILES += hugepage-shm
@@ -12,8 +13,6 @@ TEST_GEN_FILES += transhuge-stress
 TEST_GEN_FILES += userfaultfd
 TEST_GEN_FILES += mlock-random-test
 
-%: %.c
-	$(CC) $(CFLAGS) -o $@ $^ -lrt
 userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
 	$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
-- 
1.8.4.5

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

* [PATCH RFC 3/6] selftests: add default rules for c source file
@ 2016-10-21 11:01   ` bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	mpe-Gsx/Oe8HsFggBc27wqDAHg

From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

There are difference rules for compiling c source file in different
testcases. In order to enable KBUILD_OUTPUT support in later patch,
this patch introduce the default rules in
"tools/testing/selftest/lib.mk" and remove the existing rules in each
testcase.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 tools/testing/selftests/exec/Makefile  | 2 --
 tools/testing/selftests/lib.mk         | 3 +++
 tools/testing/selftests/mount/Makefile | 3 ---
 tools/testing/selftests/net/Makefile   | 2 --
 tools/testing/selftests/size/Makefile  | 4 +---
 tools/testing/selftests/vm/Makefile    | 3 +--
 6 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index b3bf091..9eb1c3e 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -11,8 +11,6 @@ execveat.symlink: execveat
 execveat.denatured: execveat
 	cp $< $@
 	chmod -x $@
-%: %.c
-	$(CC) $(CFLAGS) -o $@ $^
 
 TEST_GEN_PROGS := execveat
 TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 8c0440d..9ccec4b 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -45,4 +45,7 @@ all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 clean:
 	$(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 
+%: %.c
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
+
 .PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index e8fb15e..9093d7f 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -2,9 +2,6 @@
 CFLAGS = -Wall \
          -O2
 
-unprivileged-remount-test: unprivileged-remount-test.c
-	$(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
-
 TEST_GEN_PROGS := unprivileged-remount-test
 
 include ../lib.mk
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index c976425..d13620a 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -4,8 +4,6 @@ CFLAGS = -Wall -O2 -g
 
 CFLAGS += -I../../../../usr/include/
 
-%: %.c
-	$(CC) $(CFLAGS) -o $@ $^
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
 TEST_GEN_FILES := socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
 
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index c67f357..4685b3e 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,6 +1,4 @@
-
-get_size: get_size.c
-	$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
+CFLAGS := -static -ffreestanding -nostartfiles -s
 
 TEST_GEN_PROGS := get_size
 
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 323383a..eb0aaff 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,6 +1,7 @@
 # Makefile for vm selftests
 
 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
+LDLIBS = -lrt
 TEST_GEN_FILES = compaction_test
 TEST_GEN_FILES += hugepage-mmap
 TEST_GEN_FILES += hugepage-shm
@@ -12,8 +13,6 @@ TEST_GEN_FILES += transhuge-stress
 TEST_GEN_FILES += userfaultfd
 TEST_GEN_FILES += mlock-random-test
 
-%: %.c
-	$(CC) $(CFLAGS) -o $@ $^ -lrt
 userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
 	$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
-- 
1.8.4.5

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

* [PATCH RFC 4/6] selftests: remove CROSS_COMPILE in dedicated Makefile
  2016-10-21 11:01 ` bamvor.zhangjian
@ 2016-10-21 11:01   ` bamvor.zhangjian
  -1 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

After previous clean up patches, memfd and timers could get
CROSS_COMPILE from tools/testing/selftest/lib.mk. There is no need to
preserve these definition. So, this patch remove them.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/memfd/Makefile  | 1 -
 tools/testing/selftests/timers/Makefile | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 2c87f23..79891d0 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += -I../../../../include/uapi/
 CFLAGS += -I../../../../include/
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 4a3bffe..b90e50c 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 BUILD_FLAGS = -DKTEST
 CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS)
 LDFLAGS += -lrt -lpthread
-- 
1.8.4.5

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

* [PATCH RFC 4/6] selftests: remove CROSS_COMPILE in dedicated Makefile
@ 2016-10-21 11:01   ` bamvor.zhangjian
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

After previous clean up patches, memfd and timers could get
CROSS_COMPILE from tools/testing/selftest/lib.mk. There is no need to
preserve these definition. So, this patch remove them.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/memfd/Makefile  | 1 -
 tools/testing/selftests/timers/Makefile | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 2c87f23..79891d0 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += -I../../../../include/uapi/
 CFLAGS += -I../../../../include/
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index 4a3bffe..b90e50c 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,4 +1,3 @@
-CC = $(CROSS_COMPILE)gcc
 BUILD_FLAGS = -DKTEST
 CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS)
 LDFLAGS += -lrt -lpthread
-- 
1.8.4.5

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

* [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
@ 2016-10-21 11:01   ` bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Some testcases need the clean extra data after running. This patch
introduce the "EXTRA_CLEAN" variable to address this requirement.

After KOUTPUT_BUILD is enabled in later patch, it will be easy to
decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
testcase ran immediately after compiled.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/exec/Makefile                 | 19 +++++++++----------
 tools/testing/selftests/ftrace/Makefile               |  4 +---
 tools/testing/selftests/kcmp/Makefile                 |  4 ++--
 tools/testing/selftests/lib.mk                        |  2 +-
 tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
 tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
 tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
 tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
 tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
 .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---
 tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
 tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---
 tools/testing/selftests/pstore/Makefile               |  4 +---
 tools/testing/selftests/zram/Makefile                 |  3 +--
 15 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 9eb1c3e..48d1f86 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,5 +1,14 @@
 CFLAGS = -Wall
 
+TEST_GEN_PROGS := execveat
+TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
+# Makefile is a run-time dependency, since it's accessed by the execveat test
+TEST_FILES := Makefile
+
+EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
+
+include ../lib.mk
+
 subdir:
 	mkdir -p $@
 script:
@@ -11,13 +20,3 @@ execveat.symlink: execveat
 execveat.denatured: execveat
 	cp $< $@
 	chmod -x $@
-
-TEST_GEN_PROGS := execveat
-TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
-# Makefile is a run-time dependency, since it's accessed by the execveat test
-TEST_FILES := Makefile
-
-include ../lib.mk
-
-clean:
-	rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index a715300..6c64b42 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -2,8 +2,6 @@ all:
 
 TEST_PROGS := ftracetest
 TEST_FILES := test.d
+EXTRA_CLEAN := logs/*
 
 include ../lib.mk
-
-clean:
-	rm -rf logs/*
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 9e8b673..74a8add 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -I../../../../usr/include/
 
 TEST_GEN_PROGS := kcmp_test
 
+EXTRA_CLEAN := kcmp-test-file
+
 include ../lib.mk
 
-clean:
-	$(RM) $(TEST_GEN_PROGS) kcmp-test-file
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 9ccec4b..0f7a371 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -43,7 +43,7 @@ emit_tests:
 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 
 clean:
-	$(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 
 %: %.c
 	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 985a77c..1f94b31 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -4,11 +4,10 @@ CFLAGS += -O2
 
 $(TEST_GEN_PROGS): ../harness.c
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 context_switch: ../utils.c
 context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
 context_switch: LDLIBS += -lpthread
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index eff1034..a768179 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -9,6 +9,7 @@ ASFLAGS = $(CFLAGS)
 
 TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
+EXTRA_CLEAN := *.o
 
 include ../../lib.mk
 
@@ -19,5 +20,3 @@ memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
 
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 96e0de0..7b43ac3 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -2,11 +2,11 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
 	      dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test	\
 	      dscr_sysfs_thread_test
 
+EXTRA_CLEAN := *.o
+
 include ../../lib.mk
 
 dscr_default_test: LDLIBS += -lpthread
 
 $(TEST_GEN_PROGS): ../harness.c
 
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index 8a5dde5..9aa9b22 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -1,5 +1,7 @@
 TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
@@ -15,6 +17,3 @@ vmx_signal: vmx_asm.S
 
 vsx_preempt: CFLAGS += -mvsx
 vsx_preempt: vsx_asm.S
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index 32cd56c..681627d 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -2,9 +2,8 @@ CFLAGS += -I$(CURDIR)
 
 TEST_GEN_PROGS := load_unaligned_zeropad
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index c0ce663..166fdb8 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -5,9 +5,8 @@ CFLAGS += -I$(CURDIR)
 TEST_GEN_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
index bd01223..dbd05ac 100644
--- a/tools/testing/selftests/powerpc/switch_endian/Makefile
+++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
@@ -2,6 +2,8 @@ TEST_GEN_PROGS := switch_endian_test
 
 ASFLAGS += -O2 -Wall -g -nostdlib -m64
 
+EXTRA_CLEAN = *.o check-reversed.S
+
 include ../../lib.mk
 
 switch_endian_test: check-reversed.S
@@ -11,6 +13,3 @@ check-reversed.o: check.o
 
 check-reversed.S: check-reversed.o
 	hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index 5bea391..1590938 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -2,9 +2,8 @@ TEST_GEN_PROGS := ipc_unmuxed
 
 CFLAGS += -I../../../../../usr/include
 
+EXTRAN_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index cad0821..0ad4674 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -4,6 +4,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
 TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
 	tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c
@@ -16,6 +18,3 @@ tm-tmspr: CFLAGS += -pthread
 
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/selftests/pstore/Makefile
index bd7abe2..c5f2440 100644
--- a/tools/testing/selftests/pstore/Makefile
+++ b/tools/testing/selftests/pstore/Makefile
@@ -5,11 +5,9 @@ all:
 
 TEST_PROGS := pstore_tests pstore_post_reboot_tests
 TEST_FILES := common_tests pstore_crash_test
+EXTRA_CLEAN := logs/* *uuid
 
 include ../lib.mk
 
 run_crash:
 	@sh pstore_crash_test || { echo "pstore_crash_test: [FAIL]"; exit 1; }
-
-clean:
-	rm -rf logs/* *uuid
diff --git a/tools/testing/selftests/zram/Makefile b/tools/testing/selftests/zram/Makefile
index 29d8034..c3a87e5 100644
--- a/tools/testing/selftests/zram/Makefile
+++ b/tools/testing/selftests/zram/Makefile
@@ -2,8 +2,7 @@ all:
 
 TEST_PROGS := zram.sh
 TEST_FILES := zram01.sh zram02.sh zram_lib.sh
+EXTRA_CLEAN := err.log
 
 include ../lib.mk
 
-clean:
-	$(RM) err.log
-- 
1.8.4.5

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

* [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
@ 2016-10-21 11:01   ` bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	mpe-Gsx/Oe8HsFggBc27wqDAHg

From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Some testcases need the clean extra data after running. This patch
introduce the "EXTRA_CLEAN" variable to address this requirement.

After KOUTPUT_BUILD is enabled in later patch, it will be easy to
decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
testcase ran immediately after compiled.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 tools/testing/selftests/exec/Makefile                 | 19 +++++++++----------
 tools/testing/selftests/ftrace/Makefile               |  4 +---
 tools/testing/selftests/kcmp/Makefile                 |  4 ++--
 tools/testing/selftests/lib.mk                        |  2 +-
 tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
 tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
 tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
 tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
 tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
 .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---
 tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
 tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---
 tools/testing/selftests/pstore/Makefile               |  4 +---
 tools/testing/selftests/zram/Makefile                 |  3 +--
 15 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 9eb1c3e..48d1f86 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,5 +1,14 @@
 CFLAGS = -Wall
 
+TEST_GEN_PROGS := execveat
+TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
+# Makefile is a run-time dependency, since it's accessed by the execveat test
+TEST_FILES := Makefile
+
+EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
+
+include ../lib.mk
+
 subdir:
 	mkdir -p $@
 script:
@@ -11,13 +20,3 @@ execveat.symlink: execveat
 execveat.denatured: execveat
 	cp $< $@
 	chmod -x $@
-
-TEST_GEN_PROGS := execveat
-TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
-# Makefile is a run-time dependency, since it's accessed by the execveat test
-TEST_FILES := Makefile
-
-include ../lib.mk
-
-clean:
-	rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index a715300..6c64b42 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -2,8 +2,6 @@ all:
 
 TEST_PROGS := ftracetest
 TEST_FILES := test.d
+EXTRA_CLEAN := logs/*
 
 include ../lib.mk
-
-clean:
-	rm -rf logs/*
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 9e8b673..74a8add 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -I../../../../usr/include/
 
 TEST_GEN_PROGS := kcmp_test
 
+EXTRA_CLEAN := kcmp-test-file
+
 include ../lib.mk
 
-clean:
-	$(RM) $(TEST_GEN_PROGS) kcmp-test-file
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 9ccec4b..0f7a371 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -43,7 +43,7 @@ emit_tests:
 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 
 clean:
-	$(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
+	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 
 %: %.c
 	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 985a77c..1f94b31 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -4,11 +4,10 @@ CFLAGS += -O2
 
 $(TEST_GEN_PROGS): ../harness.c
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 context_switch: ../utils.c
 context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
 context_switch: LDLIBS += -lpthread
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index eff1034..a768179 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -9,6 +9,7 @@ ASFLAGS = $(CFLAGS)
 
 TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
+EXTRA_CLEAN := *.o
 
 include ../../lib.mk
 
@@ -19,5 +20,3 @@ memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
 
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 96e0de0..7b43ac3 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -2,11 +2,11 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
 	      dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test	\
 	      dscr_sysfs_thread_test
 
+EXTRA_CLEAN := *.o
+
 include ../../lib.mk
 
 dscr_default_test: LDLIBS += -lpthread
 
 $(TEST_GEN_PROGS): ../harness.c
 
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index 8a5dde5..9aa9b22 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -1,5 +1,7 @@
 TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
@@ -15,6 +17,3 @@ vmx_signal: vmx_asm.S
 
 vsx_preempt: CFLAGS += -mvsx
 vsx_preempt: vsx_asm.S
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index 32cd56c..681627d 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -2,9 +2,8 @@ CFLAGS += -I$(CURDIR)
 
 TEST_GEN_PROGS := load_unaligned_zeropad
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index c0ce663..166fdb8 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -5,9 +5,8 @@ CFLAGS += -I$(CURDIR)
 TEST_GEN_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
index bd01223..dbd05ac 100644
--- a/tools/testing/selftests/powerpc/switch_endian/Makefile
+++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
@@ -2,6 +2,8 @@ TEST_GEN_PROGS := switch_endian_test
 
 ASFLAGS += -O2 -Wall -g -nostdlib -m64
 
+EXTRA_CLEAN = *.o check-reversed.S
+
 include ../../lib.mk
 
 switch_endian_test: check-reversed.S
@@ -11,6 +13,3 @@ check-reversed.o: check.o
 
 check-reversed.S: check-reversed.o
 	hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index 5bea391..1590938 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -2,9 +2,8 @@ TEST_GEN_PROGS := ipc_unmuxed
 
 CFLAGS += -I../../../../../usr/include
 
+EXTRAN_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index cad0821..0ad4674 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -4,6 +4,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
 TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
 	tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
 
+EXTRA_CLEAN = *.o
+
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c
@@ -16,6 +18,3 @@ tm-tmspr: CFLAGS += -pthread
 
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
-
-clean:
-	$(RM) $(TEST_GEN_PROGS) *.o
diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/selftests/pstore/Makefile
index bd7abe2..c5f2440 100644
--- a/tools/testing/selftests/pstore/Makefile
+++ b/tools/testing/selftests/pstore/Makefile
@@ -5,11 +5,9 @@ all:
 
 TEST_PROGS := pstore_tests pstore_post_reboot_tests
 TEST_FILES := common_tests pstore_crash_test
+EXTRA_CLEAN := logs/* *uuid
 
 include ../lib.mk
 
 run_crash:
 	@sh pstore_crash_test || { echo "pstore_crash_test: [FAIL]"; exit 1; }
-
-clean:
-	rm -rf logs/* *uuid
diff --git a/tools/testing/selftests/zram/Makefile b/tools/testing/selftests/zram/Makefile
index 29d8034..c3a87e5 100644
--- a/tools/testing/selftests/zram/Makefile
+++ b/tools/testing/selftests/zram/Makefile
@@ -2,8 +2,7 @@ all:
 
 TEST_PROGS := zram.sh
 TEST_FILES := zram01.sh zram02.sh zram_lib.sh
+EXTRA_CLEAN := err.log
 
 include ../lib.mk
 
-clean:
-	$(RM) err.log
-- 
1.8.4.5

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

* [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT
  2016-10-21 11:01 ` bamvor.zhangjian
@ 2016-10-21 11:01   ` bamvor.zhangjian
  -1 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
to another directory by passing O or KBUILD_OUTPUT. And O is high
priority than KBUILD_OUTPUT.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
 tools/testing/selftests/exec/Makefile              | 13 ++++----
 tools/testing/selftests/ftrace/Makefile            |  2 +-
 tools/testing/selftests/futex/Makefile             | 21 +++++++++---
 tools/testing/selftests/kcmp/Makefile              |  2 +-
 tools/testing/selftests/lib.mk                     | 19 ++++++++---
 tools/testing/selftests/powerpc/Makefile           | 14 +++++---
 .../testing/selftests/powerpc/benchmarks/Makefile  |  8 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile | 10 +++---
 tools/testing/selftests/powerpc/dscr/Makefile      |  5 ++-
 tools/testing/selftests/powerpc/math/Makefile      | 14 ++++----
 tools/testing/selftests/powerpc/mm/Makefile        |  6 ++--
 tools/testing/selftests/powerpc/pmu/Makefile       | 16 ++++-----
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   |  4 +--
 .../testing/selftests/powerpc/primitives/Makefile  |  2 +-
 .../testing/selftests/powerpc/stringloops/Makefile |  2 +-
 .../selftests/powerpc/switch_endian/Makefile       |  8 ++---
 tools/testing/selftests/powerpc/syscalls/Makefile  |  2 +-
 tools/testing/selftests/powerpc/tm/Makefile        |  8 ++---
 tools/testing/selftests/vm/Makefile                |  2 +-
 tools/testing/selftests/x86/Makefile               | 17 ++++++----
 21 files changed, 132 insertions(+), 82 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index a3144a3..79c5e97 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -47,29 +47,47 @@ override LDFLAGS =
 override MAKEFLAGS =
 endif
 
+ifeq ($(O)$(KBUILD_OUTPUT),)
+        BUILD :=$(shell pwd)
+else
+        ifneq ($(O),)
+                BUILD := $(O)
+        else
+                ifneq ($(KBUILD_OUTPUT),)
+                        BUILD := $(KBUILD_OUTPUT)
+                endif
+        endif
+endif
+export BUILD
 all:
-	for TARGET in $(TARGETS); do \
-		make -C $$TARGET; \
+	for TARGET in $(TARGETS); do		\
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET;\
 	done;
 
 run_tests: all
 	for TARGET in $(TARGETS); do \
-		make -C $$TARGET run_tests; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_tests;\
 	done;
 
 hotplug:
 	for TARGET in $(TARGETS_HOTPLUG); do \
-		make -C $$TARGET; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET;\
 	done;
 
 run_hotplug: hotplug
 	for TARGET in $(TARGETS_HOTPLUG); do \
-		make -C $$TARGET run_full_test; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_full_test;\
 	done;
 
 clean_hotplug:
 	for TARGET in $(TARGETS_HOTPLUG); do \
-		make -C $$TARGET clean; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean;\
 	done;
 
 run_pstore_crash:
@@ -84,7 +102,8 @@ ifdef INSTALL_PATH
 	@# Ask all targets to install their files
 	mkdir -p $(INSTALL_PATH)
 	for TARGET in $(TARGETS); do \
-		make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
 	done;
 
 	@# Ask all targets to emit their test scripts
@@ -93,10 +112,11 @@ ifdef INSTALL_PATH
 	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
 
 	for TARGET in $(TARGETS); do \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
 		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); \
+		make -s --no-print-directory OUTPUT=$$BUILD_TARGET/ -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
 		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
 	done;
 
@@ -107,7 +127,8 @@ endif
 
 clean:
 	for TARGET in $(TARGETS); do \
-		make -C $$TARGET clean; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean;\
 	done;
 
 .PHONY: install
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 48d1f86..fe5cdec 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -5,18 +5,19 @@ TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
 # Makefile is a run-time dependency, since it's accessed by the execveat test
 TEST_FILES := Makefile
 
-EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
+EXTRA_CLEAN := $(OUTPUT)subdir.moved $(OUTPUT)execveat.moved $(OUTPUT)xxxxx*
 
 include ../lib.mk
 
-subdir:
+$(OUTPUT)subdir:
 	mkdir -p $@
-script:
+$(OUTPUT)script:
 	echo '#!/bin/sh' > $@
 	echo 'exit $$*' >> $@
 	chmod +x $@
-execveat.symlink: execveat
-	ln -s -f $< $@
-execveat.denatured: execveat
+$(OUTPUT)execveat.symlink: execveat
+	cd $(OUTPUT) && ln -s -f $< `basename $@`
+$(OUTPUT)execveat.denatured: execveat
 	cp $< $@
 	chmod -x $@
+
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 6c64b42..33bb29b 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -2,6 +2,6 @@ all:
 
 TEST_PROGS := ftracetest
 TEST_FILES := test.d
-EXTRA_CLEAN := logs/*
+EXTRA_CLEAN := $(OUTPUT)logs/*
 
 include ../lib.mk
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile
index 6a17529..12a3ae2 100644
--- a/tools/testing/selftests/futex/Makefile
+++ b/tools/testing/selftests/futex/Makefile
@@ -3,13 +3,18 @@ SUBDIRS := functional
 TEST_PROGS := run.sh
 
 .PHONY: all clean
-all:
-	for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done
 
 include ../lib.mk
 
+all:
+	for DIR in $(SUBDIRS); do		\
+		BUILD_TARGET=$$OUTPUT/$$DIR;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$DIR $@;\
+	done
+
 override define RUN_TESTS
-	./run.sh
+	@if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi
 endef
 
 override define INSTALL_RULE
@@ -17,7 +22,9 @@ override define INSTALL_RULE
 	install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
 
 	@for SUBDIR in $(SUBDIRS); do \
-		$(MAKE) -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \
+		BUILD_TARGET=$$OUTPUT/$$SUBDIR;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \
 	done;
 endef
 
@@ -26,4 +33,8 @@ override define EMIT_TESTS
 endef
 
 clean:
-	for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done
+	for DIR in $(SUBDIRS); do		\
+		BUILD_TARGET=$$OUTPUT/$$DIR;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$DIR $@;\
+	done
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 74a8add..0fb599e 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -I../../../../usr/include/
 
 TEST_GEN_PROGS := kcmp_test
 
-EXTRA_CLEAN := kcmp-test-file
+EXTRA_CLEAN := $(OUTPUT)kcmp-test-file
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 0f7a371..fa87f98 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -4,7 +4,8 @@ CC := $(CROSS_COMPILE)gcc
 
 define RUN_TESTS
 	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
-		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
+		BASENAME_TEST=`basename $$TEST`;	\
+		cd `dirname $$TEST`; (./$$BASENAME_TEST && echo "selftests: $$BASENAME_TEST [PASS]") || echo "selftests:  $$BASENAME_TEST [FAIL]"; cd -;\
 	done;
 endef
 
@@ -33,19 +34,29 @@ endif
 
 define EMIT_TESTS
 	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
-		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
+		BASENAME_TEST=`basename $$TEST`;	\
+		echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
 	done;
 endef
 
 emit_tests:
 	$(EMIT_TESTS)
 
+TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_PROGS))
+TEST_GEN_FILES := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_FILES))
+
 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 
 clean:
 	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 
-%: %.c
-	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
+$(OUTPUT)%:%.c
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
+
+$(OUTPUT)%.o:%.S
+	$(CC) $(ASFLAGS) -c $< -o $@
+
+$(OUTPUT)%:%.S
+	$(CC) $(ASFLAGS) $< -o $@
 
 .PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index db54a33..e99a28c 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -33,31 +33,35 @@ endif
 all: $(SUB_DIRS)
 
 $(SUB_DIRS):
-	$(MAKE) -k -C $@ all
+	BUILD_TARGET=$$OUTPUT/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -k -C $@ all
 
 include ../lib.mk
 
 override define RUN_TESTS
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -C $$TARGET run_tests; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_tests;\
 	done;
 endef
 
 override define INSTALL_RULE
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -C $$TARGET install; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET install;\
 	done;
 endef
 
 override define EMIT_TESTS
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -s -C $$TARGET emit_tests; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -s -C $$TARGET emit_tests;\
 	done;
 endef
 
 clean:
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -C $$TARGET clean; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean;\
 	done;
 	rm -f tags
 
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 1f94b31..3f6552c 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -4,10 +4,10 @@ CFLAGS += -O2
 
 $(TEST_GEN_PROGS): ../harness.c
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
-context_switch: ../utils.c
-context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
-context_switch: LDLIBS += -lpthread
+$(OUTPUT)context_switch: ../utils.c
+$(OUTPUT)context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
+$(OUTPUT)context_switch: LDLIBS += -lpthread
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index a768179..07b0307 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -9,14 +9,14 @@ ASFLAGS = $(CFLAGS)
 
 TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
-EXTRA_CLEAN := *.o
+EXTRA_CLEAN := $(OUTPUT)*.o
 
 include ../../lib.mk
 
-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
+$(OUTPUT)copyuser_64:     CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base
+$(OUTPUT)copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7
+$(OUTPUT)memcpy_64:       CPPFLAGS += -D COPY_LOOP=test_memcpy
+$(OUTPUT)memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
 
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 7b43ac3..1df5da5 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -2,11 +2,10 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
 	      dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test	\
 	      dscr_sysfs_thread_test
 
-EXTRA_CLEAN := *.o
+EXTRA_CLEAN := $(OUTPUT)*.o
 
 include ../../lib.mk
 
-dscr_default_test: LDLIBS += -lpthread
+$(OUTPUT)dscr_default_test: LDLIBS += -lpthread
 
 $(TEST_GEN_PROGS): ../harness.c
-
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index 9aa9b22..3587df8 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -1,19 +1,19 @@
 TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
 $(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
 
-fpu_syscall: fpu_asm.S
-fpu_preempt: fpu_asm.S
-fpu_signal:  fpu_asm.S
+$(OUTPUT)pu_syscall: fpu_asm.S
+$(OUTPUT)pu_preempt: fpu_asm.S
+$(OUTPUT)pu_signal:  fpu_asm.S
 
-vmx_syscall: vmx_asm.S
-vmx_preempt: vmx_asm.S
-vmx_signal: vmx_asm.S
+$(OUTPUT)mx_syscall: vmx_asm.S
+$(OUTPUT)mx_preempt: vmx_asm.S
+$(OUTPUT)mx_signal: vmx_asm.S
 
 vsx_preempt: CFLAGS += -mvsx
 vsx_preempt: vsx_asm.S
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
index d563378..d4d2e68 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+++ b/tools/testing/selftests/powerpc/mm/Makefile
@@ -8,8 +8,8 @@ include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
 
-prot_sao: ../utils.c
+$(OUTPUT)prot_sao: ../utils.c
 
-tempfile:
-	dd if=/dev/zero of=tempfile bs=64k count=1
+$(OUTPUT)tempfile:
+	dd if=/dev/zero of=$@ bs=64k count=1
 
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index ab0f902..1f084d0 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -11,34 +11,34 @@ all: $(TEST_GEN_PROGS) ebb
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
 # loop.S can only be built 64-bit
-count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
+$(OUTPUT)count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
 	$(CC) $(CFLAGS) -m64 -o $@ $^
 
-per_event_excludes: ../utils.c
+$(OUTPUT)per_event_excludes: ../utils.c
 
 DEFAULT_RUN_TESTS := $(RUN_TESTS)
 override define RUN_TESTS
 	$(DEFAULT_RUN_TESTS)
-	$(MAKE) -C ebb run_tests
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_tests
 endef
 
 DEFAULT_EMIT_TESTS := $(EMIT_TESTS)
 override define EMIT_TESTS
 	$(DEFAULT_EMIT_TESTS)
-	$(MAKE) -s -C ebb emit_tests
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -s -C $$TARGET emit_tests
 endef
 
 DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
 override define INSTALL_RULE
 	$(DEFAULT_INSTALL_RULE)
-	$(MAKE) -C ebb install
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET install
 endef
 
 clean:
-	$(RM) $(TEST_PROGS) loop.o
-	$(MAKE) -C ebb clean
+	$(RM) $(TEST_GEN_PROGS) $(OUTPUT)loop.o
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean
 
 ebb:
-	$(MAKE) -k -C $@ all
+	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -k -C $$TARGET all
 
 .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 8dcedc4..c434a34 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -21,6 +21,6 @@ include ../../../lib.mk
 $(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
 	       ebb.c ebb_handler.S trace.c busy_loop.S
 
-instruction_count_test: ../loop.S
+$(OUTPUT)instruction_count_test: ../loop.S
 
-lost_exception_test: ../lib.c
+$(OUTPUT)lost_exception_test: ../lib.c
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index 681627d..f6a0d14 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -I$(CURDIR)
 
 TEST_GEN_PROGS := load_unaligned_zeropad
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index 166fdb8..49245be 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -5,7 +5,7 @@ CFLAGS += -I$(CURDIR)
 TEST_GEN_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
index dbd05ac..4d0bbf7 100644
--- a/tools/testing/selftests/powerpc/switch_endian/Makefile
+++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
@@ -2,14 +2,14 @@ TEST_GEN_PROGS := switch_endian_test
 
 ASFLAGS += -O2 -Wall -g -nostdlib -m64
 
-EXTRA_CLEAN = *.o check-reversed.S
+EXTRA_CLEAN = $(OUTPUT)*.o $(OUTPUT)check-reversed.S
 
 include ../../lib.mk
 
-switch_endian_test: check-reversed.S
+$(OUTPUT)switch_endian_test: $(OUTPUT)check-reversed.S
 
-check-reversed.o: check.o
+$(OUTPUT)check-reversed.o: $(OUTPUT)check.o
 	$(CROSS_COMPILE)objcopy -j .text --reverse-bytes=4 -O binary $< $@
 
-check-reversed.S: check-reversed.o
+$(OUTPUT)check-reversed.S: $(OUTPUT)check-reversed.o
 	hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index 1590938..5635076 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -2,7 +2,7 @@ TEST_GEN_PROGS := ipc_unmuxed
 
 CFLAGS += -I../../../../../usr/include
 
-EXTRAN_CLEAN = *.o
+EXTRAN_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 0ad4674..7604559 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -4,7 +4,7 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
 TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
 	tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
@@ -12,9 +12,9 @@ $(TEST_GEN_PROGS): ../harness.c ../utils.c
 
 CFLAGS += -mhtm
 
-tm-syscall: tm-syscall-asm.S
-tm-syscall: CFLAGS += -I../../../../../usr/include
-tm-tmspr: CFLAGS += -pthread
+$(OUTPUT)tm-syscall: tm-syscall-asm.S
+$(OUTPUT)tm-syscall: CFLAGS += -I../../../../../usr/include
+$(OUTPUT)tm-tmspr: CFLAGS += -pthread
 
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index eb0aaff..96ff395 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -13,7 +13,7 @@ TEST_GEN_FILES += transhuge-stress
 TEST_GEN_FILES += userfaultfd
 TEST_GEN_FILES += mlock-random-test
 
-userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
+$(OUTPUT)userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
 	$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
 mlock-random-test: mlock-random-test.c
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index a89f80a..b11b310 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -17,6 +17,9 @@ TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY)
 BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
 BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
 
+BINARIES_32 := $(patsubst %,$(OUTPUT)%,$(BINARIES_32))
+BINARIES_64 := $(patsubst %,$(OUTPUT)%,$(BINARIES_64))
+
 CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
 
 UNAME_M := $(shell uname -m)
@@ -40,10 +43,10 @@ all_64: $(BINARIES_64)
 clean:
 	$(RM) $(BINARIES_32) $(BINARIES_64)
 
-$(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c
+$(BINARIES_32): $(OUTPUT)%_32: %.c
 	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm
 
-$(TARGETS_C_64BIT_ALL:%=%_64): %_64: %.c
+$(BINARIES_64): $(OUTPUT)%_64: %.c
 	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
 
 # x86_64 users should be encouraged to install 32-bit libraries
@@ -65,12 +68,12 @@ warn_32bit_failure:
 endif
 
 # Some tests have additional dependencies.
-sysret_ss_attrs_64: thunks.S
-ptrace_syscall_32: raw_syscall_helper_32.S
-test_syscall_vdso_32: thunks_32.S
+$(OUTPUT)sysret_ss_attrs_64: thunks.S
+$(OUTPUT)ptrace_syscall_32: raw_syscall_helper_32.S
+$(OUTPUT)test_syscall_vdso_32: thunks_32.S
 
 # check_initial_reg_state is special: it needs a custom entry, and it
 # needs to be static so that its interpreter doesn't destroy its initial
 # state.
-check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
-check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
+$(OUTPUT)check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
+$(OUTPUT)check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
-- 
1.8.4.5

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

* [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT
@ 2016-10-21 11:01   ` bamvor.zhangjian
  0 siblings, 0 replies; 44+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
to another directory by passing O or KBUILD_OUTPUT. And O is high
priority than KBUILD_OUTPUT.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
---
 tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
 tools/testing/selftests/exec/Makefile              | 13 ++++----
 tools/testing/selftests/ftrace/Makefile            |  2 +-
 tools/testing/selftests/futex/Makefile             | 21 +++++++++---
 tools/testing/selftests/kcmp/Makefile              |  2 +-
 tools/testing/selftests/lib.mk                     | 19 ++++++++---
 tools/testing/selftests/powerpc/Makefile           | 14 +++++---
 .../testing/selftests/powerpc/benchmarks/Makefile  |  8 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile | 10 +++---
 tools/testing/selftests/powerpc/dscr/Makefile      |  5 ++-
 tools/testing/selftests/powerpc/math/Makefile      | 14 ++++----
 tools/testing/selftests/powerpc/mm/Makefile        |  6 ++--
 tools/testing/selftests/powerpc/pmu/Makefile       | 16 ++++-----
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   |  4 +--
 .../testing/selftests/powerpc/primitives/Makefile  |  2 +-
 .../testing/selftests/powerpc/stringloops/Makefile |  2 +-
 .../selftests/powerpc/switch_endian/Makefile       |  8 ++---
 tools/testing/selftests/powerpc/syscalls/Makefile  |  2 +-
 tools/testing/selftests/powerpc/tm/Makefile        |  8 ++---
 tools/testing/selftests/vm/Makefile                |  2 +-
 tools/testing/selftests/x86/Makefile               | 17 ++++++----
 21 files changed, 132 insertions(+), 82 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index a3144a3..79c5e97 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -47,29 +47,47 @@ override LDFLAGS =
 override MAKEFLAGS =
 endif
 
+ifeq ($(O)$(KBUILD_OUTPUT),)
+        BUILD :=$(shell pwd)
+else
+        ifneq ($(O),)
+                BUILD := $(O)
+        else
+                ifneq ($(KBUILD_OUTPUT),)
+                        BUILD := $(KBUILD_OUTPUT)
+                endif
+        endif
+endif
+export BUILD
 all:
-	for TARGET in $(TARGETS); do \
-		make -C $$TARGET; \
+	for TARGET in $(TARGETS); do		\
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET;\
 	done;
 
 run_tests: all
 	for TARGET in $(TARGETS); do \
-		make -C $$TARGET run_tests; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_tests;\
 	done;
 
 hotplug:
 	for TARGET in $(TARGETS_HOTPLUG); do \
-		make -C $$TARGET; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET;\
 	done;
 
 run_hotplug: hotplug
 	for TARGET in $(TARGETS_HOTPLUG); do \
-		make -C $$TARGET run_full_test; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_full_test;\
 	done;
 
 clean_hotplug:
 	for TARGET in $(TARGETS_HOTPLUG); do \
-		make -C $$TARGET clean; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean;\
 	done;
 
 run_pstore_crash:
@@ -84,7 +102,8 @@ ifdef INSTALL_PATH
 	@# Ask all targets to install their files
 	mkdir -p $(INSTALL_PATH)
 	for TARGET in $(TARGETS); do \
-		make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
 	done;
 
 	@# Ask all targets to emit their test scripts
@@ -93,10 +112,11 @@ ifdef INSTALL_PATH
 	echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
 
 	for TARGET in $(TARGETS); do \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
 		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); \
+		make -s --no-print-directory OUTPUT=$$BUILD_TARGET/ -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
 		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
 	done;
 
@@ -107,7 +127,8 @@ endif
 
 clean:
 	for TARGET in $(TARGETS); do \
-		make -C $$TARGET clean; \
+		BUILD_TARGET=$$BUILD/$$TARGET;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean;\
 	done;
 
 .PHONY: install
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 48d1f86..fe5cdec 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -5,18 +5,19 @@ TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
 # Makefile is a run-time dependency, since it's accessed by the execveat test
 TEST_FILES := Makefile
 
-EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
+EXTRA_CLEAN := $(OUTPUT)subdir.moved $(OUTPUT)execveat.moved $(OUTPUT)xxxxx*
 
 include ../lib.mk
 
-subdir:
+$(OUTPUT)subdir:
 	mkdir -p $@
-script:
+$(OUTPUT)script:
 	echo '#!/bin/sh' > $@
 	echo 'exit $$*' >> $@
 	chmod +x $@
-execveat.symlink: execveat
-	ln -s -f $< $@
-execveat.denatured: execveat
+$(OUTPUT)execveat.symlink: execveat
+	cd $(OUTPUT) && ln -s -f $< `basename $@`
+$(OUTPUT)execveat.denatured: execveat
 	cp $< $@
 	chmod -x $@
+
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 6c64b42..33bb29b 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -2,6 +2,6 @@ all:
 
 TEST_PROGS := ftracetest
 TEST_FILES := test.d
-EXTRA_CLEAN := logs/*
+EXTRA_CLEAN := $(OUTPUT)logs/*
 
 include ../lib.mk
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile
index 6a17529..12a3ae2 100644
--- a/tools/testing/selftests/futex/Makefile
+++ b/tools/testing/selftests/futex/Makefile
@@ -3,13 +3,18 @@ SUBDIRS := functional
 TEST_PROGS := run.sh
 
 .PHONY: all clean
-all:
-	for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done
 
 include ../lib.mk
 
+all:
+	for DIR in $(SUBDIRS); do		\
+		BUILD_TARGET=$$OUTPUT/$$DIR;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$DIR $@;\
+	done
+
 override define RUN_TESTS
-	./run.sh
+	@if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi
 endef
 
 override define INSTALL_RULE
@@ -17,7 +22,9 @@ override define INSTALL_RULE
 	install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
 
 	@for SUBDIR in $(SUBDIRS); do \
-		$(MAKE) -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \
+		BUILD_TARGET=$$OUTPUT/$$SUBDIR;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \
 	done;
 endef
 
@@ -26,4 +33,8 @@ override define EMIT_TESTS
 endef
 
 clean:
-	for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done
+	for DIR in $(SUBDIRS); do		\
+		BUILD_TARGET=$$OUTPUT/$$DIR;	\
+		mkdir $$BUILD_TARGET  -p;	\
+		make OUTPUT=$$BUILD_TARGET/ -C $$DIR $@;\
+	done
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index 74a8add..0fb599e 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -I../../../../usr/include/
 
 TEST_GEN_PROGS := kcmp_test
 
-EXTRA_CLEAN := kcmp-test-file
+EXTRA_CLEAN := $(OUTPUT)kcmp-test-file
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 0f7a371..fa87f98 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -4,7 +4,8 @@ CC := $(CROSS_COMPILE)gcc
 
 define RUN_TESTS
 	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
-		(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
+		BASENAME_TEST=`basename $$TEST`;	\
+		cd `dirname $$TEST`; (./$$BASENAME_TEST && echo "selftests: $$BASENAME_TEST [PASS]") || echo "selftests:  $$BASENAME_TEST [FAIL]"; cd -;\
 	done;
 endef
 
@@ -33,19 +34,29 @@ endif
 
 define EMIT_TESTS
 	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
-		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
+		BASENAME_TEST=`basename $$TEST`;	\
+		echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
 	done;
 endef
 
 emit_tests:
 	$(EMIT_TESTS)
 
+TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_PROGS))
+TEST_GEN_FILES := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_FILES))
+
 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 
 clean:
 	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 
-%: %.c
-	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
+$(OUTPUT)%:%.c
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
+
+$(OUTPUT)%.o:%.S
+	$(CC) $(ASFLAGS) -c $< -o $@
+
+$(OUTPUT)%:%.S
+	$(CC) $(ASFLAGS) $< -o $@
 
 .PHONY: run_tests all clean install emit_tests
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index db54a33..e99a28c 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -33,31 +33,35 @@ endif
 all: $(SUB_DIRS)
 
 $(SUB_DIRS):
-	$(MAKE) -k -C $@ all
+	BUILD_TARGET=$$OUTPUT/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -k -C $@ all
 
 include ../lib.mk
 
 override define RUN_TESTS
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -C $$TARGET run_tests; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_tests;\
 	done;
 endef
 
 override define INSTALL_RULE
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -C $$TARGET install; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET install;\
 	done;
 endef
 
 override define EMIT_TESTS
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -s -C $$TARGET emit_tests; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -s -C $$TARGET emit_tests;\
 	done;
 endef
 
 clean:
 	@for TARGET in $(SUB_DIRS); do \
-		$(MAKE) -C $$TARGET clean; \
+		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
+		$(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean;\
 	done;
 	rm -f tags
 
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 1f94b31..3f6552c 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -4,10 +4,10 @@ CFLAGS += -O2
 
 $(TEST_GEN_PROGS): ../harness.c
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
-context_switch: ../utils.c
-context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
-context_switch: LDLIBS += -lpthread
+$(OUTPUT)context_switch: ../utils.c
+$(OUTPUT)context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
+$(OUTPUT)context_switch: LDLIBS += -lpthread
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index a768179..07b0307 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -9,14 +9,14 @@ ASFLAGS = $(CFLAGS)
 
 TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
 EXTRA_SOURCES := validate.c ../harness.c
-EXTRA_CLEAN := *.o
+EXTRA_CLEAN := $(OUTPUT)*.o
 
 include ../../lib.mk
 
-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
+$(OUTPUT)copyuser_64:     CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base
+$(OUTPUT)copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7
+$(OUTPUT)memcpy_64:       CPPFLAGS += -D COPY_LOOP=test_memcpy
+$(OUTPUT)memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
 
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 7b43ac3..1df5da5 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -2,11 +2,10 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test	\
 	      dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test	\
 	      dscr_sysfs_thread_test
 
-EXTRA_CLEAN := *.o
+EXTRA_CLEAN := $(OUTPUT)*.o
 
 include ../../lib.mk
 
-dscr_default_test: LDLIBS += -lpthread
+$(OUTPUT)dscr_default_test: LDLIBS += -lpthread
 
 $(TEST_GEN_PROGS): ../harness.c
-
diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index 9aa9b22..3587df8 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -1,19 +1,19 @@
 TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
 $(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
 
-fpu_syscall: fpu_asm.S
-fpu_preempt: fpu_asm.S
-fpu_signal:  fpu_asm.S
+$(OUTPUT)pu_syscall: fpu_asm.S
+$(OUTPUT)pu_preempt: fpu_asm.S
+$(OUTPUT)pu_signal:  fpu_asm.S
 
-vmx_syscall: vmx_asm.S
-vmx_preempt: vmx_asm.S
-vmx_signal: vmx_asm.S
+$(OUTPUT)mx_syscall: vmx_asm.S
+$(OUTPUT)mx_preempt: vmx_asm.S
+$(OUTPUT)mx_signal: vmx_asm.S
 
 vsx_preempt: CFLAGS += -mvsx
 vsx_preempt: vsx_asm.S
diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
index d563378..d4d2e68 100644
--- a/tools/testing/selftests/powerpc/mm/Makefile
+++ b/tools/testing/selftests/powerpc/mm/Makefile
@@ -8,8 +8,8 @@ include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
 
-prot_sao: ../utils.c
+$(OUTPUT)prot_sao: ../utils.c
 
-tempfile:
-	dd if=/dev/zero of=tempfile bs=64k count=1
+$(OUTPUT)tempfile:
+	dd if=/dev/zero of=$@ bs=64k count=1
 
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index ab0f902..1f084d0 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -11,34 +11,34 @@ all: $(TEST_GEN_PROGS) ebb
 $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
 
 # loop.S can only be built 64-bit
-count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
+$(OUTPUT)count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
 	$(CC) $(CFLAGS) -m64 -o $@ $^
 
-per_event_excludes: ../utils.c
+$(OUTPUT)per_event_excludes: ../utils.c
 
 DEFAULT_RUN_TESTS := $(RUN_TESTS)
 override define RUN_TESTS
 	$(DEFAULT_RUN_TESTS)
-	$(MAKE) -C ebb run_tests
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET run_tests
 endef
 
 DEFAULT_EMIT_TESTS := $(EMIT_TESTS)
 override define EMIT_TESTS
 	$(DEFAULT_EMIT_TESTS)
-	$(MAKE) -s -C ebb emit_tests
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -s -C $$TARGET emit_tests
 endef
 
 DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
 override define INSTALL_RULE
 	$(DEFAULT_INSTALL_RULE)
-	$(MAKE) -C ebb install
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET install
 endef
 
 clean:
-	$(RM) $(TEST_PROGS) loop.o
-	$(MAKE) -C ebb clean
+	$(RM) $(TEST_GEN_PROGS) $(OUTPUT)loop.o
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -C $$TARGET clean
 
 ebb:
-	$(MAKE) -k -C $@ all
+	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET/ -k -C $$TARGET all
 
 .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 8dcedc4..c434a34 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -21,6 +21,6 @@ include ../../../lib.mk
 $(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
 	       ebb.c ebb_handler.S trace.c busy_loop.S
 
-instruction_count_test: ../loop.S
+$(OUTPUT)instruction_count_test: ../loop.S
 
-lost_exception_test: ../lib.c
+$(OUTPUT)lost_exception_test: ../lib.c
diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
index 681627d..f6a0d14 100644
--- a/tools/testing/selftests/powerpc/primitives/Makefile
+++ b/tools/testing/selftests/powerpc/primitives/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -I$(CURDIR)
 
 TEST_GEN_PROGS := load_unaligned_zeropad
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
index 166fdb8..49245be 100644
--- a/tools/testing/selftests/powerpc/stringloops/Makefile
+++ b/tools/testing/selftests/powerpc/stringloops/Makefile
@@ -5,7 +5,7 @@ CFLAGS += -I$(CURDIR)
 TEST_GEN_PROGS := memcmp
 EXTRA_SOURCES := memcmp_64.S ../harness.c
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
index dbd05ac..4d0bbf7 100644
--- a/tools/testing/selftests/powerpc/switch_endian/Makefile
+++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
@@ -2,14 +2,14 @@ TEST_GEN_PROGS := switch_endian_test
 
 ASFLAGS += -O2 -Wall -g -nostdlib -m64
 
-EXTRA_CLEAN = *.o check-reversed.S
+EXTRA_CLEAN = $(OUTPUT)*.o $(OUTPUT)check-reversed.S
 
 include ../../lib.mk
 
-switch_endian_test: check-reversed.S
+$(OUTPUT)switch_endian_test: $(OUTPUT)check-reversed.S
 
-check-reversed.o: check.o
+$(OUTPUT)check-reversed.o: $(OUTPUT)check.o
 	$(CROSS_COMPILE)objcopy -j .text --reverse-bytes=4 -O binary $< $@
 
-check-reversed.S: check-reversed.o
+$(OUTPUT)check-reversed.S: $(OUTPUT)check-reversed.o
 	hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
index 1590938..5635076 100644
--- a/tools/testing/selftests/powerpc/syscalls/Makefile
+++ b/tools/testing/selftests/powerpc/syscalls/Makefile
@@ -2,7 +2,7 @@ TEST_GEN_PROGS := ipc_unmuxed
 
 CFLAGS += -I../../../../../usr/include
 
-EXTRAN_CLEAN = *.o
+EXTRAN_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 0ad4674..7604559 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -4,7 +4,7 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
 TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
 	tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
 
-EXTRA_CLEAN = *.o
+EXTRA_CLEAN = $(OUTPUT)*.o
 
 include ../../lib.mk
 
@@ -12,9 +12,9 @@ $(TEST_GEN_PROGS): ../harness.c ../utils.c
 
 CFLAGS += -mhtm
 
-tm-syscall: tm-syscall-asm.S
-tm-syscall: CFLAGS += -I../../../../../usr/include
-tm-tmspr: CFLAGS += -pthread
+$(OUTPUT)tm-syscall: tm-syscall-asm.S
+$(OUTPUT)tm-syscall: CFLAGS += -I../../../../../usr/include
+$(OUTPUT)tm-tmspr: CFLAGS += -pthread
 
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index eb0aaff..96ff395 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -13,7 +13,7 @@ TEST_GEN_FILES += transhuge-stress
 TEST_GEN_FILES += userfaultfd
 TEST_GEN_FILES += mlock-random-test
 
-userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
+$(OUTPUT)userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
 	$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
 mlock-random-test: mlock-random-test.c
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index a89f80a..b11b310 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -17,6 +17,9 @@ TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_64BIT_ONLY)
 BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
 BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
 
+BINARIES_32 := $(patsubst %,$(OUTPUT)%,$(BINARIES_32))
+BINARIES_64 := $(patsubst %,$(OUTPUT)%,$(BINARIES_64))
+
 CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
 
 UNAME_M := $(shell uname -m)
@@ -40,10 +43,10 @@ all_64: $(BINARIES_64)
 clean:
 	$(RM) $(BINARIES_32) $(BINARIES_64)
 
-$(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c
+$(BINARIES_32): $(OUTPUT)%_32: %.c
 	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm
 
-$(TARGETS_C_64BIT_ALL:%=%_64): %_64: %.c
+$(BINARIES_64): $(OUTPUT)%_64: %.c
 	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
 
 # x86_64 users should be encouraged to install 32-bit libraries
@@ -65,12 +68,12 @@ warn_32bit_failure:
 endif
 
 # Some tests have additional dependencies.
-sysret_ss_attrs_64: thunks.S
-ptrace_syscall_32: raw_syscall_helper_32.S
-test_syscall_vdso_32: thunks_32.S
+$(OUTPUT)sysret_ss_attrs_64: thunks.S
+$(OUTPUT)ptrace_syscall_32: raw_syscall_helper_32.S
+$(OUTPUT)test_syscall_vdso_32: thunks_32.S
 
 # check_initial_reg_state is special: it needs a custom entry, and it
 # needs to be static so that its interpreter doesn't destroy its initial
 # state.
-check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
-check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
+$(OUTPUT)check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static
+$(OUTPUT)check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
-- 
1.8.4.5

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-10-21 11:11   ` Bamvor Zhang Jian
  0 siblings, 0 replies; 44+ messages in thread
From: Bamvor Zhang Jian @ 2016-10-21 11:11 UTC (permalink / raw)
  To: Zhang Jian(Bamvor)
  Cc: Shuah Khan, linux-api, lkml, Mark Brown, Michael Ellerman, Kevin Hilman

Fix the wrong email address of kevin hilman to khilman@kernel.org.
Sorry for inconvenience.

On 21 October 2016 at 19:01,  <bamvor.zhangjian@huawei.com> wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
> ppc, I test through fake target.
>
> There are six patches in these series. And five of them clean up the
> existing code. I split the clean up patches into five, hope it is easy
> to review.
>
> selftests: remove duplicated all and clean target
> selftests: remove useless TEST_DIRS
> selftests: add pattern rules
> selftests: remove CROSS_COMPILE in dedicated Makefile
> selftests: add EXTRA_CLEAN for clean target
> selftests: enable O and KBUILD_OUTPUT
>
> In the first patch, I split the test files into two types:
> TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
> means there is no need to compile before use. The main reason of this
> is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
> I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
> idea in the end. Because people may puzzle why copy the file before
> installation.
>
> Because of the introducing of TEST_GEN_XXX, I update the top-level
> Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
> could remove all the unnecessary all and clean targets.
>
> The second patch remove TEST_DIRS variable. And third patch add the
> pattern for compiling the c sourc code. The fourth patch remove the
> useless CROSS_COMPILE variable as it aleady exists in
> "tools/testing/selftests/lib.mk".
>
> Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
> the duplicated clean target
>
> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
> using the existing kbuild system because user may compile kselftest
> directly (make -C tools/testing/selftests).
>
> Bamvor Jian Zhang (6):
>   selftests: remove duplicated all and clean target
>   selftests: remove useless TEST_DIRS
>   selftests: add default rules for c source file
>   selftests: remove CROSS_COMPILE in dedicated Makefile
>   selftests: add EXTRA_CLEAN for clean target
>   selftests: enable O and KBUILD_OUTPUT
>
>  Documentation/kselftest.txt                        | 13 ++++++++
>  tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
>  tools/testing/selftests/breakpoints/Makefile       |  8 ++---
>  tools/testing/selftests/capabilities/Makefile      | 11 ++----
>  tools/testing/selftests/efivarfs/Makefile          |  8 +----
>  tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
>  tools/testing/selftests/ftrace/Makefile            |  6 ++--
>  tools/testing/selftests/futex/Makefile             | 21 +++++++++---
>  tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
>  tools/testing/selftests/ipc/Makefile               |  7 +---
>  tools/testing/selftests/kcmp/Makefile              |  6 ++--
>  tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
>  tools/testing/selftests/membarrier/Makefile        |  6 +---
>  tools/testing/selftests/memfd/Makefile             | 15 ++-------
>  tools/testing/selftests/mount/Makefile             |  7 +---
>  tools/testing/selftests/mqueue/Makefile            |  6 +---
>  tools/testing/selftests/net/Makefile               | 10 +-----
>  tools/testing/selftests/powerpc/Makefile           | 14 +++++---
>  tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
>  .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
>  .../selftests/powerpc/context_switch/Makefile      |  9 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
>  tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
>  tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
>  tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
>  tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
>  tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
>  .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
>  .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
>  .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
>  tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
>  tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
>  tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
>  tools/testing/selftests/pstore/Makefile            |  4 +--
>  tools/testing/selftests/ptrace/Makefile            |  8 +----
>  tools/testing/selftests/seccomp/Makefile           |  6 +---
>  tools/testing/selftests/sigaltstack/Makefile       |  5 +--
>  tools/testing/selftests/size/Makefile              | 10 ++----
>  tools/testing/selftests/timers/Makefile            | 10 ++----
>  tools/testing/selftests/vm/Makefile                | 29 +++++++---------
>  tools/testing/selftests/x86/Makefile               | 17 ++++++----
>  tools/testing/selftests/zram/Makefile              |  3 +-
>  42 files changed, 250 insertions(+), 323 deletions(-)
>
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-10-21 11:11   ` Bamvor Zhang Jian
  0 siblings, 0 replies; 44+ messages in thread
From: Bamvor Zhang Jian @ 2016-10-21 11:11 UTC (permalink / raw)
  To: Zhang Jian(Bamvor)
  Cc: Shuah Khan, linux-api, lkml, Mark Brown, Michael Ellerman, Kevin Hilman

Fix the wrong email address of kevin hilman to khilman-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.org
Sorry for inconvenience.

On 21 October 2016 at 19:01,  <bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
> ppc, I test through fake target.
>
> There are six patches in these series. And five of them clean up the
> existing code. I split the clean up patches into five, hope it is easy
> to review.
>
> selftests: remove duplicated all and clean target
> selftests: remove useless TEST_DIRS
> selftests: add pattern rules
> selftests: remove CROSS_COMPILE in dedicated Makefile
> selftests: add EXTRA_CLEAN for clean target
> selftests: enable O and KBUILD_OUTPUT
>
> In the first patch, I split the test files into two types:
> TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
> means there is no need to compile before use. The main reason of this
> is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
> I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
> idea in the end. Because people may puzzle why copy the file before
> installation.
>
> Because of the introducing of TEST_GEN_XXX, I update the top-level
> Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
> could remove all the unnecessary all and clean targets.
>
> The second patch remove TEST_DIRS variable. And third patch add the
> pattern for compiling the c sourc code. The fourth patch remove the
> useless CROSS_COMPILE variable as it aleady exists in
> "tools/testing/selftests/lib.mk".
>
> Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
> the duplicated clean target
>
> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
> using the existing kbuild system because user may compile kselftest
> directly (make -C tools/testing/selftests).
>
> Bamvor Jian Zhang (6):
>   selftests: remove duplicated all and clean target
>   selftests: remove useless TEST_DIRS
>   selftests: add default rules for c source file
>   selftests: remove CROSS_COMPILE in dedicated Makefile
>   selftests: add EXTRA_CLEAN for clean target
>   selftests: enable O and KBUILD_OUTPUT
>
>  Documentation/kselftest.txt                        | 13 ++++++++
>  tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
>  tools/testing/selftests/breakpoints/Makefile       |  8 ++---
>  tools/testing/selftests/capabilities/Makefile      | 11 ++----
>  tools/testing/selftests/efivarfs/Makefile          |  8 +----
>  tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
>  tools/testing/selftests/ftrace/Makefile            |  6 ++--
>  tools/testing/selftests/futex/Makefile             | 21 +++++++++---
>  tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
>  tools/testing/selftests/ipc/Makefile               |  7 +---
>  tools/testing/selftests/kcmp/Makefile              |  6 ++--
>  tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
>  tools/testing/selftests/membarrier/Makefile        |  6 +---
>  tools/testing/selftests/memfd/Makefile             | 15 ++-------
>  tools/testing/selftests/mount/Makefile             |  7 +---
>  tools/testing/selftests/mqueue/Makefile            |  6 +---
>  tools/testing/selftests/net/Makefile               | 10 +-----
>  tools/testing/selftests/powerpc/Makefile           | 14 +++++---
>  tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
>  .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
>  .../selftests/powerpc/context_switch/Makefile      |  9 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
>  tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
>  tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
>  tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
>  tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
>  tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
>  .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
>  .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
>  .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
>  tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
>  tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
>  tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
>  tools/testing/selftests/pstore/Makefile            |  4 +--
>  tools/testing/selftests/ptrace/Makefile            |  8 +----
>  tools/testing/selftests/seccomp/Makefile           |  6 +---
>  tools/testing/selftests/sigaltstack/Makefile       |  5 +--
>  tools/testing/selftests/size/Makefile              | 10 ++----
>  tools/testing/selftests/timers/Makefile            | 10 ++----
>  tools/testing/selftests/vm/Makefile                | 29 +++++++---------
>  tools/testing/selftests/x86/Makefile               | 17 ++++++----
>  tools/testing/selftests/zram/Makefile              |  3 +-
>  42 files changed, 250 insertions(+), 323 deletions(-)
>
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-11-16 23:57   ` Shuah Khan
  0 siblings, 0 replies; 44+ messages in thread
From: Shuah Khan @ 2016-11-16 23:57 UTC (permalink / raw)
  To: bamvor.zhangjian, mpe, Shuah Khan, Shuah Khan
  Cc: linux-api, linux-kernel, khilman, broonie

On 10/21/2016 05:01 AM, bamvor.zhangjian@huawei.com wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
> 
> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
> ppc, I test through fake target.
> 
> There are six patches in these series. And five of them clean up the
> existing code. I split the clean up patches into five, hope it is easy
> to review.
> 
> selftests: remove duplicated all and clean target
> selftests: remove useless TEST_DIRS
> selftests: add pattern rules
> selftests: remove CROSS_COMPILE in dedicated Makefile
> selftests: add EXTRA_CLEAN for clean target
> selftests: enable O and KBUILD_OUTPUT
> 
> In the first patch, I split the test files into two types:
> TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
> means there is no need to compile before use. The main reason of this
> is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
> I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
> idea in the end. Because people may puzzle why copy the file before
> installation.
> 
> Because of the introducing of TEST_GEN_XXX, I update the top-level
> Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
> could remove all the unnecessary all and clean targets.
> 
> The second patch remove TEST_DIRS variable. And third patch add the
> pattern for compiling the c sourc code. The fourth patch remove the
> useless CROSS_COMPILE variable as it aleady exists in
> "tools/testing/selftests/lib.mk".
> 
> Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
> the duplicated clean target
> 
> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
> using the existing kbuild system because user may compile kselftest
> directly (make -C tools/testing/selftests).

I am planning to get this into 4.10.

Michael!

Are okay with me taking powerpc tests through kselftest tree?
If so could you please give me Ack.

thanks,
-- Shuah

> 
> Bamvor Jian Zhang (6):
>   selftests: remove duplicated all and clean target
>   selftests: remove useless TEST_DIRS
>   selftests: add default rules for c source file
>   selftests: remove CROSS_COMPILE in dedicated Makefile
>   selftests: add EXTRA_CLEAN for clean target
>   selftests: enable O and KBUILD_OUTPUT
> 
>  Documentation/kselftest.txt                        | 13 ++++++++
>  tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
>  tools/testing/selftests/breakpoints/Makefile       |  8 ++---
>  tools/testing/selftests/capabilities/Makefile      | 11 ++----
>  tools/testing/selftests/efivarfs/Makefile          |  8 +----
>  tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
>  tools/testing/selftests/ftrace/Makefile            |  6 ++--
>  tools/testing/selftests/futex/Makefile             | 21 +++++++++---
>  tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
>  tools/testing/selftests/ipc/Makefile               |  7 +---
>  tools/testing/selftests/kcmp/Makefile              |  6 ++--
>  tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
>  tools/testing/selftests/membarrier/Makefile        |  6 +---
>  tools/testing/selftests/memfd/Makefile             | 15 ++-------
>  tools/testing/selftests/mount/Makefile             |  7 +---
>  tools/testing/selftests/mqueue/Makefile            |  6 +---
>  tools/testing/selftests/net/Makefile               | 10 +-----
>  tools/testing/selftests/powerpc/Makefile           | 14 +++++---
>  tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
>  .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
>  .../selftests/powerpc/context_switch/Makefile      |  9 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
>  tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
>  tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
>  tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
>  tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
>  tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
>  .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
>  .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
>  .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
>  tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
>  tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
>  tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
>  tools/testing/selftests/pstore/Makefile            |  4 +--
>  tools/testing/selftests/ptrace/Makefile            |  8 +----
>  tools/testing/selftests/seccomp/Makefile           |  6 +---
>  tools/testing/selftests/sigaltstack/Makefile       |  5 +--
>  tools/testing/selftests/size/Makefile              | 10 ++----
>  tools/testing/selftests/timers/Makefile            | 10 ++----
>  tools/testing/selftests/vm/Makefile                | 29 +++++++---------
>  tools/testing/selftests/x86/Makefile               | 17 ++++++----
>  tools/testing/selftests/zram/Makefile              |  3 +-
>  42 files changed, 250 insertions(+), 323 deletions(-)
> 

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-11-16 23:57   ` Shuah Khan
  0 siblings, 0 replies; 44+ messages in thread
From: Shuah Khan @ 2016-11-16 23:57 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA,
	mpe-Gsx/Oe8HsFggBc27wqDAHg, Shuah Khan, Shuah Khan
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

On 10/21/2016 05:01 AM, bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
> ppc, I test through fake target.
> 
> There are six patches in these series. And five of them clean up the
> existing code. I split the clean up patches into five, hope it is easy
> to review.
> 
> selftests: remove duplicated all and clean target
> selftests: remove useless TEST_DIRS
> selftests: add pattern rules
> selftests: remove CROSS_COMPILE in dedicated Makefile
> selftests: add EXTRA_CLEAN for clean target
> selftests: enable O and KBUILD_OUTPUT
> 
> In the first patch, I split the test files into two types:
> TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
> means there is no need to compile before use. The main reason of this
> is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
> I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
> idea in the end. Because people may puzzle why copy the file before
> installation.
> 
> Because of the introducing of TEST_GEN_XXX, I update the top-level
> Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
> could remove all the unnecessary all and clean targets.
> 
> The second patch remove TEST_DIRS variable. And third patch add the
> pattern for compiling the c sourc code. The fourth patch remove the
> useless CROSS_COMPILE variable as it aleady exists in
> "tools/testing/selftests/lib.mk".
> 
> Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
> the duplicated clean target
> 
> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
> using the existing kbuild system because user may compile kselftest
> directly (make -C tools/testing/selftests).

I am planning to get this into 4.10.

Michael!

Are okay with me taking powerpc tests through kselftest tree?
If so could you please give me Ack.

thanks,
-- Shuah

> 
> Bamvor Jian Zhang (6):
>   selftests: remove duplicated all and clean target
>   selftests: remove useless TEST_DIRS
>   selftests: add default rules for c source file
>   selftests: remove CROSS_COMPILE in dedicated Makefile
>   selftests: add EXTRA_CLEAN for clean target
>   selftests: enable O and KBUILD_OUTPUT
> 
>  Documentation/kselftest.txt                        | 13 ++++++++
>  tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
>  tools/testing/selftests/breakpoints/Makefile       |  8 ++---
>  tools/testing/selftests/capabilities/Makefile      | 11 ++----
>  tools/testing/selftests/efivarfs/Makefile          |  8 +----
>  tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
>  tools/testing/selftests/ftrace/Makefile            |  6 ++--
>  tools/testing/selftests/futex/Makefile             | 21 +++++++++---
>  tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
>  tools/testing/selftests/ipc/Makefile               |  7 +---
>  tools/testing/selftests/kcmp/Makefile              |  6 ++--
>  tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
>  tools/testing/selftests/membarrier/Makefile        |  6 +---
>  tools/testing/selftests/memfd/Makefile             | 15 ++-------
>  tools/testing/selftests/mount/Makefile             |  7 +---
>  tools/testing/selftests/mqueue/Makefile            |  6 +---
>  tools/testing/selftests/net/Makefile               | 10 +-----
>  tools/testing/selftests/powerpc/Makefile           | 14 +++++---
>  tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
>  .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
>  .../selftests/powerpc/context_switch/Makefile      |  9 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
>  tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
>  tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
>  tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
>  tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
>  tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
>  .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
>  .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
>  .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
>  tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
>  tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
>  tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
>  tools/testing/selftests/pstore/Makefile            |  4 +--
>  tools/testing/selftests/ptrace/Makefile            |  8 +----
>  tools/testing/selftests/seccomp/Makefile           |  6 +---
>  tools/testing/selftests/sigaltstack/Makefile       |  5 +--
>  tools/testing/selftests/size/Makefile              | 10 ++----
>  tools/testing/selftests/timers/Makefile            | 10 ++----
>  tools/testing/selftests/vm/Makefile                | 29 +++++++---------
>  tools/testing/selftests/x86/Makefile               | 17 ++++++----
>  tools/testing/selftests/zram/Makefile              |  3 +-
>  42 files changed, 250 insertions(+), 323 deletions(-)
> 

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
  2016-11-16 23:57   ` Shuah Khan
@ 2016-11-18  0:15     ` Michael Ellerman
  -1 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18  0:15 UTC (permalink / raw)
  To: Shuah Khan, bamvor.zhangjian, Shuah Khan, Shuah Khan
  Cc: linux-api, linux-kernel, khilman, broonie

Shuah Khan <shuahkh@osg.samsung.com> writes:

> On 10/21/2016 05:01 AM, bamvor.zhangjian@huawei.com wrote:
>> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>> 
>> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
>> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
>> ppc, I test through fake target.
...
>> 
>> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
>> using the existing kbuild system because user may compile kselftest
>> directly (make -C tools/testing/selftests).
>
> I am planning to get this into 4.10.
>
> Michael!
>
> Are okay with me taking powerpc tests through kselftest tree?
> If so could you please give me Ack.

I already have quite a lot of selftests queued for 4.10, so this will
conflict badly with those I suspect.

If you put this series in a topic branch that we can both merge then
that will probably be OK.

I'd like to review the series first too, will try and get that done
today.

cheers

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-11-18  0:15     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18  0:15 UTC (permalink / raw)
  To: Shuah Khan, bamvor.zhangjian; +Cc: linux-api, linux-kernel, khilman, broonie

Shuah Khan <shuahkh@osg.samsung.com> writes:

> On 10/21/2016 05:01 AM, bamvor.zhangjian@huawei.com wrote:
>> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>> 
>> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
>> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
>> ppc, I test through fake target.
...
>> 
>> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
>> using the existing kbuild system because user may compile kselftest
>> directly (make -C tools/testing/selftests).
>
> I am planning to get this into 4.10.
>
> Michael!
>
> Are okay with me taking powerpc tests through kselftest tree?
> If so could you please give me Ack.

I already have quite a lot of selftests queued for 4.10, so this will
conflict badly with those I suspect.

If you put this series in a topic branch that we can both merge then
that will probably be OK.

I'd like to review the series first too, will try and get that done
today.

cheers

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-11-18  0:18       ` Shuah Khan
  0 siblings, 0 replies; 44+ messages in thread
From: Shuah Khan @ 2016-11-18  0:18 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian, Shuah Khan
  Cc: linux-api, linux-kernel, khilman, broonie, Shuah Khan

On 11/17/2016 05:15 PM, Michael Ellerman wrote:
> Shuah Khan <shuahkh@osg.samsung.com> writes:
> 
>> On 10/21/2016 05:01 AM, bamvor.zhangjian@huawei.com wrote:
>>> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>>>
>>> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
>>> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
>>> ppc, I test through fake target.
> ...
>>>
>>> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
>>> using the existing kbuild system because user may compile kselftest
>>> directly (make -C tools/testing/selftests).
>>
>> I am planning to get this into 4.10.
>>
>> Michael!
>>
>> Are okay with me taking powerpc tests through kselftest tree?
>> If so could you please give me Ack.
> 
> I already have quite a lot of selftests queued for 4.10, so this will
> conflict badly with those I suspect.

Let me know how bad it is, maybe we can wait on these until 4.11
> 
> If you put this series in a topic branch that we can both merge then
> that will probably be OK.

Once you are done with reviews, we can make a call on whether to merge
them now or later.

> 
> I'd like to review the series first too, will try and get that done
> today.
> 
> cheers
> 

Okay sounds good.

thanks,
-- Shuah

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

* Re: [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-11-18  0:18       ` Shuah Khan
  0 siblings, 0 replies; 44+ messages in thread
From: Shuah Khan @ 2016-11-18  0:18 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, Shuah Khan
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	Shuah Khan

On 11/17/2016 05:15 PM, Michael Ellerman wrote:
> Shuah Khan <shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org> writes:
> 
>> On 10/21/2016 05:01 AM, bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org wrote:
>>> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>>>
>>> Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
>>> I fix and test all the TARGET in tools/testing/selftest/Makefile. For
>>> ppc, I test through fake target.
> ...
>>>
>>> The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
>>> using the existing kbuild system because user may compile kselftest
>>> directly (make -C tools/testing/selftests).
>>
>> I am planning to get this into 4.10.
>>
>> Michael!
>>
>> Are okay with me taking powerpc tests through kselftest tree?
>> If so could you please give me Ack.
> 
> I already have quite a lot of selftests queued for 4.10, so this will
> conflict badly with those I suspect.

Let me know how bad it is, maybe we can wait on these until 4.11
> 
> If you put this series in a topic branch that we can both merge then
> that will probably be OK.

Once you are done with reviews, we can make a call on whether to merge
them now or later.

> 
> I'd like to review the series first too, will try and get that done
> today.
> 
> cheers
> 

Okay sounds good.

thanks,
-- Shuah

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-11-18 10:31     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:31 UTC (permalink / raw)
  To: bamvor.zhangjian, shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie

Hi Bamvor,

bamvor.zhangjian@huawei.com writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
> indicate the default test program, extended test program and test files.
> These lead to duplicated all and clean targets.
>
> In order to remove them, introduce TEST_GEN_PROGS,
> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
> objected.

It's nice to be able to drop the clean rules, but renaming all those
variables causes a lot of churn.

I think it would be better if we add a new variable, maybe NO_CLEAN,
which can be used to specify anything in TEST_PROGS/EXTENDED which
should *not* be cleaned.

And then the default clean rule will just do:

clean:
	$(RM) -fr $(filter-out $(NO_CLEAN),$(TEST_PROGS))


I think that would require less changes overall, because most tests just
want to build some files, run them, and then clean them. The tests that
need to do more elaborate things are the exception.

cheers

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-11-18 10:31     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:31 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

Hi Bamvor,

bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
> indicate the default test program, extended test program and test files.
> These lead to duplicated all and clean targets.
>
> In order to remove them, introduce TEST_GEN_PROGS,
> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
> objected.

It's nice to be able to drop the clean rules, but renaming all those
variables causes a lot of churn.

I think it would be better if we add a new variable, maybe NO_CLEAN,
which can be used to specify anything in TEST_PROGS/EXTENDED which
should *not* be cleaned.

And then the default clean rule will just do:

clean:
	$(RM) -fr $(filter-out $(NO_CLEAN),$(TEST_PROGS))


I think that would require less changes overall, because most tests just
want to build some files, run them, and then clean them. The tests that
need to do more elaborate things are the exception.

cheers

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

* Re: [PATCH RFC 2/6] selftests: remove useless TEST_DIRS
@ 2016-11-18 10:31     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:31 UTC (permalink / raw)
  To: bamvor.zhangjian, shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie

bamvor.zhangjian@huawei.com writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> The TEST_DIRS was introduced in Commit e8c1d7cdf137 ("selftests: copy
> TEST_DIRS to INSTALL_PATH") for coping a whole directory in ftrace.
>
> After rsync(with -a) is introduced by Commit 900d65ee11aa ("selftests:
> change install command to rsync"). Rsync could handle the directory
> without the definition of TEST_DIRS.
>
> This patch simply replace TEST_DIRS with TEST_FILES in ftrace and remove
> the TEST_DIRS in tools/testing/selftest/lib.mk

Thanks for cleaning it up.

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

cheers

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

* Re: [PATCH RFC 2/6] selftests: remove useless TEST_DIRS
@ 2016-11-18 10:31     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:31 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> The TEST_DIRS was introduced in Commit e8c1d7cdf137 ("selftests: copy
> TEST_DIRS to INSTALL_PATH") for coping a whole directory in ftrace.
>
> After rsync(with -a) is introduced by Commit 900d65ee11aa ("selftests:
> change install command to rsync"). Rsync could handle the directory
> without the definition of TEST_DIRS.
>
> This patch simply replace TEST_DIRS with TEST_FILES in ftrace and remove
> the TEST_DIRS in tools/testing/selftest/lib.mk

Thanks for cleaning it up.

Acked-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>

cheers

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

* Re: [PATCH RFC 3/6] selftests: add default rules for c source file
@ 2016-11-18 10:57     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:57 UTC (permalink / raw)
  To: bamvor.zhangjian, shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie

bamvor.zhangjian@huawei.com writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> There are difference rules for compiling c source file in different
> testcases. In order to enable KBUILD_OUTPUT support in later patch,
> this patch introduce the default rules in
> "tools/testing/selftest/lib.mk" and remove the existing rules in each
> testcase.

Looks good.

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

cheers

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

* Re: [PATCH RFC 3/6] selftests: add default rules for c source file
@ 2016-11-18 10:57     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:57 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> There are difference rules for compiling c source file in different
> testcases. In order to enable KBUILD_OUTPUT support in later patch,
> this patch introduce the default rules in
> "tools/testing/selftest/lib.mk" and remove the existing rules in each
> testcase.

Looks good.

Acked-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>

cheers

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

* Re: [PATCH RFC 4/6] selftests: remove CROSS_COMPILE in dedicated Makefile
@ 2016-11-18 10:58     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:58 UTC (permalink / raw)
  To: bamvor.zhangjian, shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie

bamvor.zhangjian@huawei.com writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> After previous clean up patches, memfd and timers could get
> CROSS_COMPILE from tools/testing/selftest/lib.mk. There is no need to
> preserve these definition. So, this patch remove them.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Another nice cleanup, thanks.

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

cheers

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

* Re: [PATCH RFC 4/6] selftests: remove CROSS_COMPILE in dedicated Makefile
@ 2016-11-18 10:58     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 10:58 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> After previous clean up patches, memfd and timers could get
> CROSS_COMPILE from tools/testing/selftest/lib.mk. There is no need to
> preserve these definition. So, this patch remove them.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Another nice cleanup, thanks.

Acked-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>

cheers

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

* Re: [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
@ 2016-11-18 11:01     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 11:01 UTC (permalink / raw)
  To: bamvor.zhangjian, shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie

bamvor.zhangjian@huawei.com writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> Some testcases need the clean extra data after running. This patch
> introduce the "EXTRA_CLEAN" variable to address this requirement.

The idea here is fine I think. But this will need reworking if you
follow my suggestions for patch 1.

> After KOUTPUT_BUILD is enabled in later patch, it will be easy to
> decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
> testcase ran immediately after compiled.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

All of these:

>  tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
>  tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
>  tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
>  tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
>  tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
>  tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
>  tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---

are just cleaning *.o, and I'm pretty sure none of them need to. So for
those you can just drop the custom clean rule.

This one does need a custom rule:

>  .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---


cheers

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

* Re: [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
@ 2016-11-18 11:01     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 11:01 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Some testcases need the clean extra data after running. This patch
> introduce the "EXTRA_CLEAN" variable to address this requirement.

The idea here is fine I think. But this will need reworking if you
follow my suggestions for patch 1.

> After KOUTPUT_BUILD is enabled in later patch, it will be easy to
> decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
> testcase ran immediately after compiled.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

All of these:

>  tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
>  tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
>  tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
>  tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
>  tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
>  tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
>  tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---

are just cleaning *.o, and I'm pretty sure none of them need to. So for
those you can just drop the custom clean rule.

This one does need a custom rule:

>  .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---


cheers

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

* Re: [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT
@ 2016-11-18 11:29     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 11:29 UTC (permalink / raw)
  To: bamvor.zhangjian, shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie

bamvor.zhangjian@huawei.com writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
> to another directory by passing O or KBUILD_OUTPUT. And O is high
> priority than KBUILD_OUTPUT.

We end up saying $(OUTPUT) a lot, kbuild uses $(obj), which is shorter
and less shouty and reads nicer I think ?

> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index a3144a3..79c5e97 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -47,29 +47,47 @@ override LDFLAGS =
>  override MAKEFLAGS =
>  endif
>  
> +ifeq ($(O)$(KBUILD_OUTPUT),)
> +        BUILD :=$(shell pwd)
> +else
> +        ifneq ($(O),)
> +                BUILD := $(O)
> +        else
> +                ifneq ($(KBUILD_OUTPUT),)
> +                        BUILD := $(KBUILD_OUTPUT)
> +                endif
> +        endif
> +endif

That should be equivalent to:

BUILD := $(O)
ifndef BUILD
  BUILD := $(KBUILD_OUTPUT)
endif
ifndef BUILD
  BUILD := $(shell pwd)
endif



> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
> index 48d1f86..fe5cdec 100644
> --- a/tools/testing/selftests/exec/Makefile
> +++ b/tools/testing/selftests/exec/Makefile
> @@ -5,18 +5,19 @@ TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
>  # Makefile is a run-time dependency, since it's accessed by the execveat test
>  TEST_FILES := Makefile
>  
> -EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
> +EXTRA_CLEAN := $(OUTPUT)subdir.moved $(OUTPUT)execveat.moved $(OUTPUT)xxxxx*

It reads strangely to not have a slash after the output I think it would
be better if you used a slash everywhere you use it, like:

EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*

That makes it clear that it's a directory, and not some other prefix.


Having said that, I think for EXTRA_CLEAN it should just be defined that
the contents are in $(OUTPUT), and so we can just do that in lib.mk, eg:

EXTRA_CLEAN := $(addprefix $(OUTPUT)/,$(EXTRA_CLEAN))

clean:
  	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)


>  include ../lib.mk
>  
> -subdir:
> +$(OUTPUT)subdir:
>  	mkdir -p $@
> -script:
> +$(OUTPUT)script:
>  	echo '#!/bin/sh' > $@
>  	echo 'exit $$*' >> $@
>  	chmod +x $@
> -execveat.symlink: execveat
> -	ln -s -f $< $@
> -execveat.denatured: execveat
> +$(OUTPUT)execveat.symlink: execveat
> +	cd $(OUTPUT) && ln -s -f $< `basename $@`
> +$(OUTPUT)execveat.denatured: execveat
>  	cp $< $@
>  	chmod -x $@

Do those work? I would have thought you'd need $(OUTPUT) on the right
hand side also?

> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 0f7a371..fa87f98 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -33,19 +34,29 @@ endif
>  
>  define EMIT_TESTS
>  	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
> -		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
> +		BASENAME_TEST=`basename $$TEST`;	\
> +		echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
>  	done;
>  endef
>  
>  emit_tests:
>  	$(EMIT_TESTS)
>  
> +TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_PROGS))
> +TEST_GEN_FILES := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_FILES))

You should just be able to use addprefix there.

> +
>  all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
>  
>  clean:
>  	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
>  
> -%: %.c
> -	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
> +$(OUTPUT)%:%.c
> +	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@

I think it reads better with a space after the ":"

$(OUTPUT)/%: %.c
	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@



I'll have to go through and check all those conversions. But I think
I've sent you enough comments for today :)

cheers

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

* Re: [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT
@ 2016-11-18 11:29     ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-18 11:29 UTC (permalink / raw)
  To: bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A

bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:

> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
> to another directory by passing O or KBUILD_OUTPUT. And O is high
> priority than KBUILD_OUTPUT.

We end up saying $(OUTPUT) a lot, kbuild uses $(obj), which is shorter
and less shouty and reads nicer I think ?

> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index a3144a3..79c5e97 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -47,29 +47,47 @@ override LDFLAGS =
>  override MAKEFLAGS =
>  endif
>  
> +ifeq ($(O)$(KBUILD_OUTPUT),)
> +        BUILD :=$(shell pwd)
> +else
> +        ifneq ($(O),)
> +                BUILD := $(O)
> +        else
> +                ifneq ($(KBUILD_OUTPUT),)
> +                        BUILD := $(KBUILD_OUTPUT)
> +                endif
> +        endif
> +endif

That should be equivalent to:

BUILD := $(O)
ifndef BUILD
  BUILD := $(KBUILD_OUTPUT)
endif
ifndef BUILD
  BUILD := $(shell pwd)
endif



> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
> index 48d1f86..fe5cdec 100644
> --- a/tools/testing/selftests/exec/Makefile
> +++ b/tools/testing/selftests/exec/Makefile
> @@ -5,18 +5,19 @@ TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
>  # Makefile is a run-time dependency, since it's accessed by the execveat test
>  TEST_FILES := Makefile
>  
> -EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
> +EXTRA_CLEAN := $(OUTPUT)subdir.moved $(OUTPUT)execveat.moved $(OUTPUT)xxxxx*

It reads strangely to not have a slash after the output I think it would
be better if you used a slash everywhere you use it, like:

EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*

That makes it clear that it's a directory, and not some other prefix.


Having said that, I think for EXTRA_CLEAN it should just be defined that
the contents are in $(OUTPUT), and so we can just do that in lib.mk, eg:

EXTRA_CLEAN := $(addprefix $(OUTPUT)/,$(EXTRA_CLEAN))

clean:
  	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)


>  include ../lib.mk
>  
> -subdir:
> +$(OUTPUT)subdir:
>  	mkdir -p $@
> -script:
> +$(OUTPUT)script:
>  	echo '#!/bin/sh' > $@
>  	echo 'exit $$*' >> $@
>  	chmod +x $@
> -execveat.symlink: execveat
> -	ln -s -f $< $@
> -execveat.denatured: execveat
> +$(OUTPUT)execveat.symlink: execveat
> +	cd $(OUTPUT) && ln -s -f $< `basename $@`
> +$(OUTPUT)execveat.denatured: execveat
>  	cp $< $@
>  	chmod -x $@

Do those work? I would have thought you'd need $(OUTPUT) on the right
hand side also?

> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 0f7a371..fa87f98 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -33,19 +34,29 @@ endif
>  
>  define EMIT_TESTS
>  	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
> -		echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
> +		BASENAME_TEST=`basename $$TEST`;	\
> +		echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
>  	done;
>  endef
>  
>  emit_tests:
>  	$(EMIT_TESTS)
>  
> +TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_PROGS))
> +TEST_GEN_FILES := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_FILES))

You should just be able to use addprefix there.

> +
>  all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
>  
>  clean:
>  	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
>  
> -%: %.c
> -	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
> +$(OUTPUT)%:%.c
> +	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@

I think it reads better with a space after the ":"

$(OUTPUT)/%: %.c
	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@



I'll have to go through and check all those conversions. But I think
I've sent you enough comments for today :)

cheers

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

* Re: [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
  2016-11-18 11:01     ` Michael Ellerman
@ 2016-11-18 12:51       ` Zhangjian (Bamvor)
  -1 siblings, 0 replies; 44+ messages in thread
From: Zhangjian (Bamvor) @ 2016-11-18 12:51 UTC (permalink / raw)
  To: Michael Ellerman, shuahkh
  Cc: linux-api, linux-kernel, khilman, broonie, Bamvor Zhang Jian

Hi, Micheal

On 2016/11/18 19:01, Michael Ellerman wrote:
> bamvor.zhangjian@huawei.com writes:
>
>> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>>
>> Some testcases need the clean extra data after running. This patch
>> introduce the "EXTRA_CLEAN" variable to address this requirement.
>
> The idea here is fine I think. But this will need reworking if you
> follow my suggestions for patch 1.
>
>> After KOUTPUT_BUILD is enabled in later patch, it will be easy to
>> decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
>> testcase ran immediately after compiled.
>>
>> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> All of these:
>
>>  tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
>>  tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
>>  tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
>>  tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
>>  tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
>>  tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
>>  tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
>>  tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---
>
> are just cleaning *.o, and I'm pretty sure none of them need to. So for
> those you can just drop the custom clean rule.
Sorry I do not check these. Because I define the fake target for
testing for ppc. Then I could remove *.o directly in above files.

Regards

Bamvor
>
> This one does need a custom rule:
>
>>  .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---
>
>
> cheers
>

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

* Re: [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
@ 2016-11-18 12:51       ` Zhangjian (Bamvor)
  0 siblings, 0 replies; 44+ messages in thread
From: Zhangjian (Bamvor) @ 2016-11-18 12:51 UTC (permalink / raw)
  To: Michael Ellerman, shuahkh
  Cc: linux-api, linux-kernel, khilman, broonie, Bamvor Zhang Jian

Hi, Micheal

On 2016/11/18 19:01, Michael Ellerman wrote:
> bamvor.zhangjian@huawei.com writes:
>
>> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>>
>> Some testcases need the clean extra data after running. This patch
>> introduce the "EXTRA_CLEAN" variable to address this requirement.
>
> The idea here is fine I think. But this will need reworking if you
> follow my suggestions for patch 1.
>
>> After KOUTPUT_BUILD is enabled in later patch, it will be easy to
>> decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
>> testcase ran immediately after compiled.
>>
>> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> All of these:
>
>>  tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
>>  tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
>>  tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
>>  tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
>>  tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
>>  tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
>>  tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
>>  tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---
>
> are just cleaning *.o, and I'm pretty sure none of them need to. So for
> those you can just drop the custom clean rule.
Sorry I do not check these. Because I define the fake target for
testing for ppc. Then I could remove *.o directly in above files.

Regards

Bamvor
>
> This one does need a custom rule:
>
>>  .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---
>
>
> cheers
>

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-11-18 12:59       ` Zhangjian (Bamvor)
  0 siblings, 0 replies; 44+ messages in thread
From: Zhangjian (Bamvor) @ 2016-11-18 12:59 UTC (permalink / raw)
  To: Michael Ellerman, shuahkh
  Cc: linux-api, linux-kernel, khilman, broonie, Bamvor Zhang Jian

Hi, Michael

On 2016/11/18 18:31, Michael Ellerman wrote:
 >Hi Bamvor,
 >
 >bamvor.zhangjian@huawei.com writes:
 >
 >> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
 >>
 >> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
 >> indicate the default test program, extended test program and test files.
 >> These lead to duplicated all and clean targets.
 >>
 >> In order to remove them, introduce TEST_GEN_PROGS,
 >> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
 >> objected.
 >
 >It's nice to be able to drop the clean rules, but renaming all those
 >variables causes a lot of churn.
 >
 >I think it would be better if we add a new variable, maybe NO_CLEAN,
 >which can be used to specify anything in TEST_PROGS/EXTENDED which
 >should *not* be cleaned.
 >
 >And then the default clean rule will just do:
 >
 >clean:
 >    $(RM) -fr $(filter-out $(NO_CLEAN),$(TEST_PROGS))
Maybe I lost somewhere. I add these variable for all and
clean target. They will be used to output the objects to OUTPUT
directory. Could you please explain in details how should I do it for
"all" target if I do not introduce TEST_GEN_PROGS,
TEST_GEN_PROGS_EXTENDED and TEST_GEN_FILES?

Regards

Bamvor
 >
 >
 >I think that would require less changes overall, because most tests just
 >want to build some files, run them, and then clean them. The tests that
 >need to do more elaborate things are the exception.
 >
 >cheers

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-11-18 12:59       ` Zhangjian (Bamvor)
  0 siblings, 0 replies; 44+ messages in thread
From: Zhangjian (Bamvor) @ 2016-11-18 12:59 UTC (permalink / raw)
  To: Michael Ellerman, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	Bamvor Zhang Jian

Hi, Michael

On 2016/11/18 18:31, Michael Ellerman wrote:
 >Hi Bamvor,
 >
 >bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:
 >
 >> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
 >>
 >> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
 >> indicate the default test program, extended test program and test files.
 >> These lead to duplicated all and clean targets.
 >>
 >> In order to remove them, introduce TEST_GEN_PROGS,
 >> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
 >> objected.
 >
 >It's nice to be able to drop the clean rules, but renaming all those
 >variables causes a lot of churn.
 >
 >I think it would be better if we add a new variable, maybe NO_CLEAN,
 >which can be used to specify anything in TEST_PROGS/EXTENDED which
 >should *not* be cleaned.
 >
 >And then the default clean rule will just do:
 >
 >clean:
 >    $(RM) -fr $(filter-out $(NO_CLEAN),$(TEST_PROGS))
Maybe I lost somewhere. I add these variable for all and
clean target. They will be used to output the objects to OUTPUT
directory. Could you please explain in details how should I do it for
"all" target if I do not introduce TEST_GEN_PROGS,
TEST_GEN_PROGS_EXTENDED and TEST_GEN_FILES?

Regards

Bamvor
 >
 >
 >I think that would require less changes overall, because most tests just
 >want to build some files, run them, and then clean them. The tests that
 >need to do more elaborate things are the exception.
 >
 >cheers

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

* Re: [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT
@ 2016-11-18 13:03       ` Zhangjian (Bamvor)
  0 siblings, 0 replies; 44+ messages in thread
From: Zhangjian (Bamvor) @ 2016-11-18 13:03 UTC (permalink / raw)
  To: Michael Ellerman, shuahkh
  Cc: linux-api, linux-kernel, khilman, broonie, Bamvor Zhang Jian

Hi, Macheal

Thanks your reply.

On 2016/11/18 19:29, Michael Ellerman wrote:
 >> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
 >>
 >> Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
 >> to another directory by passing O or KBUILD_OUTPUT. And O is high
 >> priority than KBUILD_OUTPUT.
 >
 >We end up saying $(OUTPUT) a lot, kbuild uses $(obj), which is shorter
 >and less shouty and reads nicer I think ?
I agree that we need a clearly name. Meanwhile the $(obj) sounds like
compile objects. But it is actually a directory which we put objs to
there. I am wondering if people may confuse about he name. Given that
kbuild make KBUILD_OUTPUT work by defining the srctree. How about pick
up dst (means dsttree) instead of OUTPUT?
 >
 >> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
 >> index a3144a3..79c5e97 100644
 >> --- a/tools/testing/selftests/Makefile
 >> +++ b/tools/testing/selftests/Makefile
 >> @@ -47,29 +47,47 @@ override LDFLAGS =
 >>  override MAKEFLAGS =
 >>  endif
 >>
 >> +ifeq ($(O)$(KBUILD_OUTPUT),)
 >> +        BUILD :=$(shell pwd)
 >> +else
 >> +        ifneq ($(O),)
 >> +                BUILD := $(O)
 >> +        else
 >> +                ifneq ($(KBUILD_OUTPUT),)
 >> +                        BUILD := $(KBUILD_OUTPUT)
 >> +                endif
 >> +        endif
 >> +endif
 >
 >That should be equivalent to:
 >
 >BUILD := $(O)
 >ifndef BUILD
 >  BUILD := $(KBUILD_OUTPUT)
 >endif
 >ifndef BUILD
 >  BUILD := $(shell pwd)
 >endif
Thanks. It works for me. I will update in my next version.
 >
 >> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
 >> index 48d1f86..fe5cdec 100644
 >> --- a/tools/testing/selftests/exec/Makefile
 >> +++ b/tools/testing/selftests/exec/Makefile
 >> @@ -5,18 +5,19 @@ TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
 >>  # Makefile is a run-time dependency, since it's accessed by the execveat test
 >>  TEST_FILES := Makefile
 >>
 >> -EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
 >> +EXTRA_CLEAN := $(OUTPUT)subdir.moved $(OUTPUT)execveat.moved $(OUTPUT)xxxxx*
 >
 >It reads strangely to not have a slash after the output I think it would
 >be better if you used a slash everywhere you use it, like:
 >
 >EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*
 >
 >That makes it clear that it's a directory, and not some other prefix.
Oh, yes. The origin code is not work if remove the slash. I eventually
found that it is because I do the wrong replacement in TEST_GEN_PROGS
and TEST_GEN_FILES. They should be:
TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
 >
 >
 >Having said that, I think for EXTRA_CLEAN it should just be defined that
 >the contents are in $(OUTPUT), and so we can just do that in lib.mk, eg:
 >
 >EXTRA_CLEAN := $(addprefix $(OUTPUT)/,$(EXTRA_CLEAN))
 >
 >clean:
 >    $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
The OUTPUT is the directory we build. It may be not be not the
directory we run the test. For example, pstore do not need compile.
It could run in the source directory.
 >
 >
 >>  include ../lib.mk
 >>
 >> -subdir:
 >> +$(OUTPUT)subdir:
 >>   mkdir -p $@
 >> -script:
 >> +$(OUTPUT)script:
 >>   echo '#!/bin/sh' > $@
 >>   echo 'exit $$*' >> $@
 >>   chmod +x $@
 >> -execveat.symlink: execveat
 >> - ln -s -f $< $@
 >> -execveat.denatured: execveat
 >> +$(OUTPUT)execveat.symlink: execveat
 >> + cd $(OUTPUT) && ln -s -f $< `basename $@`
 >> +$(OUTPUT)execveat.denatured: execveat
 >>   cp $< $@
 >>   chmod -x $@
 >
 >Do those work? I would have thought you'd need $(OUTPUT) on the right
 >hand side also?
It works because execveat will generate twice which is wrong. I will
fix in next version.
 >
 >> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
 >> index 0f7a371..fa87f98 100644
 >> --- a/tools/testing/selftests/lib.mk
 >> +++ b/tools/testing/selftests/lib.mk
 >> @@ -33,19 +34,29 @@ endif
 >>
 >>  define EMIT_TESTS
 >>   @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 >> -     echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
 >> +     BASENAME_TEST=`basename $$TEST`;    \
 >> +     echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
 >>   done;
 >>  endef
 >>
 >>  emit_tests:
 >>   $(EMIT_TESTS)
 >>
 >> +TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_PROGS))
 >> +TEST_GEN_FILES := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_FILES))
 >
 >You should just be able to use addprefix there.
Yes.
 >
 >> +
 >>  all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 >>
 >>  clean:
 >>   $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 >>
 >> -%: %.c
 >> - $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
 >> +$(OUTPUT)%:%.c
 >> + $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
 >
 >I think it reads better with a space after the ":"
Sure

Regards

Bamvor

 >
 >$(OUTPUT)/%: %.c
 >    $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
 >

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

* Re: [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT
@ 2016-11-18 13:03       ` Zhangjian (Bamvor)
  0 siblings, 0 replies; 44+ messages in thread
From: Zhangjian (Bamvor) @ 2016-11-18 13:03 UTC (permalink / raw)
  To: Michael Ellerman, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-DgEjT+Ai2ygdnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	Bamvor Zhang Jian

Hi, Macheal

Thanks your reply.

On 2016/11/18 19:29, Michael Ellerman wrote:
 >> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
 >>
 >> Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
 >> to another directory by passing O or KBUILD_OUTPUT. And O is high
 >> priority than KBUILD_OUTPUT.
 >
 >We end up saying $(OUTPUT) a lot, kbuild uses $(obj), which is shorter
 >and less shouty and reads nicer I think ?
I agree that we need a clearly name. Meanwhile the $(obj) sounds like
compile objects. But it is actually a directory which we put objs to
there. I am wondering if people may confuse about he name. Given that
kbuild make KBUILD_OUTPUT work by defining the srctree. How about pick
up dst (means dsttree) instead of OUTPUT?
 >
 >> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
 >> index a3144a3..79c5e97 100644
 >> --- a/tools/testing/selftests/Makefile
 >> +++ b/tools/testing/selftests/Makefile
 >> @@ -47,29 +47,47 @@ override LDFLAGS =
 >>  override MAKEFLAGS =
 >>  endif
 >>
 >> +ifeq ($(O)$(KBUILD_OUTPUT),)
 >> +        BUILD :=$(shell pwd)
 >> +else
 >> +        ifneq ($(O),)
 >> +                BUILD := $(O)
 >> +        else
 >> +                ifneq ($(KBUILD_OUTPUT),)
 >> +                        BUILD := $(KBUILD_OUTPUT)
 >> +                endif
 >> +        endif
 >> +endif
 >
 >That should be equivalent to:
 >
 >BUILD := $(O)
 >ifndef BUILD
 >  BUILD := $(KBUILD_OUTPUT)
 >endif
 >ifndef BUILD
 >  BUILD := $(shell pwd)
 >endif
Thanks. It works for me. I will update in my next version.
 >
 >> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
 >> index 48d1f86..fe5cdec 100644
 >> --- a/tools/testing/selftests/exec/Makefile
 >> +++ b/tools/testing/selftests/exec/Makefile
 >> @@ -5,18 +5,19 @@ TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
 >>  # Makefile is a run-time dependency, since it's accessed by the execveat test
 >>  TEST_FILES := Makefile
 >>
 >> -EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
 >> +EXTRA_CLEAN := $(OUTPUT)subdir.moved $(OUTPUT)execveat.moved $(OUTPUT)xxxxx*
 >
 >It reads strangely to not have a slash after the output I think it would
 >be better if you used a slash everywhere you use it, like:
 >
 >EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*
 >
 >That makes it clear that it's a directory, and not some other prefix.
Oh, yes. The origin code is not work if remove the slash. I eventually
found that it is because I do the wrong replacement in TEST_GEN_PROGS
and TEST_GEN_FILES. They should be:
TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
 >
 >
 >Having said that, I think for EXTRA_CLEAN it should just be defined that
 >the contents are in $(OUTPUT), and so we can just do that in lib.mk, eg:
 >
 >EXTRA_CLEAN := $(addprefix $(OUTPUT)/,$(EXTRA_CLEAN))
 >
 >clean:
 >    $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
The OUTPUT is the directory we build. It may be not be not the
directory we run the test. For example, pstore do not need compile.
It could run in the source directory.
 >
 >
 >>  include ../lib.mk
 >>
 >> -subdir:
 >> +$(OUTPUT)subdir:
 >>   mkdir -p $@
 >> -script:
 >> +$(OUTPUT)script:
 >>   echo '#!/bin/sh' > $@
 >>   echo 'exit $$*' >> $@
 >>   chmod +x $@
 >> -execveat.symlink: execveat
 >> - ln -s -f $< $@
 >> -execveat.denatured: execveat
 >> +$(OUTPUT)execveat.symlink: execveat
 >> + cd $(OUTPUT) && ln -s -f $< `basename $@`
 >> +$(OUTPUT)execveat.denatured: execveat
 >>   cp $< $@
 >>   chmod -x $@
 >
 >Do those work? I would have thought you'd need $(OUTPUT) on the right
 >hand side also?
It works because execveat will generate twice which is wrong. I will
fix in next version.
 >
 >> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
 >> index 0f7a371..fa87f98 100644
 >> --- a/tools/testing/selftests/lib.mk
 >> +++ b/tools/testing/selftests/lib.mk
 >> @@ -33,19 +34,29 @@ endif
 >>
 >>  define EMIT_TESTS
 >>   @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 >> -     echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
 >> +     BASENAME_TEST=`basename $$TEST`;    \
 >> +     echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \
 >>   done;
 >>  endef
 >>
 >>  emit_tests:
 >>   $(EMIT_TESTS)
 >>
 >> +TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_PROGS))
 >> +TEST_GEN_FILES := $(patsubst %,$(OUTPUT)%,$(TEST_GEN_FILES))
 >
 >You should just be able to use addprefix there.
Yes.
 >
 >> +
 >>  all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
 >>
 >>  clean:
 >>   $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 >>
 >> -%: %.c
 >> - $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
 >> +$(OUTPUT)%:%.c
 >> + $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
 >
 >I think it reads better with a space after the ":"
Sure

Regards

Bamvor

 >
 >$(OUTPUT)/%: %.c
 >    $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
 >

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-11-21  8:53         ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-21  8:53 UTC (permalink / raw)
  To: Zhangjian (Bamvor), shuahkh
  Cc: linux-api, linux-kernel, khilman, broonie, Bamvor Zhang Jian

"Zhangjian (Bamvor)" <bamvor.zhangjian@huawei.com> writes:
> On 2016/11/18 18:31, Michael Ellerman wrote:
>  >bamvor.zhangjian@huawei.com writes:
>  >> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>  >> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
>  >> indicate the default test program, extended test program and test files.
>  >> These lead to duplicated all and clean targets.
>  >>
>  >> In order to remove them, introduce TEST_GEN_PROGS,
>  >> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
>  >> objected.
>  >
>  >It's nice to be able to drop the clean rules, but renaming all those
>  >variables causes a lot of churn.
>  >
>  >I think it would be better if we add a new variable, maybe NO_CLEAN,
>  >which can be used to specify anything in TEST_PROGS/EXTENDED which
>  >should *not* be cleaned.
>  >
>  >And then the default clean rule will just do:
>  >
>  >clean:
>  >    $(RM) -fr $(filter-out $(NO_CLEAN),$(TEST_PROGS))

> Maybe I lost somewhere. I add these variable for all and
> clean target. They will be used to output the objects to OUTPUT
> directory.

No you're right, that won't work as I described it.

I reviewed this patch first and didn't look at how it was required for
patch 6 to work (and the change log doesn't mention that you need it for
patch 6 :)

> Could you please explain in details how should I do it for
> "all" target if I do not introduce TEST_GEN_PROGS,
> TEST_GEN_PROGS_EXTENDED and TEST_GEN_FILES?

I'll have to think about it a bit more.

cheers

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-11-21  8:53         ` Michael Ellerman
  0 siblings, 0 replies; 44+ messages in thread
From: Michael Ellerman @ 2016-11-21  8:53 UTC (permalink / raw)
  To: Zhangjian (Bamvor), shuahkh-JPH+aEBZ4P+UEJcrhfAQsw
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	khilman-QSEj5FYQhm4dnm+yROfE0A, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	Bamvor Zhang Jian

"Zhangjian (Bamvor)" <bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> writes:
> On 2016/11/18 18:31, Michael Ellerman wrote:
>  >bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org writes:
>  >> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>  >> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
>  >> indicate the default test program, extended test program and test files.
>  >> These lead to duplicated all and clean targets.
>  >>
>  >> In order to remove them, introduce TEST_GEN_PROGS,
>  >> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
>  >> objected.
>  >
>  >It's nice to be able to drop the clean rules, but renaming all those
>  >variables causes a lot of churn.
>  >
>  >I think it would be better if we add a new variable, maybe NO_CLEAN,
>  >which can be used to specify anything in TEST_PROGS/EXTENDED which
>  >should *not* be cleaned.
>  >
>  >And then the default clean rule will just do:
>  >
>  >clean:
>  >    $(RM) -fr $(filter-out $(NO_CLEAN),$(TEST_PROGS))

> Maybe I lost somewhere. I add these variable for all and
> clean target. They will be used to output the objects to OUTPUT
> directory.

No you're right, that won't work as I described it.

I reviewed this patch first and didn't look at how it was required for
patch 6 to work (and the change log doesn't mention that you need it for
patch 6 :)

> Could you please explain in details how should I do it for
> "all" target if I do not introduce TEST_GEN_PROGS,
> TEST_GEN_PROGS_EXTENDED and TEST_GEN_FILES?

I'll have to think about it a bit more.

cheers

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-10-21 11:14 ` Bamvor Zhang Jian
  0 siblings, 0 replies; 44+ messages in thread
From: Bamvor Zhang Jian @ 2016-10-21 11:14 UTC (permalink / raw)
  To: Zhang Jian(Bamvor)
  Cc: Shuah Khan, linux-api, lkml, Mark Brown, Michael Ellerman, Kevin Hilman

Fix the wrong email address of kevin hilman to khilman@kernel.org.
Sorry for inconvenience.

On 21 October 2016 at 19:01,  <bamvor.zhangjian@huawei.com> wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
> indicate the default test program, extended test program and test files.
> These lead to duplicated all and clean targets.
>
> In order to remove them, introduce TEST_GEN_PROGS,
> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
> objected.
>
> And add this changes to "Contributing new tests(details)" of
> Documentation/kselftest.txt.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
> ---
>  Documentation/kselftest.txt                        | 13 ++++++++++++
>  tools/testing/selftests/breakpoints/Makefile       |  8 ++------
>  tools/testing/selftests/capabilities/Makefile      | 11 ++--------
>  tools/testing/selftests/efivarfs/Makefile          |  8 +-------
>  tools/testing/selftests/exec/Makefile              | 10 ++++-----
>  tools/testing/selftests/futex/functional/Makefile  | 12 +++--------
>  tools/testing/selftests/ipc/Makefile               |  7 +------
>  tools/testing/selftests/kcmp/Makefile              |  6 ++----
>  tools/testing/selftests/lib.mk                     | 18 ++++++++++++----
>  tools/testing/selftests/membarrier/Makefile        |  6 +-----
>  tools/testing/selftests/memfd/Makefile             | 14 +++----------
>  tools/testing/selftests/mount/Makefile             |  6 ++----
>  tools/testing/selftests/mqueue/Makefile            |  6 +-----
>  tools/testing/selftests/net/Makefile               |  8 +-------
>  tools/testing/selftests/powerpc/alignment/Makefile |  9 ++------
>  .../testing/selftests/powerpc/benchmarks/Makefile  | 10 ++++-----
>  .../selftests/powerpc/context_switch/Makefile      |  9 ++------
>  tools/testing/selftests/powerpc/copyloops/Makefile | 10 ++++-----
>  tools/testing/selftests/powerpc/dscr/Makefile      | 12 +++++------
>  tools/testing/selftests/powerpc/math/Makefile      | 12 +++++------
>  tools/testing/selftests/powerpc/mm/Makefile        | 12 ++++-------
>  tools/testing/selftests/powerpc/pmu/Makefile       | 12 +++++------
>  tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 11 +++-------
>  .../testing/selftests/powerpc/primitives/Makefile  | 10 ++++-----
>  .../testing/selftests/powerpc/stringloops/Makefile | 10 ++++-----
>  .../selftests/powerpc/switch_endian/Makefile       |  8 +++-----
>  tools/testing/selftests/powerpc/syscalls/Makefile  | 10 ++++-----
>  tools/testing/selftests/powerpc/tm/Makefile        | 10 ++++-----
>  tools/testing/selftests/powerpc/vphn/Makefile      | 10 +++------
>  tools/testing/selftests/ptrace/Makefile            |  8 +-------
>  tools/testing/selftests/seccomp/Makefile           |  6 +-----
>  tools/testing/selftests/sigaltstack/Makefile       |  5 +----
>  tools/testing/selftests/size/Makefile              |  6 +-----
>  tools/testing/selftests/timers/Makefile            |  9 ++------
>  tools/testing/selftests/vm/Makefile                | 24 +++++++++-------------
>  35 files changed, 123 insertions(+), 223 deletions(-)
>
> diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
> index 54bee77..11cdd06 100644
> --- a/Documentation/kselftest.txt
> +++ b/Documentation/kselftest.txt
> @@ -84,3 +84,16 @@ In general, the rules for selftests are
>
>   * Don't cause the top-level "make run_tests" to fail if your feature is
>     unconfigured.
> +
> +Contributing new tests(details)
> +===============================
> +
> + * Use TEST_GEN_XXX if such binaries or files are generated during
> +   compiling.
> +   TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
> +   default.
> +   TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
> +   executable which is not tested by default.
> +   TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
> +   test.
> +
> diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
> index 74e533f..616f36a 100644
> --- a/tools/testing/selftests/breakpoints/Makefile
> +++ b/tools/testing/selftests/breakpoints/Makefile
> @@ -3,14 +3,10 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
>  ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
>
>  ifeq ($(ARCH),x86)
> -TEST_PROGS := breakpoint_test
> +TEST_GEN_PROGS := breakpoint_test
>  endif
>
> -TEST_PROGS += step_after_suspend_test
> -
> -all: $(TEST_PROGS)
> +TEST_GEN_PROGS += step_after_suspend_test
>
>  include ../lib.mk
>
> -clean:
> -       rm -fr breakpoint_test step_after_suspend_test
> diff --git a/tools/testing/selftests/capabilities/Makefile b/tools/testing/selftests/capabilities/Makefile
> index 008602a..29b8adf 100644
> --- a/tools/testing/selftests/capabilities/Makefile
> +++ b/tools/testing/selftests/capabilities/Makefile
> @@ -1,15 +1,8 @@
> -TEST_FILES := validate_cap
> -TEST_PROGS := test_execve
> -
> -BINARIES := $(TEST_FILES) $(TEST_PROGS)
> +TEST_GEN_FILES := validate_cap
> +TEST_GEN_PROGS := test_execve
>
>  CFLAGS += -O2 -g -std=gnu99 -Wall
>  LDLIBS += -lcap-ng -lrt -ldl
>
> -all: $(BINARIES)
> -
> -clean:
> -       $(RM) $(BINARIES)
> -
>  include ../lib.mk
>
> diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
> index 736c3dd..c49dcea 100644
> --- a/tools/testing/selftests/efivarfs/Makefile
> +++ b/tools/testing/selftests/efivarfs/Makefile
> @@ -1,13 +1,7 @@
>  CFLAGS = -Wall
>
> -test_objs = open-unlink create-read
> -
> -all: $(test_objs)
> -
> +TEST_GEN_FILES := open-unlink create-read
>  TEST_PROGS := efivarfs.sh
> -TEST_FILES := $(test_objs)
>
>  include ../lib.mk
>
> -clean:
> -       rm -f $(test_objs)
> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
> index d430060..b3bf091 100644
> --- a/tools/testing/selftests/exec/Makefile
> +++ b/tools/testing/selftests/exec/Makefile
> @@ -1,7 +1,4 @@
>  CFLAGS = -Wall
> -BINARIES = execveat
> -DEPS = execveat.symlink execveat.denatured script subdir
> -all: $(BINARIES) $(DEPS)
>
>  subdir:
>         mkdir -p $@
> @@ -17,11 +14,12 @@ execveat.denatured: execveat
>  %: %.c
>         $(CC) $(CFLAGS) -o $@ $^
>
> -TEST_PROGS := execveat
> +TEST_GEN_PROGS := execveat
> +TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
>  # Makefile is a run-time dependency, since it's accessed by the execveat test
> -TEST_FILES := $(DEPS) Makefile
> +TEST_FILES := Makefile
>
>  include ../lib.mk
>
>  clean:
> -       rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
> +       rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
> diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
> index 9d6b75e..ac35782 100644
> --- a/tools/testing/selftests/futex/functional/Makefile
> +++ b/tools/testing/selftests/futex/functional/Makefile
> @@ -3,7 +3,7 @@ CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
>  LDFLAGS := $(LDFLAGS) -pthread -lrt
>
>  HEADERS := ../include/futextest.h
> -TARGETS := \
> +TEST_GEN_FILES := \
>         futex_wait_timeout \
>         futex_wait_wouldblock \
>         futex_requeue_pi \
> @@ -12,14 +12,8 @@ TARGETS := \
>         futex_wait_uninitialized_heap \
>         futex_wait_private_mapped_file
>
> -TEST_PROGS := $(TARGETS) run.sh
> -
> -.PHONY: all clean
> -all: $(TARGETS)
> -
> -$(TARGETS): $(HEADERS)
> +TEST_PROGS := run.sh
>
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TARGETS)
> +$(TEST_GEN_FILES): $(HEADERS)
> diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
> index 25d2e70..30ef4c7 100644
> --- a/tools/testing/selftests/ipc/Makefile
> +++ b/tools/testing/selftests/ipc/Makefile
> @@ -11,12 +11,7 @@ endif
>
>  CFLAGS += -I../../../../usr/include/
>
> -all:
> -       $(CC) $(CFLAGS) msgque.c -o msgque_test
> -
> -TEST_PROGS := msgque_test
> +TEST_GEN_PROGS := msgque
>
>  include ../lib.mk
>
> -clean:
> -       rm -fr ./msgque_test
> diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
> index 2ae7450..9e8b673 100644
> --- a/tools/testing/selftests/kcmp/Makefile
> +++ b/tools/testing/selftests/kcmp/Makefile
> @@ -1,10 +1,8 @@
>  CFLAGS += -I../../../../usr/include/
>
> -all: kcmp_test
> -
> -TEST_PROGS := kcmp_test
> +TEST_GEN_PROGS := kcmp_test
>
>  include ../lib.mk
>
>  clean:
> -       $(RM) kcmp_test kcmp-test-file
> +       $(RM) $(TEST_GEN_PROGS) kcmp-test-file
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 50a93f5..12edfb1f 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -3,7 +3,7 @@
>  CC := $(CROSS_COMPILE)gcc
>
>  define RUN_TESTS
> -       @for TEST in $(TEST_PROGS); do \
> +       @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
>                 (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
>         done;
>  endef
> @@ -14,8 +14,13 @@ run_tests: all
>  define INSTALL_RULE
>         @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then                                        \
>                 mkdir -p ${INSTALL_PATH};                                                                               \
> -               echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
> -               rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
> +               echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
> +               rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
> +       fi
> +       @if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then                                    \
> +               mkdir -p ${INSTALL_PATH};                                                                               \
> +               echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/";        \
> +               rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/;               \
>         fi
>  endef
>
> @@ -27,7 +32,7 @@ else
>  endif
>
>  define EMIT_TESTS
> -       @for TEST in $(TEST_PROGS); do \
> +       @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
>                 echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
>         done;
>  endef
> @@ -35,4 +40,9 @@ endef
>  emit_tests:
>         $(EMIT_TESTS)
>
> +all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
> +
> +clean:
> +       $(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
> +
>  .PHONY: run_tests all clean install emit_tests
> diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile
> index a1a9708..0284553 100644
> --- a/tools/testing/selftests/membarrier/Makefile
> +++ b/tools/testing/selftests/membarrier/Makefile
> @@ -1,10 +1,6 @@
>  CFLAGS += -g -I../../../../usr/include/
>
> -TEST_PROGS := membarrier_test
> -
> -all: $(TEST_PROGS)
> +TEST_GEN_PROGS := membarrier_test
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(TEST_PROGS)
> diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
> index fd396ac..2c87f23 100644
> --- a/tools/testing/selftests/memfd/Makefile
> +++ b/tools/testing/selftests/memfd/Makefile
> @@ -4,19 +4,11 @@ CFLAGS += -I../../../../include/uapi/
>  CFLAGS += -I../../../../include/
>  CFLAGS += -I../../../../usr/include/
>
> -TEST_PROGS := memfd_test
> -
> -all: $(TEST_PROGS)
> -
> -include ../lib.mk
> -
> -build_fuse: fuse_mnt fuse_test
> +TEST_PROGS := run_fuse_test.sh
> +TEST_GEN_FILES := memfd_test fuse_mnt fuse_test
>
>  fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
>  fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
>
> -run_fuse: build_fuse
> -       @./run_fuse_test.sh || echo "fuse_test: [FAIL]"
> +include ../lib.mk
>
> -clean:
> -       $(RM) memfd_test fuse_test
> diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
> index 5e35c9c..e8fb15e 100644
> --- a/tools/testing/selftests/mount/Makefile
> +++ b/tools/testing/selftests/mount/Makefile
> @@ -1,14 +1,14 @@
>  # Makefile for mount selftests.
>  CFLAGS = -Wall \
>           -O2
> -all: unprivileged-remount-test
>
>  unprivileged-remount-test: unprivileged-remount-test.c
>         $(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
>
> +TEST_GEN_PROGS := unprivileged-remount-test
> +
>  include ../lib.mk
>
> -TEST_PROGS := unprivileged-remount-test
>  override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
>                       then      \
>                                 ./unprivileged-remount-test ; \
> @@ -17,5 +17,3 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
>                       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 eebac29..79a664a 100644
> --- a/tools/testing/selftests/mqueue/Makefile
> +++ b/tools/testing/selftests/mqueue/Makefile
> @@ -1,8 +1,6 @@
>  CFLAGS += -O2
>  LDLIBS = -lrt -lpthread -lpopt
> -TEST_PROGS := mq_open_tests mq_perf_tests
> -
> -all: $(TEST_PROGS)
> +TEST_GEN_PROGS := mq_open_tests mq_perf_tests
>
>  include ../lib.mk
>
> @@ -16,5 +14,3 @@ override define EMIT_TESTS
>         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 0e53407..c976425 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -4,16 +4,10 @@ CFLAGS = -Wall -O2 -g
>
>  CFLAGS += -I../../../../usr/include/
>
> -NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
> -
> -all: $(NET_PROGS)
>  %: %.c
>         $(CC) $(CFLAGS) -o $@ $^
> -
>  TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
> -TEST_FILES := $(NET_PROGS)
> +TEST_GEN_FILES := socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(NET_PROGS)
> diff --git a/tools/testing/selftests/powerpc/alignment/Makefile b/tools/testing/selftests/powerpc/alignment/Makefile
> index ad6a4e4..16b2200 100644
> --- a/tools/testing/selftests/powerpc/alignment/Makefile
> +++ b/tools/testing/selftests/powerpc/alignment/Makefile
> @@ -1,10 +1,5 @@
> -TEST_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
> -
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
> +TEST_GEN_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
>
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
> diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
> index a9adfb7..985a77c 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/Makefile
> +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
> @@ -1,16 +1,14 @@
> -TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench
> +TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench
>
>  CFLAGS += -O2
>
> -all: $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c
>
> -$(TEST_PROGS): ../harness.c
> +include ../../lib.mk
>
>  context_switch: ../utils.c
>  context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
>  context_switch: LDLIBS += -lpthread
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/context_switch/Makefile b/tools/testing/selftests/powerpc/context_switch/Makefile
> index e164d14..e9351bb 100644
> --- a/tools/testing/selftests/powerpc/context_switch/Makefile
> +++ b/tools/testing/selftests/powerpc/context_switch/Makefile
> @@ -1,10 +1,5 @@
> -TEST_PROGS := cp_abort
> -
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c ../utils.c
> +TEST_GEN_PROGS := cp_abort
>
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c ../utils.c
> diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
> index 384843e..eff1034 100644
> --- a/tools/testing/selftests/powerpc/copyloops/Makefile
> +++ b/tools/testing/selftests/powerpc/copyloops/Makefile
> @@ -7,19 +7,17 @@ CFLAGS += -maltivec
>  # Use our CFLAGS for the implicit .S rule
>  ASFLAGS = $(CFLAGS)
>
> -TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
> +TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
>  EXTRA_SOURCES := validate.c ../harness.c
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
>  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
>
> -$(TEST_PROGS): $(EXTRA_SOURCES)
> -
> -include ../../lib.mk
> +$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
>
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index 49327ee..96e0de0 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,14 +1,12 @@
> -TEST_PROGS := dscr_default_test dscr_explicit_test dscr_user_test      \
> +TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test  \
>               dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test  \
>               dscr_sysfs_thread_test
>
> -dscr_default_test: LDLIBS += -lpthread
> -
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c
> +dscr_default_test: LDLIBS += -lpthread
>
> -include ../../lib.mk
> +$(TEST_GEN_PROGS): ../harness.c
>
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
> index a505b66..8a5dde5 100644
> --- a/tools/testing/selftests/powerpc/math/Makefile
> +++ b/tools/testing/selftests/powerpc/math/Makefile
> @@ -1,9 +1,9 @@
> -TEST_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
> +TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c
> -$(TEST_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
> +$(TEST_GEN_PROGS): ../harness.c
> +$(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
>
>  fpu_syscall: fpu_asm.S
>  fpu_preempt: fpu_asm.S
> @@ -16,7 +16,5 @@ vmx_signal: vmx_asm.S
>  vsx_preempt: CFLAGS += -mvsx
>  vsx_preempt: vsx_asm.S
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
> index 3bdb96e..d563378 100644
> --- a/tools/testing/selftests/powerpc/mm/Makefile
> +++ b/tools/testing/selftests/powerpc/mm/Makefile
> @@ -1,19 +1,15 @@
>  noarg:
>         $(MAKE) -C ../
>
> -TEST_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
> -TEST_FILES := tempfile
> +TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
> +TEST_GEN_FILES := tempfile
>
> -all: $(TEST_PROGS) $(TEST_FILES)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c
> +$(TEST_GEN_PROGS): ../harness.c
>
>  prot_sao: ../utils.c
>
> -include ../../lib.mk
> -
>  tempfile:
>         dd if=/dev/zero of=tempfile bs=64k count=1
>
> -clean:
> -       rm -f $(TEST_PROGS) tempfile
> diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
> index ac41a71..ab0f902 100644
> --- a/tools/testing/selftests/powerpc/pmu/Makefile
> +++ b/tools/testing/selftests/powerpc/pmu/Makefile
> @@ -1,12 +1,14 @@
>  noarg:
>         $(MAKE) -C ../
>
> -TEST_PROGS := count_instructions l3_bank_test per_event_excludes
> +TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes
>  EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c
>
> -all: $(TEST_PROGS) ebb
> +include ../../lib.mk
> +
> +all: $(TEST_GEN_PROGS) ebb
>
> -$(TEST_PROGS): $(EXTRA_SOURCES)
> +$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
>
>  # loop.S can only be built 64-bit
>  count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
> @@ -14,8 +16,6 @@ count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
>
>  per_event_excludes: ../utils.c
>
> -include ../../lib.mk
> -
>  DEFAULT_RUN_TESTS := $(RUN_TESTS)
>  override define RUN_TESTS
>         $(DEFAULT_RUN_TESTS)
> @@ -35,7 +35,7 @@ override define INSTALL_RULE
>  endef
>
>  clean:
> -       rm -f $(TEST_PROGS) loop.o
> +       $(RM) $(TEST_PROGS) loop.o
>         $(MAKE) -C ebb clean
>
>  ebb:
> diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
> index 6b0453e..8dcedc4 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
>
> -TEST_PROGS := reg_access_test event_attributes_test cycles_test        \
> +TEST_GEN_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,16 +16,11 @@ TEST_PROGS := reg_access_test event_attributes_test cycles_test     \
>          lost_exception_test no_handler_test                    \
>          cycles_with_mmcr2_test ebb_lmr ebb_lmr_regs
>
> -all: $(TEST_PROGS)
> +include ../../../lib.mk
>
> -$(TEST_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
> +$(TEST_GEN_PROGS): ../../harness.c ../../utils.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
> -
> -include ../../../lib.mk
> -
> -clean:
> -       rm -f $(TEST_PROGS)
> diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
> index b68c622..32cd56c 100644
> --- a/tools/testing/selftests/powerpc/primitives/Makefile
> +++ b/tools/testing/selftests/powerpc/primitives/Makefile
> @@ -1,12 +1,10 @@
>  CFLAGS += -I$(CURDIR)
>
> -TEST_PROGS := load_unaligned_zeropad
> -
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c
> +TEST_GEN_PROGS := load_unaligned_zeropad
>
>  include ../../lib.mk
>
> +$(TEST_GEN_PROGS): ../harness.c
> +
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
> index 2a728f4..c0ce663 100644
> --- a/tools/testing/selftests/powerpc/stringloops/Makefile
> +++ b/tools/testing/selftests/powerpc/stringloops/Makefile
> @@ -2,14 +2,12 @@
>  CFLAGS += -m64
>  CFLAGS += -I$(CURDIR)
>
> -TEST_PROGS := memcmp
> +TEST_GEN_PROGS := memcmp
>  EXTRA_SOURCES := memcmp_64.S ../harness.c
>
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): $(EXTRA_SOURCES)
> -
>  include ../../lib.mk
>
> +$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
> +
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
> index e21d106..bd01223 100644
> --- a/tools/testing/selftests/powerpc/switch_endian/Makefile
> +++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
> @@ -1,8 +1,8 @@
> -TEST_PROGS := switch_endian_test
> +TEST_GEN_PROGS := switch_endian_test
>
>  ASFLAGS += -O2 -Wall -g -nostdlib -m64
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
>  switch_endian_test: check-reversed.S
>
> @@ -12,7 +12,5 @@ check-reversed.o: check.o
>  check-reversed.S: check-reversed.o
>         hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o check-reversed.S
> +       $(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
> diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
> index b35c794..5bea391 100644
> --- a/tools/testing/selftests/powerpc/syscalls/Makefile
> +++ b/tools/testing/selftests/powerpc/syscalls/Makefile
> @@ -1,12 +1,10 @@
> -TEST_PROGS := ipc_unmuxed
> +TEST_GEN_PROGS := ipc_unmuxed
>
>  CFLAGS += -I../../../../../usr/include
>
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c
> -
>  include ../../lib.mk
>
> +$(TEST_GEN_PROGS): ../harness.c
> +
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
> index c6c53c8..cad0821 100644
> --- a/tools/testing/selftests/powerpc/tm/Makefile
> +++ b/tools/testing/selftests/powerpc/tm/Makefile
> @@ -1,12 +1,12 @@
>  SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu \
>         tm-signal-context-chk-vmx tm-signal-context-chk-vsx
>
> -TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
> +TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
>         tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c ../utils.c
> +$(TEST_GEN_PROGS): ../harness.c ../utils.c
>
>  CFLAGS += -mhtm
>
> @@ -17,7 +17,5 @@ tm-tmspr: CFLAGS += -pthread
>  $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
>  $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/vphn/Makefile b/tools/testing/selftests/powerpc/vphn/Makefile
> index a485f2e..f8ced26 100644
> --- a/tools/testing/selftests/powerpc/vphn/Makefile
> +++ b/tools/testing/selftests/powerpc/vphn/Makefile
> @@ -1,12 +1,8 @@
> -TEST_PROGS := test-vphn
> +TEST_GEN_PROGS := test-vphn
>
>  CFLAGS += -m64
>
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c
> -
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c
> +
> diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
> index 453927f..8a2bc55 100644
> --- a/tools/testing/selftests/ptrace/Makefile
> +++ b/tools/testing/selftests/ptrace/Makefile
> @@ -1,11 +1,5 @@
>  CFLAGS += -iquote../../../../include/uapi -Wall
> -peeksiginfo: peeksiginfo.c
>
> -all: peeksiginfo
> -
> -clean:
> -       rm -f peeksiginfo
> -
> -TEST_PROGS := peeksiginfo
> +TEST_GEN_PROGS := peeksiginfo
>
>  include ../lib.mk
> diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
> index 8401e87..5fa6fd2 100644
> --- a/tools/testing/selftests/seccomp/Makefile
> +++ b/tools/testing/selftests/seccomp/Makefile
> @@ -1,10 +1,6 @@
> -TEST_PROGS := seccomp_bpf
> +TEST_GEN_PROGS := seccomp_bpf
>  CFLAGS += -Wl,-no-as-needed -Wall
>  LDFLAGS += -lpthread
>
> -all: $(TEST_PROGS)
> -
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(TEST_PROGS)
> diff --git a/tools/testing/selftests/sigaltstack/Makefile b/tools/testing/selftests/sigaltstack/Makefile
> index 56af56e..f68fbf8 100644
> --- a/tools/testing/selftests/sigaltstack/Makefile
> +++ b/tools/testing/selftests/sigaltstack/Makefile
> @@ -1,8 +1,5 @@
>  CFLAGS = -Wall
> -BINARIES = sas
> -all: $(BINARIES)
> +TEST_GEN_PROGS = sas
>
>  include ../lib.mk
>
> -clean:
> -       rm -rf $(BINARIES)
> diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
> index bbd0b53..c67f357 100644
> --- a/tools/testing/selftests/size/Makefile
> +++ b/tools/testing/selftests/size/Makefile
> @@ -1,11 +1,7 @@
> -all: get_size
>
>  get_size: get_size.c
>         $(CC) -static -ffreestanding -nostartfiles -s $< -o $@
>
> -TEST_PROGS := get_size
> +TEST_GEN_PROGS := get_size
>
>  include ../lib.mk
> -
> -clean:
> -       $(RM) get_size
> diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
> index 1d55568..4a3bffe 100644
> --- a/tools/testing/selftests/timers/Makefile
> +++ b/tools/testing/selftests/timers/Makefile
> @@ -5,16 +5,13 @@ LDFLAGS += -lrt -lpthread
>
>  # these are all "safe" tests that don't modify
>  # system time or require escalated privledges
> -TEST_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
> +TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
>              inconsistency-check raw_skew threadtest rtctest
>
> -TEST_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
> +TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
>                       skew_consistency clocksource-switch leap-a-day \
>                       leapcrash set-tai set-2038 set-tz
>
> -bins = $(TEST_PROGS) $(TEST_PROGS_EXTENDED)
> -
> -all: ${bins}
>
>  include ../lib.mk
>
> @@ -34,5 +31,3 @@ run_destructive_tests: run_tests
>         ./set-tai
>         ./set-2038
>
> -clean:
> -       rm -f ${bins}
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index bbab7f4..323383a 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -1,18 +1,17 @@
>  # Makefile for vm selftests
>
>  CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
> -BINARIES = compaction_test
> -BINARIES += hugepage-mmap
> -BINARIES += hugepage-shm
> -BINARIES += map_hugetlb
> -BINARIES += mlock2-tests
> -BINARIES += on-fault-limit
> -BINARIES += thuge-gen
> -BINARIES += transhuge-stress
> -BINARIES += userfaultfd
> -BINARIES += mlock-random-test
> +TEST_GEN_FILES = compaction_test
> +TEST_GEN_FILES += hugepage-mmap
> +TEST_GEN_FILES += hugepage-shm
> +TEST_GEN_FILES += map_hugetlb
> +TEST_GEN_FILES += mlock2-tests
> +TEST_GEN_FILES += on-fault-limit
> +TEST_GEN_FILES += thuge-gen
> +TEST_GEN_FILES += transhuge-stress
> +TEST_GEN_FILES += userfaultfd
> +TEST_GEN_FILES += mlock-random-test
>
> -all: $(BINARIES)
>  %: %.c
>         $(CC) $(CFLAGS) -o $@ $^ -lrt
>  userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
> @@ -25,9 +24,6 @@ mlock-random-test: mlock-random-test.c
>         make -C ../../../.. headers_install
>
>  TEST_PROGS := run_vmtests
> -TEST_FILES := $(BINARIES)
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(BINARIES)
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH RFC 1/6] selftests: remove duplicated all and clean target
@ 2016-10-21 11:14 ` Bamvor Zhang Jian
  0 siblings, 0 replies; 44+ messages in thread
From: Bamvor Zhang Jian @ 2016-10-21 11:14 UTC (permalink / raw)
  To: Zhang Jian(Bamvor)
  Cc: Shuah Khan, linux-api, lkml, Mark Brown, Michael Ellerman, Kevin Hilman

Fix the wrong email address of kevin hilman to khilman-DgEjT+Ai2yi4UlQgPVntAg@public.gmane.org
Sorry for inconvenience.

On 21 October 2016 at 19:01,  <bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
> indicate the default test program, extended test program and test files.
> These lead to duplicated all and clean targets.
>
> In order to remove them, introduce TEST_GEN_PROGS,
> TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
> objected.
>
> And add this changes to "Contributing new tests(details)" of
> Documentation/kselftest.txt.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  Documentation/kselftest.txt                        | 13 ++++++++++++
>  tools/testing/selftests/breakpoints/Makefile       |  8 ++------
>  tools/testing/selftests/capabilities/Makefile      | 11 ++--------
>  tools/testing/selftests/efivarfs/Makefile          |  8 +-------
>  tools/testing/selftests/exec/Makefile              | 10 ++++-----
>  tools/testing/selftests/futex/functional/Makefile  | 12 +++--------
>  tools/testing/selftests/ipc/Makefile               |  7 +------
>  tools/testing/selftests/kcmp/Makefile              |  6 ++----
>  tools/testing/selftests/lib.mk                     | 18 ++++++++++++----
>  tools/testing/selftests/membarrier/Makefile        |  6 +-----
>  tools/testing/selftests/memfd/Makefile             | 14 +++----------
>  tools/testing/selftests/mount/Makefile             |  6 ++----
>  tools/testing/selftests/mqueue/Makefile            |  6 +-----
>  tools/testing/selftests/net/Makefile               |  8 +-------
>  tools/testing/selftests/powerpc/alignment/Makefile |  9 ++------
>  .../testing/selftests/powerpc/benchmarks/Makefile  | 10 ++++-----
>  .../selftests/powerpc/context_switch/Makefile      |  9 ++------
>  tools/testing/selftests/powerpc/copyloops/Makefile | 10 ++++-----
>  tools/testing/selftests/powerpc/dscr/Makefile      | 12 +++++------
>  tools/testing/selftests/powerpc/math/Makefile      | 12 +++++------
>  tools/testing/selftests/powerpc/mm/Makefile        | 12 ++++-------
>  tools/testing/selftests/powerpc/pmu/Makefile       | 12 +++++------
>  tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 11 +++-------
>  .../testing/selftests/powerpc/primitives/Makefile  | 10 ++++-----
>  .../testing/selftests/powerpc/stringloops/Makefile | 10 ++++-----
>  .../selftests/powerpc/switch_endian/Makefile       |  8 +++-----
>  tools/testing/selftests/powerpc/syscalls/Makefile  | 10 ++++-----
>  tools/testing/selftests/powerpc/tm/Makefile        | 10 ++++-----
>  tools/testing/selftests/powerpc/vphn/Makefile      | 10 +++------
>  tools/testing/selftests/ptrace/Makefile            |  8 +-------
>  tools/testing/selftests/seccomp/Makefile           |  6 +-----
>  tools/testing/selftests/sigaltstack/Makefile       |  5 +----
>  tools/testing/selftests/size/Makefile              |  6 +-----
>  tools/testing/selftests/timers/Makefile            |  9 ++------
>  tools/testing/selftests/vm/Makefile                | 24 +++++++++-------------
>  35 files changed, 123 insertions(+), 223 deletions(-)
>
> diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt
> index 54bee77..11cdd06 100644
> --- a/Documentation/kselftest.txt
> +++ b/Documentation/kselftest.txt
> @@ -84,3 +84,16 @@ In general, the rules for selftests are
>
>   * Don't cause the top-level "make run_tests" to fail if your feature is
>     unconfigured.
> +
> +Contributing new tests(details)
> +===============================
> +
> + * Use TEST_GEN_XXX if such binaries or files are generated during
> +   compiling.
> +   TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by
> +   default.
> +   TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the
> +   executable which is not tested by default.
> +   TEST_FILES, TEST_GEN_FILES mean it is the file which is used by
> +   test.
> +
> diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
> index 74e533f..616f36a 100644
> --- a/tools/testing/selftests/breakpoints/Makefile
> +++ b/tools/testing/selftests/breakpoints/Makefile
> @@ -3,14 +3,10 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
>  ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
>
>  ifeq ($(ARCH),x86)
> -TEST_PROGS := breakpoint_test
> +TEST_GEN_PROGS := breakpoint_test
>  endif
>
> -TEST_PROGS += step_after_suspend_test
> -
> -all: $(TEST_PROGS)
> +TEST_GEN_PROGS += step_after_suspend_test
>
>  include ../lib.mk
>
> -clean:
> -       rm -fr breakpoint_test step_after_suspend_test
> diff --git a/tools/testing/selftests/capabilities/Makefile b/tools/testing/selftests/capabilities/Makefile
> index 008602a..29b8adf 100644
> --- a/tools/testing/selftests/capabilities/Makefile
> +++ b/tools/testing/selftests/capabilities/Makefile
> @@ -1,15 +1,8 @@
> -TEST_FILES := validate_cap
> -TEST_PROGS := test_execve
> -
> -BINARIES := $(TEST_FILES) $(TEST_PROGS)
> +TEST_GEN_FILES := validate_cap
> +TEST_GEN_PROGS := test_execve
>
>  CFLAGS += -O2 -g -std=gnu99 -Wall
>  LDLIBS += -lcap-ng -lrt -ldl
>
> -all: $(BINARIES)
> -
> -clean:
> -       $(RM) $(BINARIES)
> -
>  include ../lib.mk
>
> diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
> index 736c3dd..c49dcea 100644
> --- a/tools/testing/selftests/efivarfs/Makefile
> +++ b/tools/testing/selftests/efivarfs/Makefile
> @@ -1,13 +1,7 @@
>  CFLAGS = -Wall
>
> -test_objs = open-unlink create-read
> -
> -all: $(test_objs)
> -
> +TEST_GEN_FILES := open-unlink create-read
>  TEST_PROGS := efivarfs.sh
> -TEST_FILES := $(test_objs)
>
>  include ../lib.mk
>
> -clean:
> -       rm -f $(test_objs)
> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
> index d430060..b3bf091 100644
> --- a/tools/testing/selftests/exec/Makefile
> +++ b/tools/testing/selftests/exec/Makefile
> @@ -1,7 +1,4 @@
>  CFLAGS = -Wall
> -BINARIES = execveat
> -DEPS = execveat.symlink execveat.denatured script subdir
> -all: $(BINARIES) $(DEPS)
>
>  subdir:
>         mkdir -p $@
> @@ -17,11 +14,12 @@ execveat.denatured: execveat
>  %: %.c
>         $(CC) $(CFLAGS) -o $@ $^
>
> -TEST_PROGS := execveat
> +TEST_GEN_PROGS := execveat
> +TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
>  # Makefile is a run-time dependency, since it's accessed by the execveat test
> -TEST_FILES := $(DEPS) Makefile
> +TEST_FILES := Makefile
>
>  include ../lib.mk
>
>  clean:
> -       rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
> +       rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
> diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
> index 9d6b75e..ac35782 100644
> --- a/tools/testing/selftests/futex/functional/Makefile
> +++ b/tools/testing/selftests/futex/functional/Makefile
> @@ -3,7 +3,7 @@ CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
>  LDFLAGS := $(LDFLAGS) -pthread -lrt
>
>  HEADERS := ../include/futextest.h
> -TARGETS := \
> +TEST_GEN_FILES := \
>         futex_wait_timeout \
>         futex_wait_wouldblock \
>         futex_requeue_pi \
> @@ -12,14 +12,8 @@ TARGETS := \
>         futex_wait_uninitialized_heap \
>         futex_wait_private_mapped_file
>
> -TEST_PROGS := $(TARGETS) run.sh
> -
> -.PHONY: all clean
> -all: $(TARGETS)
> -
> -$(TARGETS): $(HEADERS)
> +TEST_PROGS := run.sh
>
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TARGETS)
> +$(TEST_GEN_FILES): $(HEADERS)
> diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
> index 25d2e70..30ef4c7 100644
> --- a/tools/testing/selftests/ipc/Makefile
> +++ b/tools/testing/selftests/ipc/Makefile
> @@ -11,12 +11,7 @@ endif
>
>  CFLAGS += -I../../../../usr/include/
>
> -all:
> -       $(CC) $(CFLAGS) msgque.c -o msgque_test
> -
> -TEST_PROGS := msgque_test
> +TEST_GEN_PROGS := msgque
>
>  include ../lib.mk
>
> -clean:
> -       rm -fr ./msgque_test
> diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
> index 2ae7450..9e8b673 100644
> --- a/tools/testing/selftests/kcmp/Makefile
> +++ b/tools/testing/selftests/kcmp/Makefile
> @@ -1,10 +1,8 @@
>  CFLAGS += -I../../../../usr/include/
>
> -all: kcmp_test
> -
> -TEST_PROGS := kcmp_test
> +TEST_GEN_PROGS := kcmp_test
>
>  include ../lib.mk
>
>  clean:
> -       $(RM) kcmp_test kcmp-test-file
> +       $(RM) $(TEST_GEN_PROGS) kcmp-test-file
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 50a93f5..12edfb1f 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -3,7 +3,7 @@
>  CC := $(CROSS_COMPILE)gcc
>
>  define RUN_TESTS
> -       @for TEST in $(TEST_PROGS); do \
> +       @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
>                 (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
>         done;
>  endef
> @@ -14,8 +14,13 @@ run_tests: all
>  define INSTALL_RULE
>         @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then                                        \
>                 mkdir -p ${INSTALL_PATH};                                                                               \
> -               echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
> -               rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
> +               echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/";       \
> +               rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/;              \
> +       fi
> +       @if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then                                    \
> +               mkdir -p ${INSTALL_PATH};                                                                               \
> +               echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/";        \
> +               rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/;               \
>         fi
>  endef
>
> @@ -27,7 +32,7 @@ else
>  endif
>
>  define EMIT_TESTS
> -       @for TEST in $(TEST_PROGS); do \
> +       @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
>                 echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \
>         done;
>  endef
> @@ -35,4 +40,9 @@ endef
>  emit_tests:
>         $(EMIT_TESTS)
>
> +all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
> +
> +clean:
> +       $(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
> +
>  .PHONY: run_tests all clean install emit_tests
> diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile
> index a1a9708..0284553 100644
> --- a/tools/testing/selftests/membarrier/Makefile
> +++ b/tools/testing/selftests/membarrier/Makefile
> @@ -1,10 +1,6 @@
>  CFLAGS += -g -I../../../../usr/include/
>
> -TEST_PROGS := membarrier_test
> -
> -all: $(TEST_PROGS)
> +TEST_GEN_PROGS := membarrier_test
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(TEST_PROGS)
> diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
> index fd396ac..2c87f23 100644
> --- a/tools/testing/selftests/memfd/Makefile
> +++ b/tools/testing/selftests/memfd/Makefile
> @@ -4,19 +4,11 @@ CFLAGS += -I../../../../include/uapi/
>  CFLAGS += -I../../../../include/
>  CFLAGS += -I../../../../usr/include/
>
> -TEST_PROGS := memfd_test
> -
> -all: $(TEST_PROGS)
> -
> -include ../lib.mk
> -
> -build_fuse: fuse_mnt fuse_test
> +TEST_PROGS := run_fuse_test.sh
> +TEST_GEN_FILES := memfd_test fuse_mnt fuse_test
>
>  fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
>  fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
>
> -run_fuse: build_fuse
> -       @./run_fuse_test.sh || echo "fuse_test: [FAIL]"
> +include ../lib.mk
>
> -clean:
> -       $(RM) memfd_test fuse_test
> diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
> index 5e35c9c..e8fb15e 100644
> --- a/tools/testing/selftests/mount/Makefile
> +++ b/tools/testing/selftests/mount/Makefile
> @@ -1,14 +1,14 @@
>  # Makefile for mount selftests.
>  CFLAGS = -Wall \
>           -O2
> -all: unprivileged-remount-test
>
>  unprivileged-remount-test: unprivileged-remount-test.c
>         $(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test
>
> +TEST_GEN_PROGS := unprivileged-remount-test
> +
>  include ../lib.mk
>
> -TEST_PROGS := unprivileged-remount-test
>  override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
>                       then      \
>                                 ./unprivileged-remount-test ; \
> @@ -17,5 +17,3 @@ override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \
>                       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 eebac29..79a664a 100644
> --- a/tools/testing/selftests/mqueue/Makefile
> +++ b/tools/testing/selftests/mqueue/Makefile
> @@ -1,8 +1,6 @@
>  CFLAGS += -O2
>  LDLIBS = -lrt -lpthread -lpopt
> -TEST_PROGS := mq_open_tests mq_perf_tests
> -
> -all: $(TEST_PROGS)
> +TEST_GEN_PROGS := mq_open_tests mq_perf_tests
>
>  include ../lib.mk
>
> @@ -16,5 +14,3 @@ override define EMIT_TESTS
>         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 0e53407..c976425 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -4,16 +4,10 @@ CFLAGS = -Wall -O2 -g
>
>  CFLAGS += -I../../../../usr/include/
>
> -NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
> -
> -all: $(NET_PROGS)
>  %: %.c
>         $(CC) $(CFLAGS) -o $@ $^
> -
>  TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh
> -TEST_FILES := $(NET_PROGS)
> +TEST_GEN_FILES := socket psock_fanout psock_tpacket reuseport_bpf reuseport_bpf_cpu reuseport_dualstack
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(NET_PROGS)
> diff --git a/tools/testing/selftests/powerpc/alignment/Makefile b/tools/testing/selftests/powerpc/alignment/Makefile
> index ad6a4e4..16b2200 100644
> --- a/tools/testing/selftests/powerpc/alignment/Makefile
> +++ b/tools/testing/selftests/powerpc/alignment/Makefile
> @@ -1,10 +1,5 @@
> -TEST_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
> -
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
> +TEST_GEN_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned
>
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
> diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
> index a9adfb7..985a77c 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/Makefile
> +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
> @@ -1,16 +1,14 @@
> -TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench
> +TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench
>
>  CFLAGS += -O2
>
> -all: $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c
>
> -$(TEST_PROGS): ../harness.c
> +include ../../lib.mk
>
>  context_switch: ../utils.c
>  context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
>  context_switch: LDLIBS += -lpthread
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/context_switch/Makefile b/tools/testing/selftests/powerpc/context_switch/Makefile
> index e164d14..e9351bb 100644
> --- a/tools/testing/selftests/powerpc/context_switch/Makefile
> +++ b/tools/testing/selftests/powerpc/context_switch/Makefile
> @@ -1,10 +1,5 @@
> -TEST_PROGS := cp_abort
> -
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c ../utils.c
> +TEST_GEN_PROGS := cp_abort
>
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c ../utils.c
> diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
> index 384843e..eff1034 100644
> --- a/tools/testing/selftests/powerpc/copyloops/Makefile
> +++ b/tools/testing/selftests/powerpc/copyloops/Makefile
> @@ -7,19 +7,17 @@ CFLAGS += -maltivec
>  # Use our CFLAGS for the implicit .S rule
>  ASFLAGS = $(CFLAGS)
>
> -TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
> +TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
>  EXTRA_SOURCES := validate.c ../harness.c
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
>  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
>
> -$(TEST_PROGS): $(EXTRA_SOURCES)
> -
> -include ../../lib.mk
> +$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
>
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index 49327ee..96e0de0 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,14 +1,12 @@
> -TEST_PROGS := dscr_default_test dscr_explicit_test dscr_user_test      \
> +TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test  \
>               dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test  \
>               dscr_sysfs_thread_test
>
> -dscr_default_test: LDLIBS += -lpthread
> -
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c
> +dscr_default_test: LDLIBS += -lpthread
>
> -include ../../lib.mk
> +$(TEST_GEN_PROGS): ../harness.c
>
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
> index a505b66..8a5dde5 100644
> --- a/tools/testing/selftests/powerpc/math/Makefile
> +++ b/tools/testing/selftests/powerpc/math/Makefile
> @@ -1,9 +1,9 @@
> -TEST_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
> +TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c
> -$(TEST_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
> +$(TEST_GEN_PROGS): ../harness.c
> +$(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
>
>  fpu_syscall: fpu_asm.S
>  fpu_preempt: fpu_asm.S
> @@ -16,7 +16,5 @@ vmx_signal: vmx_asm.S
>  vsx_preempt: CFLAGS += -mvsx
>  vsx_preempt: vsx_asm.S
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/selftests/powerpc/mm/Makefile
> index 3bdb96e..d563378 100644
> --- a/tools/testing/selftests/powerpc/mm/Makefile
> +++ b/tools/testing/selftests/powerpc/mm/Makefile
> @@ -1,19 +1,15 @@
>  noarg:
>         $(MAKE) -C ../
>
> -TEST_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
> -TEST_FILES := tempfile
> +TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao
> +TEST_GEN_FILES := tempfile
>
> -all: $(TEST_PROGS) $(TEST_FILES)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c
> +$(TEST_GEN_PROGS): ../harness.c
>
>  prot_sao: ../utils.c
>
> -include ../../lib.mk
> -
>  tempfile:
>         dd if=/dev/zero of=tempfile bs=64k count=1
>
> -clean:
> -       rm -f $(TEST_PROGS) tempfile
> diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
> index ac41a71..ab0f902 100644
> --- a/tools/testing/selftests/powerpc/pmu/Makefile
> +++ b/tools/testing/selftests/powerpc/pmu/Makefile
> @@ -1,12 +1,14 @@
>  noarg:
>         $(MAKE) -C ../
>
> -TEST_PROGS := count_instructions l3_bank_test per_event_excludes
> +TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes
>  EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c
>
> -all: $(TEST_PROGS) ebb
> +include ../../lib.mk
> +
> +all: $(TEST_GEN_PROGS) ebb
>
> -$(TEST_PROGS): $(EXTRA_SOURCES)
> +$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
>
>  # loop.S can only be built 64-bit
>  count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
> @@ -14,8 +16,6 @@ count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
>
>  per_event_excludes: ../utils.c
>
> -include ../../lib.mk
> -
>  DEFAULT_RUN_TESTS := $(RUN_TESTS)
>  override define RUN_TESTS
>         $(DEFAULT_RUN_TESTS)
> @@ -35,7 +35,7 @@ override define INSTALL_RULE
>  endef
>
>  clean:
> -       rm -f $(TEST_PROGS) loop.o
> +       $(RM) $(TEST_PROGS) loop.o
>         $(MAKE) -C ebb clean
>
>  ebb:
> diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
> index 6b0453e..8dcedc4 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
>
> -TEST_PROGS := reg_access_test event_attributes_test cycles_test        \
> +TEST_GEN_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,16 +16,11 @@ TEST_PROGS := reg_access_test event_attributes_test cycles_test     \
>          lost_exception_test no_handler_test                    \
>          cycles_with_mmcr2_test ebb_lmr ebb_lmr_regs
>
> -all: $(TEST_PROGS)
> +include ../../../lib.mk
>
> -$(TEST_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
> +$(TEST_GEN_PROGS): ../../harness.c ../../utils.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
> -
> -include ../../../lib.mk
> -
> -clean:
> -       rm -f $(TEST_PROGS)
> diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
> index b68c622..32cd56c 100644
> --- a/tools/testing/selftests/powerpc/primitives/Makefile
> +++ b/tools/testing/selftests/powerpc/primitives/Makefile
> @@ -1,12 +1,10 @@
>  CFLAGS += -I$(CURDIR)
>
> -TEST_PROGS := load_unaligned_zeropad
> -
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c
> +TEST_GEN_PROGS := load_unaligned_zeropad
>
>  include ../../lib.mk
>
> +$(TEST_GEN_PROGS): ../harness.c
> +
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
> index 2a728f4..c0ce663 100644
> --- a/tools/testing/selftests/powerpc/stringloops/Makefile
> +++ b/tools/testing/selftests/powerpc/stringloops/Makefile
> @@ -2,14 +2,12 @@
>  CFLAGS += -m64
>  CFLAGS += -I$(CURDIR)
>
> -TEST_PROGS := memcmp
> +TEST_GEN_PROGS := memcmp
>  EXTRA_SOURCES := memcmp_64.S ../harness.c
>
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): $(EXTRA_SOURCES)
> -
>  include ../../lib.mk
>
> +$(TEST_GEN_PROGS): $(EXTRA_SOURCES)
> +
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
> index e21d106..bd01223 100644
> --- a/tools/testing/selftests/powerpc/switch_endian/Makefile
> +++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
> @@ -1,8 +1,8 @@
> -TEST_PROGS := switch_endian_test
> +TEST_GEN_PROGS := switch_endian_test
>
>  ASFLAGS += -O2 -Wall -g -nostdlib -m64
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
>  switch_endian_test: check-reversed.S
>
> @@ -12,7 +12,5 @@ check-reversed.o: check.o
>  check-reversed.S: check-reversed.o
>         hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o check-reversed.S
> +       $(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
> diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
> index b35c794..5bea391 100644
> --- a/tools/testing/selftests/powerpc/syscalls/Makefile
> +++ b/tools/testing/selftests/powerpc/syscalls/Makefile
> @@ -1,12 +1,10 @@
> -TEST_PROGS := ipc_unmuxed
> +TEST_GEN_PROGS := ipc_unmuxed
>
>  CFLAGS += -I../../../../../usr/include
>
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c
> -
>  include ../../lib.mk
>
> +$(TEST_GEN_PROGS): ../harness.c
> +
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
> index c6c53c8..cad0821 100644
> --- a/tools/testing/selftests/powerpc/tm/Makefile
> +++ b/tools/testing/selftests/powerpc/tm/Makefile
> @@ -1,12 +1,12 @@
>  SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu \
>         tm-signal-context-chk-vmx tm-signal-context-chk-vsx
>
> -TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
> +TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
>         tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
>
> -all: $(TEST_PROGS)
> +include ../../lib.mk
>
> -$(TEST_PROGS): ../harness.c ../utils.c
> +$(TEST_GEN_PROGS): ../harness.c ../utils.c
>
>  CFLAGS += -mhtm
>
> @@ -17,7 +17,5 @@ tm-tmspr: CFLAGS += -pthread
>  $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
>  $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
>
> -include ../../lib.mk
> -
>  clean:
> -       rm -f $(TEST_PROGS) *.o
> +       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/vphn/Makefile b/tools/testing/selftests/powerpc/vphn/Makefile
> index a485f2e..f8ced26 100644
> --- a/tools/testing/selftests/powerpc/vphn/Makefile
> +++ b/tools/testing/selftests/powerpc/vphn/Makefile
> @@ -1,12 +1,8 @@
> -TEST_PROGS := test-vphn
> +TEST_GEN_PROGS := test-vphn
>
>  CFLAGS += -m64
>
> -all: $(TEST_PROGS)
> -
> -$(TEST_PROGS): ../harness.c
> -
>  include ../../lib.mk
>
> -clean:
> -       rm -f $(TEST_PROGS)
> +$(TEST_GEN_PROGS): ../harness.c
> +
> diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
> index 453927f..8a2bc55 100644
> --- a/tools/testing/selftests/ptrace/Makefile
> +++ b/tools/testing/selftests/ptrace/Makefile
> @@ -1,11 +1,5 @@
>  CFLAGS += -iquote../../../../include/uapi -Wall
> -peeksiginfo: peeksiginfo.c
>
> -all: peeksiginfo
> -
> -clean:
> -       rm -f peeksiginfo
> -
> -TEST_PROGS := peeksiginfo
> +TEST_GEN_PROGS := peeksiginfo
>
>  include ../lib.mk
> diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
> index 8401e87..5fa6fd2 100644
> --- a/tools/testing/selftests/seccomp/Makefile
> +++ b/tools/testing/selftests/seccomp/Makefile
> @@ -1,10 +1,6 @@
> -TEST_PROGS := seccomp_bpf
> +TEST_GEN_PROGS := seccomp_bpf
>  CFLAGS += -Wl,-no-as-needed -Wall
>  LDFLAGS += -lpthread
>
> -all: $(TEST_PROGS)
> -
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(TEST_PROGS)
> diff --git a/tools/testing/selftests/sigaltstack/Makefile b/tools/testing/selftests/sigaltstack/Makefile
> index 56af56e..f68fbf8 100644
> --- a/tools/testing/selftests/sigaltstack/Makefile
> +++ b/tools/testing/selftests/sigaltstack/Makefile
> @@ -1,8 +1,5 @@
>  CFLAGS = -Wall
> -BINARIES = sas
> -all: $(BINARIES)
> +TEST_GEN_PROGS = sas
>
>  include ../lib.mk
>
> -clean:
> -       rm -rf $(BINARIES)
> diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
> index bbd0b53..c67f357 100644
> --- a/tools/testing/selftests/size/Makefile
> +++ b/tools/testing/selftests/size/Makefile
> @@ -1,11 +1,7 @@
> -all: get_size
>
>  get_size: get_size.c
>         $(CC) -static -ffreestanding -nostartfiles -s $< -o $@
>
> -TEST_PROGS := get_size
> +TEST_GEN_PROGS := get_size
>
>  include ../lib.mk
> -
> -clean:
> -       $(RM) get_size
> diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
> index 1d55568..4a3bffe 100644
> --- a/tools/testing/selftests/timers/Makefile
> +++ b/tools/testing/selftests/timers/Makefile
> @@ -5,16 +5,13 @@ LDFLAGS += -lrt -lpthread
>
>  # these are all "safe" tests that don't modify
>  # system time or require escalated privledges
> -TEST_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
> +TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \
>              inconsistency-check raw_skew threadtest rtctest
>
> -TEST_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
> +TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \
>                       skew_consistency clocksource-switch leap-a-day \
>                       leapcrash set-tai set-2038 set-tz
>
> -bins = $(TEST_PROGS) $(TEST_PROGS_EXTENDED)
> -
> -all: ${bins}
>
>  include ../lib.mk
>
> @@ -34,5 +31,3 @@ run_destructive_tests: run_tests
>         ./set-tai
>         ./set-2038
>
> -clean:
> -       rm -f ${bins}
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index bbab7f4..323383a 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -1,18 +1,17 @@
>  # Makefile for vm selftests
>
>  CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
> -BINARIES = compaction_test
> -BINARIES += hugepage-mmap
> -BINARIES += hugepage-shm
> -BINARIES += map_hugetlb
> -BINARIES += mlock2-tests
> -BINARIES += on-fault-limit
> -BINARIES += thuge-gen
> -BINARIES += transhuge-stress
> -BINARIES += userfaultfd
> -BINARIES += mlock-random-test
> +TEST_GEN_FILES = compaction_test
> +TEST_GEN_FILES += hugepage-mmap
> +TEST_GEN_FILES += hugepage-shm
> +TEST_GEN_FILES += map_hugetlb
> +TEST_GEN_FILES += mlock2-tests
> +TEST_GEN_FILES += on-fault-limit
> +TEST_GEN_FILES += thuge-gen
> +TEST_GEN_FILES += transhuge-stress
> +TEST_GEN_FILES += userfaultfd
> +TEST_GEN_FILES += mlock-random-test
>
> -all: $(BINARIES)
>  %: %.c
>         $(CC) $(CFLAGS) -o $@ $^ -lrt
>  userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
> @@ -25,9 +24,6 @@ mlock-random-test: mlock-random-test.c
>         make -C ../../../.. headers_install
>
>  TEST_PROGS := run_vmtests
> -TEST_FILES := $(BINARIES)
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(BINARIES)
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-11-21  8:54 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21 11:01 [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest bamvor.zhangjian
2016-10-21 11:01 ` bamvor.zhangjian
2016-10-21 11:01 ` [PATCH RFC 1/6] selftests: remove duplicated all and clean target bamvor.zhangjian
2016-10-21 11:01   ` bamvor.zhangjian
2016-11-18 10:31   ` Michael Ellerman
2016-11-18 10:31     ` Michael Ellerman
2016-11-18 12:59     ` Zhangjian (Bamvor)
2016-11-18 12:59       ` Zhangjian (Bamvor)
2016-11-21  8:53       ` Michael Ellerman
2016-11-21  8:53         ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 2/6] selftests: remove useless TEST_DIRS bamvor.zhangjian
2016-10-21 11:01   ` bamvor.zhangjian
2016-11-18 10:31   ` Michael Ellerman
2016-11-18 10:31     ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 3/6] selftests: add default rules for c source file bamvor.zhangjian
2016-10-21 11:01   ` bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
2016-11-18 10:57   ` Michael Ellerman
2016-11-18 10:57     ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 4/6] selftests: remove CROSS_COMPILE in dedicated Makefile bamvor.zhangjian
2016-10-21 11:01   ` bamvor.zhangjian
2016-11-18 10:58   ` Michael Ellerman
2016-11-18 10:58     ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target bamvor.zhangjian
2016-10-21 11:01   ` bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
2016-11-18 11:01   ` Michael Ellerman
2016-11-18 11:01     ` Michael Ellerman
2016-11-18 12:51     ` Zhangjian (Bamvor)
2016-11-18 12:51       ` Zhangjian (Bamvor)
2016-10-21 11:01 ` [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT bamvor.zhangjian
2016-10-21 11:01   ` bamvor.zhangjian
2016-11-18 11:29   ` Michael Ellerman
2016-11-18 11:29     ` Michael Ellerman
2016-11-18 13:03     ` Zhangjian (Bamvor)
2016-11-18 13:03       ` Zhangjian (Bamvor)
2016-10-21 11:11 ` [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest Bamvor Zhang Jian
2016-10-21 11:11   ` Bamvor Zhang Jian
2016-11-16 23:57 ` Shuah Khan
2016-11-16 23:57   ` Shuah Khan
2016-11-18  0:15   ` Michael Ellerman
2016-11-18  0:15     ` Michael Ellerman
2016-11-18  0:18     ` Shuah Khan
2016-11-18  0:18       ` Shuah Khan
2016-10-21 11:14 [PATCH RFC 1/6] selftests: remove duplicated all and clean target Bamvor Zhang Jian
2016-10-21 11:14 ` Bamvor Zhang Jian

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.