Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libpthread Try to trigger the cond_timedwait_race ...
details: https://anonhg.NetBSD.org/src/rev/3eb13173f7b2
branches: trunk
changeset: 785518:3eb13173f7b2
user: jmmv <jmmv%NetBSD.org@localhost>
date: Sun Mar 17 05:13:13 2013 +0000
description:
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:
tests/lib/libpthread/t_cond.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diffs (52 lines):
diff -r 54f415ed5288 -r 3eb13173f7b2 tests/lib/libpthread/t_cond.c
--- a/tests/lib/libpthread/t_cond.c Sun Mar 17 05:02:13 2013 +0000
+++ b/tests/lib/libpthread/t_cond.c Sun Mar 17 05:13:13 2013 +0000
@@ -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_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++) {
+ /* 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));
- }
+ PTHREAD_REQUIRE(pthread_create(&tid[i], NULL,
+ pthread_cond_timedwait_func, NULL));
+ }
- for (i = 0; i < __arraycount(tid); i++) {
+ for (i = 0; i < __arraycount(tid); i++) {
- PTHREAD_REQUIRE(pthread_join(tid[i], NULL));
+ PTHREAD_REQUIRE(pthread_join(tid[i], NULL));
+ }
}
}
Home |
Main Index |
Thread Index |
Old Index