PIDFile::write closes the stream before throwing an exception. Also,
remove the TESTNAME2 file before and after the test.
// 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
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:
/// @brief Removes any remaining test files
void removeTestFile() const {
remove(TESTNAME);
+ remove(TESTNAME2);
}
};