[mutter] tests: Add basic X11 WM test



commit 57d3b5225eec29c8b10fbfa80323b65bc8e85599
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri May 27 17:12:46 2022 +0200

    tests: Add basic X11 WM test
    
    This launches Xvfb, using xvfb-run, and inside tests the following:
    
      1. Launching 'mutter --x11' works
      2. Launching a couple of X11 clients works (doesn't crash or result in
         warnings)
      3. Launching 'mutter --x11 --replace' works
      4. Terminating works
    
    It does this using a simple shell script.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2434>

 meson.build           | 10 +++++++++-
 src/meson.build       |  2 +-
 src/tests/meson.build | 15 +++++++++++++++
 src/tests/x11-test.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index be2909c2c4..d5d719f161 100644
--- a/meson.build
+++ b/meson.build
@@ -362,13 +362,21 @@ if have_tests
 
   add_test_setup('plain')
 
+  xvfb = find_program('xvfb-run')
+  xvfb_args = [
+    '-a',
+    '-s',
+    '+iglx -noreset',
+  ]
+  xvfb_command = [xvfb] + xvfb_args
+
   add_test_setup('CI',
     env: [
       'MUTTER_DEBUG_DUMMY_MODE_SPECS=800x600@10.0',
     ],
     exe_wrapper: [
       default_test_wrappers,
-      find_program('xvfb-run'), '-a', '-s', '+iglx -noreset',
+      xvfb_command,
     ],
     timeout_multiplier: 10,
   )
diff --git a/src/meson.build b/src/meson.build
index 42d7a5a55f..f752f03d96 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1050,7 +1050,7 @@ libmutter_dep = declare_dependency(
   ],
 )
 
-executable('mutter',
+mutter = executable('mutter',
   sources: [
     files('core/mutter.c'),
   ],
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 2ff70832a6..5ba321e0d2 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -409,3 +409,18 @@ if have_kvm_tests or have_tty_tests
     endforeach
   endif
 endif
+
+if have_x11
+  test('x11', xvfb,
+    args: [
+      xvfb_args,
+      find_program('x11-test.sh').full_path(),
+      mutter.full_path(),
+    ],
+    depends: [mutter],
+    suite: ['core', 'mutter/x11'],
+    env: test_env,
+    is_parallel: false,
+    timeout: 60,
+  )
+endif
diff --git a/src/tests/x11-test.sh b/src/tests/x11-test.sh
new file mode 100755
index 0000000000..376a01961d
--- /dev/null
+++ b/src/tests/x11-test.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/bash
+
+set -e
+
+MUTTER="$1"
+
+if [ -z "$MUTTER" ]; then
+  echo Usage: $0 PATH-TO-MUTTER > /dev/stderr
+  exit 1
+fi
+
+export GDK_BACKEND=x11
+export G_DEBUG=fatal-warnings
+
+echo \# Launching mutter > /dev/stderr
+$MUTTER --x11 --mutter-plugin="$MUTTER_TEST_PLUGIN_PATH" &
+MUTTER1_PID=$!
+gdbus wait --session org.gnome.Mutter.IdleMonitor
+echo \# Launched with pid $MUTTER1_PID
+
+sleep 2
+
+echo Launching a couple of X11 clients > /dev/stderr
+zenity --warning &
+ZENITY1_PID=$!
+sleep 2
+zenity --info &
+ZENITY2_PID=$!
+sleep 4
+
+echo \# Replacing existing mutter with a new instance > /dev/stderr
+$MUTTER --x11 --replace --mutter-plugin="$MUTTER_TEST_PLUGIN_PATH" &
+echo \# Launched with pid $MUTTER2_PID
+MUTTER2_PID=$!
+wait $MUTTER1_PID
+
+sleep 2
+
+echo \# Terminating clients > /dev/stderr
+kill $ZENITY1_PID
+sleep 1
+kill $ZENITY2_PID
+sleep 1
+
+echo \# Terminating mutter > /dev/stderr
+kill $MUTTER2_PID
+wait $MUTTER2_PID


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]