Merge branch 'thorough-tests-in-ci' into 'main'

build: Add thorough test setup

See merge request GNOME/glib!3838
This commit is contained in:
Philip Withnall 2024-02-02 14:33:22 +00:00
commit 3f4e6ddcd8
6 changed files with 39 additions and 28 deletions

View File

@ -346,6 +346,8 @@ G_DISABLE_ASSERT:
image: $FEDORA_IMAGE image: $FEDORA_IMAGE
stage: build stage: build
needs: [] needs: []
variables:
MESON_TEST_TIMEOUT_MULTIPLIER: 15
script: script:
- meson setup ${MESON_COMMON_OPTIONS} - meson setup ${MESON_COMMON_OPTIONS}
--werror --werror
@ -356,7 +358,8 @@ G_DISABLE_ASSERT:
-Dintrospection=enabled -Dintrospection=enabled
_build _build
- meson compile -C _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: artifacts:
reports: reports:
junit: junit:

View File

@ -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 its the special xmllint test in GLib, then dont
# 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[@]}"

View File

@ -189,8 +189,6 @@ test_private (void)
/* Cleaning left over files */ /* Cleaning left over files */
g_remove ("maptest"); g_remove ("maptest");
g_test_message ("test_private: ok");
} }
static void static void
@ -283,8 +281,6 @@ test_child_private (void)
/* Cleaning left over files */ /* Cleaning left over files */
g_remove ("mapchild"); g_remove ("mapchild");
g_remove ("maptest"); g_remove ("maptest");
g_test_message ("test_child_private: ok");
} }
int int
@ -303,6 +299,7 @@ main (int argc,
} }
#endif #endif
g_test_init (&argc, &argv, NULL);
local_argv = argv; local_argv = argv;
if (argc > 1) if (argc > 1)
@ -311,8 +308,6 @@ main (int argc,
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mapping/flags", test_mapping_flags); g_test_add_func ("/mapping/flags", test_mapping_flags);
g_test_add_func ("/mapping/private", test_private); g_test_add_func ("/mapping/private", test_private);
g_test_add_func ("/mapping/private-child", test_child_private); g_test_add_func ("/mapping/private-child", test_child_private);

View File

@ -395,11 +395,11 @@ test_subprocess_timeout (void)
{ {
/* loop and sleep forever */ /* loop and sleep forever */
while (TRUE) while (TRUE)
g_usleep (1000 * 1000); g_usleep (G_USEC_PER_SEC);
return; return;
} }
/* allow child to run for only a fraction of a second */ /* 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_test_trap_assert_failed ();
g_assert_true (g_test_trap_reached_timeout ()); g_assert_true (g_test_trap_reached_timeout ());
} }
@ -900,18 +900,6 @@ test_incomplete (void)
g_test_trap_assert_failed (); 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 static void
test_path_first (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/fail", test_subprocess_fail);
g_test_add_func ("/trap_subprocess/no-such-test", test_subprocess_no_such_test); 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/envp", test_subprocess_envp);
g_test_add_func ("/trap_subprocess/patterns", test_subprocess_patterns); 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/combining/subprocess/pass", test_pass);
g_test_add_func ("/misc/fail", test_fail); g_test_add_func ("/misc/fail", test_fail);
g_test_add_func ("/misc/incomplete", test_incomplete); 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/first", test_path_first);
g_test_add_func ("/misc/path/second", test_path_second); g_test_add_func ("/misc/path/second", test_path_second);

View File

@ -1157,7 +1157,6 @@ test_interface_default_init (TestInterfaceInterface *iface)
g_object_interface_install_property (iface, pspec); g_object_interface_install_property (iface, pspec);
g_test_assert_expected_messages (); g_test_assert_expected_messages ();
g_param_spec_unref (pspec);
continue; continue;
} }
@ -1432,7 +1431,7 @@ test_param_implement (void)
case 'i': case 'i':
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*g_object_class_install_property*"); g_test_trap_assert_stderr ("*pspec->flags*");
continue; continue;
case 'f': case 'f':
@ -1671,8 +1670,7 @@ main (int argc, char *argv[])
data.change_this_flag, data.change_this_type, data.change_this_flag, data.change_this_type,
data.use_this_flag, data.use_this_type); data.use_this_flag, data.use_this_type);
test_data = g_memdup2 (&data, sizeof (TestParamImplementData)); test_data = g_memdup2 (&data, sizeof (TestParamImplementData));
g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free); g_test_add_data_func_full (test_path, g_steal_pointer (&test_data), test_param_implement_child, g_free);
g_free (test_data);
g_free (test_path); g_free (test_path);
} }

View File

@ -193,6 +193,13 @@ add_test_setup('unstable_tests',
#suites: ['flaky', 'unstable'] #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 # Allow the tests to be easily run under valgrind using --setup=valgrind
valgrind = find_program('valgrind', required: false) valgrind = find_program('valgrind', required: false)
valgrind_suppression_file = files('tools' / 'glib.supp')[0] valgrind_suppression_file = files('tools' / 'glib.supp')[0]