From 776fc8c3859ba859d4212685fb383c9db9a55030 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Sep 2021 17:45:39 +0200 Subject: [PATCH] test: unify handling of supported "features" --- test/TEST-64-UDEV-STORAGE/test.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) 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 -- 2.47.3