summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-03-04 09:39:06 +0100
committerFlorian Bruhin <me@the-compiler.org>2022-03-04 09:39:06 +0100
commit941627d778f5311477c93ce13603dcbadde2b5d5 (patch)
tree125c9c38733d5ea78bbf32fe6b4115f0357a5d86
parent8fe1de2fdcdf03cd3f460e6abc5eb3a09fdbaa43 (diff)
downloadqutebrowser-941627d778f5311477c93ce13603dcbadde2b5d5.tar.gz
qutebrowser-941627d778f5311477c93ce13603dcbadde2b5d5.zip
Refactor tests to use new sandbox setting
-rw-r--r--tests/conftest.py5
-rw-r--r--tests/end2end/fixtures/quteprocess.py4
-rw-r--r--tests/end2end/test_invocations.py4
-rw-r--r--tests/helpers/testutils.py16
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):