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
3bd3068b
Commit
3bd3068b
authored
Mar 15, 2017
by
Francis Dupont
Browse files
[5151] Some small fixes
parent
670b4406
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/ctrl_dhcp4_srv.cc
View file @
3bd3068b
...
...
@@ -77,8 +77,6 @@ ControlledDhcpv4Srv::commandConfigGetHandler(const string&,
ConstElementPtr
ControlledDhcpv4Srv
::
commandConfigWriteHandler
(
const
string
&
,
ConstElementPtr
args
)
{
ConstElementPtr
config
=
CfgMgr
::
instance
().
getCurrentCfg
()
->
toElement
();
string
filename
;
if
(
args
)
{
...
...
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
View file @
3bd3068b
...
...
@@ -208,14 +208,14 @@ public:
/// @param command command expected to be on the list.
void
checkListCommands
(
const
ConstElementPtr
&
rsp
,
const
std
::
string
&
command
)
{
ConstElementPtr
params
;
int
status_code
;
int
status_code
=
-
1
;
EXPECT_NO_THROW
(
params
=
parseAnswer
(
status_code
,
rsp
));
EXPECT_EQ
(
CONTROL_RESULT_SUCCESS
,
status_code
);
ASSERT_TRUE
(
params
);
ASSERT_EQ
(
Element
::
list
,
params
->
getType
());
int
cnt
=
0
;
for
(
int
i
=
0
;
i
<
params
->
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
params
->
size
();
++
i
)
{
string
tmp
=
params
->
get
(
i
)
->
stringValue
();
if
(
tmp
==
command
)
{
// Command found, but that's not enough. Need to continue working
...
...
@@ -237,7 +237,7 @@ public:
void
checkConfigWrite
(
const
std
::
string
&
response_txt
,
int
exp_status
,
const
std
::
string
&
exp_txt
=
""
)
{
cout
<<
"#### response="
<<
response_txt
<<
endl
;
//
cout << "#### response=" << response_txt << endl;
ConstElementPtr
rsp
;
EXPECT_NO_THROW
(
rsp
=
Element
::
fromJSON
(
response_txt
));
...
...
@@ -253,13 +253,13 @@ public:
// The parameters must include filename
ASSERT_TRUE
(
params
);
ASSERT_TRUE
(
params
->
get
(
"filename"
));
EXPEC
T_EQ
(
Element
::
string
,
params
->
get
(
"filename"
)
->
getType
());
ASSER
T_EQ
(
Element
::
string
,
params
->
get
(
"filename"
)
->
getType
());
EXPECT_EQ
(
exp_txt
,
params
->
get
(
"filename"
)
->
stringValue
());
// The parameters must include size. And the size
// must indicate some content.
ASSERT_TRUE
(
params
->
get
(
"size"
));
EXPEC
T_EQ
(
Element
::
integer
,
params
->
get
(
"size"
)
->
getType
());
ASSER
T_EQ
(
Element
::
integer
,
params
->
get
(
"size"
)
->
getType
());
int64_t
size
=
params
->
get
(
"size"
)
->
intValue
();
EXPECT_LE
(
1
,
size
);
...
...
@@ -271,9 +271,13 @@ public:
// Now check that it is the correct size as reported.
EXPECT_EQ
(
size
,
static_cast
<
int64_t
>
(
f
.
tellg
()));
// Finally, check that it's really a JSON.
ElementPtr
from_file
=
Element
::
fromJSONFile
(
exp_txt
);
ASSERT_TRUE
(
from_file
);
// Check that it's really a JSON.
ElementPtr
from_file
=
parseJSON
(
exp_txt
);
EXPECT_TRUE
(
from_file
);
// Finally check it is a DHCPv4 config
EXPECT_NO_THROW
(
from_file
=
parseDHCP4
(
exp_txt
,
true
));
EXPECT_TRUE
(
from_file
);
}
else
if
(
exp_status
==
CONTROL_RESULT_ERROR
)
{
// Let's check if the reason for failure was given.
...
...
@@ -739,9 +743,9 @@ TEST_F(CtrlChannelDhcpv4SrvTest, listCommands) {
checkListCommands
(
rsp
,
"statistic-reset-all"
);
}
// Tests if the server returns its configuration using
get-
config.
// Tests if the server returns its configuration using config
-get
.
// Note there are separate tests that verify if toElement() called by the
//
get-
config handler are actually converting the configuration correctly.
// config
-get
handler are actually converting the configuration correctly.
TEST_F
(
CtrlChannelDhcpv4SrvTest
,
configGet
)
{
createUnixChannelServer
();
std
::
string
response
;
...
...
@@ -759,7 +763,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configGet) {
// Ok, now roughly check if the response seems legit.
ASSERT_TRUE
(
cfg
);
EXPEC
T_EQ
(
Element
::
map
,
cfg
->
getType
());
ASSER
T_EQ
(
Element
::
map
,
cfg
->
getType
());
EXPECT_TRUE
(
cfg
->
get
(
"Dhcp4"
));
}
...
...
src/bin/dhcp6/ctrl_dhcp6_srv.cc
View file @
3bd3068b
...
...
@@ -81,8 +81,6 @@ ControlledDhcpv6Srv::commandConfigGetHandler(const string&,
ConstElementPtr
ControlledDhcpv6Srv
::
commandConfigWriteHandler
(
const
string
&
,
ConstElementPtr
args
)
{
ConstElementPtr
config
=
CfgMgr
::
instance
().
getCurrentCfg
()
->
toElement
();
string
filename
;
if
(
args
)
{
...
...
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
View file @
3bd3068b
...
...
@@ -221,14 +221,14 @@ public:
/// @param command command expected to be on the list.
void
checkListCommands
(
const
ConstElementPtr
&
rsp
,
const
std
::
string
&
command
)
{
ConstElementPtr
params
;
int
status_code
;
int
status_code
=
-
1
;
EXPECT_NO_THROW
(
params
=
parseAnswer
(
status_code
,
rsp
));
EXPECT_EQ
(
CONTROL_RESULT_SUCCESS
,
status_code
);
ASSERT_TRUE
(
params
);
ASSERT_EQ
(
Element
::
list
,
params
->
getType
());
int
cnt
=
0
;
for
(
int
i
=
0
;
i
<
params
->
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
params
->
size
();
++
i
)
{
string
tmp
=
params
->
get
(
i
)
->
stringValue
();
if
(
tmp
==
command
)
{
// Command found, but that's not enough. Need to continue working
...
...
@@ -264,13 +264,13 @@ public:
// The parameters must include filename
ASSERT_TRUE
(
params
);
ASSERT_TRUE
(
params
->
get
(
"filename"
));
EXPEC
T_EQ
(
Element
::
string
,
params
->
get
(
"filename"
)
->
getType
());
ASSER
T_EQ
(
Element
::
string
,
params
->
get
(
"filename"
)
->
getType
());
EXPECT_EQ
(
exp_txt
,
params
->
get
(
"filename"
)
->
stringValue
());
// The parameters must include size. And the size
// must indicate some content.
ASSERT_TRUE
(
params
->
get
(
"size"
));
EXPEC
T_EQ
(
Element
::
integer
,
params
->
get
(
"size"
)
->
getType
());
ASSER
T_EQ
(
Element
::
integer
,
params
->
get
(
"size"
)
->
getType
());
int64_t
size
=
params
->
get
(
"size"
)
->
intValue
();
EXPECT_LE
(
1
,
size
);
...
...
@@ -282,9 +282,13 @@ public:
// Now check that it is the correct size as reported.
EXPECT_EQ
(
size
,
static_cast
<
int64_t
>
(
f
.
tellg
()));
// Finally, check that it's really a JSON.
ElementPtr
from_file
=
Element
::
fromJSONFile
(
exp_txt
);
ASSERT_TRUE
(
from_file
);
// Check that it's really a JSON.
ElementPtr
from_file
=
parseJSON
(
exp_txt
);
EXPECT_TRUE
(
from_file
);
// Finally check it is a DHCPv6 config
EXPECT_NO_THROW
(
from_file
=
parseDHCP6
(
exp_txt
,
true
));
EXPECT_TRUE
(
from_file
);
}
else
if
(
exp_status
==
CONTROL_RESULT_ERROR
)
{
// Let's check if the reason for failure was given.
...
...
@@ -823,9 +827,9 @@ TEST_F(CtrlChannelDhcpv6SrvTest, commandsList) {
checkListCommands
(
rsp
,
"statistic-reset-all"
);
}
// Tests if the server returns its configuration using
get-
config.
// Tests if the server returns its configuration using config
-get
.
// Note there are separate tests that verify if toElement() called by the
// config
-get
handler are actually converting the configuration correctly.
//
get-
config handler are actually converting the configuration correctly.
TEST_F
(
CtrlChannelDhcpv6SrvTest
,
configGet
)
{
createUnixChannelServer
();
std
::
string
response
;
...
...
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