ZTS: Fix stale symlinks with zfs-helpers.sh

zfs-helpers.sh is a utility script that sets up udev symlinks so you
can run ZTS from a local ZFS git workspace.  However, it doesn't check
that the udev symlinks point to the current workspace.  They may point
to an old workspace that has been deleted.  This means the udev rules
never get executed, which in turn causes the zvol tests to fail.

This commit removes old symlinks that do not point to the current
ZFS workspace.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #17766
This commit is contained in:
Tony Hutter 2025-09-23 12:58:14 -07:00 committed by Brian Behlendorf
parent 83066c9627
commit 2380e0b679

View File

@ -122,6 +122,13 @@ install() {
src=$1
dst=$2
# We may have an old symlink pointing to different ZFS workspace.
# Remove the old symlink if it doesn't point to our workspace.
if [ -h "$dst" ] && [ "$(readlink -f """$dst""")" != "$src" ] ; then
echo "Removing old symlink: $dst -> $(readlink """$dst""")"
rm "$dst"
fi
if [ -h "$dst" ]; then
echo "Symlink exists: $dst"
elif [ -e "$dst" ]; then