]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4065] Added unit test
authorFrancis Dupont <fdupont@isc.org>
Wed, 23 Sep 2015 20:44:18 +0000 (22:44 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 23 Sep 2015 20:44:18 +0000 (22:44 +0200)
src/lib/util/threads/tests/thread_unittest.cc

index dca2503e7d30e16b051da61447f0175593c5159c..347d91348b82a04266a698c115c92e39cd995a1f 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <gtest/gtest.h>
 
+#include <signal.h>
+
 // This file tests the Thread class. It's hard to test an actual thread is
 // started, but we at least check the function is run and exceptions are
 // propagated as they should.
@@ -106,4 +108,20 @@ TEST(ThreadTest, exception) {
     }
 }
 
+void
+getSignalMask(sigset_t* mask) {
+    pthread_sigmask(SIG_SETMASK, 0, mask);
+}
+
+// Verify that all signals are blocked
+TEST(ThreadTest, sigmask) {
+    sigset_t mask;
+    sigemptyset(&mask);
+    Thread thread(boost::bind(getSignalMask, &mask));
+    ASSERT_NO_THROW(thread.wait());
+    EXPECT_EQ(1, sigismember(&mask, SIGHUP));
+    EXPECT_EQ(1, sigismember(&mask, SIGINT));
+    EXPECT_EQ(1, sigismember(&mask, SIGTERM));
+}
+
 }