tests: Split out Wayland tests into its own test case

Makes it easier to run it, as one doesn't need to wait for all the other
unit tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
This commit is contained in:
Jonas Ådahl 2021-11-08 10:52:48 +01:00
parent eed6599867
commit d420a39a02
4 changed files with 42 additions and 39 deletions

View File

@ -131,8 +131,6 @@ unit_tests = executable('mutter-test-unit-tests',
'unit-tests.c', 'unit-tests.c',
'boxes-tests.c', 'boxes-tests.c',
'boxes-tests.h', 'boxes-tests.h',
'meta-wayland-test-driver.c',
'meta-wayland-test-driver.h',
'meta-gpu-test.c', 'meta-gpu-test.c',
'meta-gpu-test.h', 'meta-gpu-test.h',
'monitor-config-migration-unit-tests.c', 'monitor-config-migration-unit-tests.c',
@ -146,10 +144,6 @@ unit_tests = executable('mutter-test-unit-tests',
'monitor-unit-tests.c', 'monitor-unit-tests.c',
'orientation-manager-unit-tests.c', 'orientation-manager-unit-tests.c',
'monitor-unit-tests.h', 'monitor-unit-tests.h',
'wayland-unit-tests.c',
'wayland-unit-tests.h',
test_driver_server_header,
test_driver_protocol_code,
], ],
include_directories: tests_includes, include_directories: tests_includes,
c_args: tests_c_args, c_args: tests_c_args,
@ -182,6 +176,21 @@ stage_view_tests = executable('mutter-stage-view-tests',
install_dir: mutter_installed_tests_libexecdir, install_dir: mutter_installed_tests_libexecdir,
) )
wayland_tests = executable('mutter-wayland-tests',
sources: [
'meta-wayland-test-driver.c',
'meta-wayland-test-driver.h',
'wayland-unit-tests.c',
test_driver_server_header,
test_driver_protocol_code,
],
include_directories: tests_includes,
c_args: tests_c_args,
dependencies: libmutter_test_dep,
install: have_installed_tests,
install_dir: mutter_installed_tests_libexecdir,
)
anonymous_file_test = executable('anonymous-file-tests', anonymous_file_test = executable('anonymous-file-tests',
sources: [ sources: [
'anonymous-file.c', 'anonymous-file.c',
@ -329,6 +338,13 @@ test('stage-view', stage_view_tests,
timeout: 60, timeout: 60,
) )
test('wayland', wayland_tests,
suite: ['core', 'mutter/unit'],
env: test_env,
is_parallel: false,
timeout: 60,
)
test('anonymous-file', anonymous_file_test, test('anonymous-file', anonymous_file_test,
suite: ['core', 'mutter/unit'], suite: ['core', 'mutter/unit'],
env: test_env, env: test_env,

View File

@ -37,7 +37,6 @@
#include "tests/monitor-transform-tests.h" #include "tests/monitor-transform-tests.h"
#include "tests/meta-test-utils.h" #include "tests/meta-test-utils.h"
#include "tests/orientation-manager-unit-tests.h" #include "tests/orientation-manager-unit-tests.h"
#include "tests/wayland-unit-tests.h"
MetaContext *test_context; MetaContext *test_context;
@ -232,7 +231,6 @@ init_tests (void)
init_monitor_config_migration_tests (); init_monitor_config_migration_tests ();
init_monitor_tests (); init_monitor_tests ();
init_boxes_tests (); init_boxes_tests ();
init_wayland_tests ();
init_monitor_transform_tests (); init_monitor_transform_tests ();
init_orientation_manager_tests (); init_orientation_manager_tests ();
} }
@ -252,8 +250,6 @@ main (int argc, char *argv[])
g_signal_connect (context, "before-tests", g_signal_connect (context, "before-tests",
G_CALLBACK (pre_run_monitor_tests), NULL); G_CALLBACK (pre_run_monitor_tests), NULL);
g_signal_connect (context, "before-tests",
G_CALLBACK (pre_run_wayland_tests), NULL);
g_signal_connect (context, "after-tests", g_signal_connect (context, "after-tests",
G_CALLBACK (finish_monitor_tests), NULL); G_CALLBACK (finish_monitor_tests), NULL);

View File

@ -17,12 +17,11 @@
#include "config.h" #include "config.h"
#include "tests/wayland-unit-tests.h"
#include <gio/gio.h> #include <gio/gio.h>
#include "core/display-private.h" #include "core/display-private.h"
#include "core/window-private.h" #include "core/window-private.h"
#include "meta-test/meta-context-test.h"
#include "tests/meta-wayland-test-driver.h" #include "tests/meta-wayland-test-driver.h"
#include "wayland/meta-wayland.h" #include "wayland/meta-wayland.h"
#include "wayland/meta-wayland-surface.h" #include "wayland/meta-wayland-surface.h"
@ -248,7 +247,7 @@ toplevel_apply_limits (void)
g_test_assert_expected_messages (); g_test_assert_expected_messages ();
} }
void static void
pre_run_wayland_tests (void) pre_run_wayland_tests (void)
{ {
MetaWaylandCompositor *compositor; MetaWaylandCompositor *compositor;
@ -259,7 +258,7 @@ pre_run_wayland_tests (void)
test_driver = meta_wayland_test_driver_new (compositor); test_driver = meta_wayland_test_driver_new (compositor);
} }
void static void
init_wayland_tests (void) init_wayland_tests (void)
{ {
g_test_add_func ("/wayland/subsurface/remap-toplevel", g_test_add_func ("/wayland/subsurface/remap-toplevel",
@ -273,3 +272,20 @@ init_wayland_tests (void)
g_test_add_func ("/wayland/toplevel/apply-limits", g_test_add_func ("/wayland/toplevel/apply-limits",
toplevel_apply_limits); toplevel_apply_limits);
} }
int
main (int argc, char *argv[])
{
g_autoptr (MetaContext) context = NULL;
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
META_CONTEXT_TEST_FLAG_TEST_CLIENT);
g_assert (meta_context_configure (context, &argc, &argv, NULL));
init_wayland_tests ();
g_signal_connect (context, "before-tests",
G_CALLBACK (pre_run_wayland_tests), NULL);
return meta_context_test_run_tests (META_CONTEXT_TEST (context));
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (C) 2019 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WAYLAND_UNIT_TESTS_H
#define WAYLAND_UNIT_TESTS_H
void init_wayland_tests (void);
void pre_run_wayland_tests (void);
#endif /* WAYLAND_UNIT_TESTS_H */