test: tidy up the feature handling

This commit is contained in:
Frantisek Sumsal 2021-09-17 19:28:22 +02:00
parent babe935563
commit 70ec7736f8

View file

@ -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