[PATCH v1 06/22] selftests/nolibc: allow customize extra kernel config options

From: Zhangjin Wu
Date: Sun Jun 25 2023 - 12:21:52 EST


The default DEFCONFIG_<ARCH> may not really work for all architectures,
tuning it with the 'menuconfig' target is good for development stage,
but not enough for the default compile.

Since both of the 'defconfig' and 'tinyconfig' targets may not meet our
requirement, just like the 'CONFIG_INITRAMFS_SOURCE' we added, some
architectures may require to add extra configs, this adds a new
'extconfig' target to unify such requirement.

It allows to customize extra config options by architecture and then
trigger 'allnoconfig' to let them take effect and with missing configs
as disabled.

The old common 'CONFIG_INITRAMFS_SOURCE' setting from the 'kernel'
target is moved to this target too.

It is safe enough to share this 'extconfig' between 'defconfig' and
'tinyconfig', because 'extconfig' is often a subset of 'defconfig' or an
additions of 'defconfig' and 'tinyconfig'.

Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
tools/testing/selftests/nolibc/Makefile | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 5caf3e7023d7..0b810681547b 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -48,6 +48,15 @@ DEFCONFIG_s390 = defconfig
DEFCONFIG_loongarch = defconfig
DEFCONFIG = $(DEFCONFIG_$(ARCH))

+# extra kernel configs shared among architectures
+EXTCONFIG_COMMON = --set-str CONFIG_INITRAMFS_SOURCE $(CURDIR)/initramfs
+
+# extra kernel configs by architecture
+EXTCONFIG_ARCH = $(EXTCONFIG_$(ARCH))
+
+# extra kernel configs, include common + architecture specific
+EXTCONFIG = $(EXTCONFIG_ARCH) $(EXTCONFIG_COMMON)
+
# optional tests to run (default = all)
TEST =

@@ -183,8 +192,12 @@ tinyconfig:
menuconfig:
$(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) menuconfig

-kernel: initramfs
- $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs
+extconfig:
+ $(Q)$(srctree)/scripts/config --file $(srctree)/.config $(EXTCONFIG)
+ $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) KCONFIG_ALLCONFIG=$(srctree)/.config allnoconfig
+
+kernel: initramfs extconfig
+ $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME)

# run the tests after building the kernel
run: kernel
--
2.25.1