[glib] Add a test involving g_thread_ref/unref
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add a test involving g_thread_ref/unref
- Date: Sat, 15 Oct 2011 03:21:18 +0000 (UTC)
commit 52321def8f187eb1586c8989c407b473e19cf2e6
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 14 23:20:06 2011 -0400
Add a test involving g_thread_ref/unref
Also, fix the resource-limit test to properly unset RLIMIT_NPROC.
glib/tests/thread.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/glib/tests/thread.c b/glib/tests/thread.c
index 5d052b0..488f961 100644
--- a/glib/tests/thread.c
+++ b/glib/tests/thread.c
@@ -128,8 +128,8 @@ test_thread4 (void)
GError *error;
gint ret;
+ getrlimit (RLIMIT_NPROC, &nl);
nl.rlim_cur = 1;
- nl.rlim_max = 1;
if ((ret = prlimit (getpid(), RLIMIT_NPROC, &nl, &ol)) != 0)
g_error ("prlimit failed: %s\n", g_strerror (ret));
@@ -140,10 +140,22 @@ test_thread4 (void)
g_assert_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN);
g_error_free (error);
- prlimit (getpid (), RLIMIT_NPROC, &ol, NULL);
+ if ((ret = prlimit (getpid (), RLIMIT_NPROC, &ol, NULL)) != 0)
+ g_error ("resetting RLIMIT_NPROC failed: %s\n", g_strerror (ret));
#endif
}
+static void
+test_thread5 (void)
+{
+ GThread *thread;
+
+ thread = g_thread_new ("a", thread3_func, NULL);
+ g_thread_ref (thread);
+ g_thread_join (thread);
+ g_thread_unref (thread);
+}
+
int
main (int argc, char *argv[])
{
@@ -153,6 +165,7 @@ main (int argc, char *argv[])
g_test_add_func ("/thread/thread2", test_thread2);
g_test_add_func ("/thread/thread3", test_thread3);
g_test_add_func ("/thread/thread4", test_thread4);
+ g_test_add_func ("/thread/thread5", test_thread5);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]