From d420a39a026644eb4d44c7c212f530a62a6e09d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 8 Nov 2021 10:52:48 +0100 Subject: [PATCH] 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: --- src/tests/meson.build | 28 ++++++++++++++++++++++------ src/tests/unit-tests.c | 4 ---- src/tests/wayland-unit-tests.c | 24 ++++++++++++++++++++---- src/tests/wayland-unit-tests.h | 25 ------------------------- 4 files changed, 42 insertions(+), 39 deletions(-) delete mode 100644 src/tests/wayland-unit-tests.h diff --git a/src/tests/meson.build b/src/tests/meson.build index cdc642117..a074a325f 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -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, diff --git a/src/tests/unit-tests.c b/src/tests/unit-tests.c index 20f965ce4..0dba16535 100644 --- a/src/tests/unit-tests.c +++ b/src/tests/unit-tests.c @@ -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); diff --git a/src/tests/wayland-unit-tests.c b/src/tests/wayland-unit-tests.c index 9dd3831c6..f7a5d15d0 100644 --- a/src/tests/wayland-unit-tests.c +++ b/src/tests/wayland-unit-tests.c @@ -17,12 +17,11 @@ #include "config.h" -#include "tests/wayland-unit-tests.h" - #include #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)); +} diff --git a/src/tests/wayland-unit-tests.h b/src/tests/wayland-unit-tests.h deleted file mode 100644 index b7d8d4204..000000000 --- a/src/tests/wayland-unit-tests.h +++ /dev/null @@ -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 . - */ - -#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 */