]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test(DMSQUASH): fix autooverlay test checks the entire root.img
authorNadzeya Hutsko <nadzeya.hutsko@canonical.com>
Mon, 19 Jan 2026 09:57:29 +0000 (10:57 +0100)
committerBenjamin Drung <bdrung@ubuntu.com>
Mon, 19 Jan 2026 13:14:03 +0000 (14:14 +0100)
The test searched for the marker string in the entire root.img, but
the string also existed literally in test-init.sh embedded in the
first partition, causing a false positive. Fix by extracting and
searching only the second (overlay) partition.

Fixes: #2054
test/TEST-30-DMSQUASH/test.sh

index fbd2b7968a619c51df5fbe9c4b34802378001a89..1ed00956f7054bd33f3c136d606e91cbfa2ca48b 100755 (executable)
@@ -67,8 +67,13 @@ test_run() {
 
     rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]')
     [ "$rootPartitions" -eq 2 ]
-    # Verify that the string "dracut-autooverlay-success" occurs in the second partition in the image file.
-    test_marker_check dracut-autooverlay-success root.img
+    # Verify that the string "dracut-autooverlay-success" occurs in the second partition (overlay).
+    # Extract only the second partition to avoid false positives from the test script in the first partition.
+    part2_info=$(sfdisk -d "$TESTDIR"/root.img | grep 'root\.img2')
+    part2_start=$(echo "$part2_info" | sed -n 's/.*start= *\([0-9]*\).*/\1/p')
+    part2_size=$(echo "$part2_info" | sed -n 's/.*size= *\([0-9]*\).*/\1/p')
+    dd if="$TESTDIR"/root.img of="$TESTDIR"/overlay-part.img bs=512 skip="$part2_start" count="$part2_size" status=none
+    test_marker_check dracut-autooverlay-success overlay-part.img
 
     return 0
 }