aboutsummaryrefslogtreecommitdiff
path: root/src/platform/resolver_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-29 00:06:42 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-29 00:06:42 -0800
commitb5462f65ffa1737df7385c0955527749b77629bd (patch)
tree625d76d18e2ed54058a5da7bf8f674ac3079532a /src/platform/resolver_test.c
parenta1bc59aaeff1537f06a856f9ecfa23e9924cfad8 (diff)
downloadnng-b5462f65ffa1737df7385c0955527749b77629bd.tar.gz
nng-b5462f65ffa1737df7385c0955527749b77629bd.tar.bz2
nng-b5462f65ffa1737df7385c0955527749b77629bd.zip
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.)
Diffstat (limited to 'src/platform/resolver_test.c')
-rw-r--r--src/platform/resolver_test.c41
1 files changed, 41 insertions, 0 deletions
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 },
};