Subject: Re: [PATCH bpf 2/4] selftests/bpf: Consolidate kernel modules into common directory

From: Jiri Olsa <[email-masked]>
Date: Tue, 8 Oct 2024 19:46:37 +0200

On Tue, Oct 08, 2024 at 12:35:17PM +0200, Toke Høiland-Jørgensen wrote:

SNIP

> diff --git a/tools/testing/selftests/bpf/bpf_testmod/.gitignore b/tools/testing/selftests/bpf/test_kmods/.gitignore
> similarity index 100%
> rename from tools/testing/selftests/bpf/bpf_testmod/.gitignore
> rename to tools/testing/selftests/bpf/test_kmods/.gitignore
> diff --git a/tools/testing/selftests/bpf/test_kmods/Makefile b/tools/testing/selftests/bpf/test_kmods/Makefile
> new file mode 100644
> index 0000000000000000000000000000000000000000..393f407f35baf7e2b657b5d7910a6ffdecb35910
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/test_kmods/Makefile
> @@ -0,0 +1,25 @@
> +TEST_KMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
> +KDIR ?= $(abspath $(TEST_KMOD_DIR)/../../../../..)
> +
> +ifeq ($(V),1)
> +Q =
> +else
> +Q = @
> +endif
> +
> +MODULES = bpf_testmod.ko bpf_test_no_cfi.ko
> +
> +$(foreach m,$(MODULES),$(eval obj-m += $(m:.ko=.o)))
> +
> +CFLAGS_bpf_testmod.o = -I$(src)
> +
> +all: modules.built
> +
> +modules.built: *.[ch]

curious, the top Makefile already checks for test_kmods/*.[ch], do we need *.[ch] ?

jirka

> +	+$(Q)make -C $(KDIR) M=$(TEST_KMOD_DIR) modules
> +	touch modules.built
> +
> +clean:
> +	+$(Q)make -C $(KDIR) M=$(TEST_KMOD_DIR) clean
> +	rm -f modules.built
> +
> diff --git a/tools/testing/selftests/bpf/bpf_test_no_cfi/bpf_test_no_cfi.c b/tools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c
> similarity index 100%
> rename from tools/testing/selftests/bpf/bpf_test_no_cfi/bpf_test_no_cfi.c
> rename to tools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
> similarity index 100%
> rename from tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> rename to tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> similarity index 100%
> rename from tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> rename to tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.h
> similarity index 100%
> rename from tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.h
> rename to tools/testing/selftests/bpf/test_kmods/bpf_testmod.h
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
> similarity index 100%
> rename from tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h
> rename to tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
> 
> -- 
> 2.47.0
>