[glib/wip/kalev/recursive-mutex-locker: 2/2] tests: Update GMutexLocker tests
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/kalev/recursive-mutex-locker: 2/2] tests: Update GMutexLocker tests
- Date: Fri, 14 Dec 2018 16:33:27 +0000 (UTC)
commit 924cb8f2a6db8dc8993402849c6c9645d4628cbf
Author: Kalev Lember <klember redhat com>
Date: Fri Dec 14 17:30:58 2018 +0100
tests: Update GMutexLocker tests
Spawn a thread and assert that the mutex actually got locked, same as we
do in GRecMutexLocker tests.
glib/tests/autoptr.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c
index 8472ca9bb..465e4f473 100644
--- a/glib/tests/autoptr.c
+++ b/glib/tests/autoptr.c
@@ -329,6 +329,14 @@ test_g_mutex (void)
g_mutex_init (&val);
}
+static gpointer
+mutex_locked_thread (gpointer data)
+{
+ GMutex *mutex = (GMutex *) data;
+ g_assert_false (g_mutex_trylock (mutex));
+ return NULL;
+}
+
static void
test_g_mutex_locker (void)
{
@@ -339,8 +347,13 @@ test_g_mutex_locker (void)
if (TRUE)
{
g_autoptr(GMutexLocker) val = g_mutex_locker_new (&mutex);
+ GThread *thread;
- g_assert (val != NULL);
+ g_assert_nonnull (val);
+
+ /* verify that the mutex is actually locked */
+ thread = g_thread_new ("mutex locked", mutex_locked_thread, &mutex);
+ g_thread_join (thread);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]