Now that run_subtests() understands 77 as skipped, make the subtests that bail out early on a missing capability or precondition exit 77 instead of exit 0. Partial skips that run after real assertions, and exits from inside subshells, are deliberately left untouched. Signed-off-by: Paul Meyer <katexochen0@gmail.com>
36 lines
795 B
Bash
Executable File
36 lines
795 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
set -eux
|
|
set -o pipefail
|
|
|
|
if ! command -v systemd-hwdb >/dev/null; then
|
|
echo "systemd-hwdb not found, skipping."
|
|
exit 77
|
|
fi
|
|
|
|
# shellcheck source=test/units/util.sh
|
|
. "$(dirname "$0")"/util.sh
|
|
|
|
at_exit() (
|
|
set +e
|
|
|
|
[[ -d "$ROOTFS" ]] && rm -rf "$ROOTFS"
|
|
)
|
|
trap at_exit EXIT
|
|
|
|
ROOTFS="$(mktemp -d -t test-17-udev-hwdb.XXXX)"
|
|
HWDB=$ROOTFS/usr/lib/udev/hwdb.d
|
|
|
|
mkdir -p "$HWDB"
|
|
cat >"$HWDB/99-test.hwdb" <<EOF
|
|
scsi:*
|
|
ID_TEST=test
|
|
EOF
|
|
|
|
systemd-hwdb update --root "$ROOTFS" --usr
|
|
|
|
# check the rootfs path does not appear in hwdb.bin
|
|
run_and_grep -n "$ROOTFS" strings "$ROOTFS/usr/lib/udev/hwdb.bin"
|
|
# check the path in the rootfs does appear in hwdb.bin
|
|
run_and_grep 99-test.hwdb strings "$ROOTFS/usr/lib/udev/hwdb.bin"
|