[glib/wip/smcv/defer-test-cleanup: 1/2] Add a test-case for calling g_test_build_filename after g_test_run
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/defer-test-cleanup: 1/2] Add a test-case for calling g_test_build_filename after g_test_run
- Date: Fri, 11 Feb 2022 13:04:13 +0000 (UTC)
commit 00b17c92bf470b26f90e982e0d0550d749352eb8
Author: Simon McVittie <smcv collabora com>
Date: Thu Jan 6 15:09:31 2022 +0000
Add a test-case for calling g_test_build_filename after g_test_run
This will not reproduce the bug when run as a unit test, because in that
scenario, G_TEST_BUILDDIR and G_TEST_SRCDIR are set. It *can* reproduce
the bug (at least probabilistically) when run as an installed-test,
or manually in a build tree:
./_build/glib/tests/testing
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2563
Signed-off-by: Simon McVittie <smcv collabora com>
glib/tests/testing.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index 03cfe03e1..c1fcd8c67 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -1589,12 +1589,19 @@ int
main (int argc,
char *argv[])
{
+ int ret;
+ char *filename, *filename2;
+
argv0 = argv[0];
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
+ /* Part of a test for
+ * https://gitlab.gnome.org/GNOME/glib/-/issues/2563, see below */
+ filename = g_test_build_filename (G_TEST_BUILT, "nonexistent", NULL);
+
g_test_add_func ("/random-generator/rand-1", test_rand1);
g_test_add_func ("/random-generator/rand-2", test_rand2);
g_test_add_func ("/random-generator/random-conversions", test_random_conversions);
@@ -1675,5 +1682,16 @@ main (int argc,
g_test_add_func ("/tap", test_tap);
g_test_add_func ("/tap/summary", test_tap_summary);
- return g_test_run();
+ ret = g_test_run ();
+
+ /* We can't test for https://gitlab.gnome.org/GNOME/glib/-/issues/2563
+ * from a test-case, because the whole point of that issue is that it's
+ * about whether certain patterns are valid after g_test_run() has
+ * returned... so put an ad-hoc test here, and just crash if it fails. */
+ filename2 = g_test_build_filename (G_TEST_BUILT, "nonexistent", NULL);
+ g_assert_cmpstr (filename, ==, filename2);
+
+ g_free (filename);
+ g_free (filename2);
+ return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]