Re: [PATCH v3] selftests: Fix seccomp to support relocatable build (O=objdir)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 23, 2020 at 02:18:29PM -0600, Shuah Khan wrote:
> The following two changes work. You both have better make foo than
> I do. Can you see any issues with this proposal? I can send patch
> to do this, so we can do a larger test.
> 
> --------------------------------------------------------------
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 3ed0134a764d..54caa9a4ec8a 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -137,7 +137,7 @@ endif
>  # Selftest makefiles can override those targets by setting
>  # OVERRIDE_TARGETS = 1.
>  ifeq ($(OVERRIDE_TARGETS),)
> -$(OUTPUT)/%:%.c
> +$(OUTPUT)/%:%.c ../kselftest_harness.h ../kselftest.h
>         $(LINK.c) $^ $(LDLIBS) -o $@

I don't think this will work because some tests are in subdirectories.
The Makefile needs to know what the top-level directory of the selftest
tree is (which I think is $(selfdir) ?) I think this might be more
complete:

$(OUTPUT)/%: %.c $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
	$(LINK.c) $^ $(LDLIBS) -o $@

> diff --git a/tools/testing/selftests/seccomp/Makefile
> b/tools/testing/selftests/seccomp/Makefile
> index a0388fd2c3f2..0ebfe8b0e147 100644
> --- a/tools/testing/selftests/seccomp/Makefile
> +++ b/tools/testing/selftests/seccomp/Makefile
> @@ -2,14 +2,5 @@
>  CFLAGS += -Wl,-no-as-needed -Wall
>  LDFLAGS += -lpthread
> 
> -.PHONY: all clean
> -
> +TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark
>  include ../lib.mk
> -
> -# OUTPUT set by lib.mk
> -TEST_GEN_PROGS := $(OUTPUT)/seccomp_bpf $(OUTPUT)/seccomp_benchmark
> -
> -$(TEST_GEN_PROGS): ../kselftest_harness.h
> -
> -all: $(TEST_GEN_PROGS)
> -

This part looks right. :)

-- 
Kees Cook



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux