r16184: Convert to UI API. The async test was previously broken (fails
authorJelmer Vernooij <jelmer@samba.org>
Tue, 13 Jun 2006 10:19:01 +0000 (10:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:09:05 +0000 (14:09 -0500)
with NT_STATUS_NO_MEMORY) and still does.
(This used to be commit 5c2e136ef97fb98ae5314d1b2c73bb7b2fe4d8ee)

source4/torture/local/resolve.c

index 58e313bfb44d74c66944a0c866390e06531e5f51..29606f496609bd209cf51c38949dd665c47da767 100644 (file)
 #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);
 }