From: Yu Watanabe Date: Thu, 28 Apr 2022 10:28:11 +0000 (+0900) Subject: test: add testcase for udev-watch X-Git-Tag: v252-rc1~206^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F23087%2Fhead;p=thirdparty%2Fsystemd.git test: add testcase for udev-watch --- diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 6704e9933c0..4ddea69c51c 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -41,6 +41,48 @@ helper_check_device_symlinks() {( done < <(find "${paths[@]}" -type l) )} +helper_check_udev_watch() {( + set +x + + local link target id dev + + while read -r link; do + target="$(readlink "$link")" + echo "$link -> $target" + + if [[ ! -L "/run/udev/watch/$target" ]]; then + echo >&2 "ERROR: symlink /run/udev/watch/$target does not exist" + return 1 + fi + if [[ "$(readlink "/run/udev/watch/$target")" != "$(basename "$link")" ]]; then + echo >&2 "ERROR: symlink target of /run/udev/watch/$target is inconsistent with $link" + return 1 + fi + + if [[ "$target" =~ ^[0-9]+$ ]]; then + # $link is ID -> wd + id="$(basename "$link")" + else + # $link is wd -> ID + id="$target" + fi + + if [[ "${id:0:1}" == "b" ]]; then + dev="/dev/block/${id:1}" + elif [[ "${id:0:1}" == "c" ]]; then + dev="/dev/char/${id:1}" + else + echo >&2 "ERROR: unexpected device ID '$id'" + return 1 + fi + + if [[ ! -e "$dev" ]]; then + echo >&2 "ERROR: device '$dev' corresponding to symlink '$link' does not exist" + return 1 + fi + done < <(find /run/udev/watch -type l) +)} + testcase_megasas2_basic() { lsblk -S [[ "$(lsblk --scsi --noheadings | wc -l)" -ge 128 ]] @@ -201,6 +243,7 @@ EOF if ((i % 10 == 0)); then udevadm wait --settle --timeout="$timeout" "$blockdev" helper_check_device_symlinks + helper_check_udev_watch fi done