From e772458a32ef55e68d15a08d95df2d97fa6ef22a Mon Sep 17 00:00:00 2001 From: Orion Hodson Date: Thu, 20 Oct 2022 15:28:01 +0100 Subject: buildbot-setup-device.sh: minor fix getting date from older devices The output of the date command on older devices can include CRLF and this otherwise breaks the time comparisons in this script. Bug: 224733324 Test: manual Change-Id: I2e0bccceef95abbb8304184c404fedb05052a5cc --- tools/buildbot-setup-device.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/buildbot-setup-device.sh b/tools/buildbot-setup-device.sh index 1cad3e3793..decb24735a 100755 --- a/tools/buildbot-setup-device.sh +++ b/tools/buildbot-setup-device.sh @@ -36,7 +36,11 @@ msginfo "Date on device" adb shell date host_seconds_since_epoch=$(date -u +%s) -device_seconds_since_epoch=$(adb shell date -u +%s) + +# Get the device time in seconds, but filter the output as some +# devices emit CRLF at the end of the command which then breaks the +# time comparisons in this script (Hammerhead, MRA59G 2457013). +device_seconds_since_epoch=$(adb shell date -u +%s | tr -c -d '[:digit:]') abs_time_difference_in_seconds=$(expr $host_seconds_since_epoch - $device_seconds_since_epoch) if [ $abs_time_difference_in_seconds -lt 0 ]; then -- cgit v1.2.3-59-g8ed1b