Improvement on vts systrace controller
* more error logging
* use default temp file name when process name is not defined
* start systrace after other test setup procedures are done
Test: make vts
Change-Id: Ieb8c0a1dfea2a79b7b49f9a40de019a94c22dfa8
diff --git a/runners/host/base_test_with_webdb.py b/runners/host/base_test_with_webdb.py
index 75e8f3b..b3aa4ee 100644
--- a/runners/host/base_test_with_webdb.py
+++ b/runners/host/base_test_with_webdb.py
@@ -324,12 +324,17 @@
def _setUpTest(self, test_name):
"""Proxy function to guarantee the base implementation of _setUpTest is called.
+ Systrace will be started after other setup procedures are done.
+
Args:
test_name: string, test name
"""
+ ret = super(BaseTestWithWebDbClass, self)._setUpTest(test_name)
+
if self._systrace_controller:
self._systrace_controller.Start()
- return super(BaseTestWithWebDbClass, self)._setUpTest(test_name)
+
+ return ret
def _tearDownTest(self, test_name):
"""Proxy function to guarantee the base implementation of test_name is called.
diff --git a/utils/python/systrace/systrace_controller.py b/utils/python/systrace/systrace_controller.py
index 8ebabfd..7107ca7 100644
--- a/utils/python/systrace/systrace_controller.py
+++ b/utils/python/systrace/systrace_controller.py
@@ -91,8 +91,9 @@
if self.process_name:
process_name_arg = '-a %s' % self.process_name
- self._path_output = os.path.join(tempfile.mkdtemp(),
- self.process_name + '.html')
+ tmp_dir = tempfile.mkdtemp()
+ tmp_filename = self.process_name if self.process_name else 'systrace'
+ self._path_output = os.path.join(tmp_dir, tmp_filename + '.html')
cmd = ('python -u {script} hal sched '
'{process_name_arg} -o {output}').format(
@@ -119,7 +120,7 @@
if not success:
logging.error('Failed to start systrace on process %s',
- process_name)
+ self.process_name)
stdout, stderr = process.communicate()
logging.error('stdout: %s', line + stdout)
logging.error('stderr: %s', stderr)
@@ -147,8 +148,10 @@
self._subprocess.stdin.flush()
# Wait for output to be written down
- self._subprocess.communicate()
+ out, err = self._subprocess.communicate()
logging.info('Systrace stopped for %s', self.process_name)
+ logging.info('Systrace stdout: %s', out)
+ logging.info('Systrace stderr: %s', err)
return True
def ReadLastOutput(self):