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/279adf52781f
branches: trunk
changeset: 350697:279adf52781f
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 6e6d6871bf02 -r 279adf52781f 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