Module Name:    src
Committed By:   jmmv
Date:           Sun Mar 17 05:13:13 UTC 2013

Modified Files:
        src/tests/lib/libpthread: t_cond.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libpthread/t_cond.c
diff -u src/tests/lib/libpthread/t_cond.c:1.3 src/tests/lib/libpthread/t_cond.c:1.4
--- src/tests/lib/libpthread/t_cond.c:1.3	Sun Mar 27 16:45:15 2011
+++ src/tests/lib/libpthread/t_cond.c	Sun Mar 17 05:13:13 2013
@@ -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");
+	/* 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++) {
+		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));
+			PTHREAD_REQUIRE(pthread_join(tid[i], NULL));
+		}
 	}
 }
 

Reply via email to