2020-07-04 16:31:36 +00:00
|
|
|
#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) {
|
2020-07-07 14:55:52 +00:00
|
|
|
fail_unless(ip_addr_eq(dns_getserver(i), &server) == 1);
|
2020-07-04 16:31:36 +00:00
|
|
|
} 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);
|
|
|
|
}
|