From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-09 09:05:27
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(-)
@@ -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@forTESTin$(TEST_GEN_PROGS)$(TEST_PROGS);do\BASENAME_TEST=`basename$$TEST`;\
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-09 09:05:29
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(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-09 09:05:30
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(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-09 09:07:07
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(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-14 02:09:31
Michael Ellerman [off-list ref] 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
Tested by: Bamvor Jian Zhang [off-list ref]
On 9 February 2017 at 16:56, Michael Ellerman [off-list ref] wrote:
quoted hunk
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(-)
@@ -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@forTESTin$(TEST_GEN_PROGS)$(TEST_PROGS);do\BASENAME_TEST=`basename$$TEST`;\
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
Tested-by: Bamvor Jian Zhang <redacted>
On 9 February 2017 at 16:56, Michael Ellerman [off-list ref] wrote:
quoted hunk
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(-)
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
Tested-by: Bamvor Jian Zhang <redacted>
On 9 February 2017 at 16:56, Michael Ellerman [off-list ref] wrote:
quoted hunk
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(-)
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
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.
...
quoted
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
From: Michael Ellerman <hidden> Date: 2017-02-14 20:33:36
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:
quoted
Michael Ellerman <mpe@ellerman=2Eid=2Eau> writes:
=20
quoted
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
quoted
Fix it by moving the "all" target to the start of lib=2Emk, making it
the
quoted
quoted
default target=2E
Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean
target")
quoted
quoted
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
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.
...
quoted
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 [off-list ref]
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
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-03-02 06:53:04
Shuah Khan [off-list ref] 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 [off-list ref]
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.
@@ -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))
Hi Michael and Bamovar,
On 03/01/2017 11:43 PM, Michael Ellerman wrote:
quoted hunk
Shuah Khan [off-list ref] writes:
quoted
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.
quoted
commit a8ba798bc8ec663cf02e80b0dd770324de9bafd9
Author: bamvor.zhangjian@huawei.com [off-list ref]
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.
quoted
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.
quoted
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.
@@ -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