From: Francis Dupont Date: Sat, 19 Sep 2015 19:18:49 +0000 (+0200) Subject: [4062] Fixed waitpid() with debug and KEA_PIDFILE_DIR issues X-Git-Tag: trac3874_base~34^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e2f5ea1dbc5e6c31e12ab0928ef430a4ac40758;p=thirdparty%2Fkea.git [4062] Fixed waitpid() with debug and KEA_PIDFILE_DIR issues --- diff --git a/src/lib/dhcpsrv/tests/daemon_unittest.cc b/src/lib/dhcpsrv/tests/daemon_unittest.cc index d961e39d9c..b5a3d754f7 100644 --- a/src/lib/dhcpsrv/tests/daemon_unittest.cc +++ b/src/lib/dhcpsrv/tests/daemon_unittest.cc @@ -74,6 +74,9 @@ public: // Very simple test. Checks whether Daemon can be instantiated and its // default parameters are sane TEST_F(DaemonTest, constructor) { + // Disable KEA_PIDFILE_DIR + EXPECT_EQ(0, unsetenv("KEA_PIDFILE_DIR")); + EXPECT_NO_THROW(Daemon instance1); // Check that the verbose mode is not set by default. @@ -164,7 +167,7 @@ TEST_F(DaemonTest, makePIDFileName) { // Make sure the name is as we expect std::ostringstream stream; - stream << CfgMgr::instance().getDataDir() << "/test.myproc.pid"; + stream << instance.getPIDFileDir() << "/test.myproc.pid"; EXPECT_EQ(stream.str(), name); // Verify that the default directory can be overridden @@ -207,8 +210,12 @@ TEST_F(DaemonTest, createPIDFileOverwrite) { } // Back in the parent test, we need to wait for the child to die + // As with debugging waitpid() can be interrupted ignore EINTR. int stat; - int ret = waitpid(pid, &stat, 0); + int ret; + do { + ret = waitpid(pid, &stat, 0); + } while ((ret == -1) && (errno == EINTR)); ASSERT_EQ(ret, pid); // Ok, so we should now have a PID that we know to be dead.