diff options
author | Jason Lowe-Power <jason@lowepower.com> | 2019-03-12 09:01:09 -0700 |
---|---|---|
committer | Jason Lowe-Power <jason@lowepower.com> | 2019-03-21 15:57:10 +0000 |
commit | f871fd33e11f9c989a865db20d2e478b0b4418b5 (patch) | |
tree | a624de10101674a259c5745ccb6ac5928f10e5de /ext/testlib | |
parent | 541d89953a4d2264702b90204ed91bb589a056ae (diff) | |
download | gem5-f871fd33e11f9c989a865db20d2e478b0b4418b5.tar.xz |
ext,test: Provide default terminal size
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>
Diffstat (limited to 'ext/testlib')
-rw-r--r-- | ext/testlib/terminal.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/testlib/terminal.py b/ext/testlib/terminal.py index 3afbb42a2..bdb20edea 100644 --- a/ext/testlib/terminal.py +++ b/ext/testlib/terminal.py @@ -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): ''' |