From: Jo Zzsi Date: Sun, 1 Sep 2024 14:51:24 +0000 (-0400) Subject: test(BASIC): allow to run the test with various fstypes X-Git-Tag: 104~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80d232472244b22cb51960063bf8d5ef07a5fb71;p=thirdparty%2Fdracut-ng.git test(BASIC): allow to run the test with various fstypes Tested with the following fstypes: - ext2 - ext3 - ext4 - btrfs - jfs --- diff --git a/test/TEST-01-BASIC/create-root.sh b/test/TEST-01-BASIC/create-root.sh index 0fe0f67d3..c94e08eb9 100755 --- a/test/TEST-01-BASIC/create-root.sh +++ b/test/TEST-01-BASIC/create-root.sh @@ -12,9 +12,12 @@ udevadm settle set -ex -mkfs.ext4 -q -L ' rdinit=/bin/sh' /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root +# populate TEST_FSTYPE +. /env + +eval "mkfs.${TEST_FSTYPE} -q -L ' rdinit=/bin/sh' /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root" mkdir -p /root -mount -t ext4 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /root +mount -t "${TEST_FSTYPE}" /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /root cp -a -t /root /source/* mkdir -p /root/run umount /root diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index eba50f0a2..fe2593613 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -1,6 +1,6 @@ #!/bin/bash # shellcheck disable=SC2034 -TEST_DESCRIPTION="root filesystem on a ext4 filesystem" +TEST_DESCRIPTION="root filesystem on ${TEST_FSTYPE} filesystem" # Uncomment this to debug failures # DEBUGFAIL="rd.shell rd.break" @@ -27,12 +27,16 @@ test_setup() { -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 mkdir -p "$TESTDIR"/overlay/source && mv "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* + # pass enviroment variables to make the root filesystem + echo "TEST_FSTYPE=${TEST_FSTYPE}" > "$TESTDIR"/overlay/env + # second, install the files needed to make the root filesystem # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ -m "test-makeroot" \ + -I "mkfs.${TEST_FSTYPE}" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay @@ -40,12 +44,12 @@ test_setup() { declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 - qemu_add_drive disk_index disk_args "$TESTDIR"/root.img root 80 + qemu_add_drive disk_index disk_args "$TESTDIR"/root.img root 160 # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ + -append "root=/dev/dracut/root rw rootfstype=${TEST_FSTYPE} quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img diff --git a/test/test-functions b/test/test-functions index 8aac2ec72..b4bbd6c15 100644 --- a/test/test-functions +++ b/test/test-functions @@ -14,6 +14,8 @@ KVERSION=${KVERSION-$(uname -r)} [ -z "$USE_NETWORK" ] && USE_NETWORK="network" +[ -z "$TEST_FSTYPE" ] && TEST_FSTYPE="ext4" + if [[ -z $basedir ]]; then basedir="$(realpath ../..)"; fi DRACUT=${DRACUT-${basedir}/dracut.sh}