mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Add a test involving g_thread_ref/unref
Also, fix the resource-limit test to properly unset RLIMIT_NPROC.
This commit is contained in:
parent
81431fa5b8
commit
52321def8f
@ -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 ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user