BIND 10 trac2202, updated. c74022e2d7acf6b77979e9c8b646d5da95419ed3 Add a timeout in case something got stuck

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 1 13:22:51 UTC 2012


The branch, trac2202 has been updated
       via  c74022e2d7acf6b77979e9c8b646d5da95419ed3 (commit)
       via  310150445a17a5043cb5e93ce5ecaddd0336b196 (commit)
      from  c4e44c1a57326915e7291e982e2271b6574f73fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c74022e2d7acf6b77979e9c8b646d5da95419ed3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 1 15:22:39 2012 +0200

    Add a timeout in case something got stuck

commit 310150445a17a5043cb5e93ce5ecaddd0336b196
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 1 15:17:51 2012 +0200

    [2202] Try throwing std::exception too

-----------------------------------------------------------------------

Summary of changes:
 src/lib/util/threads/tests/lock_unittest.cc   |   18 ++++++++++++++++++
 src/lib/util/threads/tests/thread_unittest.cc |   10 ++++++++++
 2 files changed, 28 insertions(+)

-----------------------------------------------------------------------
diff --git a/src/lib/util/threads/tests/lock_unittest.cc b/src/lib/util/threads/tests/lock_unittest.cc
index 748580c..e1edd70 100644
--- a/src/lib/util/threads/tests/lock_unittest.cc
+++ b/src/lib/util/threads/tests/lock_unittest.cc
@@ -18,6 +18,8 @@
 #include <gtest/gtest.h>
 
 #include <boost/bind.hpp>
+#include <unistd.h>
+#include <signal.h>
 
 using namespace isc::util::thread;
 
@@ -117,7 +119,18 @@ performStrangeOperation(std::vector<long long unsigned> array, int direction,
     }
 }
 
+void
+no_handler(int) {}
+
 TEST(MutexTest, swarm) {
+    // Create a timeout in case something got stuck here
+    struct sigaction ignored, original;
+    memset(&ignored, 0, sizeof ignored);
+    ignored.sa_handler = no_handler;
+    if (sigaction(SIGALRM, &ignored, &original)) {
+        FAIL() << "Couldn't set alarm";
+    }
+    alarm(10);
     // This type has a low chance of being atomic itself, further raising
     // the chance of problems appearing.
     std::vector<long long unsigned> array(length);
@@ -136,6 +149,11 @@ TEST(MutexTest, swarm) {
         sum += array[i];
     }
     EXPECT_EQ(length * value, sum) << "Threads are badly synchronized";
+    // Cancel the alarm and return the original handler
+    alarm(0);
+    if (sigaction(SIGALRM, &original, NULL)) {
+        FAIL() << "Couldn't restore alarm";
+    }
 }
 
 }
diff --git a/src/lib/util/threads/tests/thread_unittest.cc b/src/lib/util/threads/tests/thread_unittest.cc
index 97cace2..4d477ee 100644
--- a/src/lib/util/threads/tests/thread_unittest.cc
+++ b/src/lib/util/threads/tests/thread_unittest.cc
@@ -73,18 +73,28 @@ throwSomething() {
     throw 42; // Throw something really unusual, to see everything is caught.
 }
 
+void
+throwException() {
+    throw std::exception();
+}
+
 // Exception in the thread we forget about should not do anything to us
 TEST(ThreadTest, detachedException) {
     for (size_t i = 0; i < detached_iterations; ++i) {
         Thread thread(throwSomething);
     }
+    for (size_t i = 0; i < detached_iterations; ++i) {
+        Thread thread(throwException);
+    }
 }
 
 // An uncaught exception in the thread should propagate through wait
 TEST(ThreadTest, exception) {
     for (size_t i = 0; i < iterations; ++i) {
         Thread thread(throwSomething);
+        Thread thread2(throwException);
         ASSERT_THROW(thread.wait(), Thread::UncaughtException);
+        ASSERT_THROW(thread2.wait(), Thread::UncaughtException);
     }
 }
 



More information about the bind10-changes mailing list