cros_run_vm_test: stream long running commands.
BUG=chromium:829481
TEST=manual
Change-Id: I4683e8e2ac1f79866caf3313f2b48213376d6829
Reviewed-on: https://chromium-review.googlesource.com/1064708
Commit-Ready: Achuith Bhandarkar <achuith@chromium.org>
Tested-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
diff --git a/scripts/cros_vm.py b/scripts/cros_vm.py
index 2d97349..d5e2559 100644
--- a/scripts/cros_vm.py
+++ b/scripts/cros_vm.py
@@ -90,7 +90,14 @@
# moblab, etc.
def _RunCommand(self, *args, **kwargs):
- """Use SudoRunCommand or RunCommand as necessary."""
+ """Use SudoRunCommand or RunCommand as necessary.
+
+ Args:
+ args and kwargs: positional and optional args to RunCommand.
+
+ Returns:
+ cros_build_lib.CommandResult object.
+ """
if self.use_sudo:
return cros_build_lib.SudoRunCommand(*args, **kwargs)
else:
@@ -247,18 +254,16 @@
logging.debug('VM image path: %s', self.image_path)
def Run(self):
- """Performs an action, one of start, stop, or run a command in the VM.
-
- Returns:
- cmd output.
- """
-
+ """Performs an action, one of start, stop, or run a command in the VM."""
if not self.start and not self.stop and not self.cmd:
raise VMError('Must specify one of start, stop, or cmd.')
+
if self.start:
self.Start()
if self.cmd:
- return self.RemoteCommand(self.cmd)
+ if not self.IsRunning():
+ raise VMError('VM not running.')
+ self.RemoteCommand(self.cmd, stream_output=True)
if self.stop:
self.Stop()
@@ -416,6 +421,9 @@
cmd: command to run.
stream_output: Stream output of long-running commands.
kwargs: additional args (see documentation for RemoteDevice.RunCommand).
+
+ Returns:
+ cros_build_lib.CommandResult object.
"""
if not self.dry_run:
kwargs.setdefault('error_code_ok', True)