lwip/test/unit/core/test_dns.c

53 lines
1.1 KiB
C

#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 i;
LWIP_UNUSED_ARG(_i);
for (i = 0; i < 256; i++) {
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) {
/* ip_addr_cmp returns 1 if they match. */
fail_unless(ip_addr_cmp(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);
}