vm_au_worker: Output to stdout

Background is we like to run long run vmtest for informational purpose.
To prevent builder from stop working, we need to continuously output
things to stdout.

This CL Makes vm_au_worker output test result to stdout directly if
verbose is set.

BUG=chromium:750374
TEST=run ctest locally
TEST=tryjob (Done)

Change-Id: I7c0b9a95411602ed094cb95ca711125ff76e0598
Reviewed-on: https://chromium-review.googlesource.com/646946
Commit-Ready: Po-Hsien Wang <pwang@chromium.org>
Tested-by: Po-Hsien Wang <pwang@chromium.org>
Reviewed-by: Daniel Wang <wonderfly@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/au_test_harness/vm_au_worker.py b/au_test_harness/vm_au_worker.py
index 64cc0f2..aef8987 100644
--- a/au_test_harness/vm_au_worker.py
+++ b/au_test_harness/vm_au_worker.py
@@ -25,6 +25,7 @@
     """Processes vm-specific options."""
     super(VMAUWorker, self).__init__(options, test_results_root)
     self.graphics_flag = ''
+    self.verbose = options.verbose
     if options.no_graphics:
       self.graphics_flag = '--no_graphics'
     if not self.board:
@@ -190,13 +191,17 @@
     if self.ssh_private_key is not None:
       command.append('--ssh_private_key=%s' % self.ssh_private_key)
 
-    self.TestInfo('Running smoke suite to verify image.')
-    result = cros_build_lib.RunCommand(
-        command, print_cmd=False, combine_stdout_stderr=True,
-        cwd=constants.CROSUTILS_DIR, error_code_ok=True,
-        capture_output=True)
+    self.TestInfo('Running %s suite to verify image.' % test)
 
+    result = cros_build_lib.RunCommand(
+        command, print_cmd=self.verbose, combine_stdout_stderr=True,
+        cwd=constants.CROSUTILS_DIR, error_code_ok=True,
+        capture_output=not self.verbose)
     # If the command failed or printed warnings, print the output.
+    # TODO(pwang): result.output should contain the output of the command even
+    # though verbose is set to print to stdout.
+    if result.output is None:
+      result.output = ''
     if result.returncode != 0 or '@@@STEP_WARNINGS@@@' in result.output:
       print(result.output)
       self._HandleFail(log_directory, fail_directory)