Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Adam Osuchowski
Kea
Commits
af37bfe0
Commit
af37bfe0
authored
Apr 11, 2013
by
Stephen Morris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2467] Removed "raw" pointers from b10-dhcp4/6 tests
parent
784caaf1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
71 deletions
+44
-71
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/config_parser_unittest.cc
+5
-3
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
+12
-14
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+19
-44
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
+8
-10
No files found.
src/bin/dhcp4/tests/config_parser_unittest.cc
View file @
af37bfe0
...
...
@@ -25,7 +25,10 @@
#include <dhcp/option_int.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/cfgmgr.h>
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
...
...
@@ -47,7 +50,7 @@ public:
// Open port 0 means to not do anything at all. We don't want to
// deal with sockets here, just check if configuration handling
// is sane.
srv_
=
new
Dhcpv4Srv
(
0
);
srv_
.
reset
(
new
Dhcpv4Srv
(
0
)
);
}
// Checks if global parameter of name have expected_value
...
...
@@ -73,7 +76,6 @@ public:
~
Dhcp4ParserTest
()
{
resetConfiguration
();
delete
srv_
;
};
/// @brief Create the simple configuration with single option.
...
...
@@ -278,7 +280,7 @@ public:
}
}
Dhcpv4Srv
*
srv_
;
boost
::
scoped_ptr
<
Dhcpv4Srv
>
srv_
;
int
rcode_
;
ConstElementPtr
comment_
;
...
...
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
View file @
af37bfe0
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -18,6 +18,7 @@
#include <dhcp/dhcp4.h>
#include <dhcp4/ctrl_dhcp4_srv.h>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
#include <fstream>
...
...
@@ -36,7 +37,7 @@ using namespace isc::config;
namespace
{
class
NakedControlledDhcpv4Srv
:
public
ControlledDhcpv4Srv
{
// "
n
aked" DHCPv4 server, exposes internal fields
// "
N
aked" DHCPv4 server, exposes internal fields
public:
NakedControlledDhcpv4Srv
()
:
ControlledDhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
)
{
}
};
...
...
@@ -52,21 +53,21 @@ public:
TEST_F
(
CtrlDhcpv4SrvTest
,
commands
)
{
ControlledDhcpv4Srv
*
srv
=
NULL
;
ASSERT_NO_THROW
(
{
srv
=
new
ControlledDhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
);
}
);
boost
::
scoped_ptr
<
ControlledDhcpv4Srv
>
srv
;
ASSERT_NO_THROW
(
srv
.
reset
(
new
ControlledDhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
))
);
//
u
se empty parameters list
//
U
se empty parameters list
ElementPtr
params
(
new
isc
::
data
::
MapElement
());
int
rcode
=
-
1
;
//
c
ase 1: send bogus command
//
C
ase 1: send bogus command
ConstElementPtr
result
=
ControlledDhcpv4Srv
::
execDhcpv4ServerCommand
(
"blah"
,
params
);
ConstElementPtr
comment
=
parseAnswer
(
rcode
,
result
);
EXPECT_EQ
(
1
,
rcode
);
// expect failure (no such command as blah)
//
c
ase 2: send shutdown command without any parameters
//
C
ase 2: send shutdown command without any parameters
result
=
ControlledDhcpv4Srv
::
execDhcpv4ServerCommand
(
"shutdown"
,
params
);
comment
=
parseAnswer
(
rcode
,
result
);
EXPECT_EQ
(
0
,
rcode
);
// expect success
...
...
@@ -75,13 +76,10 @@ TEST_F(CtrlDhcpv4SrvTest, commands) {
ConstElementPtr
x
(
new
isc
::
data
::
IntElement
(
pid
));
params
->
set
(
"pid"
,
x
);
//
c
ase 3: send shutdown command with 1 parameter: pid
//
C
ase 3: send shutdown command with 1 parameter: pid
result
=
ControlledDhcpv4Srv
::
execDhcpv4ServerCommand
(
"shutdown"
,
params
);
comment
=
parseAnswer
(
rcode
,
result
);
EXPECT_EQ
(
0
,
rcode
);
// expect success
delete
srv
;
}
}
//
e
nd of anonymous namespace
}
//
E
nd of anonymous namespace
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
af37bfe0
...
...
@@ -29,6 +29,8 @@
#include <dhcpsrv/utils.h>
#include <gtest/gtest.h>
#include <boost/scoped_ptr.hpp>
#include <fstream>
#include <iostream>
...
...
@@ -367,26 +369,18 @@ public:
TEST_F
(
Dhcpv4SrvTest
,
basic
)
{
// Check that the base class can be instantiated
Dhcpv4Srv
*
srv
=
NULL
;
ASSERT_NO_THROW
({
srv
=
new
Dhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
);
});
delete
srv
;
boost
::
scoped_ptr
<
Dhcpv4Srv
>
srv
;
ASSERT_NO_THROW
(
srv
.
reset
(
new
Dhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
)));
srv
.
reset
();
// Check that the derived class can be instantiated
NakedDhcpv4Srv
*
naked_srv
=
NULL
;
ASSERT_NO_THROW
({
naked_srv
=
new
NakedDhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
);
});
boost
::
scoped_ptr
<
NakedDhcpv4Srv
>
naked_srv
;
ASSERT_NO_THROW
(
naked_srv
.
reset
(
new
NakedDhcpv4Srv
(
DHCP4_SERVER_PORT
+
10000
)));
EXPECT_TRUE
(
naked_srv
->
getServerID
());
delete
naked_srv
;
ASSERT_NO_THROW
({
naked_srv
=
new
NakedDhcpv4Srv
(
0
);
});
ASSERT_NO_THROW
(
naked_srv
.
reset
(
new
NakedDhcpv4Srv
(
0
)));
EXPECT_TRUE
(
naked_srv
->
getServerID
());
delete
naked_srv
;
}
// Verifies that received DISCOVER can be processed correctly,
...
...
@@ -398,7 +392,7 @@ TEST_F(Dhcpv4SrvTest, basic) {
// engine. See DiscoverBasic, DiscoverHint, DiscoverNoClientId
// and DiscoverInvalidHint.
TEST_F
(
Dhcpv4SrvTest
,
processDiscover
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
(
0
);
boost
::
scoped_ptr
<
NakedDhcpv4Srv
>
srv
(
new
NakedDhcpv4Srv
(
0
)
);
vector
<
uint8_t
>
mac
(
6
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
mac
[
i
]
=
255
-
i
;
...
...
@@ -492,8 +486,6 @@ TEST_F(Dhcpv4SrvTest, processDiscover) {
// Check that the requested options are returned.
optionsCheck
(
offer
);
delete
srv
;
}
// Verifies that received REQUEST can be processed correctly,
...
...
@@ -504,10 +496,10 @@ TEST_F(Dhcpv4SrvTest, processDiscover) {
// are other tests that verify correctness of the allocation
// engine. See RequestBasic.
TEST_F
(
Dhcpv4SrvTest
,
processRequest
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
(
0
);
boost
::
scoped_ptr
<
NakedDhcpv4Srv
>
srv
(
new
NakedDhcpv4Srv
(
0
)
);
vector
<
uint8_t
>
mac
(
6
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
mac
[
i
]
=
i
*
10
;
mac
[
i
]
=
i
*
10
;
}
boost
::
shared_ptr
<
Pkt4
>
req
(
new
Pkt4
(
DHCPREQUEST
,
1234
));
...
...
@@ -592,53 +584,36 @@ TEST_F(Dhcpv4SrvTest, processRequest) {
// Check that the requested options are returned.
optionsCheck
(
ack
);
delete
srv
;
}
TEST_F
(
Dhcpv4SrvTest
,
processRelease
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
();
NakedDhcpv4Srv
srv
;
boost
::
shared_ptr
<
Pkt4
>
pkt
(
new
Pkt4
(
DHCPRELEASE
,
1234
));
// Should not throw
EXPECT_NO_THROW
(
srv
->
processRelease
(
pkt
);
);
delete
srv
;
EXPECT_NO_THROW
(
srv
.
processRelease
(
pkt
));
}
TEST_F
(
Dhcpv4SrvTest
,
processDecline
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
();
NakedDhcpv4Srv
srv
;
boost
::
shared_ptr
<
Pkt4
>
pkt
(
new
Pkt4
(
DHCPDECLINE
,
1234
));
// Should not throw
EXPECT_NO_THROW
(
srv
->
processDecline
(
pkt
);
);
delete
srv
;
EXPECT_NO_THROW
(
srv
.
processDecline
(
pkt
));
}
TEST_F
(
Dhcpv4SrvTest
,
processInform
)
{
NakedDhcpv4Srv
*
srv
=
new
NakedDhcpv4Srv
();
NakedDhcpv4Srv
srv
;
boost
::
shared_ptr
<
Pkt4
>
pkt
(
new
Pkt4
(
DHCPINFORM
,
1234
));
// Should not throw
EXPECT_NO_THROW
(
srv
->
processInform
(
pkt
);
);
EXPECT_NO_THROW
(
srv
.
processInform
(
pkt
));
// Should return something
EXPECT_TRUE
(
srv
->
processInform
(
pkt
));
EXPECT_TRUE
(
srv
.
processInform
(
pkt
));
// @todo Implement more reasonable tests before starting
// work on processSomething() method.
delete
srv
;
}
TEST_F
(
Dhcpv4SrvTest
,
serverReceivedPacketName
)
{
...
...
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
View file @
af37bfe0
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -18,6 +18,7 @@
#include <dhcp6/ctrl_dhcp6_srv.h>
#include <config/ccsession.h>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
#include <iostream>
...
...
@@ -52,12 +53,12 @@ public:
TEST_F
(
CtrlDhcpv6SrvTest
,
commands
)
{
ControlledDhcpv6Srv
*
srv
=
NULL
;
ASSERT_NO_THROW
(
{
srv
=
new
ControlledDhcpv6Srv
(
DHCP6_SERVER_PORT
+
10000
);
}
);
boost
::
scoped_ptr
<
ControlledDhcpv6Srv
>
srv
;
ASSERT_NO_THROW
(
srv
.
reset
(
new
ControlledDhcpv6Srv
(
DHCP6_SERVER_PORT
+
10000
))
);
//
u
se empty parameters list
//
U
se empty parameters list
ElementPtr
params
(
new
isc
::
data
::
MapElement
());
int
rcode
=
-
1
;
...
...
@@ -78,10 +79,7 @@ TEST_F(CtrlDhcpv6SrvTest, commands) {
// case 3: send shutdown command with 1 parameter: pid
result
=
ControlledDhcpv6Srv
::
execDhcpv6ServerCommand
(
"shutdown"
,
params
);
comment
=
parseAnswer
(
rcode
,
result
);
EXPECT_EQ
(
0
,
rcode
);
// expect success
delete
srv
;
EXPECT_EQ
(
0
,
rcode
);
// Expect success
}
}
// end of anonymous namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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