From: Yu Watanabe Date: Thu, 31 Jul 2025 18:35:55 +0000 (+0900) Subject: TEST-64-UDEV-STORAGE: several fixlets for check_device_units() X-Git-Tag: v257.8~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a8dfc39da050b82cf48b1e24c2204b7e81ca629;p=thirdparty%2Fsystemd.git TEST-64-UDEV-STORAGE: several fixlets for check_device_units() To suppress the following warnings in case check_device_unit() failed e.g. when the device is already removed: ``` sed: couldn't write 130 items to stdout: Broken pipe awk: write failure (Broken pipe) awk: close failed on file "/dev/stdout" (Broken pipe) ``` (cherry picked from commit 453cbbe47b4e268f239f75d7c19f2ddef495bd81) --- diff --git a/test/units/TEST-64-UDEV-STORAGE.sh b/test/units/TEST-64-UDEV-STORAGE.sh index af935326252..d489159eb71 100755 --- a/test/units/TEST-64-UDEV-STORAGE.sh +++ b/test/units/TEST-64-UDEV-STORAGE.sh @@ -117,7 +117,7 @@ check_device_unit() {( fi done - read -r -a links < <(udevadm info "$syspath" | sed -ne '/SYSTEMD_ALIAS=/ { s/^E: SYSTEMD_ALIAS=//; p }' 2>/dev/null) + read -r -a links < <(udevadm info -q property --property SYSTEMD_ALIAS --value "$syspath" 2>/dev/null) for link in "${links[@]}"; do if [[ "$link" == "$path" ]]; then # SYSTEMD_ALIAS= are absolute return 0 @@ -131,7 +131,7 @@ check_device_unit() {( check_device_units() {( set +x - local log_level path paths + local log_level path paths unit units log_level="${1?}" shift @@ -143,12 +143,13 @@ check_device_units() {( fi done - while read -r unit _; do + read -r -a units < <(systemctl list-units --all --type=device --no-legend dev-* | awk '$1 !~ /dev-tty.+/ && $4 == "plugged" { print $1 }' | sed -e 's/\.device$//') + for unit in "${units[@]}"; do path=$(systemd-escape --path --unescape "$unit") if ! check_device_unit "$log_level" "$path"; then return 1 fi - done < <(systemctl list-units --all --type=device --no-legend dev-* | awk '$1 !~ /dev-tty.+/ && $4 == "plugged" { print $1 }' | sed -e 's/\.device$//') + done return 0 )}