ext,test: Provide default terminal size
authorJason Lowe-Power <jason@lowepower.com>
Tue, 12 Mar 2019 16:01:09 +0000 (09:01 -0700)
committerJason Lowe-Power <jason@lowepower.com>
Thu, 21 Mar 2019 15:57:10 +0000 (15:57 +0000)
When creating the separator for printing things to the terminal (=.*) we
use an ioctl that isn't supported in some sandboxed environments. When
running on the Google jenkins server (kokoro) it errors with an IOError.

Change-Id: I148dd87cffe6e93d6723a386aecf9a9ea6c5b455
Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17449
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

ext/testlib/terminal.py

index 3afbb42a2f2fc7466ee40f7a721cf409cf5a387e..bdb20edea47228dc39b45dfe76eb09a82262a6f9 100644 (file)
@@ -106,10 +106,16 @@ def get_termcap(use_colors = None):
 
 def terminal_size():
     '''Return the (width, heigth) of the terminal screen.'''
-    h, w, hp, wp = struct.unpack('HHHH',
-        fcntl.ioctl(0, termios.TIOCGWINSZ,
-        struct.pack('HHHH', 0, 0, 0, 0)))
-    return w, h
+    try:
+        h, w, hp, wp = struct.unpack('HHHH',
+            fcntl.ioctl(0, termios.TIOCGWINSZ,
+            struct.pack('HHHH', 0, 0, 0, 0)))
+        return w, h
+    except IOError:
+        # It's possible that in sandboxed environments the above ioctl is not
+        # allowed (e.g., some jenkins setups)
+        return 80, 24
+
 
 def separator(char=default_separator, color=None):
     '''