]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[trac3867] Update PIDFile test code per review comments
authorShawn Routhier <sar@isc.org>
Thu, 29 Jan 2015 03:37:39 +0000 (19:37 -0800)
committerShawn Routhier <sar@isc.org>
Thu, 29 Jan 2015 03:37:39 +0000 (19:37 -0800)
Update the PIDFile test code to create the file for the
not writable test.

Add entry in ChangeLog

ChangeLog
src/lib/util/tests/pid_file_unittest.cc

index 7fc007d75160d7e15d4e1f444ae74ff14f3bebcb..aed57c0270070c4ebf4609f8553dbe4176b8fe7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+880.   [func]          sar
+       A utility class has been added which handles writing and
+       deleting pid files as well as checking if the process with
+       the given pid is running.
+
 879.   [bug]           fdupont
        Drop DHCPREQUEST message from an unknown client in the
        INIT-REBOOT state.
index d4eb09ae9402e5a30456b455b94abbc3ac5687d5..d8e79645e37566c442538e0cebe885f8a002bcdb 100644 (file)
@@ -23,7 +23,6 @@ using namespace isc::util;
 
 // Filenames used for testing.
 const char* TESTNAME = "pid_file.test";
-const char* TESTNAME2 = "pid_file.test.2";
 
 class PIDFileTest : public ::testing::Test {
 public:
@@ -66,7 +65,6 @@ private:
     /// @brief Removes any remaining test files
     void removeTestFile() const {
         remove(TESTNAME);
-        remove(TESTNAME2);
     }
 
 };
@@ -184,8 +182,14 @@ TEST_F(PIDFileTest, pidGarbage) {
 
 /// @brief Test failing to write a file.
 TEST_F(PIDFileTest, pidWriteFail) {
-    PIDFile pid_file(absolutePath(TESTNAME2));
+    PIDFile pid_file(absolutePath(TESTNAME));
+
+    // Create the test file and change it's permission bits
+    // so we can't write to it.
+    pid_file.write(10);
+    chmod(absolutePath(TESTNAME).c_str(), S_IRUSR);
 
+    // Now try a write to the file, expecting an exception
     EXPECT_THROW(pid_file.write(10), PIDFileError);
 }