diff options
author | ngie <ngie@FreeBSD.org> | 2015-01-17 00:58:24 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-01-17 00:58:24 +0000 |
commit | c26ac3fe45e853d5e2b5a20ef72c217c2fbb2f53 (patch) | |
tree | 699d29b228bc7a024cc623d9fe6f362d512b9b55 /contrib/netbsd-tests | |
parent | dddf8376c3d7ac5676dd84d020f202f61b4a12a0 (diff) | |
download | FreeBSD-src-c26ac3fe45e853d5e2b5a20ef72c217c2fbb2f53.zip FreeBSD-src-c26ac3fe45e853d5e2b5a20ef72c217c2fbb2f53.tar.gz |
Fix lib/libthr/tests/detach_test
- Eliminate race with liberal use of sleep(3) [1]
- Fix NetBSD-specific implementation way of testing result from pthread_cancel
by testing with `td` instead of `NULL` [2]
PR: 196738 [1]
PR: 191906 [2]
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/netbsd-tests')
-rw-r--r-- | contrib/netbsd-tests/lib/libpthread/t_detach.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/contrib/netbsd-tests/lib/libpthread/t_detach.c b/contrib/netbsd-tests/lib/libpthread/t_detach.c index 8922d5a..b3357bc 100644 --- a/contrib/netbsd-tests/lib/libpthread/t_detach.c +++ b/contrib/netbsd-tests/lib/libpthread/t_detach.c @@ -38,11 +38,18 @@ __RCSID("$NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $"); #include "h_common.h" +#ifdef __FreeBSD__ +#include <time.h> +#endif + static void *func(void *); static void * func(void *arg) { +#ifdef __FreeBSD__ + sleep(2); +#endif return NULL; } @@ -72,18 +79,25 @@ ATF_TC_BODY(pthread_detach, tc) */ PTHREAD_REQUIRE(pthread_detach(t)); +#ifdef __FreeBSD__ + sleep(1); +#endif rv = pthread_join(t, NULL); ATF_REQUIRE(rv == EINVAL); #ifdef __FreeBSD__ - atf_tc_expect_fail("PR # 191906: fails with EINVAL, not ESRCH"); + sleep(3); #endif /* * As usual, ESRCH should follow if * we try to detach an invalid thread. */ +#ifdef __NetBSD__ rv = pthread_cancel(NULL); +#else + rv = pthread_cancel(t); +#endif ATF_REQUIRE(rv == ESRCH); } |