Make the CTL tests more resilient

Fix the find_device function to work regardless of whether "camcontrol
devlist" lists the da device first and the pass device second or vice
versa.  On FreeBSD 14 and 15 it apparently always lists da first.  But
on 13 it can do it in either order.

Sponsored by:	ConnectWise
Reviewed by:	emaste, markj, #cam
Differential Revision: https://reviews.freebsd.org/D47446

(cherry picked from commit b032be711c)
This commit is contained in:
Alan Somers 2024-11-04 17:26:01 -07:00
parent 6203d08e7a
commit 23b2704059

View file

@ -47,7 +47,14 @@ find_device() {
ctladm port -o on -p 0 >/dev/null
HEXLUN=`printf %x $LUN`
while true; do
dev=`camcontrol devlist | awk -v lun=$HEXLUN '/FREEBSD CTL/ && $9==lun {split($10, fields, /[,]/); print fields[1];}' | sed 's:[()]::'`
dev=`camcontrol devlist | awk -v lun=$HEXLUN '
/FREEBSD CTL.*,pass/ && $9==lun {
split($10, fields, /[,]/); print fields[1];
}
/FREEBSD CTL.*\(pass/ && $9==lun {
split($10, fields, /[,]/); print fields[2];
}
' | sed 's:[()]::'`
if [ -z "$dev" -o ! -c /dev/$dev ]; then
retries=$(( $retries - 1 ))
if [ $retries -eq 0 ]; then