FAFT: Record the faft client log to the results directory
We saw some errors happened inside the saft library. So far it is not easy
to know what happened. Recording the faft client log helps.
BUG=chrome-os-partner:20165
TEST=Manual
Ran a FAFT test and checked the faft_client.log exist in the results directory
Change-Id: I0a4285498f42e2a431a9d4e550fdd93e1e675a4c
Reviewed-on: https://gerrit.chromium.org/gerrit/60021
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/client/cros/faft_client.py b/client/cros/faft_client.py
index feaaacf..3b9be90 100755
--- a/client/cros/faft_client.py
+++ b/client/cros/faft_client.py
@@ -69,6 +69,7 @@
_ec_handler: An object to automate EC flashrom testing.
_ec_image: An object to automate EC image for autest.
_kernel_handler: An object to provide kernel related actions.
+ _log_file: Path of the log file.
_tpm_handler: An object to control TPM device.
_updater: An object to update firmware.
_temp_path: Path of a temp directory.
@@ -84,9 +85,11 @@
self._chromeos_interface = chromeos_interface.ChromeOSInterface(False)
# We keep the state of FAFT test in a permanent directory over reboots.
state_dir = '/var/tmp/faft'
- self._chromeos_interface.init(state_dir, log_file='/tmp/faft_log.txt')
os.chdir(state_dir)
+ self._log_file = os.path.join(state_dir, 'faft_client.log')
+ self._chromeos_interface.init(state_dir, log_file=self._log_file)
+
self._bios_handler = LazyFlashromHandlerProxy(
saft_flashrom_util,
self._chromeos_interface,
@@ -171,6 +174,21 @@
return True
+ def _system_dump_log(self, remove_log=False):
+ """Dump the log file.
+
+ Args:
+ remove_log: Remove the log file after dump.
+
+ Returns:
+ String of the log file content.
+ """
+ log = open(self._log_file).read()
+ if remove_log:
+ os.remove(self._log_file)
+ return log
+
+
def _system_run_shell_command(self, command):
"""Run shell command.