From 941627d778f5311477c93ce13603dcbadde2b5d5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 4 Mar 2022 09:39:06 +0100 Subject: Refactor tests to use new sandbox setting --- tests/conftest.py | 5 ++--- tests/end2end/fixtures/quteprocess.py | 4 ++-- tests/end2end/test_invocations.py | 4 ++-- tests/helpers/testutils.py | 16 +++++++--------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ad82b4f24..84cae784b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -194,9 +194,8 @@ def pytest_ignore_collect(path): @pytest.fixture(scope='session') def qapp_args(): """Make QtWebEngine unit tests run on older Qt versions + newer kernels.""" - seccomp_args = testutils.seccomp_args(qt_flag=False) - if seccomp_args: - return [sys.argv[0]] + seccomp_args + if testutils.disable_seccomp_bpf_sandbox(): + return [sys.argv[0], testutils.DISABLE_SECCOMP_BPF_FLAG] return [] diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 14f34b52c..ab8f28d26 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -549,8 +549,8 @@ class QuteProc(testprocess.Process): '--debug-flag', 'werror', '--debug-flag', 'test-notification-service'] - if self.request.config.webengine: - args += testutils.seccomp_args(qt_flag=True) + if self.request.config.webengine and testutils.disable_seccomp_bpf_sandbox(): + args += testutils.DISABLE_SECCOMP_BPF_ARGS args.append('about:blank') return args diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 0e252b741..c3f5bddbc 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -56,8 +56,8 @@ def _base_args(config): else: args += ['--backend', 'webkit'] - if config.webengine: - args += testutils.seccomp_args(qt_flag=True) + if config.webengine and testutils.disable_seccomp_bpf_sandbox(): + args += testutils.DISABLE_SECCOMP_BPF_ARGS args.append('about:blank') return args diff --git a/tests/helpers/testutils.py b/tests/helpers/testutils.py index 8bb622133..9079ae069 100644 --- a/tests/helpers/testutils.py +++ b/tests/helpers/testutils.py @@ -267,14 +267,15 @@ def easyprivacy_txt(): return _decompress_gzip_datafile("easyprivacy.txt.gz") -def seccomp_args(qt_flag): - """Get necessary flags to disable the seccomp BPF sandbox. +DISABLE_SECCOMP_BPF_FLAG = "--disable-seccomp-filter-sandbox" +DISABLE_SECCOMP_BPF_ARGS = ["-s", "qt.chromium.sandboxing", "disable-seccomp-bpf"] + + +def disable_seccomp_bpf_sandbox(): + """Check whether we need to disable the seccomp BPF sandbox. This is needed for some QtWebEngine setups, with older Qt versions but newer kernels. - - Args: - qt_flag: Add a '--qt-flag' argument. """ affected_versions = set() for base, patch_range in [ @@ -291,11 +292,8 @@ def seccomp_args(qt_flag): version = (PYQT_WEBENGINE_VERSION_STR if PYQT_WEBENGINE_VERSION_STR is not None else qVersion()) - if version in affected_versions: - disable_arg = 'disable-seccomp-filter-sandbox' - return ['--qt-flag', disable_arg] if qt_flag else ['--' + disable_arg] - return [] + return version in affected_versions def import_userscript(name): -- cgit v1.2.3-54-g00ecf