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
6fd04a33
Commit
6fd04a33
authored
Dec 17, 2014
by
Marcin Siodelski
Browse files
[3539] A few additions and fixes in unit tests for CfgIface class.
parent
46471f4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/cfg_iface.cc
View file @
6fd04a33
...
...
@@ -135,6 +135,7 @@ void
CfgIface
::
reset
()
{
wildcard_used_
=
false
;
iface_set_
.
clear
();
address_map_
.
clear
();
}
void
...
...
src/lib/dhcpsrv/tests/cfg_iface_unittest.cc
View file @
6fd04a33
...
...
@@ -140,16 +140,38 @@ TEST_F(CfgIfaceTest, explicitNamesAndAddressesV4) {
ASSERT_FALSE
(
socketOpen
(
"eth1"
,
"192.0.2.3"
));
ASSERT_FALSE
(
socketOpen
(
"eth1"
,
"192.0.2.5"
));
// Reset configuration.
cfg
.
reset
();
// Now check that the socket can be bound to a different address on
// eth1.
ASSERT_NO_THROW
(
cfg
.
use
(
AF_INET
,
"eth1/192.0.2.5"
));
ASSERT_THROW
(
cfg
.
use
(
AF_INET
,
"eth1/192.0.2.3"
),
DuplicateIfaceName
);
// Open sockets according to the new configuration.
cfg
.
openSockets
(
AF_INET
,
DHCP4_SERVER_PORT
);
EXPECT_FALSE
(
socketOpen
(
"eth0"
,
"10.0.0.1"
));
EXPECT_FALSE
(
socketOpen
(
"eth1"
,
"192.0.2.3"
));
EXPECT_TRUE
(
socketOpen
(
"eth1"
,
"192.0.2.5"
));
}
// This test checks that the invalid interface name and/or IPv4 address
// results in error.
TEST_F
(
CfgIfaceTest
,
explicitNamesAndAddressesInvalidV4
)
{
CfgIface
cfg
;
// An address not assigned to the interface.
EXPECT_THROW
(
cfg
.
use
(
AF_INET
,
"eth0/10.0.0.2"
),
NoSuchAddress
);
// IPv6 address.
EXPECT_THROW
(
cfg
.
use
(
AF_INET
,
"eth0/2001:db8:1::1"
),
InvalidIfaceName
);
// Wildcard interface name with an address.
EXPECT_THROW
(
cfg
.
use
(
AF_INET
,
"*/10.0.0.1"
),
InvalidIfaceName
);
// Duplicated interface.
ASSERT_NO_THROW
(
cfg
.
use
(
AF_INET
,
"eth1"
));
EXPECT_THROW
(
cfg
.
use
(
AF_INET
,
"eth1/192.0.2.3"
),
DuplicateIfaceName
);
}
// This test checks that the interface names can be explicitly selected
// by their names and IPv6 sockets are opened on these interfaces.
TEST_F
(
CfgIfaceTest
,
explicitNamesV6
)
{
...
...
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