mirror of
https://github.com/systemd/systemd
synced 2024-10-15 20:45:09 +00:00
test: use subshells a bit more
to tweak shell flags in specific functions without affecting the rest of the script.
This commit is contained in:
parent
b216501a8e
commit
de11005c1a
|
@ -26,7 +26,9 @@ if ! get_bool "$QEMU_KVM"; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_host_has_feature() {
|
_host_has_feature() {(
|
||||||
|
set -e
|
||||||
|
|
||||||
case "${1:?}" in
|
case "${1:?}" in
|
||||||
multipath)
|
multipath)
|
||||||
command -v multipath && command -v multipathd
|
command -v multipath && command -v multipathd
|
||||||
|
@ -43,36 +45,34 @@ _host_has_feature() {
|
||||||
# a missing feature
|
# a missing feature
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
}
|
)}
|
||||||
|
|
||||||
test_append_files() {
|
test_append_files() {(
|
||||||
(
|
local feature
|
||||||
local feature
|
# An associative array of requested (but optional) features and their
|
||||||
# An associative array of requested (but optional) features and their
|
# respective "handlers" from test/test-functions
|
||||||
# respective "handlers" from test/test-functions
|
local -A features=(
|
||||||
local -A features=(
|
[multipath]=install_multipath
|
||||||
[multipath]=install_multipath
|
[lvm]=install_lvm
|
||||||
[lvm]=install_lvm
|
|
||||||
)
|
|
||||||
|
|
||||||
instmods "=block" "=md" "=nvme" "=scsi"
|
|
||||||
install_dmevent
|
|
||||||
generate_module_dependencies
|
|
||||||
image_install lsblk wc
|
|
||||||
|
|
||||||
# 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
|
|
||||||
echo "device$i" >"${TESTDIR:?}/disk$i.img"
|
|
||||||
done
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
instmods "=block" "=md" "=nvme" "=scsi"
|
||||||
|
install_dmevent
|
||||||
|
generate_module_dependencies
|
||||||
|
image_install lsblk wc
|
||||||
|
|
||||||
|
# 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
|
||||||
|
echo "device$i" >"${TESTDIR:?}/disk$i.img"
|
||||||
|
done
|
||||||
|
)}
|
||||||
|
|
||||||
test_run_one() {
|
test_run_one() {
|
||||||
local test_id="${1:?}"
|
local test_id="${1:?}"
|
||||||
|
|
|
@ -6,10 +6,8 @@ set -o pipefail
|
||||||
|
|
||||||
# Check if all symlinks under /dev/disk/ are valid
|
# Check if all symlinks under /dev/disk/ are valid
|
||||||
# shellcheck disable=SC2120
|
# shellcheck disable=SC2120
|
||||||
helper_check_device_symlinks() {
|
helper_check_device_symlinks() {(
|
||||||
# Disable verbose logging only for this function (and reset the signal handler
|
set +x
|
||||||
# when leaving the function)
|
|
||||||
set +x; trap "trap - RETURN; set -x" RETURN
|
|
||||||
|
|
||||||
local dev link path paths target
|
local dev link path paths target
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ helper_check_device_symlinks() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done < <(find "${paths[@]}" -type l)
|
done < <(find "${paths[@]}" -type l)
|
||||||
}
|
)}
|
||||||
|
|
||||||
testcase_megasas2_basic() {
|
testcase_megasas2_basic() {
|
||||||
lsblk -S
|
lsblk -S
|
||||||
|
|
Loading…
Reference in a new issue