diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e89e3f606..c57faef9d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -191,7 +191,7 @@ build-fedora-container@aarch64: - .fdo.distribution-image@fedora stage: build script: - - meson . build -Dbuildtype=debugoptimized -Db_coverage=true -Degl_device=true -Dwayland_eglstream=true --werror --prefix /usr + - meson . build -Dbuildtype=debugoptimized -Db_coverage=true -Degl_device=true -Dwayland_eglstream=true -Dnative_tests=false --werror --prefix /usr - ninja -C build - ninja -C build install artifacts: @@ -221,7 +221,7 @@ build-without-opengl-and-glx@x86_64: needs: - build-fedora-container@x86_64 script: - - meson . build -Dbuildtype=debugoptimized -Dopengl=false -Dglx=false -Degl_device=true -Dwayland_eglstream=true --werror --prefix /usr + - meson . build -Dbuildtype=debugoptimized -Dopengl=false -Dglx=false -Degl_device=true -Dwayland_eglstream=true -Dnative_tests=false --werror --prefix /usr - ninja -C build - ninja -C build install artifacts: @@ -236,7 +236,7 @@ build-without-native-backend-and-wayland@x86_64: needs: - build-fedora-container@x86_64 script: - - meson . build -Dbuildtype=debugoptimized -Dnative_backend=false -Dudev=false -Dwayland=false -Dcore_tests=false --werror --prefix /usr + - meson . build -Dbuildtype=debugoptimized -Dnative_backend=false -Dudev=false -Dwayland=false -Dcore_tests=false -Dnative_tests=false --werror --prefix /usr - ninja -C build - ninja -C build install artifacts: diff --git a/meson.build b/meson.build index 4becf2b7d..c4bfdfe25 100644 --- a/meson.build +++ b/meson.build @@ -262,6 +262,7 @@ have_tests = get_option('tests') have_core_tests = false have_cogl_tests = false have_clutter_tests = false +have_native_tests = false have_installed_tests = false if have_tests @@ -271,6 +272,12 @@ if have_tests error('Tests require Wayland to be enabled') endif endif + have_native_tests = get_option('native_tests') + if have_native_tests + if not have_native_backend + error('Native tests require the native backend') + endif + endif have_cogl_tests = get_option('cogl_tests') have_clutter_tests = get_option('clutter_tests') diff --git a/meson_options.txt b/meson_options.txt index a0fb61636..84e7dcc6c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -117,6 +117,12 @@ option('core_tests', description: 'Enable mutter core tests' ) +option('native_tests', + type: 'boolean', + value: true, + description: 'Enable mutter native backend tests' +) + option('tests', type: 'boolean', value: true, diff --git a/src/backends/native/meta-backend-native.h b/src/backends/native/meta-backend-native.h index 0c7df66db..aad4c8413 100644 --- a/src/backends/native/meta-backend-native.h +++ b/src/backends/native/meta-backend-native.h @@ -32,6 +32,7 @@ #include "backends/native/meta-udev.h" #define META_TYPE_BACKEND_NATIVE (meta_backend_native_get_type ()) +META_EXPORT_TEST G_DECLARE_FINAL_TYPE (MetaBackendNative, meta_backend_native, META, BACKEND_NATIVE, MetaBackend) diff --git a/src/tests/meson.build b/src/tests/meson.build index 05c6aaf70..fbdca617c 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -157,6 +157,21 @@ anonymous_file_test = executable('anonymous-file-tests', install_dir: mutter_installed_tests_libexecdir, ) +if have_native_tests + native_headless_tests = executable('mutter-native-headless-tests', + sources: [ + 'native-headless.c', + 'test-utils.c', + 'test-utils.h', + ], + include_directories: tests_includepath, + c_args: tests_c_args, + dependencies: [tests_deps], + install: have_installed_tests, + install_dir: mutter_installed_tests_libexecdir, + ) +endif + stacking_tests = [ 'basic-x11', 'basic-wayland', @@ -223,3 +238,12 @@ test('anonymous-file', anonymous_file_test, is_parallel: false, timeout: 60, ) + +if have_native_tests + test('native-headless', native_headless_tests, + suite: ['core', 'mutter/native/headless'], + env: test_env, + is_parallel: false, + timeout: 60, + ) +endif diff --git a/src/tests/native-headless.c b/src/tests/native-headless.c new file mode 100644 index 000000000..4929fa221 --- /dev/null +++ b/src/tests/native-headless.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +#include "config.h" + +#include "backends/meta-settings-private.h" +#include "backends/native/meta-backend-native.h" +#include "compositor/meta-plugin-manager.h" +#include "core/main-private.h" +#include "meta/main.h" +#include "meta/meta-backend.h" +#include "tests/test-utils.h" + +static void +init_tests (void) +{ +} + +static gboolean +run_tests (gpointer data) +{ + MetaBackend *backend = meta_get_backend (); + MetaSettings *settings = meta_backend_get_settings (backend); + gboolean ret; + + meta_settings_override_experimental_features (settings); + meta_settings_enable_experimental_feature ( + settings, + META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER); + + ret = g_test_run (); + + meta_quit (ret != 0); + + return FALSE; +} + +int +main (int argc, + char **argv) +{ + test_init (&argc, &argv); + init_tests (); + + meta_plugin_manager_load (test_get_plugin_name ()); + + meta_override_compositor_configuration (META_COMPOSITOR_TYPE_WAYLAND, + META_TYPE_BACKEND_NATIVE, + "headless", TRUE, + NULL); + + meta_init (); + meta_register_with_session (); + + g_idle_add (run_tests, NULL); + + return meta_run (); +}