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= ./cros_au_test_harness.py -t \
      ~/chromiumos/images/chromiumos_test_image.bin \
      --test_prefix=SimpleTestVerify
Tried to run the test.

Exempt-From-Owner-Approval: achuit@ already +1'ed it.
Change-Id: Ib433b8b25bf3929b137e52e4ae97a47e21be1d2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crostestutils/+/1816809
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/au_test_harness/cros_au_test_harness.py b/au_test_harness/cros_au_test_harness.py
index 0bc03e7..54fb8fa 100755
--- a/au_test_harness/cros_au_test_harness.py
+++ b/au_test_harness/cros_au_test_harness.py
@@ -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. '
                       'testFullUpdateWipeStateful.')
-  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 @@
       raise
 
   with sudo.SudoKeepAlive():
-    if (opts.type == 'vm' or opts.type == 'gce') and opts.parallel:
+    if opts.parallel:
       _RunTestsInParallel(opts)
     else:
-      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/cros_au_test_harness_unittest.py b/au_test_harness/cros_au_test_harness_unittest.py
index 9d1734f..88ea5c2 100755
--- a/au_test_harness/cros_au_test_harness_unittest.py
+++ b/au_test_harness/cros_au_test_harness_unittest.py
@@ -25,7 +25,7 @@
 class CrosAuTestHarnessTest(unittest.TestCase):
   """Testing the GCE related funcionalities in cros_au_test_harness.py"""
 
-  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):