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
Sebastian Schrader
Kea
Commits
03ce449e
Commit
03ce449e
authored
May 06, 2013
by
Mukund Sivaraman
Browse files
[2850] Fix ZoneTableSegmentMappedTest.resetBadConfig test
parent
9784a184
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/memory/zone_table_segment.h
View file @
03ce449e
...
...
@@ -208,6 +208,12 @@ public:
/// the exception documentation below. Code that uses
/// \c ZoneTableSegment would depend on such assurances.
///
/// First, in case an existing memory segment is in use, and an
/// invalid config is passed to \c reset(), the existing memory
/// store must still be available and the \c isc::InvalidParameter
/// exception must be thrown. In this case, the segment is still
/// usable.
///
/// In case an existing memory store is in use, and an attempt to
/// open a different memory store fails, the existing memory store
/// must still be available and the \c ResetFailed exception must be
...
...
src/lib/datasrc/tests/memory/zone_table_segment_mapped_unittest.cc
View file @
03ce449e
...
...
@@ -127,43 +127,56 @@ TEST_F(ZoneTableSegmentMappedTest, isWritableUninitialized) {
}
TEST_F
(
ZoneTableSegmentMappedTest
,
resetBadConfig
)
{
// Open a mapped file in create mode.
ztable_segment_
->
reset
(
ZoneTableSegment
::
CREATE
,
config_params_
);
// Populate it with some data.
createData
(
ztable_segment_
->
getMemorySegment
());
EXPECT_TRUE
(
verifyData
(
ztable_segment_
->
getMemorySegment
()));
// All the following resets() with invalid configuration must
// provide a strong exception guarantee that the segment is still
// usable as before.
// NULL is passed in config params
EXPECT_THROW
({
ztable_segment_
->
reset
(
ZoneTableSegment
::
CREATE
,
ConstElementPtr
());
},
isc
::
InvalidParameter
);
EXPECT_TRUE
(
verifyData
(
ztable_segment_
->
getMemorySegment
()));
// Not a map
EXPECT_THROW
({
ztable_segment_
->
reset
(
ZoneTableSegment
::
CREATE
,
Element
::
fromJSON
(
"42"
));
},
isc
::
InvalidParameter
);
EXPECT_TRUE
(
verifyData
(
ztable_segment_
->
getMemorySegment
()));
// Empty map
EXPECT_THROW
({
ztable_segment_
->
reset
(
ZoneTableSegment
::
CREATE
,
Element
::
fromJSON
(
"{}"
));
},
isc
::
InvalidParameter
);
EXPECT_TRUE
(
verifyData
(
ztable_segment_
->
getMemorySegment
()));
// No "mapped-file" key
EXPECT_THROW
({
ztable_segment_
->
reset
(
ZoneTableSegment
::
CREATE
,
Element
::
fromJSON
(
"{
\"
foo
\"
:
\"
bar
\"
}"
));
},
isc
::
InvalidParameter
);
EXPECT_TRUE
(
verifyData
(
ztable_segment_
->
getMemorySegment
()));
// Value of "mapped-file" key is not a string
EXPECT_THROW
({
ztable_segment_
->
reset
(
ZoneTableSegment
::
CREATE
,
Element
::
fromJSON
(
"{
\"
mapped-file
\"
: 42}"
));
},
isc
::
InvalidParameter
);
// The following should still throw, unaffected by the failed opens.
EXPECT_THROW
(
ztable_segment_
->
getHeader
(),
isc
::
InvalidOperation
);
EXPECT_THROW
(
ztable_segment_
->
getMemorySegment
(),
isc
::
InvalidOperation
);
// isWritable() must still return false, because the segment has not
// been successfully reset() yet.
EXPECT_FALSE
(
ztable_segment_
->
isWritable
());
EXPECT_TRUE
(
verifyData
(
ztable_segment_
->
getMemorySegment
()));
}
TEST_F
(
ZoneTableSegmentMappedTest
,
reset
)
{
...
...
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