faft: Adjust the indentation of the usb info.
Previously, the first line would be indented, but the rest would not:
...
stderr:
mount: /tmp/usbcheck.sFPY: special device /dev/sdb3 does not exist.
More telemetry: lsusb:
Bus 001 Device 034: ID 18d1:5014 Google Inc.
Bus 001 Device 113: ID 18d1:501b Google Inc.
Now it will be indented:
stderr:
mount: /tmp/usbcheck.sFPY: special device /dev/sdb3 does not exist.
More telemetry:
lsusb:
Bus 001 Device 034: ID 18d1:5014 Google Inc.
Bus 001 Device 113: ID 18d1:501b Google Inc.
This change also slightly adjusts the first line to make it easy to
tell when the body of the exception will contain the extra info.
BUG=b:158972448, b:158015624
TEST=Run firmware_FAFTSetup with 'mount -o ro' altered to include something invalid.
Change-Id: Ide8b8b68694ebac895ee6d598fe607ff5e9f5c15
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2274062
Reviewed-by: Dossym Nurmukhanov <dossym@chromium.org>
Tested-by: Dana Goyette <dgoyette@chromium.org>
Commit-Queue: Dana Goyette <dgoyette@chromium.org>
diff --git a/server/cros/faft/firmware_test.py b/server/cros/faft/firmware_test.py
index 3c97585..9db71b1 100644
--- a/server/cros/faft/firmware_test.py
+++ b/server/cros/faft/firmware_test.py
@@ -544,11 +544,10 @@
try:
self.servo.system('mount -o ro %s %s' % (rootfs, tmpd))
except error.AutoservRunError as e:
+ usb_info = telemetry.collect_usb_state(self.servo)
raise error.TestError(
- ('Could not mount the partition on USB device. ' +
- 'Exception: %s\nMore telemetry: %s') %
- (e,
- telemetry.collect_usb_state(self.servo)))
+ ('Could not mount the partition on USB device. %s: %s\n'
+ 'More telemetry: %s') % (type(e).__name__, e, usb_info))
try:
usb_lsb = self.servo.system_output('cat %s' %
diff --git a/server/cros/faft/telemetry.py b/server/cros/faft/telemetry.py
index 496c67a..87b3917 100644
--- a/server/cros/faft/telemetry.py
+++ b/server/cros/faft/telemetry.py
@@ -26,22 +26,20 @@
- `ls -l /dev/sd*` to learn which storage devices are known to the OS and
what partition scheme is assumed by the kernel;
- `fdisk -l` for the partitioning as reported in GPT/MBR
+
+ Note that the return value begins with a newline.
"""
- lsusb = servo.system_output('lsusb', ignore_status=True)
- lsusb_t = servo.system_output('lsusb -t', ignore_status=True)
- lssdx = servo.system_output('ls -l /dev/sd*', ignore_status=True)
- fdisk = servo.system_output('fdisk -l', ignore_status=True)
- return """lsusb:
- %s
-
- lsusb -t:
- %s
-
- ls -l /dev/sd*:
- %s
-
- fdisk -l:
- %s
- """ % (lsusb, lsusb_t, lssdx, fdisk)
+ lines = []
+ for cmd in [
+ 'lsusb',
+ 'lsusb -t',
+ 'ls -l /dev/sd*',
+ 'fdisk -l'
+ ]:
+ output = servo.system_output(cmd, ignore_status=True)
+ lines.append('')
+ lines.append('%s:' % cmd)
+ lines.extend(' %s' % line for line in output.splitlines())
+ return '\n'.join(lines)
# Add more collect functions here as necessary