tests: Add a timeout to getremotetime
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 17 Jan 2020 19:48:40 +0000 (19:48 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 21 Jan 2020 13:54:52 +0000 (13:54 +0000)
The helper is meant to check if the local binary is younger than the
remote binary (on gem5.org). If the call fails it is giving up and
it is just using the local regression (producing a warning).
The code is not handling the blocking behaviour of the connection:
simulaton might stall indefinitely
The patch is addressing this by providing a 10 seconds timeout.

Change-Id: I8f9c2e555c9a55d850a66d02f8e55f56ceda2ca3
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24531
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

tests/gem5/fixture.py

index ddf43d17d3e2fa7595c7c7f47ec6bc610c2b0fd4..c22d1a33453da5c7a3dada7393c655666adeadbb 100644 (file)
@@ -43,6 +43,7 @@ import os
 import tempfile
 import shutil
 import sys
+import socket
 import threading
 import urllib
 import urllib2
@@ -282,7 +283,7 @@ class DownloadedProgram(UniqueFixture):
         import datetime, time
         import _strptime # Needed for python threading bug
 
-        u = urllib2.urlopen(self.url)
+        u = urllib2.urlopen(self.url, timeout=10)
         return time.mktime(datetime.datetime.strptime( \
                     u.info().getheaders("Last-Modified")[0],
                     "%a, %d %b %Y %X GMT").timetuple())
@@ -294,7 +295,7 @@ class DownloadedProgram(UniqueFixture):
         else:
             try:
                 t = self._getremotetime()
-            except urllib2.URLError:
+            except (urllib2.URLError, socket.timeout):
                 # Problem checking the server, use the old files.
                 log.test_log.debug("Could not contact server. Binaries may be old.")
                 return
@@ -320,7 +321,7 @@ class DownloadedArchive(DownloadedProgram):
         else:
             try:
                 t = self._getremotetime()
-            except urllib2.URLError:
+            except (urllib2.URLError, socket.timeout):
                 # Problem checking the server, use the old files.
                 log.test_log.debug("Could not contact server. "
                                    "Binaries may be old.")