Skip to content

Commit

Permalink
test(BASIC): add support for zfs TEST_FSTYPE
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jozzsi authored and LaszloGombos committed Nov 5, 2024
1 parent 9f8c48b commit f1bbca9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 23 additions & 3 deletions test/TEST-10-BASIC/create-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 13 additions & 2 deletions test/TEST-10-BASIC/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
}

Expand Down

0 comments on commit f1bbca9

Please sign in to comment.