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

View File

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

View File

@ -17,12 +17,11 @@
#include "config.h"
#include "tests/wayland-unit-tests.h"
#include <gio/gio.h>
#include "core/display-private.h"
#include "core/window-private.h"
#include "meta-test/meta-context-test.h"
#include "tests/meta-wayland-test-driver.h"
#include "wayland/meta-wayland.h"
#include "wayland/meta-wayland-surface.h"
@ -248,7 +247,7 @@ toplevel_apply_limits (void)
g_test_assert_expected_messages ();
}
void
static void
pre_run_wayland_tests (void)
{
MetaWaylandCompositor *compositor;
@ -259,7 +258,7 @@ pre_run_wayland_tests (void)
test_driver = meta_wayland_test_driver_new (compositor);
}
void
static void
init_wayland_tests (void)
{
g_test_add_func ("/wayland/subsurface/remap-toplevel",
@ -273,3 +272,20 @@ init_wayland_tests (void)
g_test_add_func ("/wayland/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 */