summaryrefslogtreecommitdiffstats
path: root/chromium/build/fuchsia/emu_target.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-02-02 12:21:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-02-12 08:13:00 +0000
commit606d85f2a5386472314d39923da28c70c60dc8e7 (patch)
treea8f4d7bf997f349f45605e6058259fba0630e4d7 /chromium/build/fuchsia/emu_target.py
parent5786336dda477d04fb98483dca1a5426eebde2d7 (diff)
BASELINE: Update Chromium to 96.0.4664.181
Change-Id: I762cd1da89d73aa6313b4a753fe126c34833f046 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/build/fuchsia/emu_target.py')
-rw-r--r--chromium/build/fuchsia/emu_target.py73
1 files changed, 35 insertions, 38 deletions
diff --git a/chromium/build/fuchsia/emu_target.py b/chromium/build/fuchsia/emu_target.py
index 4a86bdce670..3f0711300b3 100644
--- a/chromium/build/fuchsia/emu_target.py
+++ b/chromium/build/fuchsia/emu_target.py
@@ -8,7 +8,6 @@ import pkg_repo
import boot_data
import logging
import os
-import runner_logs
import subprocess
import sys
import target
@@ -16,15 +15,14 @@ import tempfile
class EmuTarget(target.Target):
- def __init__(self, out_dir, target_cpu, system_log_file):
+ def __init__(self, out_dir, target_cpu, logs_dir):
"""out_dir: The directory which will contain the files that are
generated to support the emulator deployment.
target_cpu: The emulated target CPU architecture.
Can be 'x64' or 'arm64'."""
- super(EmuTarget, self).__init__(out_dir, target_cpu)
+ super(EmuTarget, self).__init__(out_dir, target_cpu, logs_dir)
self._emu_process = None
- self._system_log_file = system_log_file
self._pkg_repo = None
def __enter__(self):
@@ -37,11 +35,6 @@ class EmuTarget(target.Target):
def _SetEnv(self):
return os.environ.copy()
- # Used by the context manager to ensure that the emulator is killed when
- # the Python process exits.
- def __exit__(self, exc_type, exc_val, exc_tb):
- self.Shutdown();
-
def Start(self):
emu_command = self._BuildCommand()
@@ -59,14 +52,14 @@ class EmuTarget(target.Target):
# to a temporary file, and print that out if we are unable to connect to
# the emulator guest, to make it easier to diagnose connectivity issues.
temporary_log_file = None
- if runner_logs.IsEnabled():
- stdout = runner_logs.FileStreamFor('serial_log')
+ if self._log_manager.IsLoggingEnabled():
+ stdout = self._log_manager.Open('serial_log')
else:
temporary_log_file = tempfile.NamedTemporaryFile('w')
stdout = temporary_log_file
- LogProcessStatistics('proc_stat_start_log')
- LogSystemStatistics('system_statistics_start_log')
+ self.LogProcessStatistics('proc_stat_start_log')
+ self.LogSystemStatistics('system_statistics_start_log')
self._emu_process = subprocess.Popen(emu_command,
stdin=open(os.devnull),
@@ -76,13 +69,19 @@ class EmuTarget(target.Target):
try:
self._WaitUntilReady()
- LogProcessStatistics('proc_stat_ready_log')
+ self.LogProcessStatistics('proc_stat_ready_log')
except target.FuchsiaTargetException:
if temporary_log_file:
logging.info('Kernel logs:\n' +
open(temporary_log_file.name, 'r').read())
raise
+ def Stop(self):
+ try:
+ super(EmuTarget, self).Stop()
+ finally:
+ self.Shutdown()
+
def GetPkgRepo(self):
if not self._pkg_repo:
self._pkg_repo = pkg_repo.ManagedPkgRepo(self)
@@ -106,8 +105,8 @@ class EmuTarget(target.Target):
logging.error('%s quit unexpectedly with exit code %d' %
(self.EMULATOR_NAME, returncode))
- LogProcessStatistics('proc_stat_end_log')
- LogSystemStatistics('system_statistics_end_log')
+ self.LogProcessStatistics('proc_stat_end_log')
+ self.LogSystemStatistics('system_statistics_end_log')
def _IsEmuStillRunning(self):
@@ -121,25 +120,23 @@ class EmuTarget(target.Target):
return ('localhost', self._host_ssh_port)
def _GetSshConfigPath(self):
- return boot_data.GetSSHConfigPath(self._out_dir)
-
-
-def LogSystemStatistics(log_file_name):
- statistics_log = runner_logs.FileStreamFor(log_file_name)
- # Log the cpu load and process information.
- subprocess.call(['top', '-b', '-n', '1'],
- stdin=open(os.devnull),
- stdout=statistics_log,
- stderr=subprocess.STDOUT)
- subprocess.call(['ps', '-ax'],
- stdin=open(os.devnull),
- stdout=statistics_log,
- stderr=subprocess.STDOUT)
-
-
-def LogProcessStatistics(log_file_name):
- statistics_log = runner_logs.FileStreamFor(log_file_name)
- subprocess.call(['cat', '/proc/stat'],
- stdin=open(os.devnull),
- stdout=statistics_log,
- stderr=subprocess.STDOUT)
+ return boot_data.GetSSHConfigPath()
+
+ def LogSystemStatistics(self, log_file_name):
+ self._LaunchSubprocessWithLogs(['top', '-b', '-n', '1'], log_file_name)
+ self._LaunchSubprocessWithLogs(['ps', '-ax'], log_file_name)
+
+ def LogProcessStatistics(self, log_file_name):
+ self._LaunchSubprocessWithLogs(['cat', '/proc/stat'], log_file_name)
+
+ def _LaunchSubprocessWithLogs(self, command, log_file_name):
+ """Launch a subprocess and redirect stdout and stderr to log_file_name.
+ Command will not be run if logging directory is not set."""
+
+ if not self._log_manager.IsLoggingEnabled():
+ return
+ log = self._log_manager.Open(log_file_name)
+ subprocess.call(command,
+ stdin=open(os.devnull),
+ stdout=log,
+ stderr=subprocess.STDOUT)