autotest: Collect log of chart process in camerabox chart fixture. Redirect stdout/stderr of chart process to log file and collect the log file in cleanup stage of camerabox test. BUG=b:140256285 TEST=test_that <DUT> cheets_CTS_P.9.0_r10.arm.CtsCameraTestCases.camerabox.front --args="chart=<CHART>" Change-Id: I0bd9d77632647ddeb33b91623df13d72d5b70bdd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2100700 Tested-by: Kuo Jen Wei <[email protected]> Reviewed-by: Rohit Makasana <[email protected]> Commit-Queue: Kuo Jen Wei <[email protected]>
diff --git a/server/cros/camerabox_utils.py b/server/cros/camerabox_utils.py index ff8a7e0..491c87e 100644 --- a/server/cros/camerabox_utils.py +++ b/server/cros/camerabox_utils.py
@@ -16,31 +16,39 @@ class ChartFixture: """Sets up chart tablet to display dummy scene image.""" DISPLAY_SCRIPT = '/usr/local/autotest/bin/display_chart.py' + OUTPUT_LOG = '/tmp/chart_service.log' def __init__(self, chart_host, scene_uri): self.host = chart_host self.scene_uri = scene_uri self.display_pid = None + self.host.run(['rm', '-f', self.OUTPUT_LOG]) def initialize(self): """Prepare scene file and display it on chart host.""" logging.info('Prepare scene file') - chart_dir = self.host.get_tmp_dir() + tmpdir = self.host.get_tmp_dir() scene_path = os.path.join( - chart_dir, self.scene_uri[self.scene_uri.rfind('/') + 1:]) + tmpdir, self.scene_uri[self.scene_uri.rfind('/') + 1:]) self.host.run('wget', args=('-O', scene_path, self.scene_uri)) - self.host.run('chmod', args=('-R', '755', chart_dir)) logging.info('Display scene file') self.display_pid = self.host.run_background( - 'python2 %s %s' % (self.DISPLAY_SCRIPT, scene_path)) + 'python2 {script} {scene} >{log} 2>&1'.format( + script=self.DISPLAY_SCRIPT, + scene=scene_path, + log=self.OUTPUT_LOG)) # TODO(inker): Suppose chart should be displayed very soon. Or require # of waiting until chart actually displayed. def cleanup(self): """Cleanup display script.""" if self.display_pid is not None: - self.host.run('kill', args=('-2', str(self.display_pid))) + self.host.run( + 'kill', + args=('-2', str(self.display_pid)), + ignore_status=True) + self.host.get_file(self.OUTPUT_LOG, '.') def get_chart_address(host_address, args):