]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test: improve precondition checking for test to pass
authorJo Zzsi <jozzsicsataban@gmail.com>
Thu, 7 Nov 2024 02:06:20 +0000 (21:06 -0500)
committerLaszlo <laszlo.gombos@gmail.com>
Thu, 7 Nov 2024 11:27:56 +0000 (06:27 -0500)
Tested using a minimal alpine container.

test/TEST-20-RAID/test.sh
test/TEST-21-LVM/test.sh
test/TEST-22-RAID-DEG/test.sh
test/TEST-25-LVM-THIN/test.sh
test/TEST-26-ENC-RAID-LVM/test.sh
test/TEST-30-DMSQUASH/test.sh
test/TEST-81-SKIPCPIO/test.sh

index b82cb9b950ce0d4f7730d823aef83b5d8385e906..824e742c774a94581991247b8a43b223868c54b7 100755 (executable)
@@ -2,6 +2,13 @@
 # shellcheck disable=SC2034
 TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a RAID-5"
 
+test_check() {
+    if ! type -p cryptsetup &> /dev/null; then
+        echo "Test needs cryptsetup for crypt module... Skipping"
+        return 1
+    fi
+}
+
 # Uncomment this to debug failures
 #DEBUGFAIL="rd.shell rd.udev.log-priority=debug loglevel=70 systemd.log_target=kmsg"
 #DEBUGFAIL="rd.break rd.shell rd.debug debug"
index d8b8a241ab6c840eebe1819b0314a0c94835b11c..72d9d27f75e79c3768232eb4cd33ae32ff32ffa1 100755 (executable)
@@ -6,6 +6,13 @@ TEST_DESCRIPTION="root filesystem on LVM PV"
 # Uncomment this to debug failures
 #DEBUGFAIL="rd.break rd.shell"
 
+test_check() {
+    if ! type -p lvm &> /dev/null; then
+        echo "Test needs lvm for lvm module... Skipping"
+        return 1
+    fi
+}
+
 test_run() {
     declare -a disk_args=()
     declare -i disk_index=0
index b3fd9a0765e4a487c245089371ef9fe4b7eaa4ca..56eb9e8eb67118f4e3d55fd87885ce3c5fd61a61 100755 (executable)
@@ -8,6 +8,13 @@ TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a degraded RAID-5"
 #DEBUGFAIL="rd.shell rd.udev.log-priority=debug loglevel=70 systemd.log_target=kmsg"
 #DEBUGFAIL="rd.shell loglevel=70 systemd.log_target=kmsg"
 
+test_check() {
+    if ! type -p cryptsetup &> /dev/null; then
+        echo "Test needs cryptsetup for crypt module... Skipping"
+        return 1
+    fi
+}
+
 client_run() {
     echo "CLIENT TEST START: $*"
     declare -a disk_args=()
index 74fec85cbd2c0a540c1af76899f4bb2dbdd6d3b4..76192ee014bf9f63ae767108e692c0da8a8e9851 100755 (executable)
@@ -5,6 +5,13 @@ TEST_DESCRIPTION="root filesystem on LVM PV with thin pool"
 # Uncomment this to debug failures
 #DEBUGFAIL="rd.break rd.shell"
 
+test_check() {
+    if ! type -p lvm &> /dev/null; then
+        echo "Test needs lvm for lvm module... Skipping"
+        return 1
+    fi
+}
+
 test_run() {
     declare -a disk_args=()
     declare -i disk_index=0
index 7db75db47a1c96b2105d18e751b52ec48e72c0e8..002ab2970ebcd42838c29ecda545a1cb8612b9db 100755 (executable)
@@ -7,6 +7,13 @@ TEST_DESCRIPTION="root filesystem on LVM on encrypted partitions of a RAID-5"
 #DEBUGFAIL="rd.shell rd.udev.log-priority=debug loglevel=70 systemd.log_target=kmsg systemd.log_target=debug"
 #DEBUGFAIL="rd.shell loglevel=70 systemd.log_target=kmsg systemd.log_target=debug"
 
+test_check() {
+    if ! type -p cryptsetup &> /dev/null; then
+        echo "Test needs cryptsetup for crypt module... Skipping"
+        return 1
+    fi
+}
+
 test_run() {
     LUKSARGS=$(cat "$TESTDIR"/luks.txt)
 
index 2f2ca74609bfd504ce45c28e68391fd838bf6cfc..c9a3807b748dee3d3f7aa4c4ffaf93b68d5bd82f 100755 (executable)
@@ -6,6 +6,13 @@ TEST_DESCRIPTION="live root on a squash filesystem"
 # Uncomment these to debug failures
 #DEBUGFAIL="rd.shell rd.debug rd.live.debug loglevel=7"
 
+test_check() {
+    if ! type -p mksquashfs &> /dev/null; then
+        echo "Test needs mksquashfs for crypt module... Skipping"
+        return 1
+    fi
+}
+
 test_run() {
     declare -a disk_args=()
     declare -i disk_index=0
index 5001da9f4523fba0a25dd4641febc492cae597bd..6355100a399280cc0b674853f520aa5af1d1e073 100755 (executable)
@@ -17,7 +17,7 @@ skipcpio_simple() {
         echo "first archive file $i" >> ./"$i"
     done
     find . -print0 | sort -z \
-        | cpio -o --null -H newc --file "$CPIO_TESTDIR/skipcpio_simple.cpio"
+        | cpio -o --null -H newc > "$CPIO_TESTDIR/skipcpio_simple.cpio"
     popd
 
     mkdir -p "$CPIO_TESTDIR/skipcpio_simple/second_archive"