]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: move more code out from tests into common test functions
authorJo Zzsi <jozzsicsataban@gmail.com>
Sat, 14 Sep 2024 14:51:42 +0000 (10:51 -0400)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Thu, 19 Sep 2024 18:46:14 +0000 (14:46 -0400)
test/TEST-18-UEFI/test.sh
test/run-qemu
test/test-functions

index ff383c178190e92f19e07c7328e8c3b0570763c4..5261f923b82f0c03a733bb38b28491d9655448af 100755 (executable)
@@ -3,44 +3,10 @@
 # shellcheck disable=SC2034
 TEST_DESCRIPTION="UEFI boot"
 
-ovmf_code() {
-    for path in \
-        "/usr/share/OVMF/OVMF_CODE.fd" \
-        "/usr/share/OVMF/OVMF_CODE_4M.fd" \
-        "/usr/share/edk2/x64/OVMF_CODE.fd" \
-        "/usr/share/edk2-ovmf/OVMF_CODE.fd" \
-        "/usr/share/qemu/ovmf-x86_64-4m.bin"; do
-        [[ -s $path ]] && echo -n "$path" && return
-    done
-}
-
 test_check() {
     [[ -n "$(ovmf_code)" ]]
 }
 
-VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
-if ! [ -f "$VMLINUZ" ]; then
-    VMLINUZ="/lib/modules/${KVERSION}/vmlinux"
-fi
-
-if ! [ -f "$VMLINUZ" ]; then
-    [[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id
-
-    if [[ $MACHINE_ID ]] && { [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]; }; then
-        VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
-    elif [ -f "/boot/vmlinuz-${KVERSION}" ]; then
-        VMLINUZ="/boot/vmlinuz-${KVERSION}"
-    elif [ -f "/boot/vmlinux-${KVERSION}" ]; then
-        VMLINUZ="/boot/vmlinux-${KVERSION}"
-    elif [ -f "/boot/kernel-${KVERSION}" ]; then
-        VMLINUZ="/boot/kernel-${KVERSION}"
-    else
-        echo "Could not find a Linux kernel version $KVERSION to test with!" >&2
-        echo "Please install linux." >&2
-        exit 1
-    fi
-fi
-
 test_run() {
     declare -a disk_args=()
     declare -i disk_index=1
index fbf8b590dfec3e6fcc1f6007899adb8f6aaf4631..471415772c31d36268001e2b79f4ccfbe9568a8d 100755 (executable)
@@ -47,31 +47,6 @@ if [[ $ARCH != "s390x" ]]; then
     ARGS+=(-device i6300esb)
 fi
 
-KVERSION=${KVERSION-$(uname -r)}
-
-VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
-if ! [ -f "$VMLINUZ" ]; then
-    VMLINUZ="/lib/modules/${KVERSION}/vmlinux"
-fi
-
-if ! [ -f "$VMLINUZ" ]; then
-    [[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id
-
-    if [[ $MACHINE_ID ]] && { [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]; }; then
-        VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
-    elif [ -f "/boot/vmlinuz-${KVERSION}" ]; then
-        VMLINUZ="/boot/vmlinuz-${KVERSION}"
-    elif [ -f "/boot/vmlinux-${KVERSION}" ]; then
-        VMLINUZ="/boot/vmlinux-${KVERSION}"
-    elif [ -f "/boot/kernel-${KVERSION}" ]; then
-        VMLINUZ="/boot/kernel-${KVERSION}"
-    else
-        echo "Could not find a Linux kernel version $KVERSION to test with!" >&2
-        echo "Please install linux." >&2
-        exit 1
-    fi
-fi
-
 # only set -kernel if -initrd is specified
 if [[ $* == *-initrd* ]]; then
     ARGS+=(-kernel "$VMLINUZ")
index feddd7a193f2b8793da17e49a7a4a4d1782dccb8..b64cffaecf2570889037674062775a01d8d44c4e 100644 (file)
@@ -55,6 +55,42 @@ test_dracut() {
         "$@" || return 1
 }
 
+ovmf_code() {
+    for path in \
+        "/usr/share/OVMF/OVMF_CODE.fd" \
+        "/usr/share/OVMF/OVMF_CODE_4M.fd" \
+        "/usr/share/edk2/x64/OVMF_CODE.fd" \
+        "/usr/share/edk2-ovmf/OVMF_CODE.fd" \
+        "/usr/share/qemu/ovmf-x86_64-4m.bin"; do
+        [[ -s $path ]] && echo -n "$path" && return
+    done
+}
+
+VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
+if ! [ -f "$VMLINUZ" ]; then
+    VMLINUZ="/lib/modules/${KVERSION}/vmlinux"
+fi
+
+if ! [ -f "$VMLINUZ" ]; then
+    [[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id
+
+    if [[ $MACHINE_ID ]] && { [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]; }; then
+        VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
+    elif [ -f "/boot/vmlinuz-${KVERSION}" ]; then
+        VMLINUZ="/boot/vmlinuz-${KVERSION}"
+    elif [ -f "/boot/vmlinux-${KVERSION}" ]; then
+        VMLINUZ="/boot/vmlinux-${KVERSION}"
+    elif [ -f "/boot/kernel-${KVERSION}" ]; then
+        VMLINUZ="/boot/kernel-${KVERSION}"
+    else
+        echo "Could not find a Linux kernel version $KVERSION to test with!" >&2
+        echo "Please install linux." >&2
+        exit 1
+    fi
+fi
+
+export VMLINUZ
+
 command -v test_check &> /dev/null || test_check() {
     :
 }