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
BIND
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
637
Issues
637
List
Boards
Labels
Service Desk
Milestones
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
BIND
Commits
73780729
Commit
73780729
authored
Apr 16, 1999
by
David Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added "check" command to test dns_rbt_findnode and dns_rbtnodechain_current.
input can now have comments.
parent
ec80744a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
7 deletions
+109
-7
bin/tests/rbt_test.c
bin/tests/rbt_test.c
+109
-7
No files found.
bin/tests/rbt_test.c
View file @
73780729
...
...
@@ -51,9 +51,9 @@ create_name(char *s) {
/*
* It isn't really necessary in this program to create individual
* memory spaces for each name structure and its associate character
* string. It is done
in this program to provide a relatively
*
easy way to test the callback from dns_rbt_deletename that is
*
supposed to free the
data associated with a node.
* string. It is done
here to provide a relatively easy way to test
*
the callback from dns_rbt_deletename that is supposed to free the
* data associated with a node.
*
* The buffer for the actual name will immediately follow the
* name structure.
...
...
@@ -103,6 +103,86 @@ print_name(dns_name_t *name) {
printf
(
"%.*s"
,
(
int
)
target
.
used
,
(
char
*
)
target
.
base
);
}
static
void
detail
(
dns_rbt_t
*
rbt
,
dns_name_t
*
name
)
{
dns_name_t
*
foundname
,
*
origin
,
*
fullname
;
dns_fixedname_t
fixedfoundname
,
fixedorigin
,
fixedfullname
;
dns_rbtnode_t
*
node1
,
*
node2
;
dns_rbtnodechain_t
chain
;
dns_result_t
result
;
isc_boolean_t
nodes_should_match
=
ISC_FALSE
;
dns_rbtnodechain_init
(
&
chain
,
mctx
);
dns_fixedname_init
(
&
fixedorigin
);
dns_fixedname_init
(
&
fixedfullname
);
dns_fixedname_init
(
&
fixedfoundname
);
origin
=
dns_fixedname_name
(
&
fixedorigin
);
fullname
=
dns_fixedname_name
(
&
fixedfullname
);
foundname
=
dns_fixedname_name
(
&
fixedfoundname
);
node1
=
node2
=
NULL
;
printf
(
"checking chain information for "
);
print_name
(
name
);
printf
(
"
\n
"
);
result
=
dns_rbt_findnode
(
rbt
,
name
,
foundname
,
&
node1
,
&
chain
,
ISC_TRUE
,
NULL
,
NULL
);
switch
(
result
)
{
case
DNS_R_SUCCESS
:
printf
(
" found exact."
);
nodes_should_match
=
ISC_TRUE
;
break
;
case
DNS_R_PARTIALMATCH
:
printf
(
" found parent."
);
break
;
case
DNS_R_NOTFOUND
:
printf
(
" name not found."
);
break
;
default:
printf
(
" unexpected result: %s
\n
"
,
dns_result_totext
(
result
));
return
;
}
if
(
node1
!=
NULL
&&
node1
->
data
!=
NULL
)
{
printf
(
" data at node: "
);
print_name
(
node1
->
data
);
}
else
printf
(
" no data at node."
);
if
(
result
==
DNS_R_SUCCESS
||
result
==
DNS_R_PARTIALMATCH
)
{
printf
(
"
\n
name from dns_rbt_findnode: "
);
print_name
(
foundname
);
}
result
=
dns_rbtnodechain_current
(
&
chain
,
foundname
,
origin
,
&
node2
);
if
(
result
==
DNS_R_SUCCESS
)
{
printf
(
"
\n
name from dns_rbtnodechain_current: "
);
result
=
dns_name_concatenate
(
foundname
,
origin
,
fullname
,
NULL
);
if
(
result
==
DNS_R_SUCCESS
)
print_name
(
fullname
);
else
printf
(
"%s
\n
"
,
dns_result_totext
(
result
));
printf
(
"
\n
(foundname = "
);
print_name
(
foundname
);
printf
(
", origin = "
);
print_name
(
origin
);
printf
(
")
\n
"
);
if
(
nodes_should_match
&&
node1
!=
node2
)
printf
(
" nodes returned from each function "
"DO NOT match!
\n
"
);
}
else
printf
(
"
\n
result from dns_rbtnodechain_current: %s
\n
"
,
dns_result_totext
(
result
));
}
static
void
iterate
(
dns_rbt_t
*
rbt
,
isc_boolean_t
forward
)
{
dns_name_t
foundname
,
*
origin
;
...
...
@@ -122,14 +202,15 @@ iterate(dns_rbt_t *rbt, isc_boolean_t forward) {
printf
(
"iterating forward
\n
"
);
move
=
dns_rbtnodechain_next
;
result
=
dns_rbtnodechain_first
(
&
chain
,
rbt
,
&
foundname
,
origin
);
result
=
dns_rbtnodechain_first
(
&
chain
,
rbt
,
&
foundname
,
origin
);
}
else
{
printf
(
"iterating backward
\n
"
);
move
=
dns_rbtnodechain_prev
;
result
=
dns_rbtnodechain_last
(
&
chain
,
rbt
,
&
foundname
,
origin
);
result
=
dns_rbtnodechain_last
(
&
chain
,
rbt
,
&
foundname
,
origin
);
}
if
(
result
!=
DNS_R_SUCCESS
&&
result
!=
DNS_R_NEWORIGIN
)
...
...
@@ -228,6 +309,10 @@ main (int argc, char **argv) {
buffer
[
length
-
1
]
=
'\0'
;
command
=
buffer
+
strspn
(
buffer
,
whitespace
);
if
(
*
command
==
'#'
)
continue
;
arg
=
strpbrk
(
command
,
whitespace
);
if
(
arg
!=
NULL
)
{
*
arg
++
=
'\0'
;
...
...
@@ -291,7 +376,6 @@ main (int argc, char **argv) {
printf
(
"
\n\t
(foundname: "
);
print_name
(
foundname
);
printf
(
")
\n
"
);
break
;
case
DNS_R_NOTFOUND
:
printf
(
"NOT FOUND!
\n
"
);
...
...
@@ -306,6 +390,24 @@ main (int argc, char **argv) {
delete_name
(
name
,
NULL
);
}
}
else
if
(
CMDCHECK
(
"check"
))
{
/*
* Or "chain". I know, I know. Lame name.
* I was having a hard time thinking of a
* name (especially one that did not have
* a conflicting first letter with another
* command) that would differentiate this
* from the search command.
*
* But it is just a test program, eh?
*/
name
=
create_name
(
arg
);
if
(
name
!=
NULL
)
{
detail
(
rbt
,
name
);
delete_name
(
name
,
NULL
);
}
}
else
if
(
CMDCHECK
(
"forward"
))
{
iterate
(
rbt
,
ISC_TRUE
);
...
...
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