On Thu, Dec 05, 2024 at 05:17:56PM +0530, Siddharth Menon wrote:

> Currently, kselftests does not have a generalised mechanism to skip 
> compilation
> and run tests when required kernel configuration flags are missing.

Should this be a build dependency or only a runtime dependency, or
should these be separate options for cases where the selftest builds a
module?  If people are building the selftests once and then using them
with a bunch of kernel builds it might be surprising if some of the
binaries vanish.

> -all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \
> +KDIR ?= /lib/modules/$(shell uname -r)/build
> +

Shouldn't we try the current kernel tree, and for runtime checks
/proc/config.gz would be good to check when it's enabled?

> +define CHECK_CONFIG_DEPS
> +    $(if $(wildcard $(KDIR)/scripts/config),
> +        $(eval MISSING_FLAGS := $(filter-out 1,$(foreach 
> cfg,$(TEST_CONFIG_DEPS),\
> +            $(shell cd $(KDIR) && scripts/config --state $(cfg) | grep -q 
> '^\(y\|m\)$$' && echo 1 || echo $(cfg))))),
> +        $(info Skipping CHECK_GEN_REQ: $(KDIR)/scripts/config not found)
> +    )
> +    $(if $(MISSING_FLAGS),$(error Missing required config flags: 
> $(MISSING_FLAGS)))
> +endef

This is going to use a separate set of config options to those listed in
the config file in the selftest directory which is perhaps a bit
surprising.  OTOH we do have a lot of the selftests directories where
not every test needs all the options so that's probably a good choice
unless we make things finer grained which might be more trouble than
it's worth.

Attachment: signature.asc
Description: PGP signature

Reply via email to