]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: define test expectation in test.sh
authorBenjamin Drung <benjamin.drung@canonical.com>
Sun, 1 Feb 2026 22:52:28 +0000 (23:52 +0100)
committerLaszlo <laszlo.gombos@gmail.com>
Mon, 2 Feb 2026 02:14:24 +0000 (21:14 -0500)
Test 21 defines the test expectation in `assertion.sh` based on the boot
parameters. Every time a new kind of subtest is added in `test.sh` the
expectation in `assertion.sh` needs to be changed accordingly.

To avoid touching two places, define the test expectation in the kernel
boot parameter `test.expect` and let `assertion.sh` operate on that.

test/TEST-21-OVERLAYFS/assertion.sh
test/TEST-21-OVERLAYFS/test.sh

index 08085e3e286ddda5108e756f719be5e5a68ff8a7..a74f6e4fc78d50d37d9d21b63f75d5408cf5c134 100755 (executable)
@@ -10,20 +10,13 @@ if ! echo > /test-overlay-write; then
     echo "overlay is not writable" >> /run/failed
 fi
 
-if grep -qE 'rd\.overlay=(LABEL|UUID|PARTUUID|PARTLABEL|/dev/)' /proc/cmdline; then
-    if grep -q "rd.overlay=LABEL=NONEXISTENT" /proc/cmdline; then
-        if grep -q "/run/overlayfs-backing" /proc/mounts; then
-            echo "non-existent device should have fallen back to tmpfs but backing is mounted" >> /run/failed
-        fi
-    else
-        if ! grep -q "/run/overlayfs-backing" /proc/mounts; then
-            echo "persistent overlay device not mounted at /run/overlayfs-backing" >> /run/failed
-        fi
+if grep -q 'test.expect=device' /proc/cmdline; then
+    if ! grep -q "/run/overlayfs-backing" /proc/mounts; then
+        echo "persistent overlay device not mounted at /run/overlayfs-backing" >> /run/failed
     fi
 else
-    # tmpfs mode - verify persistent backing is NOT mounted
     if grep -q "/run/overlayfs-backing" /proc/mounts; then
-        echo "tmpfs mode but persistent backing is mounted at /run/overlayfs-backing" >> /run/failed
+        echo "persistent overlay device is mounted at /run/overlayfs-backing" >> /run/failed
     fi
 fi
 
index e96bc2c0c46868b604a7df2f26bc5a1c66c0af51..13c5bfabefbe3447f465e9f75d97800c4e6190c2 100755 (executable)
@@ -27,12 +27,12 @@ test_run() {
     local overlay_uuid
     overlay_uuid=$(blkid -s UUID -o value "$TESTDIR"/overlay.img)
 
-    client_run "tmpfs overlay" "rd.overlayfs=1"
-    client_run "persistent device overlay (LABEL)" "rd.overlay=LABEL=OVERLAY"
-    client_run "persistent device overlay (UUID)" "rd.overlay=UUID=$overlay_uuid"
+    client_run "tmpfs overlay" "rd.overlayfs=1 test.expect=tmpfs"
+    client_run "persistent device overlay (LABEL)" "rd.overlay=LABEL=OVERLAY test.expect=device"
+    client_run "persistent device overlay (UUID)" "rd.overlay=UUID=$overlay_uuid test.expect=device"
     client_run "persistent device overlay (device path)" \
-        "rd.overlay=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_overlay"
-    client_run "fallback to tmpfs (non-existent LABEL)" "rd.overlay=LABEL=NONEXISTENT"
+        "rd.overlay=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_overlay test.expect=device"
+    client_run "fallback to tmpfs (non-existent LABEL)" "rd.overlay=LABEL=NONEXISTENT test.expect=tmpfs"
 }
 
 test_setup() {