[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <d18c46b935f2c7d56a8857b387067cb3fec11d05.1690916314.git.falcon@tinylab.org>
Date: Wed, 2 Aug 2023 03:40:21 +0800
From: Zhangjin Wu <falcon@...ylab.org>
To: thomas@...ch.de
Cc: falcon@...ylab.org, arnd@...db.de, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, w@....eu
Subject: [PATCH v4 04/12] selftests/nolibc: add macros to reduce duplicated changes
The kernel targets share the same kernel make operations, the same
.config file, the same kernel image, add MAKE_KERNEL, KERNEL_CONFIG and
KERNEL_IMAGE for them.
Many targets use the same log file, add RUN_OUT to allow save log by
architecture, for example: 'make RUN_OUT=$PWD/run.$arch.out'.
The qemu run/rerun targets share the same qemu system run command, add
QEMU_SYSTEM_RUN for them.
Suggested-by: Willy Tarreau <w@....eu>
Link: https://lore.kernel.org/lkml/20230722122009.GE17311@1wt.eu/
Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
tools/testing/selftests/nolibc/Makefile | 35 ++++++++++++++++---------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index f0bda0d28000..fdc72ca75589 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -142,41 +142,52 @@ endif
libc-test: nolibc-test.c
$(QUIET_CC)$(CC) -o $@ $<
+# common macros for logging
+RUN_OUT = $(CURDIR)/run.out
+
# local libc-test
run-libc-test: libc-test
- $(Q)./libc-test > "$(CURDIR)/run.out" || :
- $(Q)$(REPORT) $(CURDIR)/run.out
+ $(Q)./libc-test > "$(RUN_OUT)" || :
+ $(Q)$(REPORT) "$(RUN_OUT)"
# local nolibc-test
run-nolibc-test: nolibc-test
- $(Q)./nolibc-test > "$(CURDIR)/run.out" || :
- $(Q)$(REPORT) $(CURDIR)/run.out
+ $(Q)./nolibc-test > "$(RUN_OUT)" || :
+ $(Q)$(REPORT) "$(RUN_OUT)"
# qemu user-land test
run-user: nolibc-test
- $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || :
- $(Q)$(REPORT) $(CURDIR)/run.out
+ $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(RUN_OUT)" || :
+ $(Q)$(REPORT) "$(RUN_OUT)"
initramfs: nolibc-test
$(QUIET_MKDIR)mkdir -p initramfs
$(call QUIET_INSTALL, initramfs/init)
$(Q)cp nolibc-test initramfs/init
+# common macros for kernel targets
+MAKE_KERNEL = $(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE)
+KERNEL_CONFIG = $(objtree)/.config
+KERNEL_IMAGE = $(objtree)/$(IMAGE)
+
defconfig:
- $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare
+ $(Q)$(MAKE_KERNEL) mrproper $(DEFCONFIG) prepare
kernel: initramfs
- $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs
+ $(Q)$(MAKE_KERNEL) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs
+
+# common macros for qemu run/rerun targets
+QEMU_SYSTEM_RUN = qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(KERNEL_IMAGE)" -serial stdio $(QEMU_ARGS)
# run the tests after building the kernel
run: kernel
- $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(objtree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
- $(Q)$(REPORT) $(CURDIR)/run.out
+ $(Q)$(QEMU_SYSTEM_RUN) > "$(RUN_OUT)"
+ $(Q)$(REPORT) "$(RUN_OUT)"
# re-run the tests from an existing kernel
rerun:
- $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(objtree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
- $(Q)$(REPORT) $(CURDIR)/run.out
+ $(Q)$(QEMU_SYSTEM_RUN) > "$(RUN_OUT)"
+ $(Q)$(REPORT) "$(RUN_OUT)"
clean:
$(call QUIET_CLEAN, sysroot)
--
2.25.1
Powered by blists - more mailing lists