]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: print error in case root partition count mismatch
authorBenjamin Drung <benjamin.drung@canonical.com>
Tue, 3 Feb 2026 12:23:30 +0000 (13:23 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 4 Feb 2026 13:07:45 +0000 (08:07 -0500)
The dmsquash test case can fail by not creating an overlay partition. In
this case the test fails with exit code 1 without printing an error.
This is hard to debug.

So print an error message in case the root partition count mismatches.

test/TEST-30-DMSQUASH/test.sh

index 02c9f0bdc8530fb56ca0f1c85dfe81b250c1c539..5da1d8238d9f79ab054f648141152dbca0f6c452 100755 (executable)
@@ -43,7 +43,10 @@ client_run() {
 check_autooverlay_marker() {
     local rootPartitions part2_info part2_start part2_size
     rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]')
-    [ "$rootPartitions" -eq 2 ]
+    if [ "$rootPartitions" -ne 2 ]; then
+        echo >&2 "E: Expected two partitions on root.img, but got $rootPartitions."
+        return 1
+    fi
     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')