Browse Source

[4065] Added unit test

Francis Dupont 9 years ago
parent
commit
eb23a705a4
1 changed files with 18 additions and 0 deletions
  1. 18 0
      src/lib/util/threads/tests/thread_unittest.cc

+ 18 - 0
src/lib/util/threads/tests/thread_unittest.cc

@@ -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));
+}
+
 }