t_resolver.c revision c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840e
69fe9aaafdd6a141610e86a777d325db75422070Mark Andrews * Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and/or distribute this software for any
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * purpose with or without fee is hereby granted, provided that the above
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley/* $Id: t_resolver.c,v 1.3 2011/02/03 12:18:11 tbox Exp $ */
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley#define CHECK(x) RUNTIME_CHECK(ISC_R_SUCCESS == (x))
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley CHECK(dns_dispatch_getudp(dispatch_manager, socket_manager,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley /* 2 */ CHECK(isc_timermgr_create(mctx, &timer_manager));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley /* 3 */ CHECK(isc_taskmgr_create(mctx, 1, 0, &task_manager));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley /* 4 */ CHECK(isc_socketmgr_create(mctx, &socket_manager));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley /* 5 */ CHECK(dns_dispatchmgr_create(mctx, NULL, &dispatch_manager));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley /* 6 */ CHECK(dns_view_create(mctx, dns_rdataclass_in, "testview", &view));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley /* 5 */ dns_dispatchmgr_destroy(&dispatch_manager);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley 0, /* unsigned int options, */
bfa633fc0e5dea8f65676c5393993ba7053a9899Andreas Gustafssondestroy_resolver(dns_resolver_t **resolverp) {
e605e98f3e4be079f545b26bb53ba02a6d04b0b6Andreas Gustafsson t_assert("test_dns_resolver_create", 1, T_REQUIRED, "%s",
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley "a resolver can be created successfully");
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley unsigned int timeout;
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_assert("test_dns_resolver_gettimeout", 1, T_REQUIRED, "%s",
9297259c7abecc78470fdeca173c101137e4b5bbMark Andrews "The default timeout is returned from _gettimeout()");
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_info("The default timeout is %d second%s\n", timeout, (timeout == 1 ? "" : "s"));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_assert("test_dns_resolver_settimeout", 1, T_REQUIRED, "%s",
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley "_settimeout() can change the timeout to a non-default");
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley default_timeout = dns_resolver_gettimeout(resolver);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_info("The default timeout is %d second%s\n", default_timeout,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley dns_resolver_settimeout(resolver, default_timeout + 1);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_info("The new timeout is %d second%s\n", timeout,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley test_result = (timeout == default_timeout + 1) ? T_PASS : T_FAIL;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff t_assert("test_dns_resolver_settimeout_to_default", 1, T_REQUIRED, "%s",
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley "_settimeout() can change the timeout back to a default value"
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley " by specifying 0 as the timeout.");
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley default_timeout = dns_resolver_gettimeout(resolver);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_info("The default timeout is %d second%s\n", default_timeout,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley dns_resolver_settimeout(resolver, default_timeout - 1);
808af432356c7592e80bd41416eca61e7bc8791dBob Halley t_info("The new timeout is %d second%s\n", timeout,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley test_result = (timeout == default_timeout) ? T_PASS : T_FAIL;
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley unsigned int timeout;
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_assert("test_dns_resolver_settimeout_over_maximum", 1, T_REQUIRED, "%s",
558ab0f6a8046499bfe3e39ea4789036313b72b3Michael Graff "_settimeout() cannot set the value larger than the maximum.");
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley t_info("The new timeout is %d second%s\n", timeout,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley test_result = (timeout < 4000000 && timeout > 0) ? T_PASS : T_FAIL;
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley { (PFV) test_dns_resolver_create, "dns_resolver_create" },
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley { (PFV) test_dns_resolver_settimeout, "dns_resolver_settimeout" },
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley { (PFV) test_dns_resolver_gettimeout, "dns_resolver_gettimeout" },
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley { (PFV) test_dns_resolver_settimeout_to_default, "test_dns_resolver_settimeout_to_default" },
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley { (PFV) test_dns_resolver_settimeout_over_maximum, "test_dns_resolver_settimeout_over_maximum" },