check_ethernet: fix up nits in toggle_usb_interface() method
Recently added "toggle USB interface" method wasn't consistently
using that same pattern to find/test ethernet devices.
Add quotes around use of the complete path for "authorized" field.
These changes were supposed to land with patchset 9 but the CQ picked up
patchset 8 instead. :/
https://chromium-review.googlesource.com/c/chromiumos/platform/crostestutils/+/608612/
BUG=chromium:677572
TEST=on local machine from console:
touch /mnt/stateful_partition/.labmachine
# disconnect ethernet cable
bash -x /usr/local/bin/hooks/check_ethernet.hook
# review output for all methods
rm /mnt/stateful_partition/.labmachine
Change-Id: I4837c7e55676cb90b7a6d51dcefca1f51e5a243b
Reviewed-on: https://chromium-review.googlesource.com/674327
Commit-Ready: Grant Grundler <grundler@chromium.org>
Tested-by: Grant Grundler <grundler@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@google.com>
Reviewed-by: Grant Grundler <grundler@chromium.org>
diff --git a/recover_duts/hooks/check_ethernet.hook b/recover_duts/hooks/check_ethernet.hook
index 0c8305f..17a3974 100755
--- a/recover_duts/hooks/check_ethernet.hook
+++ b/recover_duts/hooks/check_ethernet.hook
@@ -145,15 +145,17 @@
# usbpath=/sys/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/net/eth1
#
# But we want the port for that device:
- # echo ${usbpath%/*/net/eth[0-9]*}
+ # echo ${usbpath%/*/net/*}
# /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2
- usbpath=${usbpath%/*/net/eth[0-9]*}
- if [ -w ${usbpath}/authorized ]; then
+ usbpath=${usbpath%/*/net/*}
+
+ # Only USB devices have "authorized" field in /sys
+ if [ -w "${usbpath}/authorized" ]; then
ret=0
# disable port: sort of like unplugging/plugging the dongle
- echo 0 > ${usbpath}/authorized
+ echo 0 > "${usbpath}/authorized"
sleep 3
- echo 1 > ${usbpath}/authorized
+ echo 1 > "${usbpath}/authorized"
fi
done
return $ret