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
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
c7e4fc13
Commit
c7e4fc13
authored
Jul 25, 2016
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the resolving of multiple hostnames at the same time
parent
db503b23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
tests/dns.cpp
tests/dns.cpp
+28
-14
No files found.
tests/dns.cpp
View file @
c7e4fc13
...
...
@@ -9,6 +9,8 @@
TEST_CASE
(
"DNS resolver"
)
{
Resolver
resolver
;
Resolver
resolver2
;
Resolver
resolver3
;
/**
* If we are using cares, we need to run a poller loop until each
...
...
@@ -36,38 +38,50 @@ TEST_CASE("DNS resolver")
bool
success
=
true
;
auto
error_cb
=
[
&
success
,
&
hostname
,
&
port
](
const
char
*
msg
)
{
INFO
(
"Failed to resolve "
<<
hostname
<<
":"
<<
port
<<
": "
<<
msg
);
success
=
false
;
};
auto
success_cb
=
[
&
success
,
&
hostname
,
&
port
](
const
struct
addrinfo
*
addr
)
{
INFO
(
"Successfully resolved "
<<
hostname
<<
":"
<<
port
<<
": "
<<
addr_to_string
(
addr
));
success
=
true
;
};
const
auto
error_cb
=
[
&
success
](
const
std
::
string
&
hostname
)
{
return
[
&
success
,
hostname
](
const
char
*
msg
)
{
INFO
(
"Failed to resolve "
<<
hostname
<<
":"
<<
msg
);
success
=
false
;
};
};
const
auto
success_cb
=
[
&
success
](
const
std
::
string
&
hostname
)
{
return
[
&
success
,
hostname
](
const
struct
addrinfo
*
addr
)
{
INFO
(
"Successfully resolved "
<<
hostname
<<
": "
<<
addr_to_string
(
addr
));
success
=
true
;
};
};
hostname
=
"example.com"
;
resolver
.
resolve
(
hostname
,
port
,
success_cb
,
error_cb
);
success_cb
(
hostname
),
error_cb
(
hostname
));
hostname
=
"poez.io"
;
resolver2
.
resolve
(
hostname
,
port
,
success_cb
(
hostname
),
error_cb
(
hostname
));
hostname
=
"louiz.org"
;
resolver3
.
resolve
(
hostname
,
port
,
success_cb
(
hostname
),
error_cb
(
hostname
));
loop
();
CHECK
(
success
);
hostname
=
"this.should.fail.because.it.is..misformatted"
;
resolver
.
resolve
(
hostname
,
port
,
success_cb
,
error_cb
);
success_cb
(
hostname
),
error_cb
(
hostname
)
);
loop
();
CHECK
(
!
success
);
hostname
=
"this.should.fail.because.it.is.does.not.exist.invalid"
;
resolver
.
resolve
(
hostname
,
port
,
success_cb
,
error_cb
);
success_cb
(
hostname
),
error_cb
(
hostname
)
);
loop
();
CHECK
(
!
success
);
hostname
=
"localhost"
;
resolver
.
resolve
(
hostname
,
port
,
success_cb
,
error_cb
);
success_cb
(
hostname
),
error_cb
(
hostname
)
);
loop
();
CHECK
(
success
);
...
...
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