diff options
author | Azat Khuzhin <azat@libevent.org> | 2020-06-26 10:35:44 +0300 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2020-06-28 21:38:40 +0300 |
commit | 4d3ff29cac429a3f08350662f40694c01ec94a61 (patch) | |
tree | 62493fc1d567f8e51030947c9b6b0bcbbc1cac5a | |
parent | cb4b87380d26fa3f6a87d4cfea54ffafd07bcc35 (diff) | |
download | libevent-4d3ff29cac429a3f08350662f40694c01ec94a61.tar.gz |
test: add getaddrinfo(AI_ADDRCONFIG) test (off by default)
(cherry picked from commit 0ac3cfc0b70edc2cfb429712d6aaf1b3a63d2d1a)
-rw-r--r-- | test/regress_util.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/regress_util.c b/test/regress_util.c index c345cdf3..45caa270 100644 --- a/test/regress_util.c +++ b/test/regress_util.c @@ -1190,6 +1190,41 @@ end: evutil_freeaddrinfo(ai); } +static void +test_evutil_getaddrinfo_AI_ADDRCONFIG(void *arg) +{ + struct evutil_addrinfo *ai = NULL; + struct evutil_addrinfo hints; + int r; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = EVUTIL_AI_PASSIVE|EVUTIL_AI_ADDRCONFIG; + + /* IPv4 */ + r = evutil_getaddrinfo("127.0.0.1", "80", &hints, &ai); + tt_int_op(r, ==, 0); + tt_assert(ai); + tt_ptr_op(ai->ai_next, ==, NULL); + test_ai_eq(ai, "127.0.0.1:80", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(ai); + ai = NULL; + + /* IPv6 */ + r = evutil_getaddrinfo("::1", "80", &hints, &ai); + tt_int_op(r, ==, 0); + tt_assert(ai); + tt_ptr_op(ai->ai_next, ==, NULL); + test_ai_eq(ai, "[::1]:80", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(ai); + ai = NULL; + +end: + if (ai) + evutil_freeaddrinfo(ai); +} + #ifdef _WIN32 static void test_evutil_loadsyslib(void *arg) @@ -1624,6 +1659,7 @@ struct testcase_t util_testcases[] = { { "EVUTIL_IS_", test_EVUTIL_IS_, 0, NULL, NULL }, { "getaddrinfo", test_evutil_getaddrinfo, TT_FORK, NULL, NULL }, { "getaddrinfo_live", test_evutil_getaddrinfo_live, TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL }, + { "getaddrinfo_AI_ADDRCONFIG", test_evutil_getaddrinfo_AI_ADDRCONFIG, TT_FORK|TT_OFF_BY_DEFAULT, NULL, NULL }, #ifdef _WIN32 { "loadsyslib", test_evutil_loadsyslib, TT_FORK, NULL, NULL }, #endif |