From 16efcd4f9a0fb7697b0ba6c2b0bdc61f3432e22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 15 Jun 2024 22:39:09 +0200 Subject: [PATCH] Stop using xvfb-run in tests Except the X11 backend test, it still needs an X server. Eventually we can replace it with the equivalent that uses Xwayland, but that needs a "scaled down" mutter that runs as the host compositor for Xwayland, that doesn't expose anything on the session bus. Part-of: --- .gitlab-ci.yml | 39 +++++++++++++++++++------------------- doc/debugging.md | 4 +--- meson.build | 16 ++++++++-------- src/tests/meson.build | 8 +++++++- src/tests/stacking.test.in | 2 +- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e5bccb47..7763491e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -516,18 +516,18 @@ build-wayland-only@x86_64: - .test-mutter-base script: - glib-compile-schemas $GSETTINGS_SCHEMA_DIR - - xvfb-run -a -s "$XVFB_SERVER_ARGS" - ./src/tests/meta-dbus-runner.py - --launch=pipewire - --launch=wireplumber - -- - meson test - -C build - --setup plain - --no-suite 'mutter/kvm' - --no-rebuild - --timeout-multiplier 10 - --print-errorlogs + - mkdir -m 1777 /tmp/.X11-unix + - ./src/tests/meta-dbus-runner.py + --launch=pipewire + --launch=wireplumber + -- + meson test + -C build + --setup plain + --no-suite 'mutter/kvm' + --no-rebuild + --timeout-multiplier 10 + --print-errorlogs artifacts: reports: junit: "build/meson-logs/testlog-plain.junit.xml" @@ -614,7 +614,8 @@ can-run-gnome-shell@x86_64: - .gitlab-ci/checkout-gnome-shell.sh - meson setup gnome-shell gnome-shell/build --prefix /usr -Dbuildtype=debugoptimized -Dman=false --werror --fatal-meson-warnings - sudo meson install -C gnome-shell/build - - dbus-run-session -- xvfb-run meson test -C gnome-shell/build --no-rebuild --timeout-multiplier 5 + - mkdir -m 1777 /tmp/.X11-unix + - dbus-run-session -- meson test -C gnome-shell/build --no-rebuild --timeout-multiplier 5 artifacts: expire_in: 7 day name: "mutter-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" @@ -685,12 +686,12 @@ dist-mutter: - meson setup . build --werror --prefix /usr -Dbuildtype=debugoptimized - glib-compile-schemas $GSETTINGS_SCHEMA_DIR - - xvfb-run -a -s "$XVFB_SERVER_ARGS" - ./src/tests/meta-dbus-runner.py - --launch=pipewire - --launch=wireplumber - -- - meson dist -C build + - mkdir -m 1777 /tmp/.X11-unix + - ./src/tests/meta-dbus-runner.py + --launch=pipewire + --launch=wireplumber + -- + meson dist -C build artifacts: expire_in: 7 day name: "mutter-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" diff --git a/doc/debugging.md b/doc/debugging.md index fb6752315..23f4583a7 100644 --- a/doc/debugging.md +++ b/doc/debugging.md @@ -92,11 +92,9 @@ Renderdoc is usually the better tool to debug something with, but it's also hard ```sh export XDG_RUNTIME_DIR=$PWD/runtime-dir mkdir -p $XDG_RUNTIME_DIR - ./src/tests/meta-dbus-runner.py xvfb-run meson test -C build --setup plain --gdb failing-test-case + ./src/tests/meta-dbus-runner.py meson test -C build --setup plain --gdb failing-test-case ``` - The need for `xvfb-run` depends on whether the test case uses the nested backend or the headless backend. - If it involves screen casting, it becomes a bit more complicated: ```sh diff --git a/meson.build b/meson.build index 0a15def9e..9f18f33c1 100644 --- a/meson.build +++ b/meson.build @@ -351,6 +351,7 @@ have_native_tests = false have_kvm_tests = false have_tty_tests = false have_installed_tests = false +have_x11_tests = false if have_tests gtk3_dep = dependency('gtk+-3.0', version: gtk3_req) @@ -417,13 +418,12 @@ if have_tests add_test_setup('plain') - xvfb = find_program('xvfb-run') - xvfb_args = [ - '-a', - '-s', - '+iglx -noreset', - ] - xvfb_command = [xvfb] + xvfb_args + if have_x11 + xvfb = find_program('xvfb-run', required: false) + if xvfb.found() + have_x11_tests = true + endif + endif add_test_setup('CI', env: [ @@ -431,7 +431,6 @@ if have_tests ], exe_wrapper: [ default_test_wrappers, - xvfb_command, ], timeout_multiplier: 10, ) @@ -759,5 +758,6 @@ summary('Core tests', have_core_tests, section: 'Tests') summary('Cogl tests', have_cogl_tests, section: 'Tests') summary('Clutter tests', have_clutter_tests, section: 'Tests') summary('KVM tests', get_option('kvm_tests'), section: 'Tests') +summary('X11 backend', have_x11_tests, section: 'Tests') summary('Installed tests', have_installed_tests, section: 'Tests') summary('Coverage', get_option('b_coverage'), section: 'Tests') diff --git a/src/tests/meson.build b/src/tests/meson.build index 757bb2cf2..f8bc50993 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -828,7 +828,13 @@ if have_kvm_tests or have_tty_tests endif endif -if have_x11 +if have_x11_tests + xvfb_args = [ + '-a', + '-s', + '+iglx -noreset', + ] + foreach mode: ['', 'sync'] x11_env = test_env if mode == 'sync' diff --git a/src/tests/stacking.test.in b/src/tests/stacking.test.in index 63438da6d..2cc229f34 100644 --- a/src/tests/stacking.test.in +++ b/src/tests/stacking.test.in @@ -4,6 +4,6 @@ Description=Mutter stacking test: @stacking_test@ # a solution for # https://gitlab.gnome.org/GNOME/gnome-desktop-testing/-/issues/1, # and anyway that wouldn't be sufficient to handle XDG_RUNTIME_DIR -Exec=sh -ec 'env GSETTINGS_BACKEND=memory XDG_CURRENT_DESKTOP= XDG_RUNTIME_DIR="$(mktemp -d -t mutter-@apiversion@-@stacking_test@-XXXXXX)" @libexecdir@/installed-tests/mutter-@apiversion@/mutter-installed-dbus-session.py xvfb-run -a -s "+iglx -noreset" -- @libexecdir@/installed-tests/mutter-@apiversion@/mutter-test-runner @tests_datadir@/stacking/@stacking_test@.metatest' +Exec=sh -ec 'env GSETTINGS_BACKEND=memory XDG_CURRENT_DESKTOP= XDG_RUNTIME_DIR="$(mktemp -d -t mutter-@apiversion@-@stacking_test@-XXXXXX)" @libexecdir@/installed-tests/mutter-@apiversion@/mutter-installed-dbus-session.py -- @libexecdir@/installed-tests/mutter-@apiversion@/mutter-test-runner @tests_datadir@/stacking/@stacking_test@.metatest' Type=session Output=TAP