diff mbox series

selftests: enforce local header dependency in lib.mk

Message ID 20200325231649.13049-1-skhan@linuxfoundation.org (mailing list archive)
State Mainlined
Commit 1056d3d2c97e47397d0037cbbdf24235ae8f88cb
Headers show
Series selftests: enforce local header dependency in lib.mk | expand

Commit Message

Shuah Khan March 25, 2020, 11:16 p.m. UTC
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.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
 tools/testing/selftests/lib.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kees Cook March 25, 2020, 11:28 p.m. UTC | #1
On Wed, Mar 25, 2020 at 05:16:49PM -0600, Shuah Khan wrote:
> 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.
> 
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

style nit below...

> ---
>  tools/testing/selftests/lib.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 3ed0134a764d..b0556c752443 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -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

>  
>  $(OUTPUT)/%.o:%.S
> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 3ed0134a764d..b0556c752443 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -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