From f1bbca90697351b9a185dad1f77d0113990b6ffe Mon Sep 17 00:00:00 2001 From: Jo Zzsi Date: Mon, 4 Nov 2024 20:42:02 -0500 Subject: [PATCH] test(BASIC): add support for zfs TEST_FSTYPE Basic tests now installs the upstream version of dracut modules on top of the dracut modules that comes with the downstream distribution or other dowstream out of tree dracut modules. --- .github/workflows/integration.yml | 2 +- Makefile | 1 + test/TEST-10-BASIC/create-root.sh | 26 +++++++++++++++++++++++--- test/TEST-10-BASIC/test.sh | 15 +++++++++++++-- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index e6342dc38..3ae04e631 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -48,7 +48,7 @@ jobs: - name: "Checkout Repository" uses: actions/checkout@v4 - name: "${{ matrix.container }} TEST-${{ matrix.test }}" - run: ./test/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} + run: TARGETS='all install check' DRACUT=dracut ./test/test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }} # syncheck syncheck: diff --git a/Makefile b/Makefile index 71272687b..0bbef19e3 100644 --- a/Makefile +++ b/Makefile @@ -171,6 +171,7 @@ install: all ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions install -m 0755 dracut-logger.sh $(DESTDIR)$(pkglibdir)/dracut-logger.sh install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore + rm -rf $(DESTDIR)$(pkglibdir)/modules.d/80test* cp -arx modules.d dracut.conf.d $(DESTDIR)$(pkglibdir) ifneq ($(enable_test),no) cp -arx test $(DESTDIR)$(pkglibdir) diff --git a/test/TEST-10-BASIC/create-root.sh b/test/TEST-10-BASIC/create-root.sh index 2c583c329..43c3a974d 100755 --- a/test/TEST-10-BASIC/create-root.sh +++ b/test/TEST-10-BASIC/create-root.sh @@ -6,11 +6,31 @@ set -ex # populate TEST_FSTYPE . /env -eval "mkfs.${TEST_FSTYPE} -q -L dracut /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root" +if [ "$TEST_FSTYPE" = "zfs" ]; then + zpool create dracut /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root + zfs create dracut/root +else + eval "mkfs.${TEST_FSTYPE} -q -L dracut /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root" +fi + mkdir -p /root -mount -t "${TEST_FSTYPE}" /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /root + +if [ "$TEST_FSTYPE" = "zfs" ]; then + zfs set mountpoint=/root dracut/root + zfs get mounted dracut/root +else + mount -t "${TEST_FSTYPE}" /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /root +fi + cp -a -t /root /source/* mkdir -p /root/run -umount /root + +if [ "$TEST_FSTYPE" = "zfs" ]; then + zfs unmount /root + zfs set mountpoint=/ dracut/root +else + umount /root +fi + echo "dracut-root-block-created" | dd oflag=direct,dsync status=none of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker poweroff -f diff --git a/test/TEST-10-BASIC/test.sh b/test/TEST-10-BASIC/test.sh index 2b0e926e7..b7f210870 100755 --- a/test/TEST-10-BASIC/test.sh +++ b/test/TEST-10-BASIC/test.sh @@ -11,10 +11,16 @@ test_run() { qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker qemu_add_drive disk_index disk_args "$TESTDIR"/root.img root + if [ "$TEST_FSTYPE" = "zfs" ]; then + TEST_KERNEL_CMDLINE+=" root=ZFS=dracut/root " + else + TEST_KERNEL_CMDLINE+=" root=LABEL=dracut " + fi + test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ - -append "$TEST_KERNEL_CMDLINE root=LABEL=dracut" \ + -append "$TEST_KERNEL_CMDLINE" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 @@ -34,9 +40,12 @@ test_setup() { # 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. + + # shellcheck disable=SC2046 "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ --add-confdir test-makeroot \ - -I "mkfs.${TEST_FSTYPE}" \ + -i /bin/dd /usr/sbin/dd \ + $(if [ "$TEST_FSTYPE" = "zfs" ]; then echo "-a zfs"; else echo "-I mkfs.${TEST_FSTYPE}"; fi) \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 @@ -53,7 +62,9 @@ test_setup() { test_marker_check dracut-root-block-created || return 1 rm -- "$TESTDIR"/marker.img + # shellcheck disable=SC2046 test_dracut \ + $(if [ "$TEST_FSTYPE" = "zfs" ]; then echo "-a zfs"; fi) \ "$TESTDIR"/initramfs.testing }