EXPECT_FALSE(server.getDataSrcClientList(RRClass::CH()));
}
+#ifdef ENABLE_DEBUG
+
// We just test the mutex can be locked (exactly once).
TEST_F(AuthSrvTest, mutex) {
isc::util::thread::Mutex::Locker l1(server.getDataSrcClientListMutex());
}, isc::InvalidOperation);
}
+#endif // ENABLE_DEBUG
+
}
isc_throw(isc::InvalidOperation, std::strerror(result));
}
Deinitializer deinitializer(attributes);
+
+#ifdef ENABLE_DEBUG
// TODO: Distinguish if debug mode is enabled in compilation.
- // If so, it should be PTHREAD_MUTEX_NORMAL or NULL
result = pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_ERRORCHECK);
if (result != 0) {
isc_throw(isc::InvalidOperation, std::strerror(result));
}
+#endif // ENABLE_DEBUG
+
auto_ptr<Impl> impl(new Impl);
result = pthread_mutex_init(&impl->mutex, &attributes);
switch (result) {
}, "");
}
+#ifdef ENABLE_DEBUG
+
TEST_F(CondVarTest, badWait) {
// In our implementation, wait() requires acquiring the lock beforehand.
-#ifdef ENABLE_DEBUG
EXPECT_THROW(condvar_.wait(mutex_), isc::InvalidOperation);
-#else
- EXPECT_THROW(condvar_.wait(mutex_), isc::BadValue);
-#endif // ENABLE_DEBUG
}
+#endif // ENABLE_DEBUG
+
TEST_F(CondVarTest, emptySignal) {
// It's okay to call signal when no one waits.
EXPECT_NO_THROW(condvar_.signal());
namespace {
-// If we try to lock the debug mutex multiple times, it should throw.
+#ifdef ENABLE_DEBUG
+
+// If we try to lock the debug mutex multiple times, it should
+// throw. This test will complete properly only when pthread debugging
+// facilities are enabled by configuring the code for debug build.
TEST(MutexTest, lockMultiple) {
// TODO: Once we support non-debug mutexes, disable the test if we compile
// with them.
Mutex mutex;
-#ifdef ENABLE_DEBUG
EXPECT_FALSE(mutex.locked()); // Debug-only build
-#endif // ENABLE_DEBUG
Mutex::Locker l1(mutex);
-#ifdef ENABLE_DEBUG
EXPECT_TRUE(mutex.locked()); // Debug-only build
-#endif // ENABLE_DEBUG
EXPECT_THROW({
Mutex::Locker l2(mutex); // Attempt to lock again.
}, isc::InvalidOperation);
-#ifdef ENABLE_DEBUG
EXPECT_TRUE(mutex.locked()); // Debug-only build
-#endif // ENABLE_DEBUG
}
+#endif // ENABLE_DEBUG
+
// Destroying a locked mutex is a bad idea as well
#ifdef EXPECT_DEATH
TEST(MutexTest, destroyLocked) {