From b5462f65ffa1737df7385c0955527749b77629bd Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 29 Dec 2024 00:06:42 -0800 Subject: resolver: add some additional test coverage While here, remove some code paths that do not occur by definition. (For example, if the resolver succeeds, we will definitely have a valid set of addresses, but if it fails, we will definitely not.) --- src/platform/resolver_test.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/platform/resolver_test.c') diff --git a/src/platform/resolver_test.c b/src/platform/resolver_test.c index 09a2e51e..653753ef 100644 --- a/src/platform/resolver_test.c +++ b/src/platform/resolver_test.c @@ -262,6 +262,45 @@ test_null_not_passive(void) nng_aio_free(aio); } +void +test_bad_family(void) +{ + nng_aio *aio; + nng_sockaddr sa; + nni_resolv_item item = { 0 }; + + NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); + item.ri_family = NNG_AF_INPROC; + item.ri_host = "/abcdef"; + item.ri_port = 80; + item.ri_passive = false; + item.ri_sa = &sa; + nni_resolv(&item, aio); + nng_aio_wait(aio); + NUTS_FAIL(nng_aio_result(aio), NNG_ENOTSUP); + nng_aio_free(aio); +} + +void +test_aio_stopped(void) +{ + nng_aio *aio; + nng_sockaddr sa; + nni_resolv_item item = { 0 }; + + NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL)); + item.ri_family = NNG_AF_INPROC; + item.ri_host = "/abcdef"; + item.ri_port = 80; + item.ri_passive = false; + item.ri_sa = &sa; + nng_aio_stop(aio); + nni_resolv(&item, aio); + nng_aio_wait(aio); + NUTS_FAIL(nng_aio_result(aio), NNG_ESTOPPED); + nng_aio_free(aio); +} + NUTS_TESTS = { { "resolve google dns", test_google_dns }, { "resolve hostname too long", test_hostname_too_long }, @@ -274,5 +313,7 @@ NUTS_TESTS = { { "resolve localhost unspecified", test_localhost_unspecified }, { "resolve null passive", test_null_passive }, { "resolve null not passive", test_null_not_passive }, + { "resolve bad family", test_bad_family }, + { "resolve aio stopped", test_bad_family }, { NULL, NULL }, }; -- cgit v1.2.3-70-g09d2