[glib/fix-gnulib-msvc-isnan: 14/37] tests: Tidy up test naming in glib/tests/once.c
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/fix-gnulib-msvc-isnan: 14/37] tests: Tidy up test naming in glib/tests/once.c
- Date: Tue, 9 Jun 2020 10:22:20 +0000 (UTC)
commit 8c331889dedee794fd5841326b69068fe4c0fa05
Author: Philip Withnall <withnall endlessm com>
Date: Thu Feb 13 14:45:33 2020 +0000
tests: Tidy up test naming in glib/tests/once.c
Make it a little clearer. This introduces no functional changes.
Signed-off-by: Philip Withnall <withnall endlessm com>
Helps: #1323
glib/tests/once.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/glib/tests/once.c b/glib/tests/once.c
index b11e577f6..223a1945e 100644
--- a/glib/tests/once.c
+++ b/glib/tests/once.c
@@ -34,11 +34,13 @@ do_once (gpointer data)
}
static void
-test_once1 (void)
+test_once_single_threaded (void)
{
GOnce once = G_ONCE_INIT;
gpointer res;
+ g_test_summary ("Test g_once() usage from a single thread");
+
g_assert (once.status == G_ONCE_STATUS_NOTCALLED);
res = g_once (&once, do_once, NULL);
@@ -51,10 +53,12 @@ test_once1 (void)
}
static void
-test_once2 (void)
+test_once_init_single_threaded (void)
{
static gsize init = 0;
+ g_test_summary ("Test g_once_init_{enter,leave}() usage from a single thread");
+
if (g_once_init_enter (&init))
{
g_assert (TRUE);
@@ -96,15 +100,17 @@ thread_func (gpointer data)
}
static void
-test_once3 (void)
+test_once_init_multi_threaded (void)
{
gint i;
GThread *threads[THREADS];
+ g_test_summary ("Test g_once_init_{enter,leave}() usage from multiple threads");
+
shared = 0;
for (i = 0; i < THREADS; i++)
- threads[i] = g_thread_new ("once3", thread_func, NULL);
+ threads[i] = g_thread_new ("once-init-multi-threaded", thread_func, NULL);
for (i = 0; i < THREADS; i++)
g_thread_join (threads[i]);
@@ -113,10 +119,12 @@ test_once3 (void)
}
static void
-test_once4 (void)
+test_once_init_string (void)
{
static const gchar *val;
+ g_test_summary ("Test g_once_init_{enter,leave}() usage with a string");
+
if (g_once_init_enter (&val))
g_once_init_leave (&val, "foo");
@@ -128,10 +136,10 @@ main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/thread/once1", test_once1);
- g_test_add_func ("/thread/once2", test_once2);
- g_test_add_func ("/thread/once3", test_once3);
- g_test_add_func ("/thread/once4", test_once4);
+ g_test_add_func ("/once/single-threaded", test_once_single_threaded);
+ g_test_add_func ("/once-init/single-threaded", test_once_init_single_threaded);
+ g_test_add_func ("/once-init/multi-threaded", test_once_init_multi_threaded);
+ g_test_add_func ("/once-init/string", test_once_init_string);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]