GTS waivers fix.

This change makes it so that waivers are applied to GTS on ARM and x86.

BUG=b:32616452
TEST=test_that <ip> cheets_GTS.3.0r6.google.placement (cyan and minnie)
TEST=test_that <ip> cheets_CTS.6.0_r9.arm.android.app

Change-Id: I50ae5822c32d610e75615541830361281431be59
Reviewed-on: https://chromium-review.googlesource.com/407056
Commit-Ready: David Haddock <dhaddock@chromium.org>
Tested-by: David Haddock <dhaddock@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
(cherry picked from commit 16712330357a0919018f3360e2e2200b77684a64)
Reviewed-on: https://chromium-review.googlesource.com/413091
Reviewed-by: David Haddock <dhaddock@chromium.org>
diff --git a/server/cros/tradefed_test.py b/server/cros/tradefed_test.py
index e818ab6..79c6ec6 100644
--- a/server/cros/tradefed_test.py
+++ b/server/cros/tradefed_test.py
@@ -575,14 +575,24 @@
         # only parse for waivers for the running ABI.
         if waivers:
             for testname in waivers:
-                if testname + ' FAIL' in result.stdout:
-                    failed -= 1
+                # 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.')
+                    failed -= fail_count
                     # To maintain total count consistency.
-                    passed += 1
-                    logging.info('Waived failure %s', testname)
-
+                    passed += 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',
                 tests, passed, failed, not_executed)
+        if failed < 0:
+            raise error.TestFail('Error: Internal waiver book keeping has '
+                                 'become inconsistent.')
         return (tests, passed, failed, not_executed)
 
     def _collect_logs(self, repository, datetime, destination):