Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libpthread PR/51885: Ngie Cooper: Add delays to av...



details:   https://anonhg.NetBSD.org/src/rev/c13921a8f9b2
branches:  trunk
changeset: 820948:c13921a8f9b2
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 16 16:29:54 2017 +0000

description:
PR/51885: Ngie Cooper: Add delays to avoid races.

diffstat:

 tests/lib/libpthread/t_detach.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r 8c1bec7c060f -r c13921a8f9b2 tests/lib/libpthread/t_detach.c
--- a/tests/lib/libpthread/t_detach.c   Mon Jan 16 16:29:19 2017 +0000
+++ b/tests/lib/libpthread/t_detach.c   Mon Jan 16 16:29:54 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $ */
+/* $NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,10 +29,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $");
+__RCSID("$NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $");
 
+#include <errno.h>
 #include <pthread.h>
-#include <errno.h>
+#include <time.h>
 
 #include <atf-c.h>
 
@@ -43,6 +44,7 @@
 static void *
 func(void *arg)
 {
+       sleep(2);
        return NULL;
 }
 
@@ -72,14 +74,17 @@
         */
        PTHREAD_REQUIRE(pthread_detach(t));
 
+       sleep(1);
        rv = pthread_join(t, NULL);
        ATF_REQUIRE(rv == EINVAL);
 
+       sleep(3);
+
        /*
         * As usual, ESRCH should follow if
         * we try to detach an invalid thread.
         */
-       rv = pthread_cancel(NULL);
+       rv = pthread_cancel(t);
        ATF_REQUIRE(rv == ESRCH);
 }
 



Home | Main Index | Thread Index | Old Index