Commit 48888c80 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3687] Two minor changes as a result of code review.

PIDFile::write closes the stream before throwing an exception. Also,
remove the TESTNAME2 file before and after the test.
parent 389eb04b
......@@ -75,13 +75,14 @@ PIDFile::write(int pid) const {
// File is open, write the pid.
fs << pid << std::endl;
if (!fs.good()) {
bool good = fs.good();
fs.close();
if (!good()) {
isc_throw(PIDFileError, "Unable to write to PID file '"
<< filename_ << "'");
}
// That's it
fs.close();
}
void
......
......@@ -19,8 +19,9 @@
namespace {
using namespace isc::util;
#define TESTNAME "pid_file.test"
#define TESTNAME2 "pid_file.test.2"
// Filenames used for testing.
const char* TESTNAME = "pid_file.test";
const char* TESTNAME2 = "pid_file.test.2";
class PIDFileTest : public ::testing::Test {
public:
......@@ -63,6 +64,7 @@ private:
/// @brief Removes any remaining test files
void removeTestFile() const {
remove(TESTNAME);
remove(TESTNAME2);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment