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
77e78881
Commit
77e78881
authored
Nov 23, 2015
by
Marcin Siodelski
Browse files
[4204] Eval parser allows for referencing option by its name.
parent
6011b532
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/libdhcp++.cc
View file @
77e78881
...
...
@@ -248,7 +248,6 @@ LibDHCP::clearRuntimeOptionDefs() {
runtime_option_defs_
.
clearItems
();
}
bool
LibDHCP
::
isStandardOption
(
const
Option
::
Universe
u
,
const
uint16_t
code
)
{
if
(
u
==
Option
::
V6
)
{
...
...
src/lib/dhcp/libdhcp++.h
View file @
77e78881
...
...
@@ -121,7 +121,6 @@ public:
static
OptionDefContainerPtr
getRuntimeOptionDefs
(
const
std
::
string
&
space
);
/// @brief Check if the specified option is a standard option.
///
/// @param u universe (V4 or V6)
...
...
src/lib/dhcpsrv/parsers/client_class_def_parser.cc
View file @
77e78881
...
...
@@ -50,7 +50,7 @@ ExpressionParser::build(ConstElementPtr expression_cfg) {
std
::
string
value
;
expression_cfg
->
getValue
(
value
);
try
{
EvalContext
eval_ctx
;
EvalContext
eval_ctx
(
global_context_
->
universe_
)
;
eval_ctx
.
parseString
(
value
);
local_expression_
.
reset
(
new
Expression
());
*
local_expression_
=
eval_ctx
.
expression
;
...
...
src/lib/eval/eval_context.cc
View file @
77e78881
...
...
@@ -15,10 +15,12 @@
#include
<eval/eval_context.h>
#include
<eval/parser.h>
#include
<exceptions/exceptions.h>
#include
<dhcp/option.h>
#include
<fstream>
EvalContext
::
EvalContext
()
:
trace_scanning_
(
false
),
trace_parsing_
(
false
)
EvalContext
::
EvalContext
(
const
Option
::
Universe
&
option_universe
)
:
trace_scanning_
(
false
),
trace_parsing_
(
false
),
option_universe_
(
option_universe
)
{
}
...
...
@@ -32,7 +34,7 @@ EvalContext::parseString(const std::string& str)
file_
=
"<string>"
;
string_
=
str
;
scanStringBegin
();
isc
::
eval
::
EvalParser
parser
(
*
this
);
isc
::
eval
::
EvalParser
parser
(
*
this
,
option_universe_
);
parser
.
set_debug_level
(
trace_parsing_
);
int
res
=
parser
.
parse
();
scanStringEnd
();
...
...
src/lib/eval/eval_context.h
View file @
77e78881
...
...
@@ -42,7 +42,11 @@ class EvalContext
{
public:
/// @brief Default constructor.
EvalContext
();
///
/// @param option_universe Option universe: DHCPv4 or DHCPv6. This is used
/// by the parser to determine which option definitions set should be used
/// to map option names to option codes.
EvalContext
(
const
Option
::
Universe
&
option_universe
);
/// @brief destructor
virtual
~
EvalContext
();
...
...
@@ -55,7 +59,7 @@ public:
/// @brief Method called after the last tokens are scanned from a string.
void
scanStringEnd
();
/// @brief Run the parser on the string specified.
///
/// @param str string to be written
...
...
@@ -87,7 +91,12 @@ public:
/// @brief Flag determing parser debugging.
bool
trace_parsing_
;
/// @brief Option universe: DHCPv4 or DHCPv6.
///
/// This is used by the parser to determine which option definitions
/// set should be used to map option name to option code.
Option
::
Universe
option_universe_
;
};
};
// end of isc::eval namespace
...
...
src/lib/eval/parser.cc
View file @
77e78881
...
...
@@ -49,10 +49,10 @@
#line 51 "parser.cc" // lalr1.cc:412
// Unqualified %code blocks.
#line
39
"parser.yy" // lalr1.cc:413
#line
40
"parser.yy" // lalr1.cc:413
# include "eval_context.h"
#line
6
7 "parser.yy" // lalr1.cc:413
#line 7
2
"parser.yy" // lalr1.cc:413
namespace
{
...
...
@@ -206,13 +206,14 @@ namespace isc { namespace eval {
/// Build a parser object.
EvalParser
::
EvalParser
(
EvalContext
&
ctx_yyarg
)
EvalParser
::
EvalParser
(
EvalContext
&
ctx_yyarg
,
const
Option
::
Universe
&
option_universe_yyarg
)
:
#if YYDEBUG
yydebug_
(
false
),
yycdebug_
(
&
std
::
cerr
),
#endif
ctx
(
ctx_yyarg
)
ctx
(
ctx_yyarg
),
option_universe
(
option_universe_yyarg
)
{}
EvalParser
::~
EvalParser
()
...
...
@@ -344,30 +345,30 @@ namespace isc { namespace eval {
{
case
15
:
// "constant string"
#line 6
4
"parser.yy" // lalr1.cc:636
#line 6
9
"parser.yy" // lalr1.cc:636
{
yyoutput
<<
yysym
.
value
.
template
as
<
std
::
string
>
();
}
#line 35
0
"parser.cc" // lalr1.cc:636
#line 35
1
"parser.cc" // lalr1.cc:636
break
;
case
16
:
// "integer"
#line 6
4
"parser.yy" // lalr1.cc:636
#line 6
9
"parser.yy" // lalr1.cc:636
{
yyoutput
<<
yysym
.
value
.
template
as
<
std
::
string
>
();
}
#line 35
7
"parser.cc" // lalr1.cc:636
#line 35
8
"parser.cc" // lalr1.cc:636
break
;
case
17
:
// "constant hexstring"
#line 6
4
"parser.yy" // lalr1.cc:636
#line 6
9
"parser.yy" // lalr1.cc:636
{
yyoutput
<<
yysym
.
value
.
template
as
<
std
::
string
>
();
}
#line 36
4
"parser.cc" // lalr1.cc:636
#line 36
5
"parser.cc" // lalr1.cc:636
break
;
case
18
:
// TOKEN
#line 6
4
"parser.yy" // lalr1.cc:636
#line 6
9
"parser.yy" // lalr1.cc:636
{
yyoutput
<<
yysym
.
value
.
template
as
<
std
::
string
>
();
}
#line 37
1
"parser.cc" // lalr1.cc:636
#line 37
2
"parser.cc" // lalr1.cc:636
break
;
...
...
@@ -592,90 +593,124 @@ namespace isc { namespace eval {
switch
(
yyn
)
{
case
3
:
#line 10
5
"parser.yy" // lalr1.cc:859
#line 1
1
0 "parser.yy" // lalr1.cc:859
{
TokenPtr
eq
(
new
TokenEqual
());
ctx
.
expression
.
push_back
(
eq
);
}
#line 60
1
"parser.cc" // lalr1.cc:859
#line 60
2
"parser.cc" // lalr1.cc:859
break
;
case
4
:
#line 11
2
"parser.yy" // lalr1.cc:859
#line 11
7
"parser.yy" // lalr1.cc:859
{
TokenPtr
str
(
new
TokenString
(
yystack_
[
0
].
value
.
as
<
std
::
string
>
()));
ctx
.
expression
.
push_back
(
str
);
}
#line 61
0
"parser.cc" // lalr1.cc:859
#line 61
1
"parser.cc" // lalr1.cc:859
break
;
case
5
:
#line 1
17
"parser.yy" // lalr1.cc:859
#line 1
22
"parser.yy" // lalr1.cc:859
{
TokenPtr
hex
(
new
TokenHexString
(
yystack_
[
0
].
value
.
as
<
std
::
string
>
()));
ctx
.
expression
.
push_back
(
hex
);
}
#line 6
19
"parser.cc" // lalr1.cc:859
#line 6
20
"parser.cc" // lalr1.cc:859
break
;
case
6
:
#line 12
2
"parser.yy" // lalr1.cc:859
#line 12
7
"parser.yy" // lalr1.cc:859
{
uint16_t
numeric_code
=
convert_option_code
(
yystack_
[
3
].
value
.
as
<
std
::
string
>
(),
yystack_
[
3
].
location
,
ctx
);
TokenPtr
opt
(
new
TokenOption
(
numeric_code
,
TokenOption
::
TEXTUAL
));
ctx
.
expression
.
push_back
(
opt
);
}
#line 6
29
"parser.cc" // lalr1.cc:859
#line 6
30
"parser.cc" // lalr1.cc:859
break
;
case
7
:
#line 1
28
"parser.yy" // lalr1.cc:859
#line 1
33
"parser.yy" // lalr1.cc:859
{
uint16_t
numeric_code
=
convert_option_code
(
yystack_
[
3
].
value
.
as
<
std
::
string
>
(),
yystack_
[
3
].
location
,
ctx
);
TokenPtr
opt
(
new
TokenOption
(
numeric_code
,
TokenOption
::
HEXADECIMAL
));
ctx
.
expression
.
push_back
(
opt
);
}
#line 6
39
"parser.cc" // lalr1.cc:859
#line 6
40
"parser.cc" // lalr1.cc:859
break
;
case
8
:
#line 134 "parser.yy" // lalr1.cc:859
#line 139 "parser.yy" // lalr1.cc:859
{
try
{
// This may result in exception if the specified
// name is unknown.
TokenPtr
opt
(
new
TokenOption
(
yystack_
[
3
].
value
.
as
<
std
::
string
>
(),
option_universe
,
TokenOption
::
TEXTUAL
));
ctx
.
expression
.
push_back
(
opt
);
}
catch
(
const
std
::
exception
&
ex
)
{
ctx
.
error
(
yystack_
[
3
].
location
,
ex
.
what
());
}
}
#line 657 "parser.cc" // lalr1.cc:859
break
;
case
9
:
#line 152 "parser.yy" // lalr1.cc:859
{
try
{
// This may result in exception if the specified
// name is unknown.
TokenPtr
opt
(
new
TokenOption
(
yystack_
[
3
].
value
.
as
<
std
::
string
>
(),
option_universe
,
TokenOption
::
HEXADECIMAL
));
ctx
.
expression
.
push_back
(
opt
);
}
catch
(
const
std
::
exception
&
ex
)
{
ctx
.
error
(
yystack_
[
3
].
location
,
ex
.
what
());
}
}
#line 674 "parser.cc" // lalr1.cc:859
break
;
case
10
:
#line 165 "parser.yy" // lalr1.cc:859
{
TokenPtr
sub
(
new
TokenSubstring
());
ctx
.
expression
.
push_back
(
sub
);
}
#line 6
4
8 "parser.cc" // lalr1.cc:859
#line 68
3
"parser.cc" // lalr1.cc:859
break
;
case
1
0
:
#line 14
3
"parser.yy" // lalr1.cc:859
case
1
2
:
#line 1
7
4 "parser.yy" // lalr1.cc:859
{
TokenPtr
str
(
new
TokenString
(
yystack_
[
0
].
value
.
as
<
std
::
string
>
()));
ctx
.
expression
.
push_back
(
str
);
}
#line 6
57
"parser.cc" // lalr1.cc:859
#line 6
92
"parser.cc" // lalr1.cc:859
break
;
case
1
1
:
#line 1
50
"parser.yy" // lalr1.cc:859
case
1
3
:
#line 1
81
"parser.yy" // lalr1.cc:859
{
TokenPtr
str
(
new
TokenString
(
yystack_
[
0
].
value
.
as
<
std
::
string
>
()));
ctx
.
expression
.
push_back
(
str
);
}
#line
666
"parser.cc" // lalr1.cc:859
#line
701
"parser.cc" // lalr1.cc:859
break
;
case
1
2
:
#line 1
55
"parser.yy" // lalr1.cc:859
case
1
4
:
#line 1
86
"parser.yy" // lalr1.cc:859
{
TokenPtr
str
(
new
TokenString
(
"all"
));
ctx
.
expression
.
push_back
(
str
);
}
#line
675
"parser.cc" // lalr1.cc:859
#line
710
"parser.cc" // lalr1.cc:859
break
;
#line
679
"parser.cc" // lalr1.cc:859
#line
714
"parser.cc" // lalr1.cc:859
default:
break
;
}
...
...
@@ -937,17 +972,19 @@ namespace isc { namespace eval {
const
signed
char
EvalParser
::
yypact_
[]
=
{
-
4
,
-
9
,
-
3
,
-
10
,
-
10
,
-
10
,
9
,
-
10
,
12
,
1
,
-
4
,
-
10
,
-
4
,
-
2
,
6
,
-
10
,
10
,
2
,
0
,
-
10
,
11
,
-
10
,
-
10
,
-
6
,
-
10
,
-
10
,
8
,
-
10
-
4
,
-
1
,
6
,
-
10
,
-
10
,
-
10
,
4
,
-
10
,
15
,
-
9
,
-
4
,
-
10
,
-
4
,
5
,
7
,
10
,
-
10
,
13
,
14
,
8
,
2
,
9
,
-
10
,
16
,
-
10
,
-
10
,
-
10
,
-
10
,
-
6
,
-
10
,
-
10
,
17
,
-
10
};
const
unsigned
char
EvalParser
::
yydefact_
[]
=
{
0
,
0
,
0
,
4
,
5
,
9
,
0
,
2
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
3
,
0
,
0
,
0
,
10
,
0
,
6
,
7
,
0
,
12
,
11
,
0
,
8
0
,
0
,
0
,
4
,
5
,
11
,
0
,
2
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
3
,
0
,
0
,
0
,
0
,
0
,
12
,
0
,
8
,
9
,
6
,
7
,
0
,
14
,
13
,
0
,
10
};
const
signed
char
...
...
@@ -959,45 +996,46 @@ namespace isc { namespace eval {
const
signed
char
EvalParser
::
yydefgoto_
[]
=
{
-
1
,
6
,
7
,
8
,
2
0
,
26
-
1
,
6
,
7
,
8
,
2
3
,
31
};
const
unsigned
char
EvalParser
::
yytable_
[]
=
{
1
,
2
,
2
4
,
1
4
,
9
,
1
5
,
2
1
,
22
,
10
,
11
,
25
,
3
,
16
,
4
,
5
,
1
2
,
1
7
,
1
3
,
1
9
,
1
8
,
27
,
23
1
,
2
,
2
9
,
1
5
,
11
,
1
6
,
1
3
,
14
,
24
,
25
,
30
,
3
,
9
,
4
,
5
,
2
6
,
2
7
,
1
0
,
1
2
,
1
7
,
19
,
18
,
20
,
21
,
22
,
0
,
28
,
0
,
0
,
32
};
const
un
signed
char
const
signed
char
EvalParser
::
yycheck_
[]
=
{
4
,
5
,
8
,
10
,
13
,
12
,
6
,
7
,
11
,
0
,
16
,
15
,
1
4
,
17
,
18
,
3
,
10
,
1
6
,
16
,
9
,
1
2
,
10
4
,
5
,
8
,
10
,
0
,
12
,
15
,
16
,
6
,
7
,
16
,
15
,
1
3
,
17
,
18
,
6
,
7
,
1
1
,
3
,
14
,
1
0
,
14
,
9
,
9
,
16
,
-
1
,
10
,
-
1
,
-
1
,
12
};
const
unsigned
char
EvalParser
::
yystos_
[]
=
{
0
,
4
,
5
,
15
,
17
,
18
,
20
,
21
,
22
,
13
,
11
,
0
,
3
,
16
,
22
,
22
,
14
,
10
,
9
,
16
,
23
,
6
,
7
,
10
,
8
,
16
,
24
,
12
11
,
0
,
3
,
15
,
16
,
22
,
22
,
14
,
14
,
10
,
9
,
9
,
16
,
23
,
6
,
7
,
6
,
7
,
10
,
8
,
16
,
24
,
12
};
const
unsigned
char
EvalParser
::
yyr1_
[]
=
{
0
,
19
,
20
,
21
,
22
,
22
,
22
,
22
,
22
,
22
,
23
,
24
,
24
22
,
22
,
23
,
24
,
24
};
const
unsigned
char
EvalParser
::
yyr2_
[]
=
{
0
,
2
,
1
,
3
,
1
,
1
,
6
,
6
,
8
,
1
,
1
,
1
,
1
0
,
2
,
1
,
3
,
1
,
1
,
6
,
6
,
6
,
6
,
8
,
1
,
1
,
1
,
1
};
...
...
@@ -1018,8 +1056,8 @@ namespace isc { namespace eval {
const
unsigned
char
EvalParser
::
yyrline_
[]
=
{
0
,
10
1
,
10
1
,
10
4
,
11
1
,
11
6
,
12
1
,
12
7
,
13
3
,
1
38
,
14
2
,
1
4
9
,
15
4
0
,
10
6
,
10
6
,
10
9
,
11
6
,
1
2
1
,
12
6
,
1
3
2
,
13
8
,
1
51
,
1
6
4
,
1
6
9
,
1
73
,
180
,
18
5
};
// Print the state stack on the debug stream.
...
...
@@ -1054,8 +1092,8 @@ namespace isc { namespace eval {
#line 21 "parser.yy" // lalr1.cc:1167
}
}
// isc::eval
#line 10
58
"parser.cc" // lalr1.cc:1167
#line 1
61
"parser.yy" // lalr1.cc:1168
#line 10
96
"parser.cc" // lalr1.cc:1167
#line 1
92
"parser.yy" // lalr1.cc:1168
void
isc
::
eval
::
EvalParser
::
error
(
const
location_type
&
loc
,
...
...
src/lib/eval/parser.h
View file @
77e78881
...
...
@@ -45,12 +45,13 @@
#include
<string>
#include
<eval/token.h>
#include
<eval/eval_context_decl.h>
#include
<dhcp/option.h>
#include
<boost/lexical_cast.hpp>
using
namespace
isc
::
dhcp
;
using
namespace
isc
::
eval
;
#line 5
4
"parser.h" // lalr1.cc:392
#line 5
5
"parser.h" // lalr1.cc:392
# include <cassert>
# include <cstdlib> // std::abort
...
...
@@ -127,7 +128,7 @@ using namespace isc::eval;
#line 21 "parser.yy" // lalr1.cc:392
namespace
isc
{
namespace
eval
{
#line 13
1
"parser.h" // lalr1.cc:392
#line 13
2
"parser.h" // lalr1.cc:392
...
...
@@ -514,7 +515,7 @@ namespace isc { namespace eval {
/// Build a parser object.
EvalParser
(
EvalContext
&
ctx_yyarg
);
EvalParser
(
EvalContext
&
ctx_yyarg
,
const
Option
::
Universe
&
option_universe_yyarg
);
virtual
~
EvalParser
();
/// Parse.
...
...
@@ -597,7 +598,7 @@ namespace isc { namespace eval {
// number is the opposite. If YYTABLE_NINF, syntax error.
static
const
unsigned
char
yytable_
[];
static
const
un
signed
char
yycheck_
[];
static
const
signed
char
yycheck_
[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
...
...
@@ -717,7 +718,7 @@ namespace isc { namespace eval {
enum
{
yyeof_
=
0
,
yylast_
=
2
1
,
///< Last index in yytable_.
yylast_
=
2
9
,
///< Last index in yytable_.
yynnts_
=
6
,
///< Number of nonterminal symbols.
yyfinal_
=
11
,
///< Termination state number.
yyterror_
=
1
,
...
...
@@ -728,6 +729,7 @@ namespace isc { namespace eval {
// User arguments.
EvalContext
&
ctx
;
const
Option
::
Universe
&
option_universe
;
};
// Symbol number corresponding to token number t.
...
...
@@ -1083,7 +1085,7 @@ namespace isc { namespace eval {
#line 21 "parser.yy" // lalr1.cc:392
}
}
// isc::eval
#line 108
7
"parser.h" // lalr1.cc:392
#line 108
9
"parser.h" // lalr1.cc:392
...
...
src/lib/eval/parser.yy
View file @
77e78881
...
...
@@ -25,6 +25,7 @@
#include <string>
#include <eval/token.h>
#include <eval/eval_context_decl.h>
#include <dhcp/option.h>
#include <boost/lexical_cast.hpp>
using namespace isc::dhcp;
...
...
@@ -39,6 +40,10 @@ using namespace isc::eval;
{
# include "eval_context.h"
}
// Option universe: DHCPv4 or DHCPv6. This is required to use correct option
// definition set to map option names to codes.
%parse-param { const Option::Universe& option_universe }
%define api.token.prefix {TOKEN_}
%token
END 0 "end of file"
...
...
@@ -130,6 +135,32 @@ string_expr : STRING
TokenPtr opt(new TokenOption(numeric_code, TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
}
| OPTION "[" STRING "]" DOT TEXT
{
try {
// This may result in exception if the specified
// name is unknown.
TokenPtr opt(new TokenOption($3, option_universe,
TokenOption::TEXTUAL));
ctx.expression.push_back(opt);
} catch (const std::exception& ex) {
ctx.error(@3, ex.what());
}
}
| OPTION "[" STRING "]" DOT HEX
{
try {
// This may result in exception if the specified
// name is unknown.
TokenPtr opt(new TokenOption($3, option_universe,
TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
} catch (const std::exception& ex) {
ctx.error(@3, ex.what());
}
}
| SUBSTRING "(" string_expr "," start_expr "," length_expr ")"
{
TokenPtr sub(new TokenSubstring());
...
...
src/lib/eval/tests/context_unittest.cc
View file @
77e78881
...
...
@@ -16,6 +16,7 @@
#include
<eval/token.h>
#include
<eval/eval_context.h>
#include
<eval/token.h>
#include
<dhcp/option.h>
#include
<dhcp/pkt4.h>
#include
<boost/shared_ptr.hpp>
...
...
@@ -94,7 +95,7 @@ public:
/// @brief checks if the given expression raises the expected message
/// when it is parsed.
void
checkError
(
const
string
&
expr
,
const
string
&
msg
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
parsed_
=
false
;
try
{
parsed_
=
eval
.
parseString
(
expr
);
...
...
@@ -115,15 +116,15 @@ public:
// Test the parsing of a basic expression
TEST_F
(
EvalContextTest
,
basic
)
{
EvalContext
tmp
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
tmp
.
parseString
(
"option[123].text == 'MSFT'"
));
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"option[123].text == 'MSFT'"
));
EXPECT_TRUE
(
parsed_
);
}
// Test the parsing of a string terminal
TEST_F
(
EvalContextTest
,
string
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"'foo' == 'bar'"
));
EXPECT_TRUE
(
parsed_
);
...
...
@@ -140,7 +141,7 @@ TEST_F(EvalContextTest, string) {
// Test the parsing of a basic expression using integers
TEST_F
(
EvalContextTest
,
integer
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"substring(option[123].text, 0, 2) == '42'"
));
...
...
@@ -149,7 +150,7 @@ TEST_F(EvalContextTest, integer) {
// Test the parsing of a hexstring terminal
TEST_F
(
EvalContextTest
,
hexstring
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"0x666f6f == 'foo'"
));
EXPECT_TRUE
(
parsed_
);
...
...
@@ -164,7 +165,7 @@ TEST_F(EvalContextTest, hexstring) {
// Test the parsing of a hexstring terminal with an odd number of
// hexadecimal digits
TEST_F
(
EvalContextTest
,
oddHexstring
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"0X7 == 'foo'"
));
EXPECT_TRUE
(
parsed_
);
...
...
@@ -178,7 +179,7 @@ TEST_F(EvalContextTest, oddHexstring) {
// Test the parsing of an equal expression
TEST_F
(
EvalContextTest
,
equal
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"'foo' == 'bar'"
));
EXPECT_TRUE
(
parsed_
);
...
...
@@ -196,7 +197,7 @@ TEST_F(EvalContextTest, equal) {
// Test the parsing of an option terminal
TEST_F
(
EvalContextTest
,
option
)
{
EvalContext
eval
;
EvalContext
eval
(
Option
::
V4
)
;
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"option[123].text == 'foo'"
));
EXPECT_TRUE
(
parsed_
);
...
...
@@ -204,9 +205,20 @@ TEST_F(EvalContextTest, option) {
checkTokenOption
(
eval
.
expression
.
at
(
0
),
123
);
}
// Test parsing of an option identified by name.
TEST_F
(
EvalContextTest
,
optionWithName
)
{
EvalContext
eval
(
Option
::
V4
);
// Option 'host-name' is a standard DHCPv4 option defined in the libdhcp++.
EXPECT_NO_THROW
(
parsed_
=
eval
.
parseString
(
"option['host-name'].text == 'foo'"
));
EXPECT_TRUE
(
parsed_
);
ASSERT_EQ
(
3
,
eval
.
expression
.
size
());
checkTokenOption
(
eval
.
expression
.
at
(
0
),
12
);
}
// Test parsing of an option represented as hexadecimal string.
TEST_F
(
EvalContextTest
,
optionHex
)
{