Module Name:    src
Committed By:   riz
Date:           Mon Feb 21 21:43:41 UTC 2011

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

Log Message:
mutex2/mutex3 are expected to fail on powerpc because of
PR port-powerpc/44387.

XXX the ugly sleep at the end is because ATF will mark an un-triggered
race condition (ie, the test passes unexpectedly) as a test failure otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libpthread/t_mutex.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_mutex.c
diff -u src/tests/lib/libpthread/t_mutex.c:1.3 src/tests/lib/libpthread/t_mutex.c:1.4
--- src/tests/lib/libpthread/t_mutex.c:1.3	Sun Feb 20 14:37:44 2011
+++ src/tests/lib/libpthread/t_mutex.c	Mon Feb 21 21:43:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mutex.c,v 1.3 2011/02/20 14:37:44 jmmv Exp $ */
+/* $NetBSD: t_mutex.c,v 1.4 2011/02/21 21:43:41 riz Exp $ */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,13 +29,15 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mutex.c,v 1.3 2011/02/20 14:37:44 jmmv Exp $");
+__RCSID("$NetBSD: t_mutex.c,v 1.4 2011/02/21 21:43:41 riz Exp $");
 
 #include <pthread.h>
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <atf-c.h>
+#include <atf-c/config.h>
 
 #include "h_common.h"
 
@@ -116,17 +118,24 @@
 ATF_TC_HEAD(mutex2, tc)
 {
 	atf_tc_set_md_var(tc, "descr", "Checks mutexes");
+	atf_tc_set_md_var(tc, "timeout", "40");
 }
 ATF_TC_BODY(mutex2, tc)
 {
+	const char *m_arch;
 	int count, count2;
 	pthread_t new;
 	void *joinval;
 
 	printf("1: Mutex-test 2\n");
 
-	PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
+	m_arch = atf_config_get("atf_arch");
+	if (strcmp(m_arch, "powerpc") == 0) {
+		atf_tc_expect_timeout("PR port-powerpc/44387");
+	}
 
+	PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
+	
 	global_x = 0;
 	count = count2 = 10000000;
 
@@ -149,6 +158,14 @@
 	printf("1: Thread joined. X was %d. Return value (long) was %ld\n",
 		global_x, (long)joinval);
 	ATF_REQUIRE_EQ(global_x, 20000000);
+
+	/* XXX force a timeout in ppc case since an un-triggered race
+	   otherwise looks like a "failure" */
+	if (strcmp(m_arch, "powerpc") == 0) {
+		/* We sleep for longer than the timeout to make ATF not
+		   complain about unexpected success */
+		sleep(41);
+	}
 }
 
 static void *
@@ -172,15 +189,22 @@
 {
 	atf_tc_set_md_var(tc, "descr", "Checks mutexes using a static "
 	    "initializer");
+	atf_tc_set_md_var(tc, "timeout", "40");
 }
 ATF_TC_BODY(mutex3, tc)
 {
+	const char *m_arch;
 	int count, count2;
 	pthread_t new;
 	void *joinval;
 
 	printf("1: Mutex-test 3\n");
 
+	m_arch = atf_config_get("atf_arch");
+	if (strcmp(m_arch, "powerpc") == 0) {
+		atf_tc_expect_timeout("PR port-powerpc/44387");
+	}
+
 	global_x = 0;
 	count = count2 = 10000000;
 
@@ -203,6 +227,14 @@
 	printf("1: Thread joined. X was %d. Return value (long) was %ld\n",
 		global_x, (long)joinval);
 	ATF_REQUIRE_EQ(global_x, 20000000);
+
+	/* XXX force a timeout in ppc case since an un-triggered race
+	   otherwise looks like a "failure" */
+	if (strcmp(m_arch, "powerpc") == 0) {
+		/* We sleep for longer than the timeout to make ATF not
+		   complain about unexpected success */
+		sleep(41);
+	}
 }
 
 static void *

Reply via email to