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
a6cd2245
Commit
a6cd2245
authored
Jul 25, 2013
by
Stephen Morris
Browse files
[2981] Final modifications before review
parent
aac023f8
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/tests/config_parser_unittest.cc
View file @
a6cd2245
...
...
@@ -1870,12 +1870,13 @@ TEST_F(Dhcp4ParserTest, NoHooksLibraries) {
string
config
=
buildHooksLibrariesConfig
();
if
(
!
executeConfiguration
(
config
,
"set configuration with no hooks libraries"
))
{
return
;
}
FAIL
()
<<
"Unable to execute configuration"
;
// No libraries should be loaded at the end of the test.
libraries
=
HooksManager
::
getLibraryNames
();
ASSERT_TRUE
(
libraries
.
empty
());
}
else
{
// No libraries should be loaded at the end of the test.
libraries
=
HooksManager
::
getLibraryNames
();
EXPECT_TRUE
(
libraries
.
empty
());
}
}
// Verify parsing fails with one library that will fail validation.
...
...
@@ -1906,8 +1907,8 @@ TEST_F(Dhcp4ParserTest, LibrariesSpecified) {
ASSERT_TRUE
(
libraries
.
empty
());
// Marker files should not be present.
EXPECT_
TRU
E
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
NULL
));
EXPECT_
TRU
E
(
checkMarkerFile
(
UNLOAD_MARKER_FILE
,
NULL
));
EXPECT_
FALS
E
(
checkMarkerFile
Exists
(
LOAD_MARKER_FILE
));
EXPECT_
FALS
E
(
checkMarkerFile
Exists
(
UNLOAD_MARKER_FILE
));
// Set up the configuration with two libraries and load them.
string
config
=
buildHooksLibrariesConfig
(
CALLOUT_LIBRARY_1
,
...
...
@@ -1917,10 +1918,10 @@ TEST_F(Dhcp4ParserTest, LibrariesSpecified) {
// Expect two libraries to be loaded in the correct order (load marker file
// is present, no unload marker file).
libraries
=
HooksManager
::
getLibraryNames
();
ASSERT_EQ
(
2
,
libraries
.
size
());
EXPECT_TRUE
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
"12"
));
EXPECT_
TRU
E
(
checkMarkerFile
(
UNLOAD_MARKER_FILE
,
NULL
));
libraries
=
HooksManager
::
getLibraryNames
();
ASSERT_EQ
(
2
,
libraries
.
size
());
EXPECT_TRUE
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
"12"
));
EXPECT_
FALS
E
(
checkMarkerFile
Exists
(
UNLOAD_MARKER_FILE
));
// Unload the libraries. The load file should not have changed, but
// the unload one should indicate the unload() functions have been run.
...
...
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
View file @
a6cd2245
...
...
@@ -123,7 +123,9 @@ TEST_F(CtrlDhcpv4SrvTest, libreload) {
ASSERT_TRUE
(
libraries
==
loaded_libraries
);
// ... which also included checking that the marker file created by the
// load functions exists.
// load functions exists and holds the correct value (of "12" - the
// first library appends "1" to the file, the second appends "2"). Also
// check that the unload marker file does not yet exist.
EXPECT_TRUE
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
"12"
));
EXPECT_FALSE
(
checkMarkerFileExists
(
UNLOAD_MARKER_FILE
));
...
...
src/bin/dhcp4/tests/marker_file.cc
View file @
a6cd2245
...
...
@@ -34,22 +34,10 @@ checkMarkerFile(const char* name, const char* expected) {
// Is it open?
if
(
!
file
.
is_open
())
{
// No. This is OK if we don't expected is to be present but is
// a failure otherwise.
if
(
expected
==
NULL
)
{
return
(
true
);
}
ADD_FAILURE
()
<<
"Unable to open "
<<
name
<<
". It was expected "
<<
"to be present and to contain the string '"
<<
expected
<<
"'"
;
return
(
false
);
}
else
if
(
expected
==
NULL
)
{
// File is open but we don't expect it to be present.
ADD_FAILURE
()
<<
"Opened "
<<
name
<<
" but it is not expected to "
<<
"be present."
;
return
(
false
);
}
// OK, is open, so read the data and see what we have. Compare it
...
...
@@ -58,7 +46,8 @@ checkMarkerFile(const char* name, const char* expected) {
getline
(
file
,
content
);
string
expected_str
(
expected
);
EXPECT_EQ
(
expected_str
,
content
)
<<
"Data was read from "
<<
name
;
EXPECT_EQ
(
expected_str
,
content
)
<<
"Marker file "
<<
name
<<
"did not contain the expected data"
;
file
.
close
();
return
(
expected_str
==
content
);
...
...
src/bin/dhcp4/tests/marker_file.h.in
View file @
a6cd2245
...
...
@@ -42,9 +42,7 @@ namespace test {
///
/// @param name Name of the marker file.
/// @param expected Characters expected. If a marker file is present,
/// it is expected to contain characters. Therefore a value of NULL
/// is used to signify that the marker file is not expected to be
/// present.
/// it is expected to contain characters.
///
/// @return true if all tests pass, false if not (in which case a failure
/// will have been logged).
...
...
src/bin/dhcp6/config_parser.cc
View file @
a6cd2245
...
...
@@ -596,7 +596,7 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
}
// Now commit any changes that have been validated but not yet committed,
//
but
which can't be rolled back.
//
and
which can't be rolled back.
if
(
hooks_parser
)
{
hooks_parser
->
commit
();
}
...
...
src/bin/dhcp6/tests/config_parser_unittest.cc
View file @
a6cd2245
...
...
@@ -1985,12 +1985,13 @@ TEST_F(Dhcp6ParserTest, NoHooksLibraries) {
string
config
=
buildHooksLibrariesConfig
();
if
(
!
executeConfiguration
(
config
,
"set configuration with no hooks libraries"
))
{
return
;
}
FAIL
()
<<
"Unable to execute configuration"
;
// No libraries should be loaded at the end of the test.
libraries
=
HooksManager
::
getLibraryNames
();
ASSERT_TRUE
(
libraries
.
empty
());
}
else
{
// No libraries should be loaded at the end of the test.
libraries
=
HooksManager
::
getLibraryNames
();
EXPECT_TRUE
(
libraries
.
empty
());
}
}
// Verify parsing fails with one library that will fail validation.
...
...
@@ -2021,8 +2022,8 @@ TEST_F(Dhcp6ParserTest, LibrariesSpecified) {
ASSERT_TRUE
(
libraries
.
empty
());
// Marker files should not be present.
EXPECT_
TRU
E
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
NULL
));
EXPECT_
TRU
E
(
checkMarkerFile
(
UNLOAD_MARKER_FILE
,
NULL
));
EXPECT_
FALS
E
(
checkMarkerFile
Exists
(
LOAD_MARKER_FILE
));
EXPECT_
FALS
E
(
checkMarkerFile
Exists
(
UNLOAD_MARKER_FILE
));
// Set up the configuration with two libraries and load them.
string
config
=
buildHooksLibrariesConfig
(
CALLOUT_LIBRARY_1
,
...
...
@@ -2035,7 +2036,7 @@ TEST_F(Dhcp6ParserTest, LibrariesSpecified) {
libraries
=
HooksManager
::
getLibraryNames
();
ASSERT_EQ
(
2
,
libraries
.
size
());
EXPECT_TRUE
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
"12"
));
EXPECT_
TRU
E
(
checkMarkerFile
(
UNLOAD_MARKER_FILE
,
NULL
));
EXPECT_
FALS
E
(
checkMarkerFile
Exists
(
UNLOAD_MARKER_FILE
));
// Unload the libraries. The load file should not have changed, but
// the unload one should indicate the unload() functions have been run.
...
...
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
View file @
a6cd2245
...
...
@@ -123,7 +123,9 @@ TEST_F(CtrlDhcpv6SrvTest, libreload) {
ASSERT_TRUE
(
libraries
==
loaded_libraries
);
// ... which also included checking that the marker file created by the
// load functions exists.
// load functions exists and holds the correct value (of "12" - the
// first library appends "1" to the file, the second appends "2"). Also
// check that the unload marker file does not yet exist.
EXPECT_TRUE
(
checkMarkerFile
(
LOAD_MARKER_FILE
,
"12"
));
EXPECT_FALSE
(
checkMarkerFileExists
(
UNLOAD_MARKER_FILE
));
...
...
src/bin/dhcp6/tests/marker_file.cc
View file @
a6cd2245
...
...
@@ -34,22 +34,10 @@ checkMarkerFile(const char* name, const char* expected) {
// Is it open?
if
(
!
file
.
is_open
())
{
// No. This is OK if we don't expected is to be present but is
// a failure otherwise.
if
(
expected
==
NULL
)
{
return
(
true
);
}
ADD_FAILURE
()
<<
"Unable to open "
<<
name
<<
". It was expected "
<<
"to be present and to contain the string '"
<<
expected
<<
"'"
;
return
(
false
);
}
else
if
(
expected
==
NULL
)
{
// File is open but we don't expect it to be present.
ADD_FAILURE
()
<<
"Opened "
<<
name
<<
" but it is not expected to "
<<
"be present."
;
return
(
false
);
}
// OK, is open, so read the data and see what we have. Compare it
...
...
@@ -58,7 +46,8 @@ checkMarkerFile(const char* name, const char* expected) {
getline
(
file
,
content
);
string
expected_str
(
expected
);
EXPECT_EQ
(
expected_str
,
content
)
<<
"Data was read from "
<<
name
;
EXPECT_EQ
(
expected_str
,
content
)
<<
"Marker file "
<<
name
<<
"did not contain the expected data"
;
file
.
close
();
return
(
expected_str
==
content
);
...
...
src/bin/dhcp6/tests/marker_file.h.in
View file @
a6cd2245
...
...
@@ -42,9 +42,7 @@ namespace test {
///
/// @param name Name of the marker file.
/// @param expected Characters expected. If a marker file is present,
/// it is expected to contain characters. Therefore a value of NULL
/// is used to signify that the marker file is not expected to be
/// present.
/// it is expected to contain characters.
///
/// @return true if all tests pass, false if not (in which case a failure
/// will have been logged).
...
...
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