All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: thomas@t-8ch.de, w@1wt.eu
Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: [PATCH v1 22/22] selftests/nolibc: detect bios existing to avoid hang
Date: Mon, 26 Jun 2023 00:45:12 +0800	[thread overview]
Message-ID: <ae3dabb001d41b3874c1a3ae9a2d76298806f167.1687706332.git.falcon@tinylab.org> (raw)
In-Reply-To: <cover.1687706332.git.falcon@tinylab.org>

Without a right -bios option, riscv32 and loongarch will hang during
boot and therefore block the whole testing, this adds necessary
detection.

Before testing, the required bios should be downloaded at first, for a
future working qemu (without a manual -bios), we can simply clear the
QEMU_BIOS_<ARCH> to stop the detection.

By default, the bios should be downloaded and put into
tools/testing/selftests/nolibc/, otherwise, users should specify the
path via QEMU_BIOS_<ARCH>.

Without this patch, it is not possible to directly run tests for all
architectures, otherwise, we should pass our own 'ARCHS' and remove the
unsupported ones explicitly, which is not convenient.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 470923dc10e1..b529bb40444a 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -110,6 +110,14 @@ QEMU_ARCH_s390       = s390x
 QEMU_ARCH_loongarch  = loongarch64
 QEMU_ARCH            = $(QEMU_ARCH_$(ARCH))
 
+# QEMU_BIOS: bios used by qemu
+# https://github.com/loongson/Firmware/raw/main/LoongArchVirtMachine/edk2-loongarch64-code.fd
+QEMU_BIOS_loongarch ?= edk2-loongarch64-code.fd
+# https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/opensbi-riscv32-generic-fw_dynamic.bin
+QEMU_BIOS_riscv32   ?= opensbi-riscv32-generic-fw_dynamic.bin
+QEMU_BIOS            = $(QEMU_BIOS_$(ARCH))
+QEMU_ARGS_BIOS       = $(if $(QEMU_BIOS),-bios $(QEMU_BIOS))
+
 # QEMU_ARGS : some arch-specific args to pass to qemu
 QEMU_ARGS_i386       = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_x86_64     = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
@@ -122,7 +130,7 @@ QEMU_ARGS_riscv64    = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_T
 QEMU_ARGS_riscv      = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_s390       = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_loongarch  = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
-QEMU_ARGS            = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA)
+QEMU_ARGS            = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)
 
 # OUTPUT is only set when run from the main makefile, otherwise
 # it defaults to this nolibc directory.
@@ -167,9 +175,15 @@ endif
 # allow run tests on all architectures: run-user-all, run-all (=run-default-all), run-tiny-all
 ARCHS   ?= $(shell sed -ne 's/^DEFCONFIG_\([^ ]*\) .*/\1/p' $(CURDIR)/Makefile)
 GOALS   ?= run-user run-tiny run-default
+export $(foreach a, $(ARCHS), QEMU_BIOS_$a)
 RUN_ALL ?= _t=$@; t=$${_t%-all}; [ "$$t" = "run" ] && t=run-default; \
 	   if echo $(GOALS) | grep -wq "$$t"; then \
-		for a in $(ARCHS); do echo "Testing $$t for $${a}:"; make $$t ARCH=$$a; cp $(CURDIR)/run.out $(CURDIR)/run-$$a.out; done; \
+		for a in $(ARCHS); do \
+			echo "Testing $$t for $${a}:"; \
+			eval bios=\$${QEMU_BIOS_$$a}; \
+			if [ -n "$${bios}" -a ! -f "$${bios}" ]; then echo "\nIgnoring $$a test, no bios: $${bios} found."; exit 0; fi; \
+			make $$t ARCH=$$a; cp $(CURDIR)/run.out $(CURDIR)/run-$$a.out; \
+		done; \
 		echo "\n\nTesting summary of $$t:\n"; \
 		for a in $(ARCHS); do echo $${a}:; echo; $(REPORT) $(CURDIR)/run-$$a.out; echo; done; \
 	   else \
-- 
2.25.1


  parent reply	other threads:[~2023-06-25 16:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25 16:10 [PATCH v1 00/22] selftests/nolibc: add minimal kernel config support Zhangjin Wu
2023-06-25 16:12 ` [PATCH v1 01/22] selftests/nolibc: add test for -include /path/to/nolibc.h Zhangjin Wu
2023-06-25 16:13 ` [PATCH v1 02/22] selftests/nolibc: print result to the screen too Zhangjin Wu
2023-06-25 16:14 ` [PATCH v1 03/22] selftests/nolibc: allow use x86_64 toolchain for i386 Zhangjin Wu
2023-06-25 16:15 ` [PATCH v1 04/22] selftests/nolibc: add menuconfig target for manual config Zhangjin Wu
2023-06-25 16:19 ` [PATCH v1 05/22] selftests/nolibc: add tinyconfig target Zhangjin Wu
2023-06-25 16:21 ` [PATCH v1 06/22] selftests/nolibc: allow customize extra kernel config options Zhangjin Wu
2023-06-25 16:22 ` [PATCH v1 07/22] selftests/nolibc: add common extra " Zhangjin Wu
2023-06-25 16:23 ` [PATCH v1 08/22] selftests/nolibc: add power reset control support Zhangjin Wu
2023-06-25 16:25 ` [PATCH v1 09/22] selftests/nolibc: add procfs, shmem and tmpfs Zhangjin Wu
2023-06-25 16:26 ` [PATCH v1 10/22] selftests/nolibc: add extra configs for i386 Zhangjin Wu
2023-06-25 16:28 ` [PATCH v1 11/22] selftests/nolibc: add extra configs for x86_64 Zhangjin Wu
2023-06-25 16:30 ` [PATCH v1 12/22] selftests/nolibc: add extra configs for arm64 Zhangjin Wu
2023-06-25 16:31 ` [PATCH v1 13/22] selftests/nolibc: add extra configs for arm Zhangjin Wu
2023-06-25 16:32 ` [PATCH v1 14/22] selftests/nolibc: add extra configs for mips Zhangjin Wu
2023-06-25 16:34 ` [PATCH v1 15/22] selftests/nolibc: add extra configs for riscv32 Zhangjin Wu
2023-06-25 16:35 ` [PATCH v1 16/22] selftests/nolibc: add extra configs for riscv64 Zhangjin Wu
2023-06-25 16:36 ` [PATCH v1 17/22] selftests/nolibc: add extra configs for s390x Zhangjin Wu
2023-06-25 16:38 ` [PATCH v1 18/22] selftests/nolibc: add extra configs for loongarch Zhangjin Wu
2023-06-25 16:39 ` [PATCH v1 19/22] selftests/nolibc: config default CROSS_COMPILE Zhangjin Wu
2023-06-25 16:41 ` [PATCH v1 20/22] selftests/nolibc: add run-tiny and run-default Zhangjin Wu
2023-06-25 16:43 ` [PATCH v1 21/22] selftests/nolibc: allow run tests on all targets Zhangjin Wu
2023-06-25 16:45 ` Zhangjin Wu [this message]
2023-07-11  3:55 ` [PATCH v1 00/22] selftests/nolibc: add minimal kernel config support Zhangjin Wu
2023-07-11  7:08   ` Willy Tarreau
2023-07-11 17:18     ` Zhangjin Wu
2023-07-11 19:36       ` Willy Tarreau
2023-07-18 13:43         ` Zhangjin Wu
2023-07-18 15:19           ` Thomas Weißschuh
2023-07-18 15:59             ` Willy Tarreau
2023-07-18 17:01             ` Zhangjin Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae3dabb001d41b3874c1a3ae9a2d76298806f167.1687706332.git.falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=thomas@t-8ch.de \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.