mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-25 06:03:40 +03:00
test: make sure all symlinks under /dev/disk/ are valid
This commit is contained in:
parent
d0cbad16c5
commit
d430e451c9
@ -4,6 +4,28 @@
|
|||||||
set -eux
|
set -eux
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
# Check if all symlinks under /dev/disk/ are valid
|
||||||
|
helper_check_device_symlinks() {
|
||||||
|
local dev link target
|
||||||
|
|
||||||
|
while read -r link; do
|
||||||
|
target="$(readlink -f "$link")"
|
||||||
|
# Both checks should do virtually the same thing, but check both to be
|
||||||
|
# on the safe side
|
||||||
|
if [[ ! -e "$link" || ! -e "$target" ]]; then
|
||||||
|
echo >&2 "ERROR: symlink '$link' points to '$target' which doesn't exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the symlink points to the correct device in /dev
|
||||||
|
dev="/dev/$(udevadm info -q name "$link")"
|
||||||
|
if [[ "$target" != "$dev" ]]; then
|
||||||
|
echo >&2 "ERROR: symlink '$link' points to '$target' but '$dev' was expected"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done < <(find /dev/disk -type l)
|
||||||
|
}
|
||||||
|
|
||||||
testcase_megasas2_basic() {
|
testcase_megasas2_basic() {
|
||||||
lsblk -S
|
lsblk -S
|
||||||
[[ "$(lsblk --scsi --noheadings | wc -l)" -ge 128 ]]
|
[[ "$(lsblk --scsi --noheadings | wc -l)" -ge 128 ]]
|
||||||
@ -121,9 +143,11 @@ EOF
|
|||||||
: >/failed
|
: >/failed
|
||||||
|
|
||||||
udevadm settle
|
udevadm settle
|
||||||
|
|
||||||
lsblk -a
|
lsblk -a
|
||||||
|
|
||||||
|
echo "Check if all symlinks under /dev/disk/ are valid (pre-test)"
|
||||||
|
helper_check_device_symlinks
|
||||||
|
|
||||||
# TEST_FUNCTION_NAME is passed on the kernel command line via systemd.setenv=
|
# TEST_FUNCTION_NAME is passed on the kernel command line via systemd.setenv=
|
||||||
# in the respective test.sh file
|
# in the respective test.sh file
|
||||||
if ! command -v "${TEST_FUNCTION_NAME:?}"; then
|
if ! command -v "${TEST_FUNCTION_NAME:?}"; then
|
||||||
@ -134,6 +158,9 @@ fi
|
|||||||
echo "TEST_FUNCTION_NAME=$TEST_FUNCTION_NAME"
|
echo "TEST_FUNCTION_NAME=$TEST_FUNCTION_NAME"
|
||||||
"$TEST_FUNCTION_NAME"
|
"$TEST_FUNCTION_NAME"
|
||||||
|
|
||||||
|
echo "Check if all symlinks under /dev/disk/ are valid (post-test)"
|
||||||
|
helper_check_device_symlinks
|
||||||
|
|
||||||
systemctl status systemd-udevd
|
systemctl status systemd-udevd
|
||||||
|
|
||||||
touch /testok
|
touch /testok
|
||||||
|
Loading…
x
Reference in New Issue
Block a user