All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-09  8:56 ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linux-kernel, linuxppc-dev, linux-kselftest, linux-api

In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
target"), the "all" target was removed from individual Makefiles and
added to lib.mk.

However the "all" target was added to lib.mk *after* the existing
"runtests" target. This means "runtests" becomes the first (default)
target for most of our Makefiles.

This has the effect of causing a plain "make" to build *and run* the
tests. Which is at best rude, but depending on which tests are run could
oops someone's build machine.

  $ make -C tools/testing/selftests/
  ...
  make[1]: Entering directory 'tools/testing/selftests/bpf'
  gcc -Wall -O2 -I../../../../usr/include   test_verifier.c -o tools/testing/selftests/bpf/test_verifier
  gcc -Wall -O2 -I../../../../usr/include   test_maps.c -o tools/testing/selftests/bpf/test_maps
  gcc -Wall -O2 -I../../../../usr/include   test_lru_map.c -o tools/testing/selftests/bpf/test_lru_map
  #0 add+sub+mul FAIL
  Failed to load prog 'Function not implemented'!
  #1 unreachable FAIL
  Unexpected error message!
  #2 unreachable2 FAIL
  ...

Fix it by moving the "all" target to the start of lib.mk, making it the
default target.

Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/lib.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 01bb7782a35e..17ed4bbe3963 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -2,6 +2,11 @@
 # Makefile can operate with or without the kbuild infrastructure.
 CC := $(CROSS_COMPILE)gcc
 
+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)
+
 define RUN_TESTS
 	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 		BASENAME_TEST=`basename $$TEST`;	\
@@ -42,11 +47,6 @@ 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)
 
-- 
2.7.4

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

* [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-09  8:56 ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
target"), the "all" target was removed from individual Makefiles and
added to lib.mk.

However the "all" target was added to lib.mk *after* the existing
"runtests" target. This means "runtests" becomes the first (default)
target for most of our Makefiles.

This has the effect of causing a plain "make" to build *and run* the
tests. Which is at best rude, but depending on which tests are run could
oops someone's build machine.

  $ make -C tools/testing/selftests/
  ...
  make[1]: Entering directory 'tools/testing/selftests/bpf'
  gcc -Wall -O2 -I../../../../usr/include   test_verifier.c -o tools/testing/selftests/bpf/test_verifier
  gcc -Wall -O2 -I../../../../usr/include   test_maps.c -o tools/testing/selftests/bpf/test_maps
  gcc -Wall -O2 -I../../../../usr/include   test_lru_map.c -o tools/testing/selftests/bpf/test_lru_map
  #0 add+sub+mul FAIL
  Failed to load prog 'Function not implemented'!
  #1 unreachable FAIL
  Unexpected error message!
  #2 unreachable2 FAIL
  ...

Fix it by moving the "all" target to the start of lib.mk, making it the
default target.

Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/lib.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 01bb7782a35e..17ed4bbe3963 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -2,6 +2,11 @@
 # Makefile can operate with or without the kbuild infrastructure.
 CC := $(CROSS_COMPILE)gcc
 
+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)
+
 define RUN_TESTS
 	@for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
 		BASENAME_TEST=`basename $$TEST`;	\
@@ -42,11 +47,6 @@ 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)
 
-- 
2.7.4

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

* [PATCH 2/5] selftests: Fix the .c linking rule
  2017-02-09  8:56 ` Michael Ellerman
@ 2017-02-09  8:56   ` Michael Ellerman
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linux-kernel, linuxppc-dev, linux-kselftest, linux-api

Currently we can't build some tests, for example:

  $ make -C tools/testing/selftests/ TARGETS=vm
  ...
  gcc -Wall -I ../../../../usr/include   -lrt -lpthread ../../../../usr/include/linux/kernel.h userfaultfd.c -o tools/testing/selftests/vm/userfaultfd
  /tmp/ccmOkQSM.o: In function `stress':
  userfaultfd.c:(.text+0xc60): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xca5): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xcee): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xd30): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xd77): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xe7d): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xe9f): undefined reference to `pthread_cancel'
  userfaultfd.c:(.text+0xec6): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xf14): undefined reference to `pthread_join'
  /tmp/ccmOkQSM.o: In function `userfaultfd_stress':
  userfaultfd.c:(.text+0x13e2): undefined reference to `pthread_attr_setstacksize'
  collect2: error: ld returned 1 exit status

This is because the rule for linking .c files to binaries is incorrect.

The first bug is that it uses $< (first prerequisite) instead of $^ (all
preqrequisites), fix it by using ^$.

Secondly the ordering of the prerequisites vs $(LDLIBS) is wrong,
meaning on toolchains that use --as-needed we fail to link (as above).
Fix that by placing $(LDLIBS) *after* ^$.

Finally switch to using the default rule $(LINK.c), so that we get
$(CPPFLAGS) etc. included.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/lib.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 17ed4bbe3963..98841c54763a 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -51,7 +51,7 @@ clean:
 	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 
 $(OUTPUT)/%:%.c
-	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
+	$(LINK.c) $^ $(LDLIBS) -o $@
 
 $(OUTPUT)/%.o:%.S
 	$(CC) $(ASFLAGS) -c $< -o $@
-- 
2.7.4

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

* [PATCH 2/5] selftests: Fix the .c linking rule
@ 2017-02-09  8:56   ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

Currently we can't build some tests, for example:

  $ make -C tools/testing/selftests/ TARGETS=vm
  ...
  gcc -Wall -I ../../../../usr/include   -lrt -lpthread ../../../../usr/include/linux/kernel.h userfaultfd.c -o tools/testing/selftests/vm/userfaultfd
  /tmp/ccmOkQSM.o: In function `stress':
  userfaultfd.c:(.text+0xc60): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xca5): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xcee): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xd30): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xd77): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xe7d): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xe9f): undefined reference to `pthread_cancel'
  userfaultfd.c:(.text+0xec6): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xf14): undefined reference to `pthread_join'
  /tmp/ccmOkQSM.o: In function `userfaultfd_stress':
  userfaultfd.c:(.text+0x13e2): undefined reference to `pthread_attr_setstacksize'
  collect2: error: ld returned 1 exit status

This is because the rule for linking .c files to binaries is incorrect.

The first bug is that it uses $< (first prerequisite) instead of $^ (all
preqrequisites), fix it by using ^$.

Secondly the ordering of the prerequisites vs $(LDLIBS) is wrong,
meaning on toolchains that use --as-needed we fail to link (as above).
Fix that by placing $(LDLIBS) *after* ^$.

Finally switch to using the default rule $(LINK.c), so that we get
$(CPPFLAGS) etc. included.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/lib.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 17ed4bbe3963..98841c54763a 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -51,7 +51,7 @@ clean:
 	$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
 
 $(OUTPUT)/%:%.c
-	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
+	$(LINK.c) $^ $(LDLIBS) -o $@
 
 $(OUTPUT)/%.o:%.S
 	$(CC) $(ASFLAGS) -c $< -o $@
-- 
2.7.4

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

* [PATCH 3/5] selftests: Fix the .S and .S -> .o rules
  2017-02-09  8:56 ` Michael Ellerman
@ 2017-02-09  8:56   ` Michael Ellerman
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linux-kernel, linuxppc-dev, linux-kselftest, linux-api

Both these rules incorrectly use $< (first prerequisite) rather than
$^ (all prerequisites), meaning they don't work if we're using more than
one .S file as input. Switch them to using $^.

They also don't include $(CPPFLAGS) and other variables used in the
default rules, which breaks targets that require those. Fix that by
using the builtin $(COMPILE.S) and $(LINK.S) rules.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/lib.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 98841c54763a..ce96d80ad64f 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -54,9 +54,9 @@ $(OUTPUT)/%:%.c
 	$(LINK.c) $^ $(LDLIBS) -o $@
 
 $(OUTPUT)/%.o:%.S
-	$(CC) $(ASFLAGS) -c $< -o $@
+	$(COMPILE.S) $^ -o $@
 
 $(OUTPUT)/%:%.S
-	$(CC) $(ASFLAGS) $< -o $@
+	$(LINK.S) $^ $(LDLIBS) -o $@
 
 .PHONY: run_tests all clean install emit_tests
-- 
2.7.4

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

* [PATCH 3/5] selftests: Fix the .S and .S -> .o rules
@ 2017-02-09  8:56   ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

Both these rules incorrectly use $< (first prerequisite) rather than
$^ (all prerequisites), meaning they don't work if we're using more than
one .S file as input. Switch them to using $^.

They also don't include $(CPPFLAGS) and other variables used in the
default rules, which breaks targets that require those. Fix that by
using the builtin $(COMPILE.S) and $(LINK.S) rules.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/lib.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 98841c54763a..ce96d80ad64f 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -54,9 +54,9 @@ $(OUTPUT)/%:%.c
 	$(LINK.c) $^ $(LDLIBS) -o $@
 
 $(OUTPUT)/%.o:%.S
-	$(CC) $(ASFLAGS) -c $< -o $@
+	$(COMPILE.S) $^ -o $@
 
 $(OUTPUT)/%:%.S
-	$(CC) $(ASFLAGS) $< -o $@
+	$(LINK.S) $^ $(LDLIBS) -o $@
 
 .PHONY: run_tests all clean install emit_tests
-- 
2.7.4

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

* [PATCH 4/5] selftests/powerpc: Fix the clean rule since recent changes
  2017-02-09  8:56 ` Michael Ellerman
@ 2017-02-09  8:56   ` Michael Ellerman
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linux-kernel, linuxppc-dev, linux-kselftest, linux-api

The clean rule is broken for the powerpc tests:

  make[1]: Entering directory 'tools/testing/selftests/powerpc'
  Makefile:63: warning: overriding recipe for target 'clean'
  ../lib.mk:51: warning: ignoring old recipe for target 'clean'
  /bin/sh: 3: Syntax error: end of file unexpected (expecting "done")
  Makefile:63: recipe for target 'clean' failed

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 1d48c0cab596..1c5d0575802e 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -62,7 +62,8 @@ endef
 clean:
 	@for TARGET in $(SUB_DIRS); do \
 		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ done;
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
+	done;
 	rm -f tags
 
 tags:
-- 
2.7.4

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

* [PATCH 4/5] selftests/powerpc: Fix the clean rule since recent changes
@ 2017-02-09  8:56   ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

The clean rule is broken for the powerpc tests:

  make[1]: Entering directory 'tools/testing/selftests/powerpc'
  Makefile:63: warning: overriding recipe for target 'clean'
  ../lib.mk:51: warning: ignoring old recipe for target 'clean'
  /bin/sh: 3: Syntax error: end of file unexpected (expecting "done")
  Makefile:63: recipe for target 'clean' failed

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 1d48c0cab596..1c5d0575802e 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -62,7 +62,8 @@ endef
 clean:
 	@for TARGET in $(SUB_DIRS); do \
 		BUILD_TARGET=$$OUTPUT/$$TARGET;	\
-		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ done;
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \
+	done;
 	rm -f tags
 
 tags:
-- 
2.7.4

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

* [PATCH 5/5] selftests/powerpc: Fix remaining fallout from recent changes
  2017-02-09  8:56 ` Michael Ellerman
@ 2017-02-09  8:56   ` Michael Ellerman
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linux-kernel, linuxppc-dev, linux-kselftest, linux-api

In benchmarks we need to use $(TEST_GEN_PROGS) after we include lib.mk,
because lib.mk does the substitution to add $(OUTPUT).

In math the vmx and fpu names were typoed so they no longer matched
correctly, put back the 'v' and 'f'.

In tm we need to substitute $(OUTPUT) into SIGNAL_CONTEXT_CHK_TESTS so
that the rule matches.

In pmu there is an extraneous ':' on the end of $$BUILD_TARGET for the
clean and install rules, which breaks the logic in the child Makefiles.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/benchmarks/Makefile |  4 ++--
 tools/testing/selftests/powerpc/math/Makefile       | 16 ++++++++--------
 tools/testing/selftests/powerpc/pmu/Makefile        |  4 ++--
 tools/testing/selftests/powerpc/tm/Makefile         |  1 +
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 286c6ed2378c..fb96a89bd953 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -2,10 +2,10 @@ TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench null_syscal
 
 CFLAGS += -O2
 
-$(TEST_GEN_PROGS): ../harness.c
-
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): ../harness.c
+
 $(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/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index da9f42feaaac..fa8bae920c91 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -5,13 +5,13 @@ include ../../lib.mk
 $(TEST_GEN_PROGS): ../harness.c
 $(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
 
-$(OUTPUT)/pu_syscall: fpu_asm.S
-$(OUTPUT)/pu_preempt: fpu_asm.S
-$(OUTPUT)/pu_signal:  fpu_asm.S
+$(OUTPUT)/fpu_syscall: fpu_asm.S
+$(OUTPUT)/fpu_preempt: fpu_asm.S
+$(OUTPUT)/fpu_signal:  fpu_asm.S
 
-$(OUTPUT)/mx_syscall: vmx_asm.S
-$(OUTPUT)/mx_preempt: vmx_asm.S
-$(OUTPUT)/mx_signal: vmx_asm.S
+$(OUTPUT)/vmx_syscall: vmx_asm.S
+$(OUTPUT)/vmx_preempt: vmx_asm.S
+$(OUTPUT)/vmx_signal: vmx_asm.S
 
-vsx_preempt: CFLAGS += -mvsx
-vsx_preempt: vsx_asm.S
+$(OUTPUT)/vsx_preempt: CFLAGS += -mvsx
+$(OUTPUT)/vsx_preempt: vsx_asm.S
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index 097b08acd867..e4e55d1d3e0f 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -31,12 +31,12 @@ endef
 DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
 override define INSTALL_RULE
 	$(DEFAULT_INSTALL_RULE)
-	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET: -C $$TARGET install
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
 endef
 
 clean:
 	$(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o
-	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET: -C $$TARGET clean
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
 
 ebb:
 	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 07da21769ff8..5576ee6a51f2 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -14,5 +14,6 @@ $(OUTPUT)/tm-syscall: tm-syscall-asm.S
 $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
 $(OUTPUT)/tm-tmspr: CFLAGS += -pthread
 
+SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS))
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
-- 
2.7.4

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

* [PATCH 5/5] selftests/powerpc: Fix remaining fallout from recent changes
@ 2017-02-09  8:56   ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-09  8:56 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

In benchmarks we need to use $(TEST_GEN_PROGS) after we include lib.mk,
because lib.mk does the substitution to add $(OUTPUT).

In math the vmx and fpu names were typoed so they no longer matched
correctly, put back the 'v' and 'f'.

In tm we need to substitute $(OUTPUT) into SIGNAL_CONTEXT_CHK_TESTS so
that the rule matches.

In pmu there is an extraneous ':' on the end of $$BUILD_TARGET for the
clean and install rules, which breaks the logic in the child Makefiles.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 tools/testing/selftests/powerpc/benchmarks/Makefile |  4 ++--
 tools/testing/selftests/powerpc/math/Makefile       | 16 ++++++++--------
 tools/testing/selftests/powerpc/pmu/Makefile        |  4 ++--
 tools/testing/selftests/powerpc/tm/Makefile         |  1 +
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 286c6ed2378c..fb96a89bd953 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -2,10 +2,10 @@ TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench null_syscal
 
 CFLAGS += -O2
 
-$(TEST_GEN_PROGS): ../harness.c
-
 include ../../lib.mk
 
+$(TEST_GEN_PROGS): ../harness.c
+
 $(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/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
index da9f42feaaac..fa8bae920c91 100644
--- a/tools/testing/selftests/powerpc/math/Makefile
+++ b/tools/testing/selftests/powerpc/math/Makefile
@@ -5,13 +5,13 @@ include ../../lib.mk
 $(TEST_GEN_PROGS): ../harness.c
 $(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec
 
-$(OUTPUT)/pu_syscall: fpu_asm.S
-$(OUTPUT)/pu_preempt: fpu_asm.S
-$(OUTPUT)/pu_signal:  fpu_asm.S
+$(OUTPUT)/fpu_syscall: fpu_asm.S
+$(OUTPUT)/fpu_preempt: fpu_asm.S
+$(OUTPUT)/fpu_signal:  fpu_asm.S
 
-$(OUTPUT)/mx_syscall: vmx_asm.S
-$(OUTPUT)/mx_preempt: vmx_asm.S
-$(OUTPUT)/mx_signal: vmx_asm.S
+$(OUTPUT)/vmx_syscall: vmx_asm.S
+$(OUTPUT)/vmx_preempt: vmx_asm.S
+$(OUTPUT)/vmx_signal: vmx_asm.S
 
-vsx_preempt: CFLAGS += -mvsx
-vsx_preempt: vsx_asm.S
+$(OUTPUT)/vsx_preempt: CFLAGS += -mvsx
+$(OUTPUT)/vsx_preempt: vsx_asm.S
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index 097b08acd867..e4e55d1d3e0f 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -31,12 +31,12 @@ endef
 DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
 override define INSTALL_RULE
 	$(DEFAULT_INSTALL_RULE)
-	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET: -C $$TARGET install
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install
 endef
 
 clean:
 	$(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o
-	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET: -C $$TARGET clean
+	TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean
 
 ebb:
 	TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 07da21769ff8..5576ee6a51f2 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -14,5 +14,6 @@ $(OUTPUT)/tm-syscall: tm-syscall-asm.S
 $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
 $(OUTPUT)/tm-tmspr: CFLAGS += -pthread
 
+SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS))
 $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
 $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
-- 
2.7.4

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14  2:09   ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-14  2:09 UTC (permalink / raw)
  To: shuahkh, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

Michael Ellerman <mpe@ellerman.id.au> writes:

> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
> target"), the "all" target was removed from individual Makefiles and
> added to lib.mk.
>
> However the "all" target was added to lib.mk *after* the existing
> "runtests" target. This means "runtests" becomes the first (default)
> target for most of our Makefiles.
...
>
> Fix it by moving the "all" target to the start of lib.mk, making it the
> default target.
>
> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Hi Shuah,

Can you please merge this series into linux-next?

The selftests are badly broken otherwise.

cheers

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14  2:09   ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-14  2:09 UTC (permalink / raw)
  To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw, bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-kselftest-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA

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

> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
> target"), the "all" target was removed from individual Makefiles and
> added to lib.mk.
>
> However the "all" target was added to lib.mk *after* the existing
> "runtests" target. This means "runtests" becomes the first (default)
> target for most of our Makefiles.
...
>
> Fix it by moving the "all" target to the start of lib.mk, making it the
> default target.
>
> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>

Hi Shuah,

Can you please merge this series into linux-next?

The selftests are badly broken otherwise.

cheers

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14  3:06   ` Bamvor Zhang Jian
  0 siblings, 0 replies; 29+ messages in thread
From: Bamvor Zhang Jian @ 2017-02-14  3:06 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Zhang Jian(Bamvor),
	lkml, linuxppc-dev, linux-kselftest, linux-api

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

On 9 February 2017 at 16:56, Michael Ellerman <mpe@ellerman.id.au> wrote:
> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
> target"), the "all" target was removed from individual Makefiles and
> added to lib.mk.
>
> However the "all" target was added to lib.mk *after* the existing
> "runtests" target. This means "runtests" becomes the first (default)
> target for most of our Makefiles.
>
> This has the effect of causing a plain "make" to build *and run* the
> tests. Which is at best rude, but depending on which tests are run could
> oops someone's build machine.
>
>   $ make -C tools/testing/selftests/
>   ...
>   make[1]: Entering directory 'tools/testing/selftests/bpf'
>   gcc -Wall -O2 -I../../../../usr/include   test_verifier.c -o tools/testing/selftests/bpf/test_verifier
>   gcc -Wall -O2 -I../../../../usr/include   test_maps.c -o tools/testing/selftests/bpf/test_maps
>   gcc -Wall -O2 -I../../../../usr/include   test_lru_map.c -o tools/testing/selftests/bpf/test_lru_map
>   #0 add+sub+mul FAIL
>   Failed to load prog 'Function not implemented'!
>   #1 unreachable FAIL
>   Unexpected error message!
>   #2 unreachable2 FAIL
>   ...
>
> Fix it by moving the "all" target to the start of lib.mk, making it the
> default target.
>
> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  tools/testing/selftests/lib.mk | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 01bb7782a35e..17ed4bbe3963 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -2,6 +2,11 @@
>  # Makefile can operate with or without the kbuild infrastructure.
>  CC := $(CROSS_COMPILE)gcc
>
> +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)
> +
>  define RUN_TESTS
>         @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
>                 BASENAME_TEST=`basename $$TEST`;        \
> @@ -42,11 +47,6 @@ 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)
>
> --
> 2.7.4
>
> --
> 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] 29+ messages in thread

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14  3:06   ` Bamvor Zhang Jian
  0 siblings, 0 replies; 29+ messages in thread
From: Bamvor Zhang Jian @ 2017-02-14  3:06 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Zhang Jian(Bamvor),
	lkml, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	linux-kselftest-u79uwXL29TY76Z2rM5mHXA, linux-api

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

On 9 February 2017 at 16:56, Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> wrote:
> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
> target"), the "all" target was removed from individual Makefiles and
> added to lib.mk.
>
> However the "all" target was added to lib.mk *after* the existing
> "runtests" target. This means "runtests" becomes the first (default)
> target for most of our Makefiles.
>
> This has the effect of causing a plain "make" to build *and run* the
> tests. Which is at best rude, but depending on which tests are run could
> oops someone's build machine.
>
>   $ make -C tools/testing/selftests/
>   ...
>   make[1]: Entering directory 'tools/testing/selftests/bpf'
>   gcc -Wall -O2 -I../../../../usr/include   test_verifier.c -o tools/testing/selftests/bpf/test_verifier
>   gcc -Wall -O2 -I../../../../usr/include   test_maps.c -o tools/testing/selftests/bpf/test_maps
>   gcc -Wall -O2 -I../../../../usr/include   test_lru_map.c -o tools/testing/selftests/bpf/test_lru_map
>   #0 add+sub+mul FAIL
>   Failed to load prog 'Function not implemented'!
>   #1 unreachable FAIL
>   Unexpected error message!
>   #2 unreachable2 FAIL
>   ...
>
> Fix it by moving the "all" target to the start of lib.mk, making it the
> default target.
>
> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> ---
>  tools/testing/selftests/lib.mk | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 01bb7782a35e..17ed4bbe3963 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -2,6 +2,11 @@
>  # Makefile can operate with or without the kbuild infrastructure.
>  CC := $(CROSS_COMPILE)gcc
>
> +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)
> +
>  define RUN_TESTS
>         @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \
>                 BASENAME_TEST=`basename $$TEST`;        \
> @@ -42,11 +47,6 @@ 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)
>
> --
> 2.7.4
>
> --
> 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] 29+ messages in thread

* Re: [PATCH 2/5] selftests: Fix the .c linking rule
@ 2017-02-14  3:07     ` Bamvor Zhang Jian
  0 siblings, 0 replies; 29+ messages in thread
From: Bamvor Zhang Jian @ 2017-02-14  3:07 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Zhang Jian(Bamvor),
	lkml, linuxppc-dev, linux-kselftest, linux-api

Tested-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

On 9 February 2017 at 16:56, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Currently we can't build some tests, for example:
>
>   $ make -C tools/testing/selftests/ TARGETS=vm
>   ...
>   gcc -Wall -I ../../../../usr/include   -lrt -lpthread ../../../../usr/include/linux/kernel.h userfaultfd.c -o tools/testing/selftests/vm/userfaultfd
>   /tmp/ccmOkQSM.o: In function `stress':
>   userfaultfd.c:(.text+0xc60): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xca5): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xcee): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xd30): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xd77): undefined reference to `pthread_join'
>   userfaultfd.c:(.text+0xe7d): undefined reference to `pthread_join'
>   userfaultfd.c:(.text+0xe9f): undefined reference to `pthread_cancel'
>   userfaultfd.c:(.text+0xec6): undefined reference to `pthread_join'
>   userfaultfd.c:(.text+0xf14): undefined reference to `pthread_join'
>   /tmp/ccmOkQSM.o: In function `userfaultfd_stress':
>   userfaultfd.c:(.text+0x13e2): undefined reference to `pthread_attr_setstacksize'
>   collect2: error: ld returned 1 exit status
>
> This is because the rule for linking .c files to binaries is incorrect.
>
> The first bug is that it uses $< (first prerequisite) instead of $^ (all
> preqrequisites), fix it by using ^$.
>
> Secondly the ordering of the prerequisites vs $(LDLIBS) is wrong,
> meaning on toolchains that use --as-needed we fail to link (as above).
> Fix that by placing $(LDLIBS) *after* ^$.
>
> Finally switch to using the default rule $(LINK.c), so that we get
> $(CPPFLAGS) etc. included.
>
> Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  tools/testing/selftests/lib.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 17ed4bbe3963..98841c54763a 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -51,7 +51,7 @@ clean:
>         $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
>
>  $(OUTPUT)/%:%.c
> -       $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
> +       $(LINK.c) $^ $(LDLIBS) -o $@
>
>  $(OUTPUT)/%.o:%.S
>         $(CC) $(ASFLAGS) -c $< -o $@
> --
> 2.7.4
>
> --
> 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] 29+ messages in thread

* Re: [PATCH 2/5] selftests: Fix the .c linking rule
@ 2017-02-14  3:07     ` Bamvor Zhang Jian
  0 siblings, 0 replies; 29+ messages in thread
From: Bamvor Zhang Jian @ 2017-02-14  3:07 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Zhang Jian(Bamvor),
	lkml, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	linux-kselftest-u79uwXL29TY76Z2rM5mHXA, linux-api

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

On 9 February 2017 at 16:56, Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> wrote:
> Currently we can't build some tests, for example:
>
>   $ make -C tools/testing/selftests/ TARGETS=vm
>   ...
>   gcc -Wall -I ../../../../usr/include   -lrt -lpthread ../../../../usr/include/linux/kernel.h userfaultfd.c -o tools/testing/selftests/vm/userfaultfd
>   /tmp/ccmOkQSM.o: In function `stress':
>   userfaultfd.c:(.text+0xc60): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xca5): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xcee): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xd30): undefined reference to `pthread_create'
>   userfaultfd.c:(.text+0xd77): undefined reference to `pthread_join'
>   userfaultfd.c:(.text+0xe7d): undefined reference to `pthread_join'
>   userfaultfd.c:(.text+0xe9f): undefined reference to `pthread_cancel'
>   userfaultfd.c:(.text+0xec6): undefined reference to `pthread_join'
>   userfaultfd.c:(.text+0xf14): undefined reference to `pthread_join'
>   /tmp/ccmOkQSM.o: In function `userfaultfd_stress':
>   userfaultfd.c:(.text+0x13e2): undefined reference to `pthread_attr_setstacksize'
>   collect2: error: ld returned 1 exit status
>
> This is because the rule for linking .c files to binaries is incorrect.
>
> The first bug is that it uses $< (first prerequisite) instead of $^ (all
> preqrequisites), fix it by using ^$.
>
> Secondly the ordering of the prerequisites vs $(LDLIBS) is wrong,
> meaning on toolchains that use --as-needed we fail to link (as above).
> Fix that by placing $(LDLIBS) *after* ^$.
>
> Finally switch to using the default rule $(LINK.c), so that we get
> $(CPPFLAGS) etc. included.
>
> Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> ---
>  tools/testing/selftests/lib.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 17ed4bbe3963..98841c54763a 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -51,7 +51,7 @@ clean:
>         $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
>
>  $(OUTPUT)/%:%.c
> -       $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $< -o $@
> +       $(LINK.c) $^ $(LDLIBS) -o $@
>
>  $(OUTPUT)/%.o:%.S
>         $(CC) $(ASFLAGS) -c $< -o $@
> --
> 2.7.4
>
> --
> 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] 29+ messages in thread

* Re: [PATCH 3/5] selftests: Fix the .S and .S -> .o rules
@ 2017-02-14  3:07     ` Bamvor Zhang Jian
  0 siblings, 0 replies; 29+ messages in thread
From: Bamvor Zhang Jian @ 2017-02-14  3:07 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Zhang Jian(Bamvor),
	lkml, linuxppc-dev, linux-kselftest, linux-api

Tested-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

On 9 February 2017 at 16:56, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Both these rules incorrectly use $< (first prerequisite) rather than
> $^ (all prerequisites), meaning they don't work if we're using more than
> one .S file as input. Switch them to using $^.
>
> They also don't include $(CPPFLAGS) and other variables used in the
> default rules, which breaks targets that require those. Fix that by
> using the builtin $(COMPILE.S) and $(LINK.S) rules.
>
> Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  tools/testing/selftests/lib.mk | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 98841c54763a..ce96d80ad64f 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -54,9 +54,9 @@ $(OUTPUT)/%:%.c
>         $(LINK.c) $^ $(LDLIBS) -o $@
>
>  $(OUTPUT)/%.o:%.S
> -       $(CC) $(ASFLAGS) -c $< -o $@
> +       $(COMPILE.S) $^ -o $@
>
>  $(OUTPUT)/%:%.S
> -       $(CC) $(ASFLAGS) $< -o $@
> +       $(LINK.S) $^ $(LDLIBS) -o $@
>
>  .PHONY: run_tests all clean install emit_tests
> --
> 2.7.4
>
> --
> 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] 29+ messages in thread

* Re: [PATCH 3/5] selftests: Fix the .S and .S -> .o rules
@ 2017-02-14  3:07     ` Bamvor Zhang Jian
  0 siblings, 0 replies; 29+ messages in thread
From: Bamvor Zhang Jian @ 2017-02-14  3:07 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Zhang Jian(Bamvor),
	lkml, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	linux-kselftest-u79uwXL29TY76Z2rM5mHXA, linux-api

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

On 9 February 2017 at 16:56, Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> wrote:
> Both these rules incorrectly use $< (first prerequisite) rather than
> $^ (all prerequisites), meaning they don't work if we're using more than
> one .S file as input. Switch them to using $^.
>
> They also don't include $(CPPFLAGS) and other variables used in the
> default rules, which breaks targets that require those. Fix that by
> using the builtin $(COMPILE.S) and $(LINK.S) rules.
>
> Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> ---
>  tools/testing/selftests/lib.mk | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 98841c54763a..ce96d80ad64f 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -54,9 +54,9 @@ $(OUTPUT)/%:%.c
>         $(LINK.c) $^ $(LDLIBS) -o $@
>
>  $(OUTPUT)/%.o:%.S
> -       $(CC) $(ASFLAGS) -c $< -o $@
> +       $(COMPILE.S) $^ -o $@
>
>  $(OUTPUT)/%:%.S
> -       $(CC) $(ASFLAGS) $< -o $@
> +       $(LINK.S) $^ $(LDLIBS) -o $@
>
>  .PHONY: run_tests all clean install emit_tests
> --
> 2.7.4
>
> --
> 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] 29+ messages in thread

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14 16:14     ` Shuah Khan
  0 siblings, 0 replies; 29+ messages in thread
From: Shuah Khan @ 2017-02-14 16:14 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api

On 02/13/2017 07:09 PM, Michael Ellerman wrote:
> Michael Ellerman <mpe@ellerman.id.au> writes:
> 
>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>> target"), the "all" target was removed from individual Makefiles and
>> added to lib.mk.
>>
>> However the "all" target was added to lib.mk *after* the existing
>> "runtests" target. This means "runtests" becomes the first (default)
>> target for most of our Makefiles.
> ...
>>
>> Fix it by moving the "all" target to the start of lib.mk, making it the
>> default target.
>>
>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> Hi Shuah,
> 
> Can you please merge this series into linux-next?
> 
> The selftests are badly broken otherwise.
> 
> cheers
> 

Hi Michael,

Thanks. All 5 patches are now in linux-kselftest next with Tested-by
tag from Bamvor for 1,2,3.

thank you both,
-- Shuah

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14 16:14     ` Shuah Khan
  0 siblings, 0 replies; 29+ messages in thread
From: Shuah Khan @ 2017-02-14 16:14 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-kselftest-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 02/13/2017 07:09 PM, Michael Ellerman wrote:
> Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> writes:
> 
>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>> target"), the "all" target was removed from individual Makefiles and
>> added to lib.mk.
>>
>> However the "all" target was added to lib.mk *after* the existing
>> "runtests" target. This means "runtests" becomes the first (default)
>> target for most of our Makefiles.
> ...
>>
>> Fix it by moving the "all" target to the start of lib.mk, making it the
>> default target.
>>
>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
> 
> Hi Shuah,
> 
> Can you please merge this series into linux-next?
> 
> The selftests are badly broken otherwise.
> 
> cheers
> 

Hi Michael,

Thanks. All 5 patches are now in linux-kselftest next with Tested-by
tag from Bamvor for 1,2,3.

thank you both,
-- Shuah

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14 20:33       ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-14 20:33 UTC (permalink / raw)
  To: Shuah Khan, Michael Ellerman, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api



On 15 February 2017 03:14:24 GMT+11:00, Shuah Khan <shuahkh@osg.samsung.com> wrote:
>On 02/13/2017 07:09 PM, Michael Ellerman wrote:
>> Michael Ellerman <mpe@ellerman.id.au> writes:
>> 
>>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>>> target"), the "all" target was removed from individual Makefiles and
>>> added to lib.mk.
>>>
>>> However the "all" target was added to lib.mk *after* the existing
>>> "runtests" target. This means "runtests" becomes the first (default)
>>> target for most of our Makefiles.
>> ...
>>>
>>> Fix it by moving the "all" target to the start of lib.mk, making it
>the
>>> default target.
>>>
>>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean
>target")
>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> 
>> Hi Shuah,
>> 
>> Can you please merge this series into linux-next?
>> 
>> The selftests are badly broken otherwise.
>> 
>> cheers
>> 
>
>Hi Michael,
>
>Thanks. All 5 patches are now in linux-kselftest next with Tested-by
>tag from Bamvor for 1,2,3.

Thanks!
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14 20:33       ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-14 20:33 UTC (permalink / raw)
  To: Shuah Khan, Michael Ellerman, bamvor.zhangjian-hv44wF8Li93QT0dZR+AlfA
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-kselftest-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA



On 15 February 2017 03:14:24 GMT+11:00, Shuah Khan <shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org> wrote:
>On 02/13/2017 07:09 PM, Michael Ellerman wrote:
>> Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> writes:
>> 
>>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>>> target"), the "all" target was removed from individual Makefiles and
>>> added to lib.mk.
>>>
>>> However the "all" target was added to lib.mk *after* the existing
>>> "runtests" target. This means "runtests" becomes the first (default)
>>> target for most of our Makefiles.
>> ...
>>>
>>> Fix it by moving the "all" target to the start of lib.mk, making it
>the
>>> default target.
>>>
>>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean
>target")
>>> Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
>> 
>> Hi Shuah,
>> 
>> Can you please merge this series into linux-next?
>> 
>> The selftests are badly broken otherwise.
>> 
>> cheers
>> 
>
>Hi Michael,
>
>Thanks. All 5 patches are now in linux-kselftest next with Tested-by
>tag from Bamvor for 1,2,3.

Thanks!
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-02-14 20:33       ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-02-14 20:33 UTC (permalink / raw)
  To: Shuah Khan, Michael Ellerman, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api



On 15 February 2017 03:14:24 GMT+11:00, Shuah Khan <shuahkh@osg=2Esamsung=
=2Ecom> wrote:
>On 02/13/2017 07:09 PM, Michael Ellerman wrote:
>> Michael Ellerman <mpe@ellerman=2Eid=2Eau> writes:
>>=20
>>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>>> target"), the "all" target was removed from individual Makefiles and
>>> added to lib=2Emk=2E
>>>
>>> However the "all" target was added to lib=2Emk *after* the existing
>>> "runtests" target=2E This means "runtests" becomes the first (default)
>>> target for most of our Makefiles=2E
>> =2E=2E=2E
>>>
>>> Fix it by moving the "all" target to the start of lib=2Emk, making it
>the
>>> default target=2E
>>>
>>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean
>target")
>>> Signed-off-by: Michael Ellerman <mpe@ellerman=2Eid=2Eau>
>>=20
>> Hi Shuah,
>>=20
>> Can you please merge this series into linux-next?
>>=20
>> The selftests are badly broken otherwise=2E
>>=20
>> cheers
>>=20
>
>Hi Michael,
>
>Thanks=2E All 5 patches are now in linux-kselftest next with Tested-by
>tag from Bamvor for 1,2,3=2E

Thanks!
--=20
Sent from my Android phone with K-9 Mail=2E Please excuse my brevity=2E

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
  2017-02-14  2:09   ` Michael Ellerman
@ 2017-03-01 19:00     ` Shuah Khan
  -1 siblings, 0 replies; 29+ messages in thread
From: Shuah Khan @ 2017-03-01 19:00 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api,
	Ingo Molnar, Thomas Gleixner, hpa, LKML, linux-kselftest

On 02/13/2017 07:09 PM, Michael Ellerman wrote:
> Michael Ellerman <mpe@ellerman.id.au> writes:
> 
>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>> target"), the "all" target was removed from individual Makefiles and
>> added to lib.mk.
>>
>> However the "all" target was added to lib.mk *after* the existing
>> "runtests" target. This means "runtests" becomes the first (default)
>> target for most of our Makefiles.
> ...
>>
>> Fix it by moving the "all" target to the start of lib.mk, making it the
>> default target.
>>
>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> Hi Shuah,
> 
> Can you please merge this series into linux-next?
> 
> The selftests are badly broken otherwise.
> 
> cheers
> 

Hi Bamovar,

Your original series badly broke the selftest build. I can no longer
build individual tests. For example:

cd breakpoints/
shuah@shuah-XPS-13-9350:/lkml/linux_4.11/tools/testing/selftests/breakpoints$ make
gcc     breakpoint_test.c  -o /breakpoint_test
/usr/bin/ld: cannot open output file /breakpoint_test: Permission denied
collect2: error: ld returned 1 exit status
../lib.mk:54: recipe for target '/breakpoint_test' failed
make: *** [/breakpoint_test] Error 1

commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
Author: bamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
Date:   Tue Nov 29 19:55:52 2016 +0800

    selftests: enable O and KBUILD_OUTPUT

I believe the above patch is one of the suspects. Michael fixed
some of the problems in this patch and others he sent.

At the moment individual tests will not build.
tools/testing/selftests/x86$ make
Makefile:44: warning: overriding recipe for target 'clean'
../lib.mk:51: warning: ignoring old recipe for target 'clean'
gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
/usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
collect2: error: ld returned 1 exit status
Makefile:50: recipe for target '/single_step_syscall_64' failed
make: *** [/single_step_syscall_64] Error 1


My guess is OUTPUT doesn't resolve in individual builds from the test directory.
We have to get this fixed for 4.11-rc1

Simply Reverting a8ba798bc8ec663cf02e80b0dd770324de9bafd9 doesn't work.
Michael's patches depend on this. So anyway, please let me know if you
can fix this quickly. I am going to be trying a few things today as well.

thanks,
-- Shuah

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-03-01 19:00     ` Shuah Khan
  0 siblings, 0 replies; 29+ messages in thread
From: Shuah Khan @ 2017-03-01 19:00 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian
  Cc: linux-api, LKML, linuxppc-dev, linux-kselftest, hpa,
	Thomas Gleixner, Ingo Molnar

On 02/13/2017 07:09 PM, Michael Ellerman wrote:
> Michael Ellerman <mpe@ellerman.id.au> writes:
> 
>> In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
>> target"), the "all" target was removed from individual Makefiles and
>> added to lib.mk.
>>
>> However the "all" target was added to lib.mk *after* the existing
>> "runtests" target. This means "runtests" becomes the first (default)
>> target for most of our Makefiles.
> ...
>>
>> Fix it by moving the "all" target to the start of lib.mk, making it the
>> default target.
>>
>> Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> Hi Shuah,
> 
> Can you please merge this series into linux-next?
> 
> The selftests are badly broken otherwise.
> 
> cheers
> 

Hi Bamovar,

Your original series badly broke the selftest build. I can no longer
build individual tests. For example:

cd breakpoints/
shuah@shuah-XPS-13-9350:/lkml/linux_4.11/tools/testing/selftests/breakpoints$ make
gcc     breakpoint_test.c  -o /breakpoint_test
/usr/bin/ld: cannot open output file /breakpoint_test: Permission denied
collect2: error: ld returned 1 exit status
../lib.mk:54: recipe for target '/breakpoint_test' failed
make: *** [/breakpoint_test] Error 1

commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
Author: bamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
Date:   Tue Nov 29 19:55:52 2016 +0800

    selftests: enable O and KBUILD_OUTPUT

I believe the above patch is one of the suspects. Michael fixed
some of the problems in this patch and others he sent.

At the moment individual tests will not build.
tools/testing/selftests/x86$ make
Makefile:44: warning: overriding recipe for target 'clean'
../lib.mk:51: warning: ignoring old recipe for target 'clean'
gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
/usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
collect2: error: ld returned 1 exit status
Makefile:50: recipe for target '/single_step_syscall_64' failed
make: *** [/single_step_syscall_64] Error 1


My guess is OUTPUT doesn't resolve in individual builds from the test directory.
We have to get this fixed for 4.11-rc1

Simply Reverting a8ba798bc8ec663cf02e80b0dd770324de9bafd9 doesn't work.
Michael's patches depend on this. So anyway, please let me know if you
can fix this quickly. I am going to be trying a few things today as well.

thanks,
-- Shuah

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
  2017-03-01 19:00     ` Shuah Khan
@ 2017-03-02  6:43       ` Michael Ellerman
  -1 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-03-02  6:43 UTC (permalink / raw)
  To: Shuah Khan, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api,
	Ingo Molnar, Thomas Gleixner, hpa, LKML, linux-kselftest

Shuah Khan <shuahkh@osg.samsung.com> writes:
> Hi Bamovar,
>
> Your original series badly broke the selftest build. I can no longer
> build individual tests. For example:
>
> cd breakpoints/
> shuah@shuah-XPS-13-9350:/lkml/linux_4.11/tools/testing/selftests/breakpoints$ make
> gcc     breakpoint_test.c  -o /breakpoint_test
> /usr/bin/ld: cannot open output file /breakpoint_test: Permission denied
> collect2: error: ld returned 1 exit status
> ../lib.mk:54: recipe for target '/breakpoint_test' failed
> make: *** [/breakpoint_test] Error 1

I also got a report of that just yesterday.

You can do:

$ cd tools/testing/selftests ; make TARGETS=breakpoints

But it's not ideal.

> commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
> Author: bamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
> Date:   Tue Nov 29 19:55:52 2016 +0800
>
>     selftests: enable O and KBUILD_OUTPUT
>
> I believe the above patch is one of the suspects. Michael fixed
> some of the problems in this patch and others he sent.

It is that patch which caused it yes.

> At the moment individual tests will not build.
> tools/testing/selftests/x86$ make
> Makefile:44: warning: overriding recipe for target 'clean'
> ../lib.mk:51: warning: ignoring old recipe for target 'clean'
> gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
> /usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
> collect2: error: ld returned 1 exit status
> Makefile:50: recipe for target '/single_step_syscall_64' failed
> make: *** [/single_step_syscall_64] Error 1
>
>
> My guess is OUTPUT doesn't resolve in individual builds from the test directory.
> We have to get this fixed for 4.11-rc1

Yeah, OUTPUT is passed down from the top-level Makefile.

> Simply Reverting a8ba798bc8ec663cf02e80b0dd770324de9bafd9 doesn't work.
> Michael's patches depend on this. So anyway, please let me know if you
> can fix this quickly. I am going to be trying a few things today as well.

This seems to work, but needs some testing with and without OUTPUT set.

Basically if OUTPUT is not set, assume the current directory. It should
only take effect when someone builds from an individual directory,
because if you build from the top level OUTPUT is already set.


diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index ce96d80ad64f..9087fa949e82 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -2,6 +2,8 @@
 # Makefile can operate with or without the kbuild infrastructure.
 CC := $(CROSS_COMPILE)gcc
 
+OUTPUT ?= $(PWD)
+
 TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
 TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
 


cheers

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-03-02  6:43       ` Michael Ellerman
  0 siblings, 0 replies; 29+ messages in thread
From: Michael Ellerman @ 2017-03-02  6:43 UTC (permalink / raw)
  To: Shuah Khan, bamvor.zhangjian
  Cc: linux-api, LKML, linuxppc-dev, linux-kselftest, hpa,
	Thomas Gleixner, Ingo Molnar

Shuah Khan <shuahkh@osg.samsung.com> writes:
> Hi Bamovar,
>
> Your original series badly broke the selftest build. I can no longer
> build individual tests. For example:
>
> cd breakpoints/
> shuah@shuah-XPS-13-9350:/lkml/linux_4.11/tools/testing/selftests/breakpoints$ make
> gcc     breakpoint_test.c  -o /breakpoint_test
> /usr/bin/ld: cannot open output file /breakpoint_test: Permission denied
> collect2: error: ld returned 1 exit status
> ../lib.mk:54: recipe for target '/breakpoint_test' failed
> make: *** [/breakpoint_test] Error 1

I also got a report of that just yesterday.

You can do:

$ cd tools/testing/selftests ; make TARGETS=breakpoints

But it's not ideal.

> commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
> Author: bamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
> Date:   Tue Nov 29 19:55:52 2016 +0800
>
>     selftests: enable O and KBUILD_OUTPUT
>
> I believe the above patch is one of the suspects. Michael fixed
> some of the problems in this patch and others he sent.

It is that patch which caused it yes.

> At the moment individual tests will not build.
> tools/testing/selftests/x86$ make
> Makefile:44: warning: overriding recipe for target 'clean'
> ../lib.mk:51: warning: ignoring old recipe for target 'clean'
> gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
> /usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
> collect2: error: ld returned 1 exit status
> Makefile:50: recipe for target '/single_step_syscall_64' failed
> make: *** [/single_step_syscall_64] Error 1
>
>
> My guess is OUTPUT doesn't resolve in individual builds from the test directory.
> We have to get this fixed for 4.11-rc1

Yeah, OUTPUT is passed down from the top-level Makefile.

> Simply Reverting a8ba798bc8ec663cf02e80b0dd770324de9bafd9 doesn't work.
> Michael's patches depend on this. So anyway, please let me know if you
> can fix this quickly. I am going to be trying a few things today as well.

This seems to work, but needs some testing with and without OUTPUT set.

Basically if OUTPUT is not set, assume the current directory. It should
only take effect when someone builds from an individual directory,
because if you build from the top level OUTPUT is already set.


diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index ce96d80ad64f..9087fa949e82 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -2,6 +2,8 @@
 # Makefile can operate with or without the kbuild infrastructure.
 CC := $(CROSS_COMPILE)gcc
 
+OUTPUT ?= $(PWD)
+
 TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
 TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
 


cheers

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
  2017-03-02  6:43       ` Michael Ellerman
@ 2017-03-02 14:41         ` Shuah Khan
  -1 siblings, 0 replies; 29+ messages in thread
From: Shuah Khan @ 2017-03-02 14:41 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian
  Cc: linuxppc-dev, linux-kernel, linux-kselftest, linux-api,
	Ingo Molnar, Thomas Gleixner, hpa, Shuah Khan

Hi Michael and Bamovar,

On 03/01/2017 11:43 PM, Michael Ellerman wrote:
> Shuah Khan <shuahkh@osg.samsung.com> writes:
>> Hi Bamovar,
>>
>> Your original series badly broke the selftest build. I can no longer
>> build individual tests. For example:
>>
>> cd breakpoints/
>> shuah@shuah-XPS-13-9350:/lkml/linux_4.11/tools/testing/selftests/breakpoints$ make
>> gcc     breakpoint_test.c  -o /breakpoint_test
>> /usr/bin/ld: cannot open output file /breakpoint_test: Permission denied
>> collect2: error: ld returned 1 exit status
>> ../lib.mk:54: recipe for target '/breakpoint_test' failed
>> make: *** [/breakpoint_test] Error 1
> 
> I also got a report of that just yesterday.
> 
> You can do:
> 
> $ cd tools/testing/selftests ; make TARGETS=breakpoints
> 
> But it's not ideal.
> 
>> commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
>> Author: bamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
>> Date:   Tue Nov 29 19:55:52 2016 +0800
>>
>>     selftests: enable O and KBUILD_OUTPUT
>>
>> I believe the above patch is one of the suspects. Michael fixed
>> some of the problems in this patch and others he sent.
> 
> It is that patch which caused it yes.
> 
>> At the moment individual tests will not build.
>> tools/testing/selftests/x86$ make
>> Makefile:44: warning: overriding recipe for target 'clean'
>> ../lib.mk:51: warning: ignoring old recipe for target 'clean'
>> gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
>> /usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
>> collect2: error: ld returned 1 exit status
>> Makefile:50: recipe for target '/single_step_syscall_64' failed
>> make: *** [/single_step_syscall_64] Error 1
>>
>>
>> My guess is OUTPUT doesn't resolve in individual builds from the test directory.
>> We have to get this fixed for 4.11-rc1
> 
> Yeah, OUTPUT is passed down from the top-level Makefile.
> 
>> Simply Reverting a8ba798bc8ec663cf02e80b0dd770324de9bafd9 doesn't work.
>> Michael's patches depend on this. So anyway, please let me know if you
>> can fix this quickly. I am going to be trying a few things today as well.
> 
> This seems to work, but needs some testing with and without OUTPUT set.
> 
> Basically if OUTPUT is not set, assume the current directory. It should
> only take effect when someone builds from an individual directory,
> because if you build from the top level OUTPUT is already set.
> 
> 
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index ce96d80ad64f..9087fa949e82 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -2,6 +2,8 @@
>  # Makefile can operate with or without the kbuild infrastructure.
>  CC := $(CROSS_COMPILE)gcc
>  
> +OUTPUT ?= $(PWD)
> +
>  TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
>  TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
>  
> 
> 
> cheers
> 

I sent a fix to lib.mk to set the OUTPUT. Please review. I can request
Linus to merge it in before 4.11-rc1 comes out.

thanks,
-- Shuah

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

* Re: [PATCH 1/5] selftests: Fix selftests build to just build, not run tests
@ 2017-03-02 14:41         ` Shuah Khan
  0 siblings, 0 replies; 29+ messages in thread
From: Shuah Khan @ 2017-03-02 14:41 UTC (permalink / raw)
  To: Michael Ellerman, bamvor.zhangjian
  Cc: linux-api, linux-kernel, Shuah Khan, linuxppc-dev,
	linux-kselftest, hpa, Thomas Gleixner, Ingo Molnar

Hi Michael and Bamovar,

On 03/01/2017 11:43 PM, Michael Ellerman wrote:
> Shuah Khan <shuahkh@osg.samsung.com> writes:
>> Hi Bamovar,
>>
>> Your original series badly broke the selftest build. I can no longer
>> build individual tests. For example:
>>
>> cd breakpoints/
>> shuah@shuah-XPS-13-9350:/lkml/linux_4.11/tools/testing/selftests/breakpoints$ make
>> gcc     breakpoint_test.c  -o /breakpoint_test
>> /usr/bin/ld: cannot open output file /breakpoint_test: Permission denied
>> collect2: error: ld returned 1 exit status
>> ../lib.mk:54: recipe for target '/breakpoint_test' failed
>> make: *** [/breakpoint_test] Error 1
> 
> I also got a report of that just yesterday.
> 
> You can do:
> 
> $ cd tools/testing/selftests ; make TARGETS=breakpoints
> 
> But it's not ideal.
> 
>> commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
>> Author: bamvor.zhangjian@huawei.com <bamvor.zhangjian@huawei.com>
>> Date:   Tue Nov 29 19:55:52 2016 +0800
>>
>>     selftests: enable O and KBUILD_OUTPUT
>>
>> I believe the above patch is one of the suspects. Michael fixed
>> some of the problems in this patch and others he sent.
> 
> It is that patch which caused it yes.
> 
>> At the moment individual tests will not build.
>> tools/testing/selftests/x86$ make
>> Makefile:44: warning: overriding recipe for target 'clean'
>> ../lib.mk:51: warning: ignoring old recipe for target 'clean'
>> gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
>> /usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
>> collect2: error: ld returned 1 exit status
>> Makefile:50: recipe for target '/single_step_syscall_64' failed
>> make: *** [/single_step_syscall_64] Error 1
>>
>>
>> My guess is OUTPUT doesn't resolve in individual builds from the test directory.
>> We have to get this fixed for 4.11-rc1
> 
> Yeah, OUTPUT is passed down from the top-level Makefile.
> 
>> Simply Reverting a8ba798bc8ec663cf02e80b0dd770324de9bafd9 doesn't work.
>> Michael's patches depend on this. So anyway, please let me know if you
>> can fix this quickly. I am going to be trying a few things today as well.
> 
> This seems to work, but needs some testing with and without OUTPUT set.
> 
> Basically if OUTPUT is not set, assume the current directory. It should
> only take effect when someone builds from an individual directory,
> because if you build from the top level OUTPUT is already set.
> 
> 
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index ce96d80ad64f..9087fa949e82 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -2,6 +2,8 @@
>  # Makefile can operate with or without the kbuild infrastructure.
>  CC := $(CROSS_COMPILE)gcc
>  
> +OUTPUT ?= $(PWD)
> +
>  TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
>  TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
>  
> 
> 
> cheers
> 

I sent a fix to lib.mk to set the OUTPUT. Please review. I can request
Linus to merge it in before 4.11-rc1 comes out.

thanks,
-- Shuah

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

end of thread, other threads:[~2017-03-02 14:42 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09  8:56 [PATCH 1/5] selftests: Fix selftests build to just build, not run tests Michael Ellerman
2017-02-09  8:56 ` Michael Ellerman
2017-02-09  8:56 ` [PATCH 2/5] selftests: Fix the .c linking rule Michael Ellerman
2017-02-09  8:56   ` Michael Ellerman
2017-02-14  3:07   ` Bamvor Zhang Jian
2017-02-14  3:07     ` Bamvor Zhang Jian
2017-02-09  8:56 ` [PATCH 3/5] selftests: Fix the .S and .S -> .o rules Michael Ellerman
2017-02-09  8:56   ` Michael Ellerman
2017-02-14  3:07   ` Bamvor Zhang Jian
2017-02-14  3:07     ` Bamvor Zhang Jian
2017-02-09  8:56 ` [PATCH 4/5] selftests/powerpc: Fix the clean rule since recent changes Michael Ellerman
2017-02-09  8:56   ` Michael Ellerman
2017-02-09  8:56 ` [PATCH 5/5] selftests/powerpc: Fix remaining fallout from " Michael Ellerman
2017-02-09  8:56   ` Michael Ellerman
2017-02-14  2:09 ` [PATCH 1/5] selftests: Fix selftests build to just build, not run tests Michael Ellerman
2017-02-14  2:09   ` Michael Ellerman
2017-02-14 16:14   ` Shuah Khan
2017-02-14 16:14     ` Shuah Khan
2017-02-14 20:33     ` Michael Ellerman
2017-02-14 20:33       ` Michael Ellerman
2017-02-14 20:33       ` Michael Ellerman
2017-03-01 19:00   ` Shuah Khan
2017-03-01 19:00     ` Shuah Khan
2017-03-02  6:43     ` Michael Ellerman
2017-03-02  6:43       ` Michael Ellerman
2017-03-02 14:41       ` Shuah Khan
2017-03-02 14:41         ` Shuah Khan
2017-02-14  3:06 ` Bamvor Zhang Jian
2017-02-14  3:06   ` 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.