Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
afcc11cc
Commit
afcc11cc
authored
Mar 31, 2019
by
michael-grunder
Browse files
Fix NXDOMAIN test case
As it turns out 'idontexist.com' actually does exist.
parent
17b41740
Changes
1
Show whitespace changes
Inline
Side-by-side
test.c
View file @
afcc11cc
...
@@ -434,22 +434,22 @@ static void test_free_null(void) {
...
@@ -434,22 +434,22 @@ static void test_free_null(void) {
test_cond
(
reply
==
NULL
);
test_cond
(
reply
==
NULL
);
}
}
#define HIREDIS_BAD_DOMAIN "idontexist-noreally.com"
static
void
test_blocking_connection_errors
(
void
)
{
static
void
test_blocking_connection_errors
(
void
)
{
redisContext
*
c
;
redisContext
*
c
;
struct
addrinfo
hints
=
{.
ai_family
=
AF_INET
};
struct
addrinfo
hints
=
{.
ai_family
=
AF_INET
};
struct
addrinfo
*
ai_tmp
=
NULL
;
struct
addrinfo
*
ai_tmp
=
NULL
;
const
char
*
bad_domain
=
"idontexist.com"
;
int
rv
=
getaddrinfo
(
bad_domain
,
"6379"
,
&
hints
,
&
ai_tmp
);
int
rv
=
getaddrinfo
(
HIREDIS_BAD_DOMAIN
,
"6379"
,
&
hints
,
&
ai_tmp
);
if
(
rv
!=
0
)
{
if
(
rv
!=
0
)
{
// Address does *not* exist
// Address does *not* exist
test
(
"Returns error when host cannot be resolved: "
);
test
(
"Returns error when host cannot be resolved: "
);
// First see if this domain name *actually* resolves to NXDOMAIN
// First see if this domain name *actually* resolves to NXDOMAIN
c
=
redisConnect
(
"dontexist.com"
,
6379
);
c
=
redisConnect
(
HIREDIS_BAD_DOMAIN
,
6379
);
test_cond
(
test_cond
(
c
->
err
==
REDIS_ERR_OTHER
&&
c
->
err
==
REDIS_ERR_OTHER
&&
(
strcmp
(
c
->
errstr
,
"Name or service not known"
)
==
0
||
(
strcmp
(
c
->
errstr
,
"Name or service not known"
)
==
0
||
strcmp
(
c
->
errstr
,
"Can't resolve:
sadkfjaskfjsa.com"
)
==
0
||
strcmp
(
c
->
errstr
,
"Can't resolve:
"
HIREDIS_BAD_DOMAIN
)
==
0
||
strcmp
(
c
->
errstr
,
strcmp
(
c
->
errstr
,
"nodename nor servname provided, or not known"
)
==
0
||
"nodename nor servname provided, or not known"
)
==
0
||
strcmp
(
c
->
errstr
,
"No address associated with hostname"
)
==
0
||
strcmp
(
c
->
errstr
,
"No address associated with hostname"
)
==
0
||
...
...
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