diff mbox series

[kvm-unit-tests,v2,07/10] scripts: Generalize EFI check

Message ID 20211116204053.220523-8-zxwang42@gmail.com (mailing list archive)
State New, archived
Headers show
Series x86_64 UEFI set up process refactor and scripts fixes | expand

Commit Message

Zixuan Wang Nov. 16, 2021, 8:40 p.m. UTC
From: Marc Orr <marcorr@google.com>

Previously, the scripts distinguish between seabios and UEFI via a
hard-coded env var in the EFI run script, `arch/x86/efi/run`.
Furthermore, this var is passed to the x86 run script, `arch/x86/run`,
and then not available in other scripts (or to other architectures).

Replace the previous approach with a common variable TARGET_EFI to check
whether the repo has been configured to run under EFI. This variable is
extracted from the `config.mak` file generated by `configure`.

Signed-off-by: Marc Orr <marcorr@google.com>
---
 x86/efi/run | 1 -
 x86/run     | 6 ++++--
 2 files changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/x86/efi/run b/x86/efi/run
index 922b266..aacc691 100755
--- a/x86/efi/run
+++ b/x86/efi/run
@@ -52,7 +52,6 @@  popd || exit 2
 # run in UEFI, some test cases, e.g. `x86/pmu.c`, require more free memory. A
 # simple fix is to increase the QEMU default memory size to 256MiB so that
 # UEFI's largest allocatable memory region is large enough.
-EFI_RUN=y \
 "$TEST_DIR/run" \
 	-drive file="$EFI_UEFI",format=raw,if=pflash,readonly=on \
 	-drive file.dir="$EFI_TEST/$EFI_CASE/",file.driver=vvfat,file.rw=on,format=raw,if=virtio \
diff --git a/x86/run b/x86/run
index 4eba2b9..9e18464 100755
--- a/x86/run
+++ b/x86/run
@@ -1,5 +1,7 @@ 
 #!/usr/bin/env bash
 
+source scripts/common.bash
+
 if [ -z "$STANDALONE" ]; then
 	if [ ! -f config.mak ]; then
 		echo "run ./configure && make first. See ./configure -h"
@@ -39,12 +41,12 @@  fi
 
 command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev"
 command+=" -machine accel=$ACCEL"
-if ! [ "$EFI_RUN" ]; then
+if [ "${TARGET_EFI}" != "y" ]; then
 	command+=" -kernel"
 fi
 command="$(timeout_cmd) $command"
 
-if [ "$EFI_RUN" ]; then
+if [ "${TARGET_EFI}" == "y" ]; then
 	# Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see
 	# 'scripts/arch-run.bash' for more details). This is because when using
 	# UEFI, the test case binaries are passed to QEMU through the disk