[kvm-unit-tests PATCH v1 6/7] scripts: Generalize EFI check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc Orr <marcorr@xxxxxxxxxx>

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 helper function to check
whether the repo has been configured to run under EFI. The helper does
this by probing the `config.mak` file generated by `configure`.

Signed-off-by: Marc Orr <marcorr@xxxxxxxxxx>
---
 scripts/common.bash | 5 +++++
 x86/efi/run         | 1 -
 x86/run             | 6 ++++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/common.bash b/scripts/common.bash
index 7b983f7..6f45843 100644
--- a/scripts/common.bash
+++ b/scripts/common.bash
@@ -1,5 +1,10 @@
 source config.mak
 
+function running_under_efi()
+{
+	[[ ${TARGET_EFI} == "y" ]] && echo "y" || echo ""
+}
+
 function for_each_unittest()
 {
 	local unittests="$1"
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..95b56b6 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 ! [ "$(running_under_efi)" ]; then
 	command+=" -kernel"
 fi
 command="$(timeout_cmd) $command"
 
-if [ "$EFI_RUN" ]; then
+if [ "$(running_under_efi)" ]; 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
-- 
2.33.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux