diff options
| author | jmmv <jmmv@NetBSD.org> | 2013-03-17 05:13:13 +0000 |
|---|---|---|
| committer | jmmv <jmmv@NetBSD.org> | 2013-03-17 05:13:13 +0000 |
| commit | ebffb39ba69b5cce7d9330404baf215fc32436f9 (patch) | |
| tree | 584fb21b42abeb8f0616035ea20d030cacbf526a /tests/lib/libpthread | |
| parent | 73edb6eb1c465f72fb68424da348fa60c9922768 (diff) | |
Try to trigger the cond_timedwait_race race several times.
Sometime this tests passes (after all, it's exercising a race condition) and
when it does it's reported as a failure. By giving the test a few chances
to expose the problem, we prevent this noisy signal. When the race is really
addressed, this will start failing consistently as expected.
Diffstat (limited to 'tests/lib/libpthread')
| -rw-r--r-- | tests/lib/libpthread/t_cond.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/tests/lib/libpthread/t_cond.c b/tests/lib/libpthread/t_cond.c index 771bf5dd0a0..1036c0d63cf 100644 --- a/tests/lib/libpthread/t_cond.c +++ b/tests/lib/libpthread/t_cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_cond.c,v 1.3 2011/03/27 16:45:15 jruoho Exp $ */ +/* $NetBSD: t_cond.c,v 1.4 2013/03/17 05:13:13 jmmv Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_cond.c,v 1.3 2011/03/27 16:45:15 jruoho Exp $"); +__RCSID("$NetBSD: t_cond.c,v 1.4 2013/03/17 05:13:13 jmmv Exp $"); #include <sys/time.h> @@ -349,19 +349,25 @@ ATF_TC_HEAD(cond_timedwait_race, tc) ATF_TC_BODY(cond_timedwait_race, tc) { pthread_t tid[64]; - size_t i; + size_t i, j; atf_tc_expect_fail("PR lib/44756"); - - for (i = 0; i < __arraycount(tid); i++) { - - PTHREAD_REQUIRE(pthread_create(&tid[i], NULL, - pthread_cond_timedwait_func, NULL)); - } - - for (i = 0; i < __arraycount(tid); i++) { - - PTHREAD_REQUIRE(pthread_join(tid[i], NULL)); + /* This outer loop is to ensure that a false positive of this race + * test does not report the test as broken (due to the test not + * triggering the expected failure). However, we want to make this + * fail consistently when the race is resolved, and this approach + * will have the desired effect. */ + for (j = 0; j < 10; j++ ) { + for (i = 0; i < __arraycount(tid); i++) { + + PTHREAD_REQUIRE(pthread_create(&tid[i], NULL, + pthread_cond_timedwait_func, NULL)); + } + + for (i = 0; i < __arraycount(tid); i++) { + + PTHREAD_REQUIRE(pthread_join(tid[i], NULL)); + } } } |
