test: enable GUI tests on Linux, headless

This will enable four tests in case_wireshark_capture on Linux, two of
them require --capture-interface to be specified.

To enable headless mode, QT_QPA_PLATFORM=minimal is set. Unfortunately
this option causes a null pointer dereference crash on macOS and it also
fails on Windows (cause not investigated). So limit it to Linux for now.

Change-Id: Id05364571b2c9da38434e611d92642a1177700df
Reviewed-on: https://code.wireshark.org/review/31664
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Peter Wu 2019-01-21 19:26:06 +01:00
parent d90eab1240
commit 0751504db7
1 changed files with 15 additions and 3 deletions

View File

@ -132,9 +132,11 @@ def cmd_wireshark(program):
@fixtures.fixture(scope='session')
def wireshark_command(cmd_wireshark):
if sys.platform not in ('win32', 'darwin'):
# TODO check DISPLAY for X11 on Linux or BSD?
fixtures.skip('Wireshark GUI tests requires DISPLAY')
# Windows and macOS can always display the GUI. On Linux, headless mode is
# used, see QT_QPA_PLATFORM in the 'test_env' fixture.
if sys.platform not in ('win32', 'darwin', 'linux'):
if 'DISPLAY' not in os.environ:
fixtures.skip('Wireshark GUI tests requires DISPLAY')
return (cmd_wireshark, '-ogui.update.enabled:FALSE')
@ -263,6 +265,16 @@ def test_env(base_env, conf_path, request, dirs):
env['WIRESHARK_RUN_FROM_BUILD_DIRECTORY'] = '1'
env['WIRESHARK_QUIT_AFTER_CAPTURE'] = '1'
# Allow GUI tests to be run without opening windows nor requiring a Xserver.
# Set envvar QT_DEBUG_BACKINGSTORE=1 to save the window contents to a file
# in the current directory, output0000.png, output0001.png, etc. Note that
# this will overwrite existing files.
if sys.platform == 'linux':
# This option was verified working on Arch Linux with Qt 5.12.0-2 and
# Ubuntu 16.04 with libqt5gui5 5.5.1+dfsg-16ubuntu7.5. On macOS and
# Windows it unfortunately crashes (Qt 5.12.0).
env['QT_QPA_PLATFORM'] = 'minimal'
# Remove this if test instances no longer inherit from SubprocessTestCase?
if isinstance(request.instance, subprocesstest.SubprocessTestCase):
# Inject the test environment as default if it was not overridden.