mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
Convert tests/refcount/properties3.c to glib test framework
This commit is contained in:
parent
ddadb89d7c
commit
94ef5ae4c7
@ -144,7 +144,7 @@ run_thread (GTest * test)
|
|||||||
my_test_do_property (test);
|
my_test_do_property (test);
|
||||||
if ((i++ % 10000) == 0)
|
if ((i++ % 10000) == 0)
|
||||||
{
|
{
|
||||||
g_print (".%c", 'a' + test->id);
|
g_test_message (".%c", 'a' + test->id);
|
||||||
g_thread_yield(); /* force context switch */
|
g_thread_yield(); /* force context switch */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,20 +152,17 @@ run_thread (GTest * test)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static void
|
||||||
main (int argc, char **argv)
|
test_refcount_properties_3 (void)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
GTest *test;
|
GTest *test;
|
||||||
GArray *test_threads;
|
GArray *test_threads;
|
||||||
const gint n_threads = 5;
|
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);
|
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);
|
g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL);
|
||||||
|
|
||||||
test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
|
test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *));
|
||||||
@ -181,7 +178,7 @@ main (int argc, char **argv)
|
|||||||
g_usleep (30000000);
|
g_usleep (30000000);
|
||||||
|
|
||||||
g_atomic_int_set (&stopping, 1);
|
g_atomic_int_set (&stopping, 1);
|
||||||
g_print ("\nstopping\n");
|
g_test_message ("\nstopping\n");
|
||||||
|
|
||||||
/* join all threads */
|
/* join all threads */
|
||||||
for (i = 0; i < n_threads; i++) {
|
for (i = 0; i < n_threads; i++) {
|
||||||
@ -191,12 +188,23 @@ main (int argc, char **argv)
|
|||||||
g_thread_join (thread);
|
g_thread_join (thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("stopped\n");
|
g_test_message ("stopped\n");
|
||||||
|
g_test_message ("%d %d\n", test->setcount, test->count);
|
||||||
g_print ("%d %d\n", test->setcount, test->count);
|
|
||||||
|
|
||||||
g_array_free (test_threads, TRUE);
|
g_array_free (test_threads, TRUE);
|
||||||
g_object_unref (test);
|
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 ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user