kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] selftests: Fix separate output directory builds
@ 2022-01-18 11:28 Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 01/10] selftests: set the BUILD variable to absolute path Muhammad Usama Anjum
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:28 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Build of several selftests fail if separate output directory is
specified by the following methods:
1) make -C tools/testing/selftests O=<build_dir>
2) export KBUILD_OUTPUT="build_dir"; make -C tools/testing/selftests

Build fails because of several reasons:
1) The kernel headers aren't found.
2) The path of output objects is wrong and hence unaccessible.

These problems can be solved by:
1) Including the correct path of uapi header files
2) By setting the BUILD variable correctly inside Makefile

Following different build scnerios have been tested after making these
changes:
make -C tools/testing/selftests
make -C tools/testing/selftests O=build
make -C tools/testing/selftests o=/opt/build
export KBUILD_OUTPUT="/opt/build"; make -C tools/testing/selftests
export KBUILD_OUTPUT="build"; make -C tools/testing/selftests
cd <any_dir>; make -C <src_path>/tools/testing/selftests
cd <any_dir>; make -C <src_path>/tools/testing/selftests O=build

Muhammad Usama Anjum (10):
  selftests: set the BUILD variable to absolute path
  selftests: Add and export a kernel uapi headers path
  selftests: Correct the headers install path
  selftests: futex: Add the uapi headers include variable
  selftests: kvm: Add the uapi headers include variable
  selftests: landlock: Add the uapi headers include variable
  selftests: net: Add the uapi headers include variable
  selftests: mptcp: Add the uapi headers include variable
  selftests: vm: Add the uapi headers include variable
  selftests: vm: remove dependecy from internal kernel macros

 tools/testing/selftests/Makefile              | 32 +++++++++++++------
 .../selftests/futex/functional/Makefile       |  5 ++-
 tools/testing/selftests/kvm/Makefile          |  6 ++--
 tools/testing/selftests/landlock/Makefile     | 11 ++-----
 tools/testing/selftests/net/Makefile          |  2 +-
 tools/testing/selftests/net/mptcp/Makefile    |  3 +-
 tools/testing/selftests/vm/Makefile           |  2 +-
 tools/testing/selftests/vm/userfaultfd.c      |  3 ++
 8 files changed, 35 insertions(+), 29 deletions(-)

-- 
2.30.2


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

* [PATCH 01/10] selftests: set the BUILD variable to absolute path
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 02/10] selftests: Add and export a kernel uapi headers path Muhammad Usama Anjum
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

The build of kselftests fails if relative path is specified through
KBUILD_OUTPUT or O=<path> method. BUILD variable is used to determine
the path of the output objects. When make is run from other directories
with relative paths, the exact path of the build objects is ambiguous
and build fails.

	make[1]: Entering directory '/home/usama/repos/kernel/linux_mainline2/tools/testing/selftests/alsa'
	gcc     mixer-test.c -L/usr/lib/x86_64-linux-gnu -lasound  -o build/kselftest/alsa/mixer-test
	/usr/bin/ld: cannot open output file build/kselftest/alsa/mixer-test

Set the BUILD variable to the absolute path of the output directory.
Make the logic readable and easy to follow. Use spaces instead of tabs
for indentation as if with tab indentation is considered recipe in make.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/Makefile | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index d08fe4cfe811..a7b63860b7bc 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -114,19 +114,27 @@ ifdef building_out_of_srctree
 override LDFLAGS =
 endif
 
-ifneq ($(O),)
-	BUILD := $(O)/kselftest
+top_srcdir ?= ../../..
+
+ifeq ("$(origin O)", "command line")
+  KBUILD_OUTPUT := $(O)
+endif
+
+ifneq ($(KBUILD_OUTPUT),)
+  # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
+  # expand a shell special character '~'. We use a somewhat tedious way here.
+  abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
+  $(if $(abs_objtree),, \
+    $(error failed to create output directory "$(KBUILD_OUTPUT)"))
+  # $(realpath ...) resolves symlinks
+  abs_objtree := $(realpath $(abs_objtree))
+  BUILD := $(abs_objtree)/kselftest
 else
-	ifneq ($(KBUILD_OUTPUT),)
-		BUILD := $(KBUILD_OUTPUT)/kselftest
-	else
-		BUILD := $(shell pwd)
-		DEFAULT_INSTALL_HDR_PATH := 1
-	endif
+  BUILD := $(CURDIR)
+  DEFAULT_INSTALL_HDR_PATH := 1
 endif
 
 # Prepare for headers install
-top_srcdir ?= ../../..
 include $(top_srcdir)/scripts/subarch.include
 ARCH           ?= $(SUBARCH)
 export KSFT_KHDR_INSTALL_DONE := 1
-- 
2.30.2


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

* [PATCH 02/10] selftests: Add and export a kernel uapi headers path
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 01/10] selftests: set the BUILD variable to absolute path Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 03/10] selftests: Correct the headers install path Muhammad Usama Anjum
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Kernel uapi headers can be present at different paths depending upon
how the build was invoked. It becomes impossible for the tests to
include the correct headers directory. Set and export KHDR_INCLUDES
variable to make it possible for sub make files to include the header
files.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index a7b63860b7bc..21f983dfd047 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -129,8 +129,11 @@ ifneq ($(KBUILD_OUTPUT),)
   # $(realpath ...) resolves symlinks
   abs_objtree := $(realpath $(abs_objtree))
   BUILD := $(abs_objtree)/kselftest
+  KHDR_INCLUDES := -I${abs_objtree}/usr/include
 else
   BUILD := $(CURDIR)
+  abs_srctree := $(shell cd $(top_srcdir) && pwd)
+  KHDR_INCLUDES := -I${abs_srctree}/usr/include
   DEFAULT_INSTALL_HDR_PATH := 1
 endif
 
@@ -139,6 +142,7 @@ include $(top_srcdir)/scripts/subarch.include
 ARCH           ?= $(SUBARCH)
 export KSFT_KHDR_INSTALL_DONE := 1
 export BUILD
+export KHDR_INCLUDES
 
 # set default goal to all, so make without a target runs all, even when
 # all isn't the first target in the file.
-- 
2.30.2


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

* [PATCH 03/10] selftests: Correct the headers install path
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 01/10] selftests: set the BUILD variable to absolute path Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 02/10] selftests: Add and export a kernel uapi headers path Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 04/10] selftests: futex: Add the uapi headers include variable Muhammad Usama Anjum
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

uapi headers should be installed at the top of the object tree,
"<obj_tree>/usr/include". There is no need for kernel headers to
be present at kselftest build directory, "<obj_tree>/kselftest/usr/
include" as well. This duplication can be avoided by correctly
specifying the INSTALL_HDR_PATH.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 21f983dfd047..80e5498eab92 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -167,7 +167,7 @@ khdr:
 ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
 	$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
 else
-	$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
+	$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(abs_objtree)/usr \
 		ARCH=$(ARCH) -C $(top_srcdir) headers_install
 endif
 
-- 
2.30.2


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

* [PATCH 04/10] selftests: futex: Add the uapi headers include variable
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (2 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 03/10] selftests: Correct the headers install path Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 05/10] selftests: kvm: " Muhammad Usama Anjum
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Out of tree build of this test fails if relative path of the output
directory is specified. KBUILD_OUTPUT also doesn't point to the correct
directory when relative path is used. Thus out of tree builds fail.
Remove the un-needed include paths and use KHDR_INCLUDES to correctly
reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/futex/functional/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 5cc38de9d8ea..7ff1e764407b 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-INCLUDES := -I../include -I../../ -I../../../../../usr/include/ \
-	-I$(KBUILD_OUTPUT)/kselftest/usr/include
-CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
+INCLUDES := -I../include -I../../
+CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES)
 LDLIBS := -lpthread -lrt
 
 HEADERS := \
-- 
2.30.2


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

* [PATCH 05/10] selftests: kvm: Add the uapi headers include variable
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (3 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 04/10] selftests: futex: Add the uapi headers include variable Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 06/10] selftests: landlock: " Muhammad Usama Anjum
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Out of tree build of this test fails if relative path of the output
directory is specified. Remove the un-needed include paths and use
KHDR_INCLUDES to correctly reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/kvm/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index ee8cf2149824..ce9c8857e14c 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -136,8 +136,6 @@ TEST_GEN_PROGS_riscv += kvm_binary_stats_test
 TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
 LIBKVM += $(LIBKVM_$(UNAME_M))
 
-INSTALL_HDR_PATH = $(top_srcdir)/usr
-LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
 ifeq ($(ARCH),x86_64)
 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
@@ -146,7 +144,7 @@ LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
 endif
 CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
 	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
-	-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
+	-I$(LINUX_TOOL_ARCH_INCLUDE) $(KHDR_INCLUDES) -Iinclude \
 	-I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS)
 
 no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
@@ -185,7 +183,7 @@ x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
 all: $(STATIC_LIBS)
 $(TEST_GEN_PROGS): $(STATIC_LIBS)
 
-cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
+cscope: include_paths = $(LINUX_TOOL_INCLUDE) include lib ..
 cscope:
 	$(RM) cscope.*
 	(find $(include_paths) -name '*.h' \
-- 
2.30.2


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

* [PATCH 06/10] selftests: landlock: Add the uapi headers include variable
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (4 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 05/10] selftests: kvm: " Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 12:35   ` Mickaël Salaün
  2022-01-18 11:29 ` [PATCH 07/10] selftests: net: " Muhammad Usama Anjum
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Out of tree build of this test fails if relative path of the output
directory is specified. Remove the un-needed include paths and use
KHDR_INCLUDES to correctly reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/landlock/Makefile | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/landlock/Makefile b/tools/testing/selftests/landlock/Makefile
index a99596ca9882..44c724b38a37 100644
--- a/tools/testing/selftests/landlock/Makefile
+++ b/tools/testing/selftests/landlock/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -Wall -O2
+CFLAGS += -Wall -O2 $(KHDR_INCLUDES)
 
 src_test := $(wildcard *_test.c)
 
@@ -12,13 +12,8 @@ KSFT_KHDR_INSTALL := 1
 OVERRIDE_TARGETS := 1
 include ../lib.mk
 
-khdr_dir = $(top_srcdir)/usr/include
-
-$(khdr_dir)/linux/landlock.h: khdr
-	@:
-
 $(OUTPUT)/true: true.c
 	$(LINK.c) $< $(LDLIBS) -o $@ -static
 
-$(OUTPUT)/%_test: %_test.c $(khdr_dir)/linux/landlock.h ../kselftest_harness.h common.h
-	$(LINK.c) $< $(LDLIBS) -o $@ -lcap -I$(khdr_dir)
+$(OUTPUT)/%_test: %_test.c ../kselftest_harness.h common.h
+	$(LINK.c) $< $(LDLIBS) -o $@ -lcap
-- 
2.30.2


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

* [PATCH 07/10] selftests: net: Add the uapi headers include variable
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (5 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 06/10] selftests: landlock: " Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 08/10] selftests: mptcp: " Muhammad Usama Anjum
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Out of tree build of this test fails if relative path of the output
directory is specified. Remove the un-needed include paths and use
KHDR_INCLUDES to correctly reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/net/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 9897fa9ab953..22759591fc79 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -2,7 +2,7 @@
 # Makefile for net selftests
 
 CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
 	      rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
-- 
2.30.2


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

* [PATCH 08/10] selftests: mptcp: Add the uapi headers include variable
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (6 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 07/10] selftests: net: " Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 21:47   ` Matthieu Baerts
  2022-01-18 11:29 ` [PATCH 09/10] selftests: vm: " Muhammad Usama Anjum
  2022-01-18 11:29 ` [PATCH 10/10] selftests: vm: remove dependecy from internal kernel macros Muhammad Usama Anjum
  9 siblings, 1 reply; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Out of tree build of this test fails if relative path of the output
directory is specified. Remove the un-needed include paths and use
KHDR_INCLUDES to correctly reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/net/mptcp/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
index 0356c4501c99..fed6866d3b73 100644
--- a/tools/testing/selftests/net/mptcp/Makefile
+++ b/tools/testing/selftests/net/mptcp/Makefile
@@ -1,9 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
-top_srcdir = ../../../../..
 KSFT_KHDR_INSTALL := 1
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g  -I$(top_srcdir)/usr/include
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
 
 TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
 	      simult_flows.sh mptcp_sockopt.sh
-- 
2.30.2


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

* [PATCH 09/10] selftests: vm: Add the uapi headers include variable
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (7 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 08/10] selftests: mptcp: " Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  2022-01-18 11:32   ` Paolo Bonzini
  2022-01-18 11:29 ` [PATCH 10/10] selftests: vm: remove dependecy from internal kernel macros Muhammad Usama Anjum
  9 siblings, 1 reply; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

Out of tree build of this test fails if relative path of the output
directory is specified. Remove the un-needed include paths and use
KHDR_INCLUDES to correctly reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/vm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 7d100a7dc462..8dc428c8a3b0 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -23,7 +23,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
 # LDLIBS.
 MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
+CFLAGS = -Wall $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
 LDLIBS = -lrt -lpthread
 TEST_GEN_FILES = compaction_test
 TEST_GEN_FILES += gup_test
-- 
2.30.2


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

* [PATCH 10/10] selftests: vm: remove dependecy from internal kernel macros
  2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
                   ` (8 preceding siblings ...)
  2022-01-18 11:29 ` [PATCH 09/10] selftests: vm: " Muhammad Usama Anjum
@ 2022-01-18 11:29 ` Muhammad Usama Anjum
  9 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 11:29 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, André Almeida, Paolo Bonzini,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: Muhammad Usama Anjum, kernel

The defination of swap() is used from kernel's internal header when this
test is built in source tree. The build fails when this test is built
out of source tree as defination of swap() isn't found. Selftests
shouldn't depend on kernel's internal header files. They can only depend
on uapi header files. Add the defination of swap() to fix the build
error:

	gcc -Wall  -I/linux_mainline2/build/usr/include -no-pie    userfaultfd.c -lrt -lpthread -o /linux_mainline2/build/kselftest/vm/userfaultfd
	userfaultfd.c: In function ‘userfaultfd_stress’:
	userfaultfd.c:1530:3: warning: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Wimplicit-function-declaration]
	 1530 |   swap(area_src, area_dst);
	      |   ^~~~
	      |   swab
	/usr/bin/ld: /tmp/cclUUH7V.o: in function `userfaultfd_stress':
	userfaultfd.c:(.text+0x4d64): undefined reference to `swap'
	/usr/bin/ld: userfaultfd.c:(.text+0x4d82): undefined reference to `swap'
	collect2: error: ld returned 1 exit status

Fixes: 2c769ed7137a ("tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/vm/userfaultfd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index d3fd24f9fae8..d2480ab93037 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -119,6 +119,9 @@ struct uffd_stats {
 				 ~(unsigned long)(sizeof(unsigned long long) \
 						  -  1)))
 
+#define swap(a, b) \
+	do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+
 const char *examples =
     "# Run anonymous memory test on 100MiB region with 99999 bounces:\n"
     "./userfaultfd anon 100 99999\n\n"
-- 
2.30.2


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

* Re: [PATCH 09/10] selftests: vm: Add the uapi headers include variable
  2022-01-18 11:29 ` [PATCH 09/10] selftests: vm: " Muhammad Usama Anjum
@ 2022-01-18 11:32   ` Paolo Bonzini
  0 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2022-01-18 11:32 UTC (permalink / raw)
  To: Muhammad Usama Anjum, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Peter Zijlstra, Darren Hart, Davidlohr Bueso, André Almeida,
	Mickaël Salaün, David S. Miller, Jakub Kicinski,
	Mat Martineau, Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: kernel

On 1/18/22 12:29, Muhammad Usama Anjum wrote:
> Out of tree build of this test fails if relative path of the output
> directory is specified. Remove the un-needed include paths and use
> KHDR_INCLUDES to correctly reach the headers.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>   tools/testing/selftests/vm/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index 7d100a7dc462..8dc428c8a3b0 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -23,7 +23,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
>   # LDLIBS.
>   MAKEFLAGS += --no-builtin-rules
>   
> -CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
> +CFLAGS = -Wall $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
>   LDLIBS = -lrt -lpthread
>   TEST_GEN_FILES = compaction_test
>   TEST_GEN_FILES += gup_test

Acked-by: Paolo Bonzini <pbonzini@redhat.com>


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

* Re: [PATCH 06/10] selftests: landlock: Add the uapi headers include variable
  2022-01-18 11:29 ` [PATCH 06/10] selftests: landlock: " Muhammad Usama Anjum
@ 2022-01-18 12:35   ` Mickaël Salaün
  2022-01-18 13:18     ` Muhammad Usama Anjum
  0 siblings, 1 reply; 16+ messages in thread
From: Mickaël Salaün @ 2022-01-18 12:35 UTC (permalink / raw)
  To: Muhammad Usama Anjum, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Peter Zijlstra, Darren Hart, Davidlohr Bueso, André Almeida,
	Paolo Bonzini, David S. Miller, Jakub Kicinski, Mat Martineau,
	Matthieu Baerts, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: kernel


On 18/01/2022 12:29, Muhammad Usama Anjum wrote:
> Out of tree build of this test fails if relative path of the output
> directory is specified. Remove the un-needed include paths and use
> KHDR_INCLUDES to correctly reach the headers.
> 
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>   tools/testing/selftests/landlock/Makefile | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/landlock/Makefile b/tools/testing/selftests/landlock/Makefile
> index a99596ca9882..44c724b38a37 100644
> --- a/tools/testing/selftests/landlock/Makefile
> +++ b/tools/testing/selftests/landlock/Makefile
> @@ -1,6 +1,6 @@
>   # SPDX-License-Identifier: GPL-2.0
>   
> -CFLAGS += -Wall -O2
> +CFLAGS += -Wall -O2 $(KHDR_INCLUDES)
>   
>   src_test := $(wildcard *_test.c)
>   
> @@ -12,13 +12,8 @@ KSFT_KHDR_INSTALL := 1
>   OVERRIDE_TARGETS := 1
>   include ../lib.mk
>   
> -khdr_dir = $(top_srcdir)/usr/include

This should be updated to:
khdr_dir = ${abs_srctree}/usr/include

Using a global KHDR_DIR instead of khdr_dir could be useful for others too.

> -
> -$(khdr_dir)/linux/landlock.h: khdr
> -	@:

This should be kept as is, otherwise we loose this check to rebuild the 
headers if linux/landlock.h is updated, which is handy for development.
KVM lost a similar behavior with this patch series.

> -
>   $(OUTPUT)/true: true.c
>   	$(LINK.c) $< $(LDLIBS) -o $@ -static
>   
> -$(OUTPUT)/%_test: %_test.c $(khdr_dir)/linux/landlock.h ../kselftest_harness.h common.h

This should not be changed.

> -	$(LINK.c) $< $(LDLIBS) -o $@ -lcap -I$(khdr_dir)
> +$(OUTPUT)/%_test: %_test.c ../kselftest_harness.h common.h
> +	$(LINK.c) $< $(LDLIBS) -o $@ -lcap

This doesn't work when building in the local directory because 
$abs_srctree and $KHDR_INCLUDES are empty:
cd tools/testing/selftests/landlock && make

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

* Re: [PATCH 06/10] selftests: landlock: Add the uapi headers include variable
  2022-01-18 12:35   ` Mickaël Salaün
@ 2022-01-18 13:18     ` Muhammad Usama Anjum
  0 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-18 13:18 UTC (permalink / raw)
  To: Mickaël Salaün, Shuah Khan, Thomas Gleixner,
	Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	André Almeida, Paolo Bonzini, David S. Miller,
	Jakub Kicinski, Mat Martineau, Matthieu Baerts, Andrew Morton,
	chiminghao, open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: usama.anjum, kernel



On 1/18/22 5:35 PM, Mickaël Salaün wrote:
> 
> On 18/01/2022 12:29, Muhammad Usama Anjum wrote:
>> Out of tree build of this test fails if relative path of the output
>> directory is specified. Remove the un-needed include paths and use
>> KHDR_INCLUDES to correctly reach the headers.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>> ---
>>   tools/testing/selftests/landlock/Makefile | 11 +++--------
>>   1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/tools/testing/selftests/landlock/Makefile
>> b/tools/testing/selftests/landlock/Makefile
>> index a99596ca9882..44c724b38a37 100644
>> --- a/tools/testing/selftests/landlock/Makefile
>> +++ b/tools/testing/selftests/landlock/Makefile
>> @@ -1,6 +1,6 @@
>>   # SPDX-License-Identifier: GPL-2.0
>>   -CFLAGS += -Wall -O2
>> +CFLAGS += -Wall -O2 $(KHDR_INCLUDES)
>>     src_test := $(wildcard *_test.c)
>>   @@ -12,13 +12,8 @@ KSFT_KHDR_INSTALL := 1
>>   OVERRIDE_TARGETS := 1
>>   include ../lib.mk
>>   -khdr_dir = $(top_srcdir)/usr/include
> 
> This should be updated to:
> khdr_dir = ${abs_srctree}/usr/include
> 
> Using a global KHDR_DIR instead of khdr_dir could be useful for others too.
> 
>> -
>> -$(khdr_dir)/linux/landlock.h: khdr
>> -    @:
> 
> This should be kept as is, otherwise we loose this check to rebuild the
> headers if linux/landlock.h is updated, which is handy for development.
> KVM lost a similar behavior with this patch series.
> 
>> -
>>   $(OUTPUT)/true: true.c
>>       $(LINK.c) $< $(LDLIBS) -o $@ -static
>>   -$(OUTPUT)/%_test: %_test.c $(khdr_dir)/linux/landlock.h
>> ../kselftest_harness.h common.h
> 
> This should not be changed.
> 
>> -    $(LINK.c) $< $(LDLIBS) -o $@ -lcap -I$(khdr_dir)
>> +$(OUTPUT)/%_test: %_test.c ../kselftest_harness.h common.h
>> +    $(LINK.c) $< $(LDLIBS) -o $@ -lcap
> 
> This doesn't work when building in the local directory because
> $abs_srctree and $KHDR_INCLUDES are empty:
> cd tools/testing/selftests/landlock && make
Hi,

Thank you. I'll update this path and the kvm one. I'll send a V2.

Thanks,
Usama

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

* Re: [PATCH 08/10] selftests: mptcp: Add the uapi headers include variable
  2022-01-18 11:29 ` [PATCH 08/10] selftests: mptcp: " Muhammad Usama Anjum
@ 2022-01-18 21:47   ` Matthieu Baerts
  2022-01-19  8:22     ` Muhammad Usama Anjum
  0 siblings, 1 reply; 16+ messages in thread
From: Matthieu Baerts @ 2022-01-18 21:47 UTC (permalink / raw)
  To: Muhammad Usama Anjum, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Peter Zijlstra, Darren Hart, Davidlohr Bueso, André Almeida,
	Paolo Bonzini, Mickaël Salaün, David S. Miller,
	Jakub Kicinski, Mat Martineau, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: kernel

Hi Muhammad,

On 18/01/2022 12:29, Muhammad Usama Anjum wrote:
> Out of tree build of this test fails if relative path of the output
> directory is specified. Remove the un-needed include paths and use
> KHDR_INCLUDES to correctly reach the headers.

Thank you for looking at that!

> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  tools/testing/selftests/net/mptcp/Makefile | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
> index 0356c4501c99..fed6866d3b73 100644
> --- a/tools/testing/selftests/net/mptcp/Makefile
> +++ b/tools/testing/selftests/net/mptcp/Makefile
> @@ -1,9 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> -top_srcdir = ../../../../..

Removing this line breaks our CI validating MPTCP selftests. That's
because this "top_srcdir" variable is needed in the "lib.mk" file which
is included at the end of this Makefile.

But that's maybe a misuse from our side. Indeed to avoid compiling
binaries and more from the VM, our CI does that as a preparation job
before starting the VM and run MPTCP selftests:

  $ make O=(...) INSTALL_HDR_PATH=(...)/kselftest/usr headers_install
  $ make O=(...) -C tools/testing/selftests/net/mptcp

From the VM, we re-use the same source directory and we can start
individual tests without having to compile anything else:

  $ cd tools/testing/selftests/net/mptcp
  $ ./mptcp_connect.sh

We want to do that because some scripts are launched multiple times with
different parameters.

With your modifications, we can drop the headers_install instruction but
we need to pass new parameters to the last 'make' command:

  $ make O=(...) top_srcdir=../../../../.. \
                 KHDR_INCLUDES=-I(...)/usr/include \
         -C tools/testing/selftests/net/mptcp

Or is there a better way to do that?
Can we leave the definition of "top_srcdir" like it was or did we miss
something else?

>  KSFT_KHDR_INSTALL := 1
>  
> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g  -I$(top_srcdir)/usr/include
> +CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
>  
>  TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
>  	      simult_flows.sh mptcp_sockopt.sh

Note: I see there is a very long recipients list. If my issue is not
directly due to your modifications, we can probably continue the
discussion with a restricted audience.

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

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

* Re: [PATCH 08/10] selftests: mptcp: Add the uapi headers include variable
  2022-01-18 21:47   ` Matthieu Baerts
@ 2022-01-19  8:22     ` Muhammad Usama Anjum
  0 siblings, 0 replies; 16+ messages in thread
From: Muhammad Usama Anjum @ 2022-01-19  8:22 UTC (permalink / raw)
  To: Matthieu Baerts, Shuah Khan, Thomas Gleixner, Ingo Molnar,
	Peter Zijlstra, Darren Hart, Davidlohr Bueso, André Almeida,
	Paolo Bonzini, Mickaël Salaün, David S. Miller,
	Jakub Kicinski, Mat Martineau, Andrew Morton, chiminghao,
	open list:KERNEL SELFTEST FRAMEWORK, open list,
	open list:KERNEL VIRTUAL MACHINE (KVM),
	open list:LANDLOCK SECURITY MODULE,
	open list:NETWORKING [GENERAL], open list:NETWORKING [MPTCP],
	open list:MEMORY MANAGEMENT
  Cc: usama.anjum, kernel

Hi Matthieu,

Thank you for putting details below.

On 1/19/22 2:47 AM, Matthieu Baerts wrote:
> Hi Muhammad,
> 
> On 18/01/2022 12:29, Muhammad Usama Anjum wrote:
>> Out of tree build of this test fails if relative path of the output
>> directory is specified. Remove the un-needed include paths and use
>> KHDR_INCLUDES to correctly reach the headers.
> 
> Thank you for looking at that!
> 
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>> ---
>>  tools/testing/selftests/net/mptcp/Makefile | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
>> index 0356c4501c99..fed6866d3b73 100644
>> --- a/tools/testing/selftests/net/mptcp/Makefile
>> +++ b/tools/testing/selftests/net/mptcp/Makefile
>> @@ -1,9 +1,8 @@
>>  # SPDX-License-Identifier: GPL-2.0
>>  
>> -top_srcdir = ../../../../..
> 
> Removing this line breaks our CI validating MPTCP selftests. That's
> because this "top_srcdir" variable is needed in the "lib.mk" file which
> is included at the end of this Makefile.
> 
> But that's maybe a misuse from our side. Indeed to avoid compiling
> binaries and more from the VM, our CI does that as a preparation job
> before starting the VM and run MPTCP selftests:
> 
>   $ make O=(...) INSTALL_HDR_PATH=(...)/kselftest/usr headers_install
>   $ make O=(...) -C tools/testing/selftests/net/mptcp
> 
> From the VM, we re-use the same source directory and we can start
> individual tests without having to compile anything else:
> 
>   $ cd tools/testing/selftests/net/mptcp
>   $ ./mptcp_connect.sh
> 
> We want to do that because some scripts are launched multiple times with
> different parameters.
> 
> With your modifications, we can drop the headers_install instruction but
> we need to pass new parameters to the last 'make' command:
> 
>   $ make O=(...) top_srcdir=../../../../.. \
>                  KHDR_INCLUDES=-I(...)/usr/include \
>          -C tools/testing/selftests/net/mptcp
> 
> Or is there a better way to do that?
> Can we leave the definition of "top_srcdir" like it was or did we miss
> something else?
> 
It seems like I've missed this use cases where people can build only one
individual test. It is not my intention to break individual test builds.
I shouldn't be fixing one thing while breaking something else. I'll
update these patches such that individual tests are also build-able. For
this to happen, I'll just add $(KHDR_INCLUDES) to the build flags while
leaving everything else intact. I'll send a V2.

>>  KSFT_KHDR_INSTALL := 1
>>  
>> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g  -I$(top_srcdir)/usr/include
>> +CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
>>  
>>  TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
>>  	      simult_flows.sh mptcp_sockopt.sh
> 
> Note: I see there is a very long recipients list. If my issue is not
> directly due to your modifications, we can probably continue the
> discussion with a restricted audience.
> 
> Cheers,
> Matt

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

end of thread, other threads:[~2022-01-19  8:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 11:28 [PATCH 00/10] selftests: Fix separate output directory builds Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 01/10] selftests: set the BUILD variable to absolute path Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 02/10] selftests: Add and export a kernel uapi headers path Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 03/10] selftests: Correct the headers install path Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 04/10] selftests: futex: Add the uapi headers include variable Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 05/10] selftests: kvm: " Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 06/10] selftests: landlock: " Muhammad Usama Anjum
2022-01-18 12:35   ` Mickaël Salaün
2022-01-18 13:18     ` Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 07/10] selftests: net: " Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 08/10] selftests: mptcp: " Muhammad Usama Anjum
2022-01-18 21:47   ` Matthieu Baerts
2022-01-19  8:22     ` Muhammad Usama Anjum
2022-01-18 11:29 ` [PATCH 09/10] selftests: vm: " Muhammad Usama Anjum
2022-01-18 11:32   ` Paolo Bonzini
2022-01-18 11:29 ` [PATCH 10/10] selftests: vm: remove dependecy from internal kernel macros Muhammad Usama Anjum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).