Skip to content
Permalink
Browse files

tests: net: getaddrinfo: Make sure we receive two queries

If user supplies AF_UNSPEC, we need to do two queries, one for
IPv4 A record and one for IPv6 AAAA record.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed Jun 13, 2019
1 parent 19806a2 commit 2c4b2a16a5d59bf9d762e88fc365220b92ec8f0a
Showing with 8 additions and 1 deletion.
  1. +8 −0 tests/net/socket/getaddrinfo/src/main.c
  2. +0 −1 tests/net/socket/getaddrinfo/testcase.yaml
@@ -34,6 +34,8 @@ static int sock_v6;
static struct sockaddr_in addr_v4;
static struct sockaddr_in6 addr_v6;

static int queries_received;

/* The mutex is there to wait the data to be received. */
static ZTEST_BMEM SYS_MUTEX_DEFINE(wait_data);

@@ -67,6 +69,7 @@ static bool check_dns_query(u8_t *buf, int buf_len)
}

queries = ret;
queries_received++;

NET_DBG("Received %d %s", queries,
queries > 1 ? "queries" : "query");
@@ -213,6 +216,8 @@ void test_getaddrinfo_ok(void)
{
struct addrinfo *res = NULL;

queries_received = 0;

/* This check simulates a local query that we will catch
* in dns_process() function. So we do not check the res variable
* as that will currently not contain anything useful. We just check
@@ -225,6 +230,9 @@ void test_getaddrinfo_ok(void)
zassert_true(false, "Timeout DNS query not received");
}

zassert_equal(queries_received, 2,
"Did not receive both IPv4 and IPv6 query");

freeaddrinfo(res);
}

@@ -1,6 +1,5 @@
common:
depends_on: netif
platform_whitelist: native_posix qemu_x86 qemu_cortex_m3
tests:
net.socket:
min_ram: 21

0 comments on commit 2c4b2a1

Please sign in to comment.
You can’t perform that action at this time.