Commit a3bcf292 authored by Stephen Morris's avatar Stephen Morris
Browse files

[3533] Minor changes as a result of review.

Comments have been improved in one file.  The other contains a test
that alters logging, so a test fixture has been added that ressets
the logging back to the default in its destructor.
parent ad896487
...@@ -13,10 +13,13 @@ ...@@ -13,10 +13,13 @@
// PERFORMANCE OF THIS SOFTWARE. // PERFORMANCE OF THIS SOFTWARE.
#include <config.h> #include <config.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
#include <cc/data.h>
#include <dhcpsrv/daemon.h> #include <dhcpsrv/daemon.h>
#include <dhcpsrv/logging.h> #include <dhcpsrv/logging.h>
#include <cc/data.h> #include <log/logger_unittest_support.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
using namespace isc; using namespace isc;
...@@ -33,10 +36,27 @@ std::string isc::dhcp::Daemon::getVersion(bool extended) { ...@@ -33,10 +36,27 @@ std::string isc::dhcp::Daemon::getVersion(bool extended) {
namespace { namespace {
/// @brief Daemon Test test fixture class
class DaemonTest : public ::testing::Test {
public:
/// @brief Constructor
DaemonTest() {
}
/// @brief Destructor
///
/// As some of the tests have the side-effect of altering the logging
/// settings (when configureLogger is called), the logging is reset to
/// the default after each test completes.
~DaemonTest() {
isc::log::resetUnitTestRootLogger();
}
};
// Very simple test. Checks whether Daemon can be instantiated and its // Very simple test. Checks whether Daemon can be instantiated and its
// default parameters are sane // default parameters are sane
TEST(DaemonTest, constructor) { TEST_F(DaemonTest, constructor) {
EXPECT_NO_THROW(Daemon instance1); EXPECT_NO_THROW(Daemon instance1);
// Check that the verbose mode is not set by default. // Check that the verbose mode is not set by default.
...@@ -47,7 +67,7 @@ TEST(DaemonTest, constructor) { ...@@ -47,7 +67,7 @@ TEST(DaemonTest, constructor) {
// Checks that configureLogger method is behaving properly. // Checks that configureLogger method is behaving properly.
// More dedicated tests are availablef for LogConfigParser class. // More dedicated tests are availablef for LogConfigParser class.
// See logger_unittest.cc // See logger_unittest.cc
TEST(DaemonTest, parsingConsoleOutput) { TEST_F(DaemonTest, parsingConsoleOutput) {
// Storage - parsed configuration will be stored here // Storage - parsed configuration will be stored here
ConfigurationPtr storage(new Configuration()); ConfigurationPtr storage(new Configuration());
......
// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
// //
// Permission to use, copy, modify, and/or distribute this software for any // Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above // purpose with or without fee is hereby granted, provided that the above
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
#include <config.h> #include <config.h>
#include <config/ccsession.h>
#include <dhcpsrv/dbaccess_parser.h> #include <dhcpsrv/dbaccess_parser.h>
#include <dhcpsrv/dhcp_parsers.h> #include <dhcpsrv/dhcp_parsers.h>
#include <dhcpsrv/lease_mgr_factory.h> #include <dhcpsrv/lease_mgr_factory.h>
#include <config/ccsession.h>
#include <gtest/gtest.h>
#include <log/logger_unittest_support.h> #include <log/logger_unittest_support.h>
#include <gtest/gtest.h>
#include <map> #include <map>
#include <string> #include <string>
...@@ -46,6 +47,10 @@ public: ...@@ -46,6 +47,10 @@ public:
/// ///
/// Just make sure that the lease database is closed after every test /// Just make sure that the lease database is closed after every test
/// (the last in particular). /// (the last in particular).
///
/// As some of the tests have the side-effect of altering the logging
/// settings (when the parser's "build" method is called), ensure that
/// the logging is reset to the default after each test completes.
~DbAccessParserTest() { ~DbAccessParserTest() {
LeaseMgrFactory::destroy(); LeaseMgrFactory::destroy();
isc::log::resetUnitTestRootLogger(); isc::log::resetUnitTestRootLogger();
......
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