Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
dd46abf6
Commit
dd46abf6
authored
Jun 08, 2011
by
Stephen Morris
Browse files
[trac976] Ensure unit tests reset back to original logging state
parent
cbe4f685
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/log/tests/logger_level_unittest.cc
View file @
dd46abf6
...
...
@@ -26,14 +26,10 @@ using namespace isc;
using
namespace
isc
::
log
;
using
namespace
std
;
namespace
{
string
ROOT_NAME
(
"logleveltest"
);
}
class
LoggerLevelTest
:
public
::
testing
::
Test
{
protected:
LoggerLevelTest
()
{
Logger
Manager
::
init
(
ROOT_NAME
);
//
Logger
initialization is done in main()
}
~
LoggerLevelTest
()
{
LoggerManager
::
reset
();
...
...
@@ -62,11 +58,6 @@ TEST_F(LoggerLevelTest, Creation) {
}
TEST
(
LoggerLevel
,
getSeverity
)
{
// Should initialize logger as getSeverity() may output
// a message. This gives a properly-qualified logger
// name.
LoggerManager
::
init
(
ROOT_NAME
);
EXPECT_EQ
(
DEBUG
,
getSeverity
(
"DEBUG"
));
EXPECT_EQ
(
DEBUG
,
getSeverity
(
"debug"
));
EXPECT_EQ
(
DEBUG
,
getSeverity
(
"DeBuG"
));
...
...
src/lib/log/tests/logger_manager_unittest.cc
View file @
dd46abf6
...
...
@@ -40,15 +40,11 @@ using namespace isc;
using
namespace
isc
::
log
;
using
namespace
std
;
namespace
{
string
ROOT_NAME
(
"logmgrtest"
);
}
/// \brief LoggerManager Test
class
LoggerManagerTest
:
public
::
testing
::
Test
{
public:
LoggerManagerTest
()
{
LoggerManager
::
init
(
ROOT_NAME
);
// Initialization of logging is done in main()
}
~
LoggerManagerTest
()
{
...
...
src/lib/log/tests/logger_name_unittest.cc
View file @
dd46abf6
...
...
@@ -21,9 +21,30 @@
using
namespace
isc
;
using
namespace
isc
::
log
;
// Test class. To avoid disturbing the root logger configuration in other
// tests in the suite, the root logger name is saved in the constructor and
// restored in the destructor. However, this is a bit chicken and egg, as the
// functions used to do the save and restore are those being tested...
//
// Note that the root name is originally set by the initialization of the
// logging configuration done in main().
class
LoggerNameTest
:
public
::
testing
::
Test
{
public:
LoggerNameTest
()
{
name_
=
getRootLoggerName
();
}
~
LoggerNameTest
()
{
setRootLoggerName
(
name_
);
}
private:
std
::
string
name_
;
///< Saved name
};
// Check setting and getting of root name
TEST
(
LoggerNameTest
,
RootNameSetGet
)
{
TEST
_F
(
LoggerNameTest
,
RootNameSetGet
)
{
const
std
::
string
name1
=
"test1"
;
const
std
::
string
name2
=
"test2"
;
...
...
@@ -44,7 +65,7 @@ TEST(LoggerNameTest, RootNameSetGet) {
// Check expansion of name
TEST
(
LoggerNameTest
,
ExpandLoggerName
)
{
TEST
_F
(
LoggerNameTest
,
ExpandLoggerName
)
{
const
std
::
string
ROOT
=
"example"
;
const
std
::
string
NAME
=
"something"
;
const
std
::
string
FULL_NAME
=
ROOT
+
"."
+
NAME
;
...
...
src/lib/log/tests/logger_unittest.cc
View file @
dd46abf6
...
...
@@ -26,10 +26,6 @@ using namespace isc;
using
namespace
isc
::
log
;
using
namespace
std
;
namespace
{
string
ROOT_NAME
=
"loggertest"
;
}
/// \brief Logger Test
///
/// As the logger is only a shell around the implementation, this tests also
...
...
@@ -38,7 +34,7 @@ string ROOT_NAME = "loggertest";
class
LoggerTest
:
public
::
testing
::
Test
{
public:
LoggerTest
()
{
LoggerManager
::
init
(
ROOT_NAME
);
// Initialization of logging is done in main()
}
~
LoggerTest
()
{
LoggerManager
::
reset
();
...
...
@@ -54,7 +50,7 @@ TEST_F(LoggerTest, Name) {
Logger
logger
(
"alpha"
);
// ... and check the name
EXPECT_EQ
(
ROOT_NAME
+
string
(
".alpha"
),
logger
.
getName
());
EXPECT_EQ
(
getRootLoggerName
()
+
string
(
".alpha"
),
logger
.
getName
());
}
// This test attempts to get two instances of a logger with the same name
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment