From 021a401bc85352b0aa7f52661f7b91693a72672b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 9 Jul 2021 12:37:14 +0200 Subject: [PATCH] tests: Move out KMS utils unit tests to its own executable Better to split things up a bit, so one can with more ease run a specific test. In the KMS utils case, we don't even need a mutter context, making it much lighter. Part-of: --- src/tests/kms-utils-unit-tests.c | 19 ++++++++++++++----- src/tests/kms-utils-unit-tests.h | 23 ----------------------- src/tests/meson.build | 20 ++++++++++++++++++-- src/tests/unit-tests.c | 2 -- 4 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 src/tests/kms-utils-unit-tests.h diff --git a/src/tests/kms-utils-unit-tests.c b/src/tests/kms-utils-unit-tests.c index 743d46e0e..ae5bb5c81 100644 --- a/src/tests/kms-utils-unit-tests.c +++ b/src/tests/kms-utils-unit-tests.c @@ -18,9 +18,8 @@ #include "config.h" -#include "tests/kms-utils-unit-tests.h" +#include -#include "tests/test-utils.h" #include "backends/native/meta-kms-utils.h" typedef struct { @@ -121,7 +120,7 @@ static const ModeInfoTestCase test_cases[] = { }; static void -refresh_rate (void) +meta_test_kms_refresh_rate (void) { size_t index; @@ -138,8 +137,18 @@ refresh_rate (void) } } -void +static void init_kms_utils_tests (void) { - g_test_add_func ("/kms-utils/refresh-rate", refresh_rate); + g_test_add_func ("/backends/native/kms/refresh-rate", + meta_test_kms_refresh_rate); +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + init_kms_utils_tests (); + return g_test_run (); } diff --git a/src/tests/kms-utils-unit-tests.h b/src/tests/kms-utils-unit-tests.h deleted file mode 100644 index e85fd87fe..000000000 --- a/src/tests/kms-utils-unit-tests.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Akihiko Odaki - * - * 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 KMS_UTILS_UNIT_TESTS_H -#define KMS_UTILS_UNIT_TESTS_H - -void init_kms_utils_tests (void); - -#endif /* KMS_UTILS_UNIT_TESTS_H */ diff --git a/src/tests/meson.build b/src/tests/meson.build index 2a2e35782..d21669503 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -76,8 +76,6 @@ unit_tests = executable('mutter-test-unit-tests', 'unit-tests.c', 'boxes-tests.c', 'boxes-tests.h', - 'kms-utils-unit-tests.c', - 'kms-utils-unit-tests.h', 'meta-backend-test.c', 'meta-backend-test.h', 'meta-gpu-test.c', @@ -165,6 +163,17 @@ ref_test_sources = [ ] if have_native_tests + native_kms_utils_tests = executable('mutter-native-kms-utils-tests', + sources: [ + 'kms-utils-unit-tests.c', + ], + include_directories: tests_includepath, + c_args: tests_c_args, + dependencies: [tests_deps], + install: have_installed_tests, + install_dir: mutter_installed_tests_libexecdir, + ) + native_headless_tests = executable('mutter-native-headless-tests', sources: [ 'native-headless.c', @@ -296,6 +305,13 @@ test('anonymous-file', anonymous_file_test, ) if have_native_tests + test('native-kms-utils', native_kms_utils_tests, + suite: ['core', 'mutter/native/kms'], + env: test_env, + is_parallel: false, + timeout: 60, + ) + test('native-headless', native_headless_tests, suite: ['core', 'mutter/native/headless'], env: test_env, diff --git a/src/tests/unit-tests.c b/src/tests/unit-tests.c index 308a2f278..880956f34 100644 --- a/src/tests/unit-tests.c +++ b/src/tests/unit-tests.c @@ -29,7 +29,6 @@ #include "core/boxes-private.h" #include "core/main-private.h" #include "tests/boxes-tests.h" -#include "tests/kms-utils-unit-tests.h" #include "tests/meta-backend-test.h" #include "tests/monitor-config-migration-unit-tests.h" #include "tests/monitor-unit-tests.h" @@ -251,7 +250,6 @@ init_tests (int argc, char **argv) g_test_add_func ("/core/boxes/adjacent-to", meta_test_adjacent_to); - init_kms_utils_tests (); init_monitor_store_tests (); init_monitor_config_migration_tests (); init_monitor_tests ();