]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: check if all paths passed to helper_check_device_symlinks() are valid
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 14 Sep 2021 12:49:11 +0000 (14:49 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 14 Sep 2021 17:15:13 +0000 (19:15 +0200)
test/units/testsuite-64.sh

index 5f68a5f1ede2ffbcce2632d1027cde3343316d9a..951a5f429140036f0b8298da948ee549b85ee59f 100755 (executable)
@@ -11,10 +11,18 @@ helper_check_device_symlinks() {
     # when leaving the function)
     set +x; trap "trap - RETURN; set -x" RETURN
 
-    local dev link paths target
+    local dev link path paths target
 
     [[ $# -gt 0 ]] && paths=("$@") || paths=("/dev/disk")
 
+    # Check if all given paths are valid
+    for path in "${paths[@]}"; do
+        if ! test -e "$path"; then
+            echo >&2 "Path '$path' doesn't exist"
+            return 1
+        fi
+    done
+
     while read -r link; do
         target="$(readlink -f "$link")"
         echo "$link -> $target"