Remove v1 code for parse_result and parse_datetime.

The code is not being used anywhere. I've renamed the v2 functions to just
be parse_result and parse_datetime.

BUG=None
TEST=test_that <IP> cheets_CTS_N.x86.CtsDumpsysHostTestCases
TEST=test_that <IP> cheets_GTS.5.0_r2.GtsPlacementTestCases

Change-Id: Id5e595218d5494890927c11929099a5b3650f459
Reviewed-on: https://chromium-review.googlesource.com/770838
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Ilja H. Friedel <ihf@chromium.org>
diff --git a/server/cros/tradefed_test.py b/server/cros/tradefed_test.py
index 0258be5..b8a68e6 100644
--- a/server/cros/tradefed_test.py
+++ b/server/cros/tradefed_test.py
@@ -244,8 +244,8 @@
         os.chdir(current)
 
 
-def parse_tradefed_v2_result(result, waivers=None):
-    """Check the result from the tradefed-v2 output.
+def parse_tradefed_result(result, waivers=None):
+    """Check the result from the tradefed output.
 
     @param result: The result stdout string from the tradefed command.
     @param waivers: a set() of tests which are permitted to fail.
@@ -856,41 +856,6 @@
                              Example: '2016.07.14_00.34.50'.
         """
         # This string is show for both 'run' and 'continue' after all tests.
-        match = re.search(r': XML test result file generated at (\S+). Passed',
-                result.stdout)
-        if not (match and match.group(1)):
-            # TODO(ihf): Find out if we ever recover something interesting in
-            # this case. Otherwise delete it.
-            # Try harder to find the remains. This string shows before all
-            # tests but only with 'run', not 'continue'.
-            logging.warning('XML test result file incomplete?')
-            match = re.search(r': Created result dir (\S+)', result.stdout)
-            if not (match and match.group(1)):
-                error_msg = 'Test did not complete due to Chrome or ARC crash.'
-                if summary:
-                    error_msg += (' Test summary from previous runs: %s'
-                            % summary)
-                raise error.TestFail(error_msg)
-        datetime_id = match.group(1)
-        logging.info('Tradefed identified results and logs with %s.',
-                     datetime_id)
-        return datetime_id
-
-    def _parse_tradefed_datetime_v2(self, result, summary=None):
-        """Get the tradefed provided result ID consisting of a datetime stamp.
-
-        Unfortunately we are unable to tell tradefed where to store the results.
-        In the lab we have multiple instances of tradefed running in parallel
-        writing results and logs to the same base directory. This function
-        finds the identifier which tradefed used during the current run and
-        returns it for further processing of result files.
-
-        @param result: The result object from utils.run.
-        @param summary: Test result summary from runs so far.
-        @return datetime_id: The result ID chosen by tradefed.
-                             Example: '2016.07.14_00.34.50'.
-        """
-        # This string is show for both 'run' and 'continue' after all tests.
         match = re.search(r'(\d\d\d\d.\d\d.\d\d_\d\d.\d\d.\d\d)', result.stdout)
         if not (match and match.group(1)):
             error_msg = 'Error: Test did not complete. (Chrome or ARC crash?)'
@@ -912,60 +877,7 @@
         @param result: The result object from utils.run.
         @param waivers: a set() of tests which are permitted to fail.
         """
-        # Parse the stdout to extract test status. In particular step over
-        # similar output for each ABI and just look at the final summary.
-        match = re.search(r'(XML test result file generated at (\S+). '
-                 r'Passed (\d+), Failed (\d+), Not Executed (\d+))',
-                 result.stdout)
-        if not match:
-            raise error.Test('Test log does not contain a summary.')
-
-        passed = int(match.group(3))
-        failed = int(match.group(4))
-        not_executed = int(match.group(5))
-        match = re.search(r'(Start test run of (\d+) packages, containing '
-                          r'(\d+(?:,\d+)?) tests)', result.stdout)
-        if match and match.group(3):
-            tests = int(match.group(3).replace(',', ''))
-        else:
-            # Unfortunately this happens. Assume it made no other mistakes.
-            logging.warning('Tradefed forgot to print number of tests.')
-            tests = passed + failed + not_executed
-        # TODO(rohitbm): make failure parsing more robust by extracting the list
-        # of failing tests instead of searching in the result blob. As well as
-        # only parse for waivers for the running ABI.
-        waived = 0
-        if waivers:
-            for testname in waivers:
-                # TODO(dhaddock): Find a more robust way to apply waivers.
-                fail_count = result.stdout.count(testname + ' FAIL')
-                if fail_count:
-                    if fail_count > 2:
-                        raise error.TestFail('Error: There are too many '
-                                             'failures found in the output to '
-                                             'be valid for applying waivers. '
-                                             'Please check output.')
-                    waived += fail_count
-                    logging.info('Waived failure for %s %d time(s)',
-                                 testname, fail_count)
-        logging.info(
-            'tests=%d, passed=%d, failed=%d, not_executed=%d, waived=%d',
-            tests, passed, failed, not_executed, waived)
-        if failed < waived:
-            raise error.TestFail('Error: Internal waiver book keeping has '
-                                 'become inconsistent.')
-        return (tests, passed, failed, not_executed, waived)
-
-    def _parse_result_v2(self, result, waivers=None):
-        """Check the result from the tradefed-v2 output.
-
-        This extracts the test pass/fail/executed list from the output of
-        tradefed. It is up to the caller to handle inconsistencies.
-
-        @param result: The result object from utils.run.
-        @param waivers: a set() of tests which are permitted to fail.
-        """
-        return parse_tradefed_v2_result(result.stdout, waivers)
+        return parse_tradefed_result(result.stdout, waivers)
 
     def _collect_logs(self, datetime, destination):
         """Collects the tradefed logs.
@@ -1108,12 +1020,12 @@
         self._collect_tradefed_global_log(output, result_destination)
         # Parse stdout to obtain datetime of the session. This is needed to
         # locate result xml files and logs.
-        datetime_id = self._parse_tradefed_datetime_v2(output, self.summary)
+        datetime_id = self._parse_tradefed_datetime(output, self.summary)
         # Collect tradefed logs for autotest.
         self._collect_logs(datetime_id, result_destination)
         # Result parsing must come after all other essential operations as test
         # warnings, errors and failures can be raised here.
-        return self._parse_result_v2(output, waivers=self._waivers)
+        return self._parse_result(output, waivers=self._waivers)
 
     def _clean_repository(self):
         """Ensures all old logs, results and plans are deleted.
diff --git a/server/cros/tradefed_test_unittest.py b/server/cros/tradefed_test_unittest.py
index 7e7e127..ef28287 100644
--- a/server/cros/tradefed_test_unittest.py
+++ b/server/cros/tradefed_test_unittest.py
@@ -17,8 +17,8 @@
 class TradefedTestTest(unittest.TestCase):
     """Unittest for tradefed_test."""
 
-    def test_parse_tradefed_v2_result(self):
-        """Test for parse_tradefed_v2_result."""
+    def test_parse_tradefed_result(self):
+        """Test for parse_tradefed_result."""
 
         waivers = set([
             'android.app.cts.SystemFeaturesTest#testUsbAccessory',
@@ -30,7 +30,7 @@
         # CTS: Tradefed may split a module to multiple chunks.
         # Besides, the module name may not end with "TestCases".
         self.assertEquals((35, 33, 2, 0, 0),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsHostsideNetworkTests.txt'),
                 waivers=waivers))
 
@@ -38,7 +38,7 @@
         # http://pantheon/storage/browser/chromeos-autotest-results/108291418-chromeos-test/
         # Crashed, but the automatic retry by tradefed executed the rest.
         self.assertEquals((1395, 1386, 9, 0, 0),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsMediaTestCases.txt'),
                 waivers=waivers))
 
@@ -46,7 +46,7 @@
         # http://pantheon/storage/browser/chromeos-autotest-results/106540705-chromeos-test/
         # Crashed in the middle, and the device didn't came back.
         self.assertEquals((110, 27, 1, 82, 0),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsSecurityTestCases.txt'),
                 waivers=waivers))
 
@@ -54,7 +54,7 @@
         # http://pantheon/storage/browser/chromeos-autotest-results/108855595-chromeos-test/
         # Crashed in the middle. Tradefed decided not to continue.
         self.assertEquals((739, 573, 3, 163, 0),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsViewTestCases.txt'),
                 waivers=waivers))
 
@@ -62,12 +62,12 @@
         # http://pantheon/storage/browser/chromeos-autotest-results/109040174-chromeos-test/
         # Mixture of real failures and waivers.
         self.assertEquals((321, 316, 5, 0, 1),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsAppTestCases.txt'),
                 waivers=waivers))
         # ... and the retry of the above failing iteration.
         self.assertEquals((5, 1, 4, 0, 1),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsAppTestCases-retry.txt'),
                 waivers=waivers))
 
@@ -75,7 +75,7 @@
         # When a test case crashed during teardown, tradefed prints the "fail"
         # message twice. Tolerate it and still return an (inconsistent) count.
         self.assertEquals((1194, 1185, 10, 0, 2),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsWidgetTestCases.txt'),
                 waivers=waivers))
 
@@ -83,7 +83,7 @@
         # When a test case unrecoverably crashed during teardown, tradefed
         # prints the "fail" and failure summary message twice. Tolerate it.
         self.assertEquals((71, 70, 1, 0, 0),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsPrintTestCases.txt'),
                 waivers=waivers))
 
@@ -99,7 +99,7 @@
         # http://pantheon/storage/browser/chromeos-autotest-results/130080763-chromeos-test/
         # 3 ABIS: x86, x86_64, and armeabi-v7a
         self.assertEquals((15, 6, 9, 0, 9),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('GtsPlacementTestCases.txt'),
                 waivers=gts_waivers))
 
@@ -108,7 +108,7 @@
         # The result of the last chunk not reported by tradefed.
         # The actual dEQP log is too big, hence the test data here is trimmed.
         self.assertEquals((157871, 116916, 0, 40955, 0),
-            tradefed_test.parse_tradefed_v2_result(
+            tradefed_test.parse_tradefed_result(
                 _load_data('CtsDeqpTestCases-trimmed.txt'),
                 waivers=waivers))