[autotest] netperf_runner: filter out 'catcher: timer popped ...'

I see a smattering of reports like these across the lab:

  MIGRATED TCP MAERTS TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.0.254 () port 12866 AF_INET
  catcher: timer popped with times_up != 0
  Recv   Send    Send
  Socket Socket  Message  Elapsed
  Size   Size    Size     Time     Throughput
  bytes  bytes   bytes    secs.    10^6bits/sec

  87380  16384  16384    2.00      207.87

Because we expected results to be on exactly the 6th or 7th line, this
trips us up with an exception:

  Unhandled IndexError: list index out of range

Looking at the netperf code, it seems like this can happen if, e.g.,
netperf gets a SIGINT at the same time as its timer alarm. Possibly for
other reasons too. In any case, all the results I've seen still look
valid, so let's ignore that warning.

While we're at it, make this slightly less fragile by avoiding
memorizing line numbers, and instead only process numeric lines.

BUG=chromium:889556
TEST=network_WiFi_Perf

Change-Id: I7d3ce90019851e9370b42d3ba39ec6d8f0266457
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1246840
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Kirtika Ruchandani <kirtika@chromium.org>
diff --git a/server/cros/network/netperf_runner.py b/server/cros/network/netperf_runner.py
index 61dff11..6b1158e 100644
--- a/server/cros/network/netperf_runner.py
+++ b/server/cros/network/netperf_runner.py
@@ -6,6 +6,7 @@
 import logging
 import math
 import numbers
+import re
 import time
 import os.path
 
@@ -27,6 +28,13 @@
 
         """
         lines = results.splitlines()
+
+        # Include only results lines, which should start with a number. This
+        # helps eliminate inconsistent output, e.g., from benign warnings
+        # like:
+        #   catcher: timer popped with times_up != 0
+        lines = [l for l in lines if re.match('[0-9]+', l.strip())]
+
         if test_type in NetperfConfig.TCP_STREAM_TESTS:
             """Parses the following (works for both TCP_STREAM, TCP_MAERTS and
             TCP_SENDFILE) and returns a singleton containing throughput.
@@ -40,11 +48,11 @@
 
             87380  16384  16384    2.00      941.28
             """
-            if len(lines) < 7:
+            if len(lines) < 1:
                 return None
 
             result = NetperfResult(test_type, duration_seconds,
-                                   throughput=float(lines[6].split()[4]))
+                                   throughput=float(lines[0].split()[4]))
         elif test_type in NetperfConfig.UDP_STREAM_TESTS:
             """Parses the following and returns a tuple containing throughput
             and the number of errors.
@@ -58,10 +66,10 @@
             129024   65507   2.00         3673      0     961.87
             131072           2.00         3673            961.87
             """
-            if len(lines) < 6:
+            if len(lines) < 1:
                 return None
 
-            udp_tokens = lines[5].split()
+            udp_tokens = lines[0].split()
             result = NetperfResult(test_type, duration_seconds,
                                    throughput=float(udp_tokens[5]),
                                    errors=float(udp_tokens[4]))
@@ -79,11 +87,11 @@
             16384  87380  1        1       2.00     14118.53
             16384  87380
             """
-            if len(lines) < 7:
+            if len(lines) < 1:
                 return None
 
             result = NetperfResult(test_type, duration_seconds,
-                                   transaction_rate=float(lines[6].split()[5]))
+                                   transaction_rate=float(lines[0].split()[5]))
         else:
             raise error.TestFail('Invalid netperf test type: %r.' % test_type)