diff options
author | Tom Rini <trini@konsulko.com> | 2024-10-16 08:10:14 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-10-16 08:10:14 -0600 |
commit | f3f86fd1fe0fb288356bff78f8a6fa2edf89e3fc (patch) | |
tree | f0a99ea87d92f63895a6d053e3185838ebecf2d0 /test/unit/core/test_dns.c |
Squashed 'lib/lwip/lwip/' content from commit 0a0452b2c39b
git-subtree-dir: lib/lwip/lwip
git-subtree-split: 0a0452b2c39bdd91e252aef045c115f88f6ca773
Diffstat (limited to 'test/unit/core/test_dns.c')
-rw-r--r-- | test/unit/core/test_dns.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/unit/core/test_dns.c b/test/unit/core/test_dns.c new file mode 100644 index 00000000000..6789d244109 --- /dev/null +++ b/test/unit/core/test_dns.c @@ -0,0 +1,52 @@ +#include "test_dns.h" + +#include "lwip/dns.h" + +/* Setups/teardown functions */ + +static void +dns_setup(void) +{ +} + +static void +dns_teardown(void) +{ +} + +/* Test functions */ + +START_TEST(test_dns_set_get_server) +{ + int n; + LWIP_UNUSED_ARG(_i); + + for (n = 0; n < 256; n++) { + u8_t i = (u8_t)n; + ip_addr_t server; + /* Should return a zeroed address for any index */ + fail_unless(dns_getserver(i)); + fail_unless(ip_addr_isany(dns_getserver(i))); + + /* Should accept setting address for any index, and ignore if out of range */ + IP_ADDR4(&server, 10, 0, 0, i); + dns_setserver(i, &server); + fail_unless(dns_getserver(i)); + if (i < DNS_MAX_SERVERS) { + fail_unless(ip_addr_eq(dns_getserver(i), &server) == 1); + } else { + fail_unless(ip_addr_isany(dns_getserver(i))); + } + } +} +END_TEST + +/** Create the suite including all tests for this module */ +Suite * +dns_suite(void) +{ + testfunc tests[] = { + TESTFUNC(test_dns_set_get_server) + }; + return create_suite("DNS", tests, sizeof(tests)/sizeof(testfunc), dns_setup, dns_teardown); +} |