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
e4ecc70f
Commit
e4ecc70f
authored
Nov 23, 2012
by
Jelte Jansen
Committed by
Michal 'vorner' Vaner
Dec 03, 2012
Browse files
[2377] Initial MasterLoader class and test class
parent
3a81d2d9
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/Makefile.am
View file @
e4ecc70f
...
...
@@ -98,6 +98,7 @@ libb10_dns___la_SOURCES += labelsequence.h labelsequence.cc
libb10_dns___la_SOURCES
+=
masterload.h masterload.cc
libb10_dns___la_SOURCES
+=
master_lexer.h master_lexer.cc
libb10_dns___la_SOURCES
+=
master_lexer_state.h
libb10_dns___la_SOURCES
+=
master_loader.h master_loader.cc
libb10_dns___la_SOURCES
+=
message.h message.cc
libb10_dns___la_SOURCES
+=
messagerenderer.h messagerenderer.cc
libb10_dns___la_SOURCES
+=
name.h name.cc
...
...
src/lib/dns/master_loader.cc
0 → 100644
View file @
e4ecc70f
// Copyright (C) 2012 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
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include
<dns/master_loader.h>
namespace
isc
{
namespace
dns
{
class
MasterLoader
::
MasterLoaderImpl
{
public:
MasterLoaderImpl
(
const
char
*
master_file
,
const
Name
&
zone_origin
,
const
RRClass
zone_class
,
MasterLoaderCallbacks
callbacks
,
MasterLoader
::
Options
options
)
:
lexer_
(),
zone_origin_
(
zone_origin
),
zone_class_
(
zone_class
),
callbacks_
(
callbacks
),
options_
(
options
)
{
lexer_
.
pushSource
(
master_file
);
}
bool
loadIncremental
(
size_t
count_limit
)
{
size_t
count
=
0
;
bool
done
=
false
;
do
{
// Code goes here
}
while
(
!
done
&&
(
count_limit
!=
0
&&
++
count
<
count_limit
));
// add remaining rrset that was being built (TODO)
return
(
false
);
}
private:
MasterLexer
lexer_
;
const
Name
&
zone_origin_
;
const
RRClass
zone_class_
;
MasterLoaderCallbacks
callbacks_
;
MasterLoader
::
Options
options_
;
RRsetPtr
current_rrset_
;
};
MasterLoader
::
MasterLoader
(
const
char
*
master_file
,
const
Name
&
zone_origin
,
const
RRClass
zone_class
,
MasterLoaderCallbacks
callbacks
,
Options
options
)
{
impl_
=
new
MasterLoaderImpl
(
master_file
,
zone_origin
,
zone_class
,
callbacks
,
options
);
}
MasterLoader
::~
MasterLoader
()
{
delete
impl_
;
}
bool
MasterLoader
::
loadIncremental
(
size_t
count_limit
)
{
return
(
impl_
->
loadIncremental
(
count_limit
));
}
}
// end namespace dns
}
// end namespace isc
src/lib/dns/master_loader.h
View file @
e4ecc70f
...
...
@@ -15,20 +15,34 @@
#ifndef MASTER_LOADER_H
#define MASTER_LOADER_H
#include
<dns/name.h>
#include
<dns/rrclass.h>
#include
<dns/master_lexer.h>
#include
<dns/master_loader_callbacks.h>
namespace
isc
{
namespace
dns
{
// Placeholder introduced by #2497. The real class should be updated in
// #2377.
class
MasterLoader
{
public:
enum
Options
{
MANY_ERRORS
,
// lenient mode
// also eventually some check policies like "check NS name"
MANY_ERRORS
,
///< Lenient mode
};
MasterLoader
(
const
char
*
master_file
,
const
Name
&
zone_origin
,
const
RRClass
zone_class
,
MasterLoaderCallbacks
callbacks
,
Options
options
);
~
MasterLoader
();
bool
loadIncremental
(
size_t
count_limit
);
//void load();
private:
class
MasterLoaderImpl
;
MasterLoaderImpl
*
impl_
;
};
}
}
}
// end namespace dns
}
// end namespace isc
#endif // MASTER_LOADER_H
src/lib/dns/tests/Makefile.am
View file @
e4ecc70f
...
...
@@ -27,6 +27,7 @@ run_unittests_SOURCES += labelsequence_unittest.cc
run_unittests_SOURCES
+=
messagerenderer_unittest.cc
run_unittests_SOURCES
+=
master_lexer_token_unittest.cc
run_unittests_SOURCES
+=
master_lexer_unittest.cc
run_unittests_SOURCES
+=
master_loader_unittest.cc
run_unittests_SOURCES
+=
master_lexer_state_unittest.cc
run_unittests_SOURCES
+=
name_unittest.cc
run_unittests_SOURCES
+=
nsec3hash_unittest.cc
...
...
src/lib/dns/tests/master_loader_unittest.cc
0 → 100644
View file @
e4ecc70f
// Copyright (C) 2012 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
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include
<dns/master_loader_callbacks.h>
#include
<dns/master_loader.h>
#include
<gtest/gtest.h>
#include
<boost/bind.hpp>
#include
<boost/scoped_ptr.hpp>
using
namespace
isc
::
dns
;
class
MasterLoaderTest
:
public
::
testing
::
Test
{
public:
MasterLoaderTest
()
:
callbacks_
(
boost
::
bind
(
&
MasterLoaderTest
::
callback
,
this
,
true
,
_1
,
_2
,
_3
),
boost
::
bind
(
&
MasterLoaderTest
::
callback
,
this
,
false
,
_1
,
_2
,
_3
))
{}
/// Concatenate file, line, and reason, and add it to either errors
/// or warnings
void
callback
(
bool
error
,
const
std
::
string
&
file
,
size_t
line
,
const
std
::
string
reason
)
{
std
::
stringstream
ss
;
ss
<<
file
<<
line
<<
reason
;
if
(
error
)
{
errors
.
push_back
(
ss
.
str
());
}
else
{
warnings
.
push_back
(
ss
.
str
());
}
}
void
setLoader
(
const
char
*
file
,
const
Name
&
origin
,
const
RRClass
rrclass
,
const
MasterLoader
::
Options
options
)
{
loader
.
reset
(
new
MasterLoader
(
file
,
origin
,
rrclass
,
callbacks_
,
options
));
}
MasterLoaderCallbacks
callbacks_
;
boost
::
scoped_ptr
<
MasterLoader
>
loader
;
std
::
vector
<
std
::
string
>
errors
;
std
::
vector
<
std
::
string
>
warnings
;
};
TEST_F
(
MasterLoaderTest
,
basicLoad
)
{
setLoader
(
"testdata/loader_test.txt"
,
Name
(
"example.com."
),
RRClass
::
IN
(),
MasterLoader
::
MANY_ERRORS
);
ASSERT_FALSE
(
loader
->
loadIncremental
(
1
));
}
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