[autotest] site_linux_router: guard against empty syslog

If /var/log/messages delivers an empty line, .split() will deliver an
empty list, and so we hit this error:

      File "/usr/local/autotest/server/site_linux_router.py", line 194, in __setup
        self._log_start_timestamp = last_log_line.strip().split(None, 2)[0]
    IndexError: list index out of range

It's safer to use .partition(), which guarantees we'll get a result. And
if that result is just an empty string, replace it with a wildcard
regex.

BUG=chromium:889556
TEST=truncate /var/log/messages on router, run network_WiFi_* tests

Change-Id: I369649121658f41fb3deff4f9be32af54bf1f14a
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1246688
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Kirtika Ruchandani <kirtika@chromium.org>
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 37fa42e..2c9c178 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -191,9 +191,15 @@
         last_log_line = self.host.run('tail -1 /var/log/messages').stdout
         # We're trying to get the timestamp from:
         # 2014-07-23T17:29:34.961056+00:00 localhost kernel: blah blah blah
-        self._log_start_timestamp = last_log_line.strip().split(None, 2)[0]
-        logging.debug('Will only retrieve logs after %s.',
-                      self._log_start_timestamp)
+        self._log_start_timestamp = last_log_line.strip().partition(' ')[0]
+        if self._log_start_timestamp:
+            logging.debug('Will only retrieve logs after %s.',
+                          self._log_start_timestamp)
+        else:
+            # If syslog is empty, we just use a wildcard pattern, to grab
+            # everything.
+            logging.debug('Empty or corrupt log; will retrieve whole log')
+            self._log_start_timestamp = '.'
 
         # hostapd configuration persists throughout the test, subsequent
         # 'config' commands only modify it.