Skip to contentSkip to conversation

selftests: enforce local header dependency in lib.mk

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

lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

PATCH 1/1 selftests: enforce local header dependency in lib.mk

Add local header dependency in lib.mk. This enforces the dependency blindly even when a test doesn't include the file, with the benefit of a simpler common logic without requiring individual tests to have special rule for it.

---
 tools/testing/selftests/lib.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/lib.mk +2 -1
index 3ed0134a764d..b0556c752443 100644
@@ -137,7 +137,8 @@ endif
 # Selftest makefiles can override those targets by setting
 # OVERRIDE_TARGETS = 1.
 ifeq ($(OVERRIDE_TARGETS),)
-$(OUTPUT)/%:%.c
+LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
+$(OUTPUT)/%:%.c $(LOCAL_HDRS)
 	$(LINK.c) $^ $(LDLIBS) -o $@
 
 $(OUTPUT)/%.o:%.S
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Shuah Khan

Add local header dependency in lib.mk. This enforces the dependency blindly even when a test doesn't include the file, with the benefit of a simpler common logic without requiring individual tests to have special rule for it.

style nit below...

Quoted 9 lines
---
 tools/testing/selftests/lib.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/lib.mk +0 -0
index 3ed0134a764d..b0556c752443 100644

tools/testing/selftests/lib.mk endif · line 142

Quoted 7 lines
tools/testing/selftests/lib.mk +2 -1
@@ -137,7 +137,8 @@ endif
 # Selftest makefiles can override those targets by setting
 # OVERRIDE_TARGETS = 1.
 ifeq ($(OVERRIDE_TARGETS),)
-$(OUTPUT)/%:%.c
+LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
+$(OUTPUT)/%:%.c $(LOCAL_HDRS)
 	$(LINK.c) $^ $(LDLIBS) -o $@

It's already in lib.mk as "target:deps" but the tradition for kernel make rules has been "target: deps". i.e.:

$(OUTPUT)/%: %.c $(LOCAL_HDRS)

But it doesn't actually matter. :)

-Kees

Quoted 5 lines
tools/testing/selftests/lib.mk +0 -0
 $(OUTPUT)/%.o:%.S
Signature · 1 line
2.20.1
Signature · 1 line
Kees Cook