cros_au_test_harness: Fix the issue with running vm/gce tests

CL:1808406 mistakenly removed the block to run the test if the
--parallel flag was not passed to the cros_au_test_harness (which we
don't pass it anyway). This CL puts that block back.

BUG=chromium:1006799, chromium:1006777
TEST=lakitu paladin tryjob
TEST= ./ -t \
      ~/chromiumos/images/chromiumos_test_image.bin \
Tried to run the test.

Exempt-From-Owner-Approval: achuit@ already +1'ed it.
Change-Id: Ib433b8b25bf3929b137e52e4ae97a47e21be1d2f
Commit-Queue: Amin Hassani <>
Tested-by: Amin Hassani <>
Reviewed-by: Sean Abraham <>
Reviewed-by: Mike Frysinger <>
diff --git a/au_test_harness/ b/au_test_harness/
index 0bc03e7..54fb8fa 100755
--- a/au_test_harness/
+++ b/au_test_harness/
@@ -109,9 +109,6 @@
     opts: Parsed opts.
-  if not opts.type in ['vm', 'gce']:
-    parser.error('Failed to specify valid test type.')
   def _IsValidImage(image):
     """Asserts that |image_path| is a valid image file for |opts.type|."""
     return (image is not None) and os.path.isfile(image)
@@ -179,7 +176,7 @@
   parser.add_argument('--test_prefix', default='test',
                       help='Only runs tests with specific prefix i.e. '
-  parser.add_argument('-p', '--type', default='vm',
+  parser.add_argument('-p', '--type', default='vm', choices=('vm', 'gce'),
                       help='type of test to run: [vm, gce]. Default: vm.')
   parser.add_argument('--verbose', default=True, action='store_true',
                       help='Print out rather than capture output as much as '
@@ -213,11 +210,13 @@
   with sudo.SudoKeepAlive():
-    if (opts.type == 'vm' or opts.type == 'gce') and opts.parallel:
+    if opts.parallel:
-      cros_build_lib.Die('Test harness failed. unsupported test type %s' %
-                         opts.type)
+      test_suite = _PrepareTestSuite(opts)
+      test_result = unittest.TextTestRunner().run(test_suite)
+      if not test_result.wasSuccessful():
+        cros_build_lib.Die('Test harness failed.')
 if __name__ == '__main__':
diff --git a/au_test_harness/ b/au_test_harness/
index 9d1734f..88ea5c2 100755
--- a/au_test_harness/
+++ b/au_test_harness/
@@ -25,7 +25,7 @@
 class CrosAuTestHarnessTest(unittest.TestCase):
   """Testing the GCE related funcionalities in"""
-  INVALID_TYPE_ERROR = 'Failed to specify valid test type.'
+  INVALID_TYPE_ERROR = 'error: argument -p/--type: invalid choice'
   INVALID_IMAGE_PATH = 'Testing requires a valid target image.'
   def testCheckOptionsDisallowsUndefinedType(self):