This patch series consists of first round of fixes to integrate Kselftest into Kernel CI.
You can find full list of problems in my announcement I sent out last week:
https://lkml.org/lkml/2020/2/27/2221
These fixes to android and seccomp tests address relocatable support. However, they will still leave the source directory dirty.
android test does headers_install in source directory. This is an easier problem to fix. seccomp on the other hand builds fixdep scripts under scripts/basic and installs headers in the source directory. It is linked to solving bpf relocatable build issue which I haven't given it a lot of thought for now.
There is no dependency on source directory for run-time which is what we want.
I will apply these kernelci topic branch for testing git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
Shuah Khan (4): selftests: Fix kselftest O=objdir build from cluttering top level objdir selftests: Fix seccomp to support relocatable build (O=objdir) selftests: android: ion: Fix ionmap_test compile error selftests: android: Fix custom install from skipping test progs
tools/testing/selftests/Makefile | 4 ++-- tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 2 +- tools/testing/selftests/seccomp/Makefile | 16 +++------------- 4 files changed, 7 insertions(+), 17 deletions(-)
make kselftest-all O=objdir builds create generated objects in objdir. This clutters the top level directory with kselftest objects. Fix it to create sub-directory under objdir for kselftest objects.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org --- tools/testing/selftests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 6ec503912bea..cd77df3e6bb8 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -91,7 +91,7 @@ override LDFLAGS = override MAKEFLAGS = endif
-# Append kselftest to KBUILD_OUTPUT to avoid cluttering +# Append kselftest to KBUILD_OUTPUT and O to avoid cluttering # KBUILD_OUTPUT with selftest objects and headers installed # by selftests Makefile or lib.mk. ifdef building_out_of_srctree @@ -99,7 +99,7 @@ override LDFLAGS = endif
ifneq ($(O),) - BUILD := $(O) + BUILD := $(O)/kselftest else ifneq ($(KBUILD_OUTPUT),) BUILD := $(KBUILD_OUTPUT)/kselftest
Shuah Khan skhan@linuxfoundation.org writes:
make kselftest-all O=objdir builds create generated objects in objdir. This clutters the top level directory with kselftest objects. Fix it to create sub-directory under objdir for kselftest objects.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
Only somewhat related to this patch, another problem that wasn't in your doci is that the current O= support doesn't support relative paths.
For example, using O=/tmp/build-arm64 works, but O=build-arm64 doesn't. Try this:
$ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 defconfig $ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 kselftest-all make[1]: Entering directory '/work/kernel/linux/build-arm64' make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=arm64 -C ../../.. headers_install make[4]: ../scripts/Makefile.build: No such file or directory make[4]: *** No rule to make target '../scripts/Makefile.build'. Stop. Makefile:500: recipe for target 'scripts_basic' failed make[3]: *** [scripts_basic] Error 2 Makefile:151: recipe for target 'khdr' failed make[2]: *** [khdr] Error 2 /work/kernel/linux/Makefile:1220: recipe for target 'kselftest-all' failed make[1]: *** [kselftest-all] Error 2 make[1]: Leaving directory '/work/kernel/linux/build-arm64' Makefile:179: recipe for target 'sub-make' failed make: *** [sub-make] Error 2
Kevin
tools/testing/selftests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 6ec503912bea..cd77df3e6bb8 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -91,7 +91,7 @@ override LDFLAGS = override MAKEFLAGS = endif -# Append kselftest to KBUILD_OUTPUT to avoid cluttering +# Append kselftest to KBUILD_OUTPUT and O to avoid cluttering # KBUILD_OUTPUT with selftest objects and headers installed # by selftests Makefile or lib.mk. ifdef building_out_of_srctree @@ -99,7 +99,7 @@ override LDFLAGS = endif ifneq ($(O),)
- BUILD := $(O)
- BUILD := $(O)/kselftest
else ifneq ($(KBUILD_OUTPUT),) BUILD := $(KBUILD_OUTPUT)/kselftest -- 2.20.1
On 3/11/20 4:58 PM, Kevin Hilman wrote:
Shuah Khan skhan@linuxfoundation.org writes:
make kselftest-all O=objdir builds create generated objects in objdir. This clutters the top level directory with kselftest objects. Fix it to create sub-directory under objdir for kselftest objects.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
Only somewhat related to this patch, another problem that wasn't in your doci is that the current O= support doesn't support relative paths.
Yes I am aware of it and it is in the document as something that will be addressed later.
"Note: Relative paths don’t work - supporting relative paths breaks work-flows e.g: powerpc. Explore fix. Compile work-flows. Not planning to support at the moment."
For example, using O=/tmp/build-arm64 works, but O=build-arm64 doesn't. Try this:
$ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 defconfig $ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 kselftest-all make[1]: Entering directory '/work/kernel/linux/build-arm64' make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=arm64 -C ../../.. headers_install make[4]: ../scripts/Makefile.build: No such file or directory make[4]: *** No rule to make target '../scripts/Makefile.build'. Stop. Makefile:500: recipe for target 'scripts_basic' failed make[3]: *** [scripts_basic] Error 2 Makefile:151: recipe for target 'khdr' failed make[2]: *** [khdr] Error 2 /work/kernel/linux/Makefile:1220: recipe for target 'kselftest-all' failed make[1]: *** [kselftest-all] Error 2 make[1]: Leaving directory '/work/kernel/linux/build-arm64' Makefile:179: recipe for target 'sub-make' failed make: *** [sub-make] Error 2
I am looking to address build and install issues first.
thanks, -- Shuah
On 3/11/20 4:31 PM, Shuah Khan wrote:
On 3/11/20 4:58 PM, Kevin Hilman wrote:
Shuah Khan skhan@linuxfoundation.org writes:
make kselftest-all O=objdir builds create generated objects in objdir. This clutters the top level directory with kselftest objects. Fix it to create sub-directory under objdir for kselftest objects.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
Only somewhat related to this patch, another problem that wasn't in your doci is that the current O= support doesn't support relative paths.
Yes I am aware of it and it is in the document as something that will be addressed later.
"Note: Relative paths don’t work - supporting relative paths breaks work-flows e.g: powerpc. Explore fix. Compile work-flows. Not planning to support at the moment."
Hi, Sorry to be dense but where is this documented (as quoted above)?
Thanks.
For example, using O=/tmp/build-arm64 works, but O=build-arm64 doesn't. Try this:
$ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 defconfig $ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 kselftest-all make[1]: Entering directory '/work/kernel/linux/build-arm64' make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=arm64 -C ../../.. headers_install make[4]: ../scripts/Makefile.build: No such file or directory make[4]: *** No rule to make target '../scripts/Makefile.build'. Stop. Makefile:500: recipe for target 'scripts_basic' failed make[3]: *** [scripts_basic] Error 2 Makefile:151: recipe for target 'khdr' failed make[2]: *** [khdr] Error 2 /work/kernel/linux/Makefile:1220: recipe for target 'kselftest-all' failed make[1]: *** [kselftest-all] Error 2 make[1]: Leaving directory '/work/kernel/linux/build-arm64' Makefile:179: recipe for target 'sub-make' failed make: *** [sub-make] Error 2
I am looking to address build and install issues first.
thanks, -- Shuah
On 5/14/20 8:27 PM, Randy Dunlap wrote:
On 3/11/20 4:31 PM, Shuah Khan wrote:
On 3/11/20 4:58 PM, Kevin Hilman wrote:
Shuah Khan skhan@linuxfoundation.org writes:
make kselftest-all O=objdir builds create generated objects in objdir. This clutters the top level directory with kselftest objects. Fix it to create sub-directory under objdir for kselftest objects.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
Only somewhat related to this patch, another problem that wasn't in your doci is that the current O= support doesn't support relative paths.
Yes I am aware of it and it is in the document as something that will be addressed later.
"Note: Relative paths don’t work - supporting relative paths breaks work-flows e.g: powerpc. Explore fix. Compile work-flows. Not planning to support at the moment."
I attempted to fix it once and had to revert the patch. This relative problem needs to be fixed and being tracked as a bug.
I am looking to address build and install issues first.
As I said above, there were higher priority test build and install failures in cross-build and native build use-cases when I made this call to prioritize fixing them first. I fixed all the known issues.
As of Linux 5.7-rc5 all of the know issues related test build and install failures have been fixed.
With tha done, it is time to work on the relative path fix. I have my reverted patch to start with and get it to work with the workflows so it doesn't break them.
I also have the following patch you gave me as reference for fixing the relative path problem:
https://lore.kernel.org/lkml/158351957799.3363.15269768530697526765.stgit@de...
In any case, based on my previous experience fixing this problem, I plan to take the fix in rc1 to allow enough time to fix any problems that show up. It will be fixed for sure.
Hope this helps addresses any concerns you may have on whether or not this problem will be fixed.
thanks, -- Shuah
Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS for objects to leverage lib.mk common framework for relocatable builds.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org --- tools/testing/selftests/seccomp/Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index 1760b3e39730..a8a9717fc1be 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,17 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -all: - -include ../lib.mk - -.PHONY: all clean - -BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall +LDFLAGS += -lpthread
-seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h - $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@ - -TEST_PROGS += $(BINARIES) -EXTRA_CLEAN := $(BINARIES) +TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark
-all: $(BINARIES) +include ../lib.mk
On Wed, Mar 04, 2020 at 03:13:33PM -0700, Shuah Khan wrote:
Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS for objects to leverage lib.mk common framework for relocatable builds.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
tools/testing/selftests/seccomp/Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index 1760b3e39730..a8a9717fc1be 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,17 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -all:
-include ../lib.mk
-.PHONY: all clean
-BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall +LDFLAGS += -lpthread -seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
How is the ../kselftest_harness.h dependency detected in the resulting build rules?
Otherwise, looks good.
-Kees
- $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
-TEST_PROGS += $(BINARIES) -EXTRA_CLEAN := $(BINARIES) +TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark -all: $(BINARIES)
+include ../lib.mk
2.20.1
On 3/4/20 3:42 PM, Kees Cook wrote:
On Wed, Mar 04, 2020 at 03:13:33PM -0700, Shuah Khan wrote:
Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS for objects to leverage lib.mk common framework for relocatable builds.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
tools/testing/selftests/seccomp/Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index 1760b3e39730..a8a9717fc1be 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,17 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -all:
-include ../lib.mk
-.PHONY: all clean
-BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall +LDFLAGS += -lpthread -seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
How is the ../kselftest_harness.h dependency detected in the resulting build rules?
Otherwise, looks good.
Didn't see any problems. I will look into adding the dependency.
thanks, -- Shuah
Shuah Khan skhan@linuxfoundation.org writes:
On 3/4/20 3:42 PM, Kees Cook wrote:
On Wed, Mar 04, 2020 at 03:13:33PM -0700, Shuah Khan wrote:
Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS for objects to leverage lib.mk common framework for relocatable builds.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
tools/testing/selftests/seccomp/Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index 1760b3e39730..a8a9717fc1be 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,17 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -all:
-include ../lib.mk
-.PHONY: all clean
-BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall +LDFLAGS += -lpthread -seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
How is the ../kselftest_harness.h dependency detected in the resulting build rules?
Otherwise, looks good.
Didn't see any problems. I will look into adding the dependency.
Before:
$ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install INSTALL /home/michael/build/adhoc/kselftest/usr/include gcc -Wl,-no-as-needed -Wall seccomp_bpf.c -lpthread -o seccomp_bpf gcc -Wl,-no-as-needed -Wall seccomp_benchmark.c -o seccomp_benchmark
$ touch tools/testing/selftests/kselftest_harness.h
$ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install INSTALL /home/michael/build/adhoc/kselftest/usr/include gcc -Wl,-no-as-needed -Wall seccomp_bpf.c -lpthread -o seccomp_bpf $
Note that touching the header causes it to rebuild seccomp_bpf.
With this patch applied:
$ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make -s --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /home/michael/build/adhoc/kselftest/seccomp/seccomp_bpf gcc -Wl,-no-as-needed -Wall -lpthread seccomp_benchmark.c -o /home/michael/build/adhoc/kselftest/seccomp/seccomp_benchmark
$ touch tools/testing/selftests/kselftest_harness.h
$ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make -s --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install make[1]: Nothing to be done for 'all'. $
So yeah it still needs:
seccomp_bpf: ../kselftest_harness.h
cheers
On 3/4/20 5:22 PM, Michael Ellerman wrote:
Shuah Khan skhan@linuxfoundation.org writes:
On 3/4/20 3:42 PM, Kees Cook wrote:
On Wed, Mar 04, 2020 at 03:13:33PM -0700, Shuah Khan wrote:
Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS for objects to leverage lib.mk common framework for relocatable builds.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org
tools/testing/selftests/seccomp/Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index 1760b3e39730..a8a9717fc1be 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,17 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -all:
-include ../lib.mk
-.PHONY: all clean
-BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall +LDFLAGS += -lpthread -seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
How is the ../kselftest_harness.h dependency detected in the resulting build rules?
Otherwise, looks good.
Didn't see any problems. I will look into adding the dependency.
Before:
$ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install INSTALL /home/michael/build/adhoc/kselftest/usr/include gcc -Wl,-no-as-needed -Wall seccomp_bpf.c -lpthread -o seccomp_bpf gcc -Wl,-no-as-needed -Wall seccomp_benchmark.c -o seccomp_benchmark $ touch tools/testing/selftests/kselftest_harness.h $ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install INSTALL /home/michael/build/adhoc/kselftest/usr/include gcc -Wl,-no-as-needed -Wall seccomp_bpf.c -lpthread -o seccomp_bpf $
Note that touching the header causes it to rebuild seccomp_bpf.
With this patch applied:
$ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make -s --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install gcc -Wl,-no-as-needed -Wall -lpthread seccomp_bpf.c -o /home/michael/build/adhoc/kselftest/seccomp/seccomp_bpf gcc -Wl,-no-as-needed -Wall -lpthread seccomp_benchmark.c -o /home/michael/build/adhoc/kselftest/seccomp/seccomp_benchmark $ touch tools/testing/selftests/kselftest_harness.h $ make --no-print-directory -C tools/testing/selftests/ TARGETS=seccomp make -s --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ ARCH=powerpc -C ../../.. headers_install make[1]: Nothing to be done for 'all'. $
Thanks. I realized I overlooked header dependency case.
So yeah it still needs:
seccomp_bpf: ../kselftest_harness.h
Yes v2 coming up. It also has to handle OUTPUT relocation.
thanks, -- Shuah
ionmap_test compile rule is missing ipcsocket.c dependency. Add it to fix the following compile errors:
..android/ion/ionutils.c:221: undefined reference to `sendtosocket' ..android/ion/ionutils.c:243: undefined reference to `receivefromsocket'
Signed-off-by: Shuah Khan skhan@linuxfoundation.org --- tools/testing/selftests/android/ion/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index 0eb7ab626e1c..42b71f005332 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -17,4 +17,4 @@ include ../../lib.mk
$(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c $(OUTPUT)/ionapp_import: ionapp_import.c ipcsocket.c ionutils.c -$(OUTPUT)/ionmap_test: ionmap_test.c ionutils.c +$(OUTPUT)/ionmap_test: ionmap_test.c ionutils.c ipcsocket.c
Update custom install rule to install all generated test programs. This fixes android/ion tests to be installed correctly.
Signed-off-by: Shuah Khan skhan@linuxfoundation.org --- tools/testing/selftests/android/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 7c462714b418..9258306cafe9 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -21,7 +21,7 @@ all:
override define INSTALL_RULE mkdir -p $(INSTALL_PATH) - install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) +install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
@for SUBDIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$SUBDIR; \
On 3/4/20 3:13 PM, Shuah Khan wrote:
This patch series consists of first round of fixes to integrate Kselftest into Kernel CI.
You can find full list of problems in my announcement I sent out last week:
Here is the lore link:
https://lore.kernel.org/lkml/3b3dc707-7ae7-955b-69fe-b9abe9ae26c5@linuxfound...
thanks, -- Shuah
linux-kselftest-mirror@lists.linaro.org