]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[mavericks] disable some thread-related death tests on OS X 10.9
authorJINMEI Tatuya <jinmei@isc.org>
Mon, 28 Oct 2013 07:09:54 +0000 (00:09 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Fri, 15 Nov 2013 08:00:39 +0000 (00:00 -0800)
pthread_cond_destroy() doesn't meet the test's assumption.  the mutext test
would still pass, but this is a minor case anyway, so it's probably okay
to just disable both rather introduce more macro variables.

configure.ac
src/lib/util/threads/tests/condvar_unittest.cc
src/lib/util/threads/tests/lock_unittest.cc

index f4c64bb1559ece039987fbeffc9c53b15c55e213..37cf6f5d5b813a136080ec0d1d76d6979c56b3f0 100644 (file)
@@ -218,6 +218,7 @@ AC_HELP_STRING([--disable-setproctitle-check],
 # OS dependent configuration
 SET_ENV_LIBRARY_PATH=no
 ENV_LIBRARY_PATH=LD_LIBRARY_PATH
+bind10_undefined_pthread_behavior=no
 
 case "$host" in
 *-solaris*)
@@ -229,13 +230,20 @@ case "$host" in
        # Destroying locked mutexes, condition variables being waited
        # on, etc. are undefined behavior on Solaris, so we set it as
        # such here.
-       AC_DEFINE([HAS_UNDEFINED_PTHREAD_BEHAVIOR], [1], [Does this platform have some undefined pthreads behavior?])
+       bind10_undefined_pthread_behavior=yes
        ;;
 *-apple-darwin*)
        # Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use
        # (RFC2292 or RFC3542).
        CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"
 
+       # In OS X 10.9 (and possibly any future versions?) pthread_cond_destroy
+       # doesn't work as documented, which makes some of unit tests fail.
+       osx_version=`/usr/bin/sw_vers -productVersion`
+       if [ test $osx_version = "10.9" ]; then
+               bind10_undefined_pthread_behavior=yes
+       fi
+
        # libtool doesn't work perfectly with Darwin: libtool embeds the
        # final install path in dynamic libraries and our loadable python
        # modules always refer to that path even if it's loaded within the
@@ -258,6 +266,9 @@ esac
 AM_CONDITIONAL(SET_ENV_LIBRARY_PATH, test $SET_ENV_LIBRARY_PATH = yes)
 AC_SUBST(SET_ENV_LIBRARY_PATH)
 AC_SUBST(ENV_LIBRARY_PATH)
+if [ test $bind10_undefined_pthread_behavior = "yes" ]; then
+   AC_DEFINE([HAS_UNDEFINED_PTHREAD_BEHAVIOR], [1], [Does this platform have some undefined pthreads behavior?])
+fi
 
 # Our experiments have shown Solaris 10 has broken support for the
 # IPV6_USE_MIN_MTU socket option for getsockopt(); it doesn't return the value
index 3bb7230e39d8cc63539b04eea02f4f00b9d0ea5f..f8043914c3cd6f5e35160c1dc39cc155d94d508f 100644 (file)
@@ -142,8 +142,13 @@ signalAndWait(CondVar* condvar, Mutex* mutex) {
     condvar->wait(*mutex);
 }
 
-#ifndef HAS_UNDEFINED_PTHREAD_BEHAVIOR
-TEST_F(CondVarTest, destroyWhileWait) {
+TEST_F(CondVarTest,
+#ifdef HAS_UNDEFINED_PTHREAD_BEHAVIOR
+       DISABLED_destroyWhileWait
+#else
+       destroyWhileWait
+#endif
+) {
     // We'll destroy a CondVar object while the thread is still waiting
     // on it.  This will trigger an assertion failure.
     if (!isc::util::unittests::runningOnValgrind()) {
@@ -155,7 +160,6 @@ TEST_F(CondVarTest, destroyWhileWait) {
             }, "");
     }
 }
-#endif // !HAS_UNDEFINED_PTHREAD_BEHAVIOR
 
 #ifdef ENABLE_DEBUG
 
index c17999ebdbfdb0ea3376f157ba3ab4dfe015a342..e72b92de50ebbfe38ceb339ed9165e9c426bd9b0 100644 (file)
@@ -86,9 +86,14 @@ TEST(MutexTest, lockNonBlocking) {
 
 #endif // ENABLE_DEBUG
 
-#ifndef HAS_UNDEFINED_PTHREAD_BEHAVIOR
 // Destroying a locked mutex is a bad idea as well
-TEST(MutexTest, destroyLocked) {
+TEST(MutexTest,
+#ifdef HAS_UNDEFINED_PTHREAD_BEHAVIOR
+     DISABLED_destroyLocked
+#else
+     destroyLocked
+#endif
+) {
     if (!isc::util::unittests::runningOnValgrind()) {
         EXPECT_DEATH_IF_SUPPORTED({
             Mutex* mutex = new Mutex;
@@ -99,7 +104,6 @@ TEST(MutexTest, destroyLocked) {
         }, "");
     }
 }
-#endif // !HAS_UNDEFINED_PTHREAD_BEHAVIOR
 
 // In this test, we try to check if a mutex really locks. We could try that
 // with a deadlock, but that's not practical (the test would not end).