Skip to contentSkip to conversation

selftests: Fix seccomp to support relocatable build (O=objdir)

PATCH In review Shuah Khan 2 participants 2 messages Mar 25, 2020

Subsystems (2)
lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

PATCH v4 1/1 selftests: Fix seccomp to support relocatable build (O=objdir)

Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS. Local header dependency is addressed in a change to lib.mk as a framework change that enforces the dependency without requiring changes to individual tests.

The following use-cases work with this change:

In seccomp directory:
make all and make clean

From top level from main Makefile:
make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc \
CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp

---
Changes since v3:
Simplified logic based on comments from Kees and Michael

 tools/testing/selftests/seccomp/Makefile | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
tools/testing/selftests/seccomp/Makefile +3 -14
index 1760b3e39730..0ebfe8b0e147 100644
@@ -1,17 +1,6 @@
 # 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)
-
-all: $(BINARIES)
+TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark
+include ../lib.mk
Signature · 1 line
2.20.1
Acked-by on v4 1/1
#1 lore raw
Quoted 8 lines · Shuah Khan

Fix seccomp relocatable builds. This is a simple fix to use the right lib.mk variable TEST_GEN_PROGS. Local header dependency is addressed in a change to lib.mk as a framework change that enforces the dependency without requiring changes to individual tests.

The following use-cases work with this change:

Quoted 8 lines

In seccomp directory:
make all and make clean

From top level from main Makefile:
make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc \
CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp

Thanks for getting this fixed. :)

-Kees

Quoted 35 lines

---
Changes since v3:
Simplified logic based on comments from Kees and Michael

 tools/testing/selftests/seccomp/Makefile | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
tools/testing/selftests/seccomp/Makefile +3 -14
index 1760b3e39730..0ebfe8b0e147 100644
@@ -1,17 +1,6 @@
 # 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)
-
-all: $(BINARIES)
+TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark
+include ../lib.mk
Signature · 1 line
2.20.1
Signature · 1 line
Kees Cook