2 Unix SMB/CIFS implementation.
4 local test for async resolve code
6 Copyright (C) Andrew Tridgell 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "lib/events/events.h"
24 #include "libcli/resolve/resolve.h"
25 #include "torture/torture.h"
27 static bool test_async_resolve(struct torture_context *tctx)
30 struct event_context *ev;
31 int timelimit = torture_setting_int(tctx, "timelimit", 2);
32 const char *host = torture_setting_string(tctx, "host", NULL);
34 struct timeval tv = timeval_current();
35 TALLOC_CTX *mem_ctx = tctx;
42 torture_comment(tctx, "Testing async resolve of '%s' for %d seconds\n",
44 while (timeval_elapsed(&tv) < timelimit) {
46 struct composite_context *c = resolve_name_host_send(mem_ctx, ev, &n);
47 torture_assert(tctx, c != NULL, "resolve_name_host_send");
48 torture_assert_ntstatus_ok(tctx, resolve_name_host_recv(c, mem_ctx, &s),
49 "async resolve failed");
53 torture_comment(tctx, "async rate of %.1f resolves/sec\n",
54 count/timeval_elapsed(&tv));
59 test resolution using sync method
61 static bool test_sync_resolve(struct torture_context *tctx)
63 int timelimit = torture_setting_int(tctx, "timelimit", 2);
64 struct timeval tv = timeval_current();
66 const char *host = torture_setting_string(tctx, "host", NULL);
68 torture_comment(tctx, "Testing sync resolve of '%s' for %d seconds\n",
70 while (timeval_elapsed(&tv) < timelimit) {
71 sys_inet_ntoa(interpret_addr2(host));
75 torture_comment(tctx, "sync rate of %.1f resolves/sec\n",
76 count/timeval_elapsed(&tv));
81 struct torture_suite *torture_local_resolve(TALLOC_CTX *mem_ctx)
83 struct torture_suite *suite = torture_suite_create(mem_ctx, "RESOLVE");
85 torture_suite_add_simple_test(suite, "async", test_async_resolve);
86 torture_suite_add_simple_test(suite, "sync", test_sync_resolve);