From 62b5fe5991335d5580585e059de6e58b0450ff64 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:26:15 +0100 Subject: [PATCH 1/9] Convert tests/refcount/objects.c to glib test framework --- tests/refcount/objects.c | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tests/refcount/objects.c b/tests/refcount/objects.c index 06b871936..0d8e20b03 100644 --- a/tests/refcount/objects.c +++ b/tests/refcount/objects.c @@ -5,7 +5,7 @@ #include #endif -#define G_TYPE_TEST (my_test_get_type ()) +#define G_TYPE_TEST (my_test_get_type ()) #define MY_TEST(test) (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest)) #define MY_IS_TEST(test) (G_TYPE_CHECK_INSTANCE_TYPE ((test), G_TYPE_TEST)) #define MY_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_CAST ((tclass), G_TYPE_TEST, GTestClass)) @@ -65,7 +65,6 @@ my_test_class_init (GTestClass * klass) GObjectClass *gobject_class; gobject_class = (GObjectClass *) klass; - parent_class = g_type_class_ref (G_TYPE_OBJECT); gobject_class->dispose = my_test_dispose; @@ -74,7 +73,7 @@ my_test_class_init (GTestClass * klass) static void my_test_init (GTest * test) { - g_print ("init %p\n", test); + g_test_message ("init %p\n", test); } static void @@ -84,7 +83,7 @@ my_test_dispose (GObject * object) test = MY_TEST (object); - g_print ("dispose %p!\n", test); + g_test_message ("dispose %p!\n", test); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -92,8 +91,8 @@ my_test_dispose (GObject * object) static void my_test_do_refcount (GTest * test) { - g_object_ref (test); - g_object_unref (test); + g_object_ref (test); + g_object_unref (test); } static gpointer @@ -104,25 +103,22 @@ run_thread (GTest * test) while (!g_atomic_int_get (&stopping)) { my_test_do_refcount (test); if ((i++ % 10000) == 0) { - g_print ("."); - g_thread_yield(); /* force context switch */ + g_test_message ("."); + g_thread_yield (); /* force context switch */ } } return NULL; } -int -main (int argc, char **argv) +static void +test_refcount_object_basics (void) { guint i; GTest *test1, *test2; GArray *test_threads; const guint n_threads = 5; - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); - test1 = g_object_new (G_TYPE_TEST, NULL); test2 = g_object_new (G_TYPE_TEST, NULL); @@ -139,12 +135,10 @@ main (int argc, char **argv) thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); g_array_append_val (test_threads, thread); } + g_usleep (5000000); - g_atomic_int_set (&stopping, 1); - g_print ("\nstopping\n"); - /* join all threads */ for (i = 0; i < 2 * n_threads; i++) { GThread *thread; @@ -156,8 +150,18 @@ main (int argc, char **argv) g_object_unref (test1); g_object_unref (test2); g_array_unref (test_threads); - - g_print ("stopped\n"); - - return 0; +} + +int +main (int argc, gchar *argv[]) +{ + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/gobject/refcount/object-basics", test_refcount_object_basics); + + return g_test_run (); } From 715ff4ea290182e116da12a76952ea254ccd0af6 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:26:53 +0100 Subject: [PATCH 2/9] Convert tests/refcount/objects2.c to glib test framework --- tests/refcount/objects2.c | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/tests/refcount/objects2.c b/tests/refcount/objects2.c index e19bc67ca..2e7c03836 100644 --- a/tests/refcount/objects2.c +++ b/tests/refcount/objects2.c @@ -73,7 +73,7 @@ my_test_class_init (GTestClass * klass) static void my_test_init (GTest * test) { - g_print ("init %p\n", test); + g_test_message ("init %p\n", test); } static void @@ -83,7 +83,7 @@ my_test_dispose (GObject * object) test = MY_TEST (object); - g_print ("dispose %p!\n", test); + g_test_message ("dispose %p!\n", test); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -92,30 +92,40 @@ static void my_test_do_refcount (GTest * test) { static guint i = 1; + if (i++ % 100000 == 0) - g_print ("."); - g_object_ref (test); - g_object_unref (test); + g_test_message ("."); + + g_object_ref (test); + g_object_unref (test); +} + +static void +test_refcount_object_advanced (void) +{ + gint i; + GTest *test; + + test = g_object_new (G_TYPE_TEST, NULL); + + for (i = 0; i < 100000000; i++) + { + my_test_do_refcount (test); + } + + g_object_unref (test); } int main (int argc, char **argv) { - gint i; - GTest *test; + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); + g_test_init (&argc, &argv, NULL); - test = g_object_new (G_TYPE_TEST, NULL); + g_test_add_func ("/gobject/refcount/object-advanced", test_refcount_object_advanced); - for (i=0; i<100000000; i++) { - my_test_do_refcount (test); - } - - g_object_unref (test); - - g_print ("\n"); - - return 0; + return g_test_run (); } From 76fccc78c057bba87335cc4a69898f5a31316823 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:27:23 +0100 Subject: [PATCH 3/9] Convert tests/refcount/properties.c to glib test framework --- tests/refcount/properties.c | 54 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/tests/refcount/properties.c b/tests/refcount/properties.c index 376d9313c..42176e923 100644 --- a/tests/refcount/properties.c +++ b/tests/refcount/properties.c @@ -5,7 +5,7 @@ #include #endif -#define G_TYPE_TEST (my_test_get_type ()) +#define G_TYPE_TEST (my_test_get_type ()) #define MY_TEST(test) (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest)) #define MY_IS_TEST(test) (G_TYPE_CHECK_INSTANCE_TYPE ((test), G_TYPE_TEST)) #define MY_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_CAST ((tclass), G_TYPE_TEST, GTestClass)) @@ -89,12 +89,12 @@ my_test_class_init (GTestClass * klass) gobject_class->set_property = my_test_set_property; g_object_class_install_property (gobject_class, - PROP_DUMMY, - g_param_spec_int ("dummy", - NULL, - NULL, - 0, G_MAXINT, 0, - G_PARAM_READWRITE)); + PROP_DUMMY, + g_param_spec_int ("dummy", + NULL, + NULL, + 0, G_MAXINT, 0, + G_PARAM_READWRITE)); } static void @@ -110,7 +110,7 @@ my_test_dispose (GObject * object) G_OBJECT_CLASS (parent_class)->dispose (object); } -static void +static void my_test_get_property (GObject *object, guint prop_id, GValue *value, @@ -131,7 +131,7 @@ my_test_get_property (GObject *object, } } -static void +static void my_test_set_property (GObject *object, guint prop_id, const GValue *value, @@ -160,7 +160,7 @@ dummy_notify (GObject *object, test = MY_TEST (object); - test->count++; + test->count++; } static void @@ -176,12 +176,12 @@ static gpointer run_thread (GTest * test) { gint i = 1; - + while (!g_atomic_int_get (&stopping)) { my_test_do_property (test); if ((i++ % 10000) == 0) { - g_print (".%c", 'a' + test->id); + g_test_message (".%c", 'a' + test->id); g_thread_yield(); /* force context switch */ } } @@ -189,24 +189,21 @@ run_thread (GTest * test) return NULL; } -int -main (int argc, char **argv) +static void +test_refcount_properties_1 (void) { #define N_THREADS 5 GThread *test_threads[N_THREADS]; GTest *test_objects[N_THREADS]; gint i; - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); - for (i = 0; i < N_THREADS; i++) { GTest *test; test = g_object_new (G_TYPE_TEST, NULL); test_objects[i] = test; - g_assert (test->count == test->dummy); + g_assert_cmpint (test->count, ==, test->dummy); g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL); } @@ -218,20 +215,29 @@ main (int argc, char **argv) g_usleep (3000000); g_atomic_int_set (&stopping, TRUE); - g_print ("\nstopping\n"); /* join all threads */ for (i = 0; i < N_THREADS; i++) g_thread_join (test_threads[i]); - g_print ("stopped\n"); - for (i = 0; i < N_THREADS; i++) { GTest *test = test_objects[i]; - g_assert (test->count == test->dummy); + g_assert_cmpint (test->count, ==, test->dummy); g_object_unref (test); } - - return 0; +} + +int +main (int argc, gchar *argv[]) +{ + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/gobject/refcount/properties-1", test_refcount_properties_1); + + return g_test_run (); } From ddadb89d7c9b9e5c5870d81191df248bf3171883 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:48:28 +0100 Subject: [PATCH 4/9] Convert tests/refcount/properties2.c to glib test framework --- tests/refcount/properties2.c | 70 ++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/tests/refcount/properties2.c b/tests/refcount/properties2.c index 1684bd45b..9536b5144 100644 --- a/tests/refcount/properties2.c +++ b/tests/refcount/properties2.c @@ -87,18 +87,18 @@ my_test_class_init (GTestClass * klass) gobject_class->set_property = my_test_set_property; g_object_class_install_property (gobject_class, - PROP_DUMMY, - g_param_spec_int ("dummy", - NULL, - NULL, - 0, G_MAXINT, 0, - G_PARAM_READWRITE)); + PROP_DUMMY, + g_param_spec_int ("dummy", + NULL, + NULL, + 0, G_MAXINT, 0, + G_PARAM_READWRITE)); } static void my_test_init (GTest * test) { - g_print ("init %p\n", test); + g_test_message ("init %p\n", test); } static void @@ -108,15 +108,15 @@ my_test_dispose (GObject * object) test = MY_TEST (object); - g_print ("dispose %p!\n", test); + g_test_message ("dispose %p!\n", test); G_OBJECT_CLASS (parent_class)->dispose (object); } -static void -my_test_get_property (GObject *object, - guint prop_id, - GValue *value, +static void +my_test_get_property (GObject *object, + guint prop_id, + GValue *value, GParamSpec *pspec) { GTest *test; @@ -134,11 +134,11 @@ my_test_get_property (GObject *object, } } -static void -my_test_set_property (GObject *object, - guint prop_id, +static void +my_test_set_property (GObject *object, + guint prop_id, const GValue *value, - GParamSpec *pspec) + GParamSpec *pspec) { GTest *test; @@ -163,7 +163,7 @@ dummy_notify (GObject *object, { count++; if (count % 10000 == 0) - g_print ("."); + g_test_message ("."); } static void @@ -175,28 +175,36 @@ my_test_do_property (GTest * test) g_object_set (test, "dummy", dummy + 1, NULL); } -int -main (int argc, char **argv) +static void +test_refcount_properties_2 (void) { gint i; GTest *test; - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); - test = g_object_new (G_TYPE_TEST, NULL); g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL); + g_assert_cmpint (count, ==, test->dummy); - g_assert (count == test->dummy); - - for (i=0; i<1000000; i++) { - my_test_do_property (test); - } - - g_assert (count == test->dummy); + for (i = 0; i < 1000000; i++) + { + my_test_do_property (test); + } + g_assert_cmpint (count, ==, test->dummy); g_object_unref (test); - - return 0; +} + +int +main (int argc, gchar *argv[]) +{ + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/gobject/refcount/properties-2", test_refcount_properties_2); + + return g_test_run (); } From 94ef5ae4c719addf531c8d1e2bf7ca3e5462ffe4 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:30:57 +0100 Subject: [PATCH 5/9] Convert tests/refcount/properties3.c to glib test framework --- tests/refcount/properties3.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/refcount/properties3.c b/tests/refcount/properties3.c index 31f26a46e..8a96fb804 100644 --- a/tests/refcount/properties3.c +++ b/tests/refcount/properties3.c @@ -144,28 +144,25 @@ run_thread (GTest * test) my_test_do_property (test); if ((i++ % 10000) == 0) { - g_print (".%c", 'a' + test->id); - g_thread_yield(); /* force context switch */ + g_test_message (".%c", 'a' + test->id); + g_thread_yield(); /* force context switch */ } } return NULL; } -int -main (int argc, char **argv) +static void +test_refcount_properties_3 (void) { gint i; GTest *test; GArray *test_threads; const gint n_threads = 5; - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); - test = g_object_new (G_TYPE_TEST, NULL); - g_assert (test->count == test->dummy); + g_assert_cmpint (test->count, ==, test->dummy); g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL); test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *)); @@ -181,7 +178,7 @@ main (int argc, char **argv) g_usleep (30000000); g_atomic_int_set (&stopping, 1); - g_print ("\nstopping\n"); + g_test_message ("\nstopping\n"); /* join all threads */ for (i = 0; i < n_threads; i++) { @@ -191,12 +188,23 @@ main (int argc, char **argv) g_thread_join (thread); } - g_print ("stopped\n"); - - g_print ("%d %d\n", test->setcount, test->count); + g_test_message ("stopped\n"); + g_test_message ("%d %d\n", test->setcount, test->count); g_array_free (test_threads, TRUE); g_object_unref (test); - - return 0; +} + +int +main (int argc, gchar *argv[]) +{ + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/gobject/refcount/properties-3", test_refcount_properties_3); + + return g_test_run (); } From d97c1a148e65c1acdc3682ad279891973bab5371 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:31:31 +0100 Subject: [PATCH 6/9] Convert tests/refcount/properties4.c to glib test framework --- tests/refcount/properties4.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/refcount/properties4.c b/tests/refcount/properties4.c index d4bca9486..462f9e3cd 100644 --- a/tests/refcount/properties4.c +++ b/tests/refcount/properties4.c @@ -143,19 +143,15 @@ my_badger_mama_notify (GObject *object, MyBadger *self; self = MY_BADGER (object); - self->mama_notify_count++; } -int -main (int argc, char **argv) +static void +test_refcount_properties_4 (void) { MyBadger * badger1, * badger2; gpointer test; - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); - badger1 = g_object_new (MY_TYPE_BADGER, NULL); badger2 = g_object_new (MY_TYPE_BADGER, NULL); @@ -163,11 +159,23 @@ main (int argc, char **argv) g_assert_cmpuint (badger1->mama_notify_count, ==, 1); g_assert_cmpuint (badger2->mama_notify_count, ==, 1); g_object_get (badger1, "mama", &test, NULL); - g_assert (test == badger2); + g_assert_cmpmem (test, sizeof (MyBadger), badger2, sizeof (MyBadger)); g_object_unref (test); g_object_unref (badger1); g_object_unref (badger2); - - return 0; +} + +int +main (int argc, gchar *argv[]) +{ + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/gobject/refcount/properties-4", test_refcount_properties_4); + + return g_test_run (); } From b65260abe482ff1e0647228446ab7ed8dbf7f40a Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:31:50 +0100 Subject: [PATCH 7/9] Convert tests/refcount/signals.c to glib test framework --- tests/refcount/signals.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/refcount/signals.c b/tests/refcount/signals.c index f714ac004..a9c11e32e 100644 --- a/tests/refcount/signals.c +++ b/tests/refcount/signals.c @@ -128,7 +128,7 @@ my_test_class_init (GTestClass * klass) static void my_test_init (GTest * test) { - g_print ("init %p\n", test); + g_test_message ("init %p\n", test); test->value = 0; } @@ -140,7 +140,7 @@ my_test_dispose (GObject * object) test = MY_TEST (object); - g_print ("dispose %p!\n", test); + g_test_message ("dispose %p!\n", test); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -236,8 +236,8 @@ run_thread (GTest * test) if (TESTNUM == 4) my_test_do_signal3 (test); if ((i++ % 10000) == 0) { - g_print ("."); - g_thread_yield(); /* force context switch */ + g_test_message ("."); + g_thread_yield (); /* force context switch */ } } @@ -250,20 +250,17 @@ notify (GObject *object, GParamSpec *spec, gpointer user_data) gint value; g_object_get (object, "test-prop", &value, NULL); - /*g_print ("+ %d", value);*/ + g_test_message ("+ %d", value); } -int -main (int argc, char **argv) +static void +test_refcount_signals (void) { gint i; GTest *test1, *test2; GArray *test_threads; const gint n_threads = 1; - g_print ("START: %s\n", argv[0]); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); - test1 = g_object_new (G_TYPE_TEST, NULL); test2 = g_object_new (G_TYPE_TEST, NULL); @@ -288,9 +285,7 @@ main (int argc, char **argv) g_atomic_int_set (&stopping, TRUE); - g_print ("\nstopping\n"); - - /* join all threads */ + /* Join all threads */ for (i = 0; i < 2 * n_threads; i++) { GThread *thread; @@ -298,11 +293,21 @@ main (int argc, char **argv) g_thread_join (thread); } - g_print ("stopped\n"); - g_array_free (test_threads, TRUE); g_object_unref (test1); g_object_unref (test2); - - return 0; +} + +int +main (int argc, gchar *argv[]) +{ + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_CRITICAL | + g_log_set_always_fatal (G_LOG_FATAL_MASK)); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/gobject/refcount/signals", test_refcount_signals); + + return g_test_run (); } From 70401ae8c395461bcd6b205d019d339e5686788e Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 16 Mar 2022 09:51:51 +0100 Subject: [PATCH 8/9] Moving tests/refcount/ directory to gobject/tests/ Modified by Philip Withnall to omit the subdirectory and drop the `refcount` suite as both seem like unnecessary over-categorisation. Related to issue #1434 --- gobject/tests/meson.build | 22 +++++++ .../tests/objects-refcount1.c | 0 .../tests/objects-refcount2.c | 0 .../tests/properties-refcount1.c | 0 .../tests/properties-refcount2.c | 0 .../tests/properties-refcount3.c | 0 .../tests/properties-refcount4.c | 0 .../tests/signals-refcount.c | 0 tests/meson.build | 1 - tests/refcount/meson.build | 60 ------------------- 10 files changed, 22 insertions(+), 61 deletions(-) rename tests/refcount/objects.c => gobject/tests/objects-refcount1.c (100%) rename tests/refcount/objects2.c => gobject/tests/objects-refcount2.c (100%) rename tests/refcount/properties.c => gobject/tests/properties-refcount1.c (100%) rename tests/refcount/properties2.c => gobject/tests/properties-refcount2.c (100%) rename tests/refcount/properties3.c => gobject/tests/properties-refcount3.c (100%) rename tests/refcount/properties4.c => gobject/tests/properties-refcount4.c (100%) rename tests/refcount/signals.c => gobject/tests/signals-refcount.c (100%) delete mode 100644 tests/refcount/meson.build diff --git a/gobject/tests/meson.build b/gobject/tests/meson.build index 8d568f00e..2b860f344 100644 --- a/gobject/tests/meson.build +++ b/gobject/tests/meson.build @@ -57,6 +57,28 @@ gobject_tests = { 'signalgroup' : {}, 'testing' : {}, 'type-flags' : {}, + 'objects-refcount1' : {}, + 'objects-refcount2' : {'suite' : ['slow']}, + 'properties-refcount1' : {}, + 'properties-refcount2' : {'suite' : ['slow']}, + 'properties-refcount3' : {'suite' : ['slow']}, + 'properties-refcount4' : {}, + 'signals-refcount1' : { + 'source' : 'signals-refcount.c', + 'c_args' : ['-DTESTNUM=1'], + }, + 'signals-refcount2' : { + 'source' : 'signals-refcount.c', + 'c_args' : ['-DTESTNUM=2'], + }, + 'signals-refcount3' : { + 'source' : 'signals-refcount.c', + 'c_args' : ['-DTESTNUM=3'], + }, + 'signals-refcount4' : { + 'source' : 'signals-refcount.c', + 'c_args' : ['-DTESTNUM=4'], + }, } if cc.get_id() != 'msvc' diff --git a/tests/refcount/objects.c b/gobject/tests/objects-refcount1.c similarity index 100% rename from tests/refcount/objects.c rename to gobject/tests/objects-refcount1.c diff --git a/tests/refcount/objects2.c b/gobject/tests/objects-refcount2.c similarity index 100% rename from tests/refcount/objects2.c rename to gobject/tests/objects-refcount2.c diff --git a/tests/refcount/properties.c b/gobject/tests/properties-refcount1.c similarity index 100% rename from tests/refcount/properties.c rename to gobject/tests/properties-refcount1.c diff --git a/tests/refcount/properties2.c b/gobject/tests/properties-refcount2.c similarity index 100% rename from tests/refcount/properties2.c rename to gobject/tests/properties-refcount2.c diff --git a/tests/refcount/properties3.c b/gobject/tests/properties-refcount3.c similarity index 100% rename from tests/refcount/properties3.c rename to gobject/tests/properties-refcount3.c diff --git a/tests/refcount/properties4.c b/gobject/tests/properties-refcount4.c similarity index 100% rename from tests/refcount/properties4.c rename to gobject/tests/properties-refcount4.c diff --git a/tests/refcount/signals.c b/gobject/tests/signals-refcount.c similarity index 100% rename from tests/refcount/signals.c rename to gobject/tests/signals-refcount.c diff --git a/tests/meson.build b/tests/meson.build index ea5b86013..7ebdc24a0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -13,7 +13,6 @@ test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256)) test_cargs = ['-DG_LOG_DOMAIN="GLib"', '-UG_DISABLE_ASSERT'] subdir('gobject') -subdir('refcount') test_extra_programs = { 'assert-msg-test' : {}, diff --git a/tests/refcount/meson.build b/tests/refcount/meson.build deleted file mode 100644 index 02571fe98..000000000 --- a/tests/refcount/meson.build +++ /dev/null @@ -1,60 +0,0 @@ -refcount_tests = { - 'objects' : {}, - 'objects2' : {'suite' : ['slow']}, - 'properties' : {}, - 'properties2' : {'suite' : ['slow']}, - 'properties3' : {'suite' : ['slow']}, - 'properties4' : {}, - 'signal1' : { - 'source' : 'signals.c', - 'c_args' : ['-DTESTNUM=1'], - }, - 'signal2' : { - 'source' : 'signals.c', - 'c_args' : ['-DTESTNUM=2'], - }, - 'signal3' : { - 'source' : 'signals.c', - 'c_args' : ['-DTESTNUM=3'], - }, - 'signal4' : { - 'source' : 'signals.c', - 'c_args' : ['-DTESTNUM=4'], - }, -} - -common_c_args = test_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'] -common_deps = [libm, thread_dep, libglib_dep, libgobject_dep] - -foreach test_name, extra_args : refcount_tests - source = extra_args.get('source', test_name + '.c') - extra_sources = extra_args.get('extra_sources', []) - install = installed_tests_enabled and extra_args.get('install', true) - - if install - test_conf = configuration_data() - test_conf.set('installed_tests_dir', installed_tests_execdir) - test_conf.set('program', test_name) - test_conf.set('env', '') - configure_file( - input: installed_tests_template, - output: test_name + '.test', - install_dir: installed_tests_metadir, - configuration: test_conf - ) - endif - - # FIXME? $(GLIB_DEBUG_FLAGS) - exe = executable(test_name, [source, extra_sources], - c_args : common_c_args + extra_args.get('c_args', []), - dependencies : common_deps + extra_args.get('dependencies', []), - install_dir: installed_tests_execdir, - install: install, - ) - - suite = ['refcount'] + extra_args.get('suite', []) - timeout = suite.contains('slow') ? test_timeout_slow : test_timeout - - # FIXME? TESTS_ENVIRONMENT = LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset - test(test_name, exe, env : test_env, timeout : timeout, suite : suite) -endforeach From ed84b8f4688b76cb56bab31890b038959720f54f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 26 May 2022 18:34:06 +0100 Subject: [PATCH 9/9] tests: Port GObject tests from g_thread_create() to g_thread_new() To avoid warnings about deprecated functions. Signed-off-by: Philip Withnall Helps: #1434 --- gobject/tests/objects-refcount1.c | 4 ++-- gobject/tests/properties-refcount1.c | 2 +- gobject/tests/properties-refcount3.c | 2 +- gobject/tests/signals-refcount.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gobject/tests/objects-refcount1.c b/gobject/tests/objects-refcount1.c index 0d8e20b03..8f99d06e6 100644 --- a/gobject/tests/objects-refcount1.c +++ b/gobject/tests/objects-refcount1.c @@ -129,10 +129,10 @@ test_refcount_object_basics (void) for (i = 0; i < n_threads; i++) { GThread *thread; - thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); + thread = g_thread_new (NULL, (GThreadFunc) run_thread, test1); g_array_append_val (test_threads, thread); - thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); + thread = g_thread_new (NULL, (GThreadFunc) run_thread, test2); g_array_append_val (test_threads, thread); } diff --git a/gobject/tests/properties-refcount1.c b/gobject/tests/properties-refcount1.c index 42176e923..5a96518dc 100644 --- a/gobject/tests/properties-refcount1.c +++ b/gobject/tests/properties-refcount1.c @@ -210,7 +210,7 @@ test_refcount_properties_1 (void) g_atomic_int_set (&stopping, FALSE); for (i = 0; i < N_THREADS; i++) - test_threads[i] = g_thread_create ((GThreadFunc) run_thread, test_objects[i], TRUE, NULL); + test_threads[i] = g_thread_new (NULL, (GThreadFunc) run_thread, test_objects[i]); g_usleep (3000000); diff --git a/gobject/tests/properties-refcount3.c b/gobject/tests/properties-refcount3.c index 8a96fb804..19b5178a7 100644 --- a/gobject/tests/properties-refcount3.c +++ b/gobject/tests/properties-refcount3.c @@ -172,7 +172,7 @@ test_refcount_properties_3 (void) for (i = 0; i < n_threads; i++) { GThread *thread; - thread = g_thread_create ((GThreadFunc) run_thread, test, TRUE, NULL); + thread = g_thread_new (NULL, (GThreadFunc) run_thread, test); g_array_append_val (test_threads, thread); } g_usleep (30000000); diff --git a/gobject/tests/signals-refcount.c b/gobject/tests/signals-refcount.c index a9c11e32e..c1a5745b8 100644 --- a/gobject/tests/signals-refcount.c +++ b/gobject/tests/signals-refcount.c @@ -275,10 +275,10 @@ test_refcount_signals (void) for (i = 0; i < n_threads; i++) { GThread *thread; - thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); + thread = g_thread_new (NULL, (GThreadFunc) run_thread, test1); g_array_append_val (test_threads, thread); - thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); + thread = g_thread_new (NULL, (GThreadFunc) run_thread, test2); g_array_append_val (test_threads, thread); } g_usleep (5000000);