mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
test: async dns: handle dynamic ads on warmcat
We use warmcat dns for testing, but for a while it has become dynamic breaking the tests. Fix up the affected tests with IPv4 addresses from getaddrinfo() so they pass when they match these results.
This commit is contained in:
parent
48e09ddf51
commit
3454cd1f8a
1 changed files with 39 additions and 1 deletions
|
@ -69,7 +69,7 @@ static const struct ipparser_tests {
|
|||
|
||||
#define TEST_FLAG_NOCHECK_RESULT_IP 0x100000
|
||||
|
||||
static const struct async_dns_tests {
|
||||
static struct async_dns_tests {
|
||||
const char *dns_name;
|
||||
int recordtype;
|
||||
int addrlen;
|
||||
|
@ -390,6 +390,36 @@ void sigint_handler(int sig)
|
|||
interrupted = 1;
|
||||
}
|
||||
|
||||
int
|
||||
fixup(int idx)
|
||||
{
|
||||
struct addrinfo hints, *ai;
|
||||
int m;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
m = getaddrinfo(adt[idx].dns_name, "80", &hints, &ai);
|
||||
if (m) {
|
||||
lwsl_err("Unable to look up %s: %s", adt[0].dns_name,
|
||||
gai_strerror(m));
|
||||
return 1;
|
||||
}
|
||||
adt[idx].ads[0] = (uint8_t)((struct sockaddr *)ai->ai_addr)->sa_data[2];
|
||||
adt[idx].ads[1] = (uint8_t)((struct sockaddr *)ai->ai_addr)->sa_data[3];
|
||||
adt[idx].ads[2] = (uint8_t)((struct sockaddr *)ai->ai_addr)->sa_data[4];
|
||||
adt[idx].ads[3] = (uint8_t)((struct sockaddr *)ai->ai_addr)->sa_data[5];
|
||||
|
||||
freeaddrinfo(ai);
|
||||
|
||||
lwsl_notice("%s: %u.%u.%u.%u\n", __func__,
|
||||
adt[idx].ads[0], adt[idx].ads[1], adt[idx].ads[2], adt[idx].ads[3]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
|
@ -397,6 +427,14 @@ main(int argc, const char **argv)
|
|||
struct lws_context_creation_info info;
|
||||
const char *p;
|
||||
|
||||
/* fixup dynamic target addresses we're testing against */
|
||||
|
||||
fixup(0);
|
||||
fixup(1);
|
||||
fixup(2);
|
||||
fixup(5);
|
||||
fixup(6);
|
||||
|
||||
/* the normal lws init */
|
||||
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
|
Loading…
Add table
Reference in a new issue