]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: tidy up the feature handling
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 17 Sep 2021 17:28:22 +0000 (19:28 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 18 Sep 2021 18:44:34 +0000 (20:44 +0200)
test/TEST-64-UDEV-STORAGE/test.sh

index fe1a88f0aa5803b9aa0aedacf2598d888e1f2e9b..fe386050e364656d681dae580223a926183d25c6 100755 (executable)
@@ -47,20 +47,25 @@ _host_has_feature() {
 
 test_append_files() {
     (
+        local feature
+        # An associative array of requested (but optional) features and their
+        # respective "handlers" from test/test-functions
+        local -A features=(
+            [multipath]=install_multipath
+            [lvm]=install_lvm
+        )
+
         instmods "=block" "=md" "=nvme" "=scsi"
         install_dmevent
         generate_module_dependencies
         image_install lsblk wc
 
-        # Configure multipath
-        if _host_has_feature "multipath"; then
-            install_multipath
-        fi
-
-        # Configure LVM
-        if _host_has_feature "lvm"; then
-            install_lvm
-        fi
+        # Install the optional features if the host has the respective tooling
+        for feature in "${!features[@]}"; do
+            if _host_has_feature "$feature"; then
+                "${features[$feature]}"
+            fi
+        done
 
         for i in {0..127}; do
             dd if=/dev/zero of="${TESTDIR:?}/disk$i.img" bs=1M count=1