Browse Source

[master] Disable MutexTest.destoryLocked on Solaris

Mukund Sivaraman 12 years ago
parent
commit
f49a406828
2 changed files with 9 additions and 3 deletions
  1. 4 0
      configure.ac
  2. 5 3
      src/lib/util/threads/tests/lock_unittest.cc

+ 4 - 0
configure.ac

@@ -217,6 +217,10 @@ case "$host" in
 	CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
 	CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
 	# "now" binding is necessary to prevent deadlocks in C++ static initialization code
 	# "now" binding is necessary to prevent deadlocks in C++ static initialization code
 	LDFLAGS="$LDFLAGS -z now"
 	LDFLAGS="$LDFLAGS -z now"
+	# 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?])
 	;;
 	;;
 *-apple-darwin*)
 *-apple-darwin*)
 	# Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use
 	# Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use

+ 5 - 3
src/lib/util/threads/tests/lock_unittest.cc

@@ -12,6 +12,8 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 // PERFORMANCE OF THIS SOFTWARE.
 
 
+#include <config.h>
+
 #include <gtest/gtest.h>
 #include <gtest/gtest.h>
 
 
 #include <util/threads/sync.h>
 #include <util/threads/sync.h>
@@ -46,11 +48,11 @@ TEST(MutexTest, lockMultiple) {
 
 
 #endif // ENABLE_DEBUG
 #endif // ENABLE_DEBUG
 
 
+#ifndef HAS_UNDEFINED_PTHREAD_BEHAVIOR
 // Destroying a locked mutex is a bad idea as well
 // Destroying a locked mutex is a bad idea as well
-#ifdef EXPECT_DEATH
 TEST(MutexTest, destroyLocked) {
 TEST(MutexTest, destroyLocked) {
     if (!isc::util::unittests::runningOnValgrind()) {
     if (!isc::util::unittests::runningOnValgrind()) {
-        EXPECT_DEATH({
+        EXPECT_DEATH_IF_SUPPORTED({
             Mutex* mutex = new Mutex;
             Mutex* mutex = new Mutex;
             new Mutex::Locker(*mutex);
             new Mutex::Locker(*mutex);
             delete mutex;
             delete mutex;
@@ -59,7 +61,7 @@ TEST(MutexTest, destroyLocked) {
         }, "");
         }, "");
     }
     }
 }
 }
-#endif
+#endif // !HAS_UNDEFINED_PTHREAD_BEHAVIOR
 
 
 // In this test, we try to check if a mutex really locks. We could try that
 // 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).
 // with a deadlock, but that's not practical (the test would not end).