diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-06-13 10:19:01 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:09:05 -0500 |
commit | 123e50735af52dd29f1874fab90ce48c26c9f3fd (patch) | |
tree | 73e9bb25f77c312fe6a2ef0fce4b1c7c75252829 | |
parent | 4d333d26b3ff8cd01b0252722f0f8d3dfbba72e8 (diff) | |
download | samba-123e50735af52dd29f1874fab90ce48c26c9f3fd.tar.gz samba-123e50735af52dd29f1874fab90ce48c26c9f3fd.tar.bz2 samba-123e50735af52dd29f1874fab90ce48c26c9f3fd.zip |
r16184: Convert to UI API. The async test was previously broken (fails
with NT_STATUS_NO_MEMORY) and still does.
(This used to be commit 5c2e136ef97fb98ae5314d1b2c73bb7b2fe4d8ee)
-rw-r--r-- | source4/torture/local/resolve.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/source4/torture/local/resolve.c b/source4/torture/local/resolve.c index 58e313bfb4..29606f4966 100644 --- a/source4/torture/local/resolve.c +++ b/source4/torture/local/resolve.c @@ -24,65 +24,73 @@ #include "lib/events/events.h" #include "libcli/resolve/resolve.h" #include "torture/torture.h" +#include "torture/ui.h" -static BOOL test_async_resolve(TALLOC_CTX *mem_ctx) +static BOOL test_async_resolve(struct torture_context *torture) { struct nbt_name n; - struct event_context *ev = event_context_find(mem_ctx); + struct torture_test *test = torture_test(torture, "async_resolve", + "asynchronous resolve"); + struct event_context *ev; int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); const char *host = lp_parm_string(-1, "torture", "host"); int count = 0; struct timeval tv = timeval_current(); + ev = event_context_init(test); + ZERO_STRUCT(n); n.name = host; - printf("Testing async resolve of localhost for %d seconds\n", timelimit); + torture_comment(test, "Testing async resolve of localhost for %d seconds", + timelimit); while (timeval_elapsed(&tv) < timelimit) { const char *s; struct composite_context *c = resolve_name_host_send(&n, ev); - NTSTATUS status = resolve_name_host_recv(c, mem_ctx, &s); - if (!NT_STATUS_IS_OK(status)) { - printf("async resolve failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert(test, c, "resolve_name_host_send"); + torture_assert_ntstatus_ok(test, resolve_name_host_recv(c, test, &s), + "async resolve failed"); count++; } - printf("async rate of %.1f resolves/sec\n", count/timeval_elapsed(&tv)); + torture_comment(test, "async rate of %.1f resolves/sec", + count/timeval_elapsed(&tv)); + + talloc_free(test); return True; } /* test resolution using sync method */ -static BOOL test_sync_resolve(TALLOC_CTX *mem_ctx) +static BOOL test_sync_resolve(struct torture_context *torture) { int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); struct timeval tv = timeval_current(); int count = 0; const char *host = lp_parm_string(-1, "torture", "host"); + struct torture_test *test = torture_test(torture, "sync resolve", + "synchronous resolve"); - printf("Testing sync resolve of localhost for %d seconds\n", timelimit); + torture_comment(test, "Testing sync resolve of localhost for %d seconds", + timelimit); while (timeval_elapsed(&tv) < timelimit) { sys_inet_ntoa(interpret_addr2(host)); count++; } - printf("sync rate of %.1f resolves/sec\n", count/timeval_elapsed(&tv)); + torture_comment(test, "sync rate of %.1f resolves/sec", + count/timeval_elapsed(&tv)); + + talloc_free(test); return True; } BOOL torture_local_resolve(struct torture_context *torture) { - TALLOC_CTX *mem_ctx = talloc_init("torture_local_irpc"); - BOOL ret = True; - - ret &= test_sync_resolve(mem_ctx); - ret &= test_async_resolve(mem_ctx); - - talloc_free(mem_ctx); + test_async_resolve(torture); + test_sync_resolve(torture); - return ret; + return torture_result(torture); } |