BIND 10 master, updated. 3acb0511190ab3c0b2711f712adfef35c172af05 Merge branch 'trac1033'
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jan 16 09:10:53 UTC 2014
The branch, master has been updated
via 3acb0511190ab3c0b2711f712adfef35c172af05 (commit)
via f45a1ff6b8d569bbaa913cbdd594b1ab6d8f88e5 (commit)
from 5a2b69ed6fcb4f4ff2589f679716cb9436116232 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3acb0511190ab3c0b2711f712adfef35c172af05
Merge: 5a2b69e f45a1ff
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu Jan 16 14:34:36 2014 +0530
Merge branch 'trac1033'
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/tests/logger_manager_unittest.cc | 81 ++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/lib/log/tests/logger_manager_unittest.cc b/src/lib/log/tests/logger_manager_unittest.cc
index e615c41..90f8904 100644
--- a/src/lib/log/tests/logger_manager_unittest.cc
+++ b/src/lib/log/tests/logger_manager_unittest.cc
@@ -36,6 +36,9 @@
#include "tempdir.h"
+#include <sys/types.h>
+#include <regex.h>
+
using namespace isc;
using namespace isc::log;
using namespace std;
@@ -323,3 +326,81 @@ TEST_F(LoggerManagerTest, FileSizeRollover) {
(void) unlink(prev_name[i].c_str());
}
}
+
+namespace { // begin unnamed namespace
+
+// When we begin to use C++11, we could replace use of POSIX API with
+// <regex>.
+
+class RegexHolder {
+public:
+ RegexHolder(const char* expr, const int flags = REG_EXTENDED) {
+ const int rc = regcomp(®ex_, expr, flags);
+ if (rc) {
+ regfree(®ex_);
+ throw;
+ }
+ }
+
+ ~RegexHolder() {
+ regfree(®ex_);
+ }
+
+ regex_t* operator*() {
+ return (®ex_);
+ }
+
+private:
+ regex_t regex_;
+};
+
+} // end of unnamed namespace
+
+// Check that the logger correctly outputs the full formatted layout
+// pattern.
+TEST_F(LoggerManagerTest, checkLayoutPattern) {
+ // Create a specification for the file logger and use the manager to
+ // connect the "filelogger" logger to it.
+ SpecificationForFileLogger file_spec;
+
+ // For the first test, we want to check that the file is created
+ // if it does not already exist. So delete the temporary file before
+ // logging the first message.
+ unlink(file_spec.getFileName().c_str());
+
+ // Set up the file appenders.
+ LoggerManager manager;
+ manager.process(file_spec.getSpecification());
+
+ // Try logging to the file. Local scope is set to ensure that the logger
+ // is destroyed before we reset the global logging.
+ {
+ Logger logger(file_spec.getLoggerName().c_str());
+ LOG_FATAL(logger, LOG_DUPLICATE_MESSAGE_ID).arg("test");
+ }
+
+ LoggerManager::reset();
+
+ // Access the file for input
+ const std::string& filename = file_spec.getFileName();
+ ifstream infile(filename.c_str());
+ if (! infile.good()) {
+ FAIL() << "Unable to open the logging file " << filename;
+ }
+
+ std::string line;
+ std::getline(infile, line);
+
+ RegexHolder regex(// %D{%Y-%m-%d %H:%M:%S.%q}
+ "^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}[[:space:]]"
+ "[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}\\.[[:digit:]]+[[:space:]]"
+ // %-5p
+ "[[:alpha:]]{1,5}[[:space:]]"
+ // [%c/%i]
+ "\\[[[:alnum:]\\-\\.]+/[[:digit:]]+\\][[:space:]]"
+ );
+
+ const int re = regexec(*regex, line.c_str(), 0, NULL, 0);
+ ASSERT_EQ(0, re)
+ << "Logged message does not match expected layout pattern";
+}
More information about the bind10-changes
mailing list