Skip to content

Commit ee8e8ab

Browse files
committed
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 <[email protected]>
1 parent cb52096 commit ee8e8ab

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

tests/net/socket/getaddrinfo/src/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ static int sock_v6;
3434
static struct sockaddr_in addr_v4;
3535
static struct sockaddr_in6 addr_v6;
3636

37+
static int queries_received;
38+
3739
/* The mutex is there to wait the data to be received. */
3840
static ZTEST_BMEM SYS_MUTEX_DEFINE(wait_data);
3941

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

6971
queries = ret;
72+
queries_received++;
7073

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

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

233+
zassert_equal(queries_received, 2,
234+
"Did not receive both IPv4 and IPv6 query");
235+
228236
freeaddrinfo(res);
229237
}
230238

tests/net/socket/getaddrinfo/testcase.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
common:
22
depends_on: netif
3-
platform_whitelist: native_posix qemu_x86 qemu_cortex_m3
43
tests:
54
net.socket:
65
min_ram: 21

0 commit comments

Comments
 (0)