diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-02 21:10:08 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-05 16:50:13 +0200 |
commit | 70bdf6e661f67dfbfd6a198f7d1ebc6fdf0dce62 (patch) | |
tree | 87f5fc76ee5da8bfac09ad464f30ddafec89cd40 | |
parent | test: fix indentation (diff) | |
download | systemd-70bdf6e661f67dfbfd6a198f7d1ebc6fdf0dce62.tar.xz systemd-70bdf6e661f67dfbfd6a198f7d1ebc6fdf0dce62.zip |
test: introduce test_require_bin() and use it
No functional change.
-rwxr-xr-x | test/TEST-21-DFUZZER/test.sh | 2 | ||||
-rwxr-xr-x | test/TEST-43-PRIVATEUSER-UNPRIV/test.sh | 2 | ||||
-rwxr-xr-x | test/TEST-46-HOMED/test.sh | 5 | ||||
-rwxr-xr-x | test/TEST-50-DISSECT/test.sh | 4 | ||||
-rwxr-xr-x | test/TEST-70-TPM2/test.sh | 3 | ||||
-rwxr-xr-x | test/TEST-75-RESOLVED/test.sh | 5 | ||||
-rw-r--r-- | test/test-functions | 11 |
7 files changed, 17 insertions, 15 deletions
diff --git a/test/TEST-21-DFUZZER/test.sh b/test/TEST-21-DFUZZER/test.sh index eb0a6549e0..4b1919b86e 100755 --- a/test/TEST-21-DFUZZER/test.sh +++ b/test/TEST-21-DFUZZER/test.sh @@ -18,7 +18,7 @@ if ! get_bool "${TEST_PREFER_NSPAWN:=}"; then TEST_NO_NSPAWN=1 fi -command -v dfuzzer >/dev/null || exit 0 +test_require_bin dfuzzer if ! get_bool "$IS_BUILT_WITH_ASAN"; then echo "systemd is built without ASan, skipping..." diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh index 844c08ab1f..1d1dab43c3 100755 --- a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh +++ b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh @@ -9,7 +9,7 @@ IMAGE_NAME="private-users" . "${TEST_BASE_DIR:?}/test-functions" has_user_dbus_socket || exit 0 -command -v mksquashfs >/dev/null 2>&1 || exit 0 +test_require_bin mksquashfs test_append_files() { inst_binary unsquashfs diff --git a/test/TEST-46-HOMED/test.sh b/test/TEST-46-HOMED/test.sh index 0daf211103..3bf3891380 100755 --- a/test/TEST-46-HOMED/test.sh +++ b/test/TEST-46-HOMED/test.sh @@ -11,10 +11,7 @@ TEST_DESCRIPTION="testing homed" . "${TEST_BASE_DIR:?}/test-functions" get_bool "${NO_BUILD:-}" && HOMECTL_BIN="homectl" || HOMECTL_BIN="${BUILD_DIR:?}/homectl" -if ! command -v "$HOMECTL_BIN" >/dev/null; then - echo "Built without systemd-homed, skipping the test" - exit 0 -fi +test_require_bin "$HOMECTL_BIN" # Need loop devices for mounting images test_append_files() { diff --git a/test/TEST-50-DISSECT/test.sh b/test/TEST-50-DISSECT/test.sh index 2d44ca2b6e..bcc81749af 100755 --- a/test/TEST-50-DISSECT/test.sh +++ b/test/TEST-50-DISSECT/test.sh @@ -12,9 +12,7 @@ TEST_INSTALL_VERITY_MINIMAL=1 # shellcheck source=test/test-functions . "${TEST_BASE_DIR:?}/test-functions" -command -v mksquashfs >/dev/null 2>&1 || exit 0 -command -v veritysetup >/dev/null 2>&1 || exit 0 -command -v sfdisk >/dev/null 2>&1 || exit 0 +test_require_bin mksquashfs veritysetup sfdisk test_append_files() { instmods squashfs =squashfs diff --git a/test/TEST-70-TPM2/test.sh b/test/TEST-70-TPM2/test.sh index db92d21c4a..f3ac1399fc 100755 --- a/test/TEST-70-TPM2/test.sh +++ b/test/TEST-70-TPM2/test.sh @@ -11,8 +11,7 @@ TEST_REQUIRE_INSTALL_TESTS=0 # shellcheck source=test/test-functions . "${TEST_BASE_DIR:?}/test-functions" -command -v swtpm >/dev/null 2>&1 || exit 0 -command -v tpm2_pcrextend >/dev/null 2>&1 || exit 0 +test_require_bin swtpm tpm2_pcrextend test_append_files() { local workspace="${1:?}" diff --git a/test/TEST-75-RESOLVED/test.sh b/test/TEST-75-RESOLVED/test.sh index 6c63db65fb..cbb9e3dbbf 100755 --- a/test/TEST-75-RESOLVED/test.sh +++ b/test/TEST-75-RESOLVED/test.sh @@ -9,10 +9,7 @@ NSPAWN_ARGUMENTS="--private-network" # shellcheck source=test/test-functions . "${TEST_BASE_DIR:?}/test-functions" -if ! command -v knotd >/dev/null; then - echo "This test requires Knot DNS server, skipping..." - exit 0 -fi +test_require_bin knotd # We need at least Knot 3.0 which support (among others) the ds-push directive if ! knotc -c "${TEST_BASE_DIR:?}/knot-data/knot.conf" conf-check; then diff --git a/test/test-functions b/test/test-functions index f374e8ade0..09e5e0d38e 100644 --- a/test/test-functions +++ b/test/test-functions @@ -326,6 +326,17 @@ if get_bool "$IS_BUILT_WITH_ASAN"; then echo "Detected ASan RT '$ASAN_RT_NAME' located at '$ASAN_RT_PATH'" fi +test_require_bin() { + local bin + + for bin in "$@"; do + if ! command -v "$bin" >/dev/null; then + echo "Required binary $bin not available, skipping the test" + exit 0 + fi + done +} + find_qemu_bin() { QEMU_BIN="${QEMU_BIN:-""}" # SUSE and Red Hat call the binary qemu-kvm. Debian and Gentoo call it kvm. |