From: Frantisek Sumsal Date: Fri, 17 Sep 2021 15:45:39 +0000 (+0200) Subject: test: unify handling of supported "features" X-Git-Tag: v250-rc1~653^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=776fc8c3859ba859d4212685fb383c9db9a55030;p=thirdparty%2Fsystemd.git test: unify handling of supported "features" --- diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index 89de1ea6927..fe1a88f0aa5 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -26,6 +26,25 @@ if ! get_bool "$QEMU_KVM"; then exit 0 fi +_host_has_feature() { + case "${1:?}" in + multipath) + command -v multipath && command -v multipathd + ;; + lvm) + command -v lvm + ;; + btrfs) + modprobe -nv btrfs && command -v mkfs.btrfs + ;; + *) + echo >&2 "ERROR: Unknown feature '$1'" + # Make this a hard error to distinguish an invalid feature from + # a missing feature + exit 1 + esac +} + test_append_files() { ( instmods "=block" "=md" "=nvme" "=scsi" @@ -34,12 +53,12 @@ test_append_files() { image_install lsblk wc # Configure multipath - if command -v multipath && command -v multipathd; then + if _host_has_feature "multipath"; then install_multipath fi # Configure LVM - if command -v lvm; then + if _host_has_feature "lvm"; then install_lvm fi @@ -201,7 +220,7 @@ EOF } testcase_multipath_basic_failover() { - if ! command -v multipath || ! command -v multipathd; then + if ! _host_has_feature "multipath"; then echo "Missing multipath tools, skipping the test..." return 77 fi @@ -260,7 +279,7 @@ testcase_simultaneous_events() { } testcase_lvm_basic() { - if ! command -v lvm; then + if ! _host_has_feature "lvm"; then echo "Missing lvm tools, skipping the test..." return 77 fi