From 615060d872a4c6c8753e216bf56c5a7d715b5ba3 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:50:40 +0000 Subject: [PATCH 1/8] tests: Drop some unnecessary messages from mapping test Signed-off-by: Philip Withnall --- glib/tests/mapping.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/glib/tests/mapping.c b/glib/tests/mapping.c index ea3495cd0..ac71e50f3 100644 --- a/glib/tests/mapping.c +++ b/glib/tests/mapping.c @@ -189,8 +189,6 @@ test_private (void) /* Cleaning left over files */ g_remove ("maptest"); - - g_test_message ("test_private: ok"); } static void @@ -283,8 +281,6 @@ test_child_private (void) /* Cleaning left over files */ g_remove ("mapchild"); g_remove ("maptest"); - - g_test_message ("test_child_private: ok"); } int From 82a6c54135fa5abd690f763cd76a7c332b240953 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:50:58 +0000 Subject: [PATCH 2/8] tests: Fix running mapping test with -m argument `g_test_init()` needs to be called before custom command line handling so it has a chance to strip out the arguments it handles. Signed-off-by: Philip Withnall --- glib/tests/mapping.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/glib/tests/mapping.c b/glib/tests/mapping.c index ac71e50f3..99cb8eee0 100644 --- a/glib/tests/mapping.c +++ b/glib/tests/mapping.c @@ -299,6 +299,7 @@ main (int argc, } #endif + g_test_init (&argc, &argv, NULL); local_argv = argv; if (argc > 1) @@ -307,8 +308,6 @@ main (int argc, return EXIT_SUCCESS; } - g_test_init (&argc, &argv, NULL); - g_test_add_func ("/mapping/flags", test_mapping_flags); g_test_add_func ("/mapping/private", test_private); g_test_add_func ("/mapping/private-child", test_child_private); From 5537ee4d7f8ec7a769040a21e18be08f91d162cc Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:51:41 +0000 Subject: [PATCH 3/8] tests: Drop a duplicate test from testing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test cancellation timeout was being tested twice, once only when run with `-m thorough`. Seems a bit pointless. Merge the two tests and use the smaller timeout values from the two, so the test suite doesn’t run any more slowly than it did. Signed-off-by: Philip Withnall --- glib/tests/testing.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/glib/tests/testing.c b/glib/tests/testing.c index 83aaad9bb..c4179eb4a 100644 --- a/glib/tests/testing.c +++ b/glib/tests/testing.c @@ -395,11 +395,11 @@ test_subprocess_timeout (void) { /* loop and sleep forever */ while (TRUE) - g_usleep (1000 * 1000); + g_usleep (G_USEC_PER_SEC); return; } /* allow child to run for only a fraction of a second */ - g_test_trap_subprocess (NULL, 0.11 * 1000000, G_TEST_SUBPROCESS_DEFAULT); + g_test_trap_subprocess (NULL, 0.05 * G_USEC_PER_SEC, G_TEST_SUBPROCESS_DEFAULT); g_test_trap_assert_failed (); g_assert_true (g_test_trap_reached_timeout ()); } @@ -900,18 +900,6 @@ test_incomplete (void) g_test_trap_assert_failed (); } -static void -test_subprocess_timed_out (void) -{ - if (g_test_subprocess ()) - { - g_usleep (1000000); - return; - } - g_test_trap_subprocess (NULL, 50000, G_TEST_SUBPROCESS_DEFAULT); - g_assert_true (g_test_trap_reached_timeout ()); -} - static void test_path_first (void) { @@ -2926,8 +2914,7 @@ main (int argc, g_test_add_func ("/trap_subprocess/fail", test_subprocess_fail); g_test_add_func ("/trap_subprocess/no-such-test", test_subprocess_no_such_test); - if (g_test_slow ()) - g_test_add_func ("/trap_subprocess/timeout", test_subprocess_timeout); + g_test_add_func ("/trap_subprocess/timeout", test_subprocess_timeout); g_test_add_func ("/trap_subprocess/envp", test_subprocess_envp); g_test_add_func ("/trap_subprocess/patterns", test_subprocess_patterns); @@ -2971,7 +2958,6 @@ main (int argc, g_test_add_func ("/misc/combining/subprocess/pass", test_pass); g_test_add_func ("/misc/fail", test_fail); g_test_add_func ("/misc/incomplete", test_incomplete); - g_test_add_func ("/misc/timeout", test_subprocess_timed_out); g_test_add_func ("/misc/path/first", test_path_first); g_test_add_func ("/misc/path/second", test_path_second); From 5d38f3ebd40212ed212a509158c7a7697fddf4ba Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:52:24 +0000 Subject: [PATCH 4/8] tests: Fix a double-unref in params tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn’t normally hit because it’s in a test which is disabled unless run with `-m thorough`. The `GParamSpec` is initially floating, but its floating ref is sunk by `g_object_interface_install_property()` (regardless of whether that call succeeds or aborts). The behaviour of `g_object_interface_install_property()` in this respect may have changed more recently than the test was written. Signed-off-by: Philip Withnall --- gobject/tests/param.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gobject/tests/param.c b/gobject/tests/param.c index 7696fc48f..76f1359e0 100644 --- a/gobject/tests/param.c +++ b/gobject/tests/param.c @@ -1157,7 +1157,6 @@ test_interface_default_init (TestInterfaceInterface *iface) g_object_interface_install_property (iface, pspec); g_test_assert_expected_messages (); - g_param_spec_unref (pspec); continue; } From d738dcc76fc96ab6c3197f15e0dfe90720b119dc Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:53:36 +0000 Subject: [PATCH 5/8] tests: Fix an expected message in param test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn’t normally hit because it’s in a test which is disabled unless run with `-m thorough`. Signed-off-by: Philip Withnall --- gobject/tests/param.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gobject/tests/param.c b/gobject/tests/param.c index 76f1359e0..9680aa42c 100644 --- a/gobject/tests/param.c +++ b/gobject/tests/param.c @@ -1431,7 +1431,7 @@ test_param_implement (void) case 'i': g_test_trap_assert_failed (); - g_test_trap_assert_stderr ("*g_object_class_install_property*"); + g_test_trap_assert_stderr ("*pspec->flags*"); continue; case 'f': From a4b9b41afc0a4fdaea4f146bb5cc0301b8b72e73 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:54:01 +0000 Subject: [PATCH 6/8] tests: Fix a double-free in param test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn’t normally hit because it’s in a test which is disabled unless run with `-m thorough`. The data is owned by `g_test_add_data_func_full()` until the end of the process. Signed-off-by: Philip Withnall --- gobject/tests/param.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gobject/tests/param.c b/gobject/tests/param.c index 9680aa42c..160eff4c3 100644 --- a/gobject/tests/param.c +++ b/gobject/tests/param.c @@ -1670,8 +1670,7 @@ main (int argc, char *argv[]) data.change_this_flag, data.change_this_type, data.use_this_flag, data.use_this_type); test_data = g_memdup2 (&data, sizeof (TestParamImplementData)); - g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free); - g_free (test_data); + g_test_add_data_func_full (test_path, g_steal_pointer (&test_data), test_param_implement_child, g_free); g_free (test_path); } From eb19551ebe45e85bb1a721cf1455df488920e073 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:54:45 +0000 Subject: [PATCH 7/8] build: Add thorough test setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows the tests to be run with `meson test --setup thorough` and it will run all the GTest tests with `-m thorough`. Since this argument isn’t supported by the Python tests, it’s not passed to them. Signed-off-by: Philip Withnall --- .gitlab-ci/thorough-test-wrapper.sh | 22 ++++++++++++++++++++++ meson.build | 7 +++++++ 2 files changed, 29 insertions(+) create mode 100644 .gitlab-ci/thorough-test-wrapper.sh diff --git a/.gitlab-ci/thorough-test-wrapper.sh b/.gitlab-ci/thorough-test-wrapper.sh new file mode 100644 index 000000000..2bb149ed8 --- /dev/null +++ b/.gitlab-ci/thorough-test-wrapper.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copyright 2024 GNOME Foundation, Inc. +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Original author: Philip Withnall + +set -e + +# If the test is run under Python (e.g. the first argument to this script is +# /usr/bin/python3) or if it’s the special xmllint test in GLib, then don’t +# pass the GTest `-m thorough` argument to it. +if [[ "$1" == *"python"* || + "$1" == *"xmllint" ]]; then + args=() +else + # See the documentation for g_test_init() + args=("-m" "thorough") +fi + +exec "$@" "${args[@]}" \ No newline at end of file diff --git a/meson.build b/meson.build index 909ddd26c..e82fdb4ee 100644 --- a/meson.build +++ b/meson.build @@ -193,6 +193,13 @@ add_test_setup('unstable_tests', #suites: ['flaky', 'unstable'] ) +add_test_setup('thorough', + exclude_suites: ['flaky', 'failing', 'performance'], + env: common_test_env, + timeout_multiplier: 20, + exe_wrapper: [find_program('./.gitlab-ci/thorough-test-wrapper.sh', required: true)], +) + # Allow the tests to be easily run under valgrind using --setup=valgrind valgrind = find_program('valgrind', required: false) valgrind_suppression_file = files('tools' / 'glib.supp')[0] From 16b93f92fa5f7ef39f8a40a34993e6d101bfbb38 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 18 Jan 2024 16:55:40 +0000 Subject: [PATCH 8/8] ci: Run the thorough test setup on a weekly schedule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge it with the `G_DISABLE_ASSERT` test run, to avoid tying up another test runner for no particular benefit. By running the thorough tests regularly, we’ll hopefully avoid them atrophying again (see the previous few commits full of fixes to them). Signed-off-by: Philip Withnall --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a4fd3fbf..d5cb7a29a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -297,6 +297,8 @@ G_DISABLE_ASSERT: image: $FEDORA_IMAGE stage: build needs: [] + variables: + MESON_TEST_TIMEOUT_MULTIPLIER: 15 script: - meson setup ${MESON_COMMON_OPTIONS} --werror @@ -307,7 +309,8 @@ G_DISABLE_ASSERT: -Dintrospection=enabled _build - meson compile -C _build - - bash -x ./.gitlab-ci/run-tests.sh + # Also take the opportunity to run the thorough tests (which are slow) + - bash -x ./.gitlab-ci/run-tests.sh --setup thorough artifacts: reports: junit: