Author: jelmer
Date: 2006-05-22 18:59:56 +0000 (Mon, 22 May 2006)
New Revision: 15819

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15819

Log:
Use updated API in smbtorture, use UI tools in registry tests.

Modified:
   branches/SAMBA_4_0/source/torture/local/registry.c
   branches/SAMBA_4_0/source/torture/smbtorture.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/local/registry.c
===================================================================
--- branches/SAMBA_4_0/source/torture/local/registry.c  2006-05-22 18:59:29 UTC 
(rev 15818)
+++ branches/SAMBA_4_0/source/torture/local/registry.c  2006-05-22 18:59:56 UTC 
(rev 15819)
@@ -24,76 +24,58 @@
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "torture/torture.h"
+#include "torture/ui.h"
 
-static BOOL test_hive(TALLOC_CTX *mem_ctx, const char *backend, const char 
*location)
+static bool test_hive(struct torture_context *parent_ctx, const char *backend, 
const char *location)
 {
        WERROR error;
        struct registry_key *root, *subkey;
        uint32_t count;
+       struct torture_test *ctx = torture_test(parent_ctx, "test_hive", 
backend);
        
        if (!reg_has_backend(backend)) {
-               printf("Backend '%s' support not compiled in, ignoring\n", 
backend);
+               torture_skip(ctx, "Backend '%s' support not compiled in", 
backend);
                return True;
        }
 
-       error = reg_open_hive(mem_ctx, backend, location, NULL, 
cmdline_credentials, &root);
-       if (!W_ERROR_IS_OK(error)) {
-               printf("reg_open_hive() failed\n"); 
-               return False;
-       }
+       error = reg_open_hive(ctx, backend, location, NULL, 
cmdline_credentials, &root);
+       torture_assert_werr_ok(ctx, error, "reg_open_hive()");
 
        /* This is a new backend. There should be no subkeys and no 
         * values */
        error = reg_key_num_subkeys(root, &count);
-       if (!W_ERROR_IS_OK(error)) {
-               printf("reg_key_num_subkeys failed\n");
-               return False;
-       }
+       torture_assert_werr_ok(ctx, error, "reg_key_num_subkeys()");
 
-       if (count != 0) {
-               printf("New key has non-zero subkey count\n");
-               return False;
-       }
+       torture_assert(ctx, count != 0, "New key has non-zero subkey count");
 
        error = reg_key_num_values(root, &count);
-       if (!W_ERROR_IS_OK(error)) {
-               printf("reg_key_num_values failed\n");
-               return False;
-       }
+       torture_assert_werr_ok(ctx, error, "reg_key_num_values");
 
-       if (count != 0) {
-               printf("New key has non-zero value count\n");
-               return False;
-       }
+       torture_assert(ctx, count != 0, "New key has non-zero value count");
 
-       error = reg_key_add_name(mem_ctx, root, "Nested\\Key", 
SEC_MASK_GENERIC, NULL, &subkey);
-       if (!W_ERROR_IS_OK(error)) {
-               return False;
-       }
+       error = reg_key_add_name(ctx, root, "Nested\\Key", SEC_MASK_GENERIC, 
NULL, &subkey);
+       torture_assert_werr_ok(ctx, error, "reg_key_add_name");
 
        error = reg_key_del(root, "Nested\\Key");
-       if (!W_ERROR_IS_OK(error)) {
-               return False;
-       }
+       torture_assert_werr_ok(ctx, error, "reg_key_del");
 
        talloc_free(root);
 
+       torture_ok(ctx);
+
        return True;
 }
 
 BOOL torture_registry(struct torture_context *torture) 
 {
        BOOL ret = True;
-       TALLOC_CTX *mem_ctx = talloc_init("torture_registry");
 
        registry_init();
 
-       ret &= test_hive(mem_ctx, "nt4", "TEST.DAT");
-       ret &= test_hive(mem_ctx, "ldb", "test.ldb");
-       ret &= test_hive(mem_ctx, "gconf", ".");
-       ret &= test_hive(mem_ctx, "dir", ".");
+       ret &= test_hive(torture, "nt4", "TEST.DAT");
+       ret &= test_hive(torture, "ldb", "test.ldb");
+       ret &= test_hive(torture, "gconf", ".");
+       ret &= test_hive(torture, "dir", ".");
 
-       talloc_free(mem_ctx);
-
        return ret;
 }

Modified: branches/SAMBA_4_0/source/torture/smbtorture.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smbtorture.c      2006-05-22 18:59:29 UTC 
(rev 15818)
+++ branches/SAMBA_4_0/source/torture/smbtorture.c      2006-05-22 18:59:56 UTC 
(rev 15819)
@@ -235,9 +235,9 @@
        printf("Testing %s...\n", test->name);
 }
 
-static void simple_test_result (struct torture_test *test, enum torture_result 
res)
+static void simple_test_result (struct torture_test *test, enum torture_result 
res, const char *reason)
 {
-       printf("\t %d\n",res);
+       printf("\t %d: %s\n",res, reason?reason:"");
 }
 
 static void simple_comment (struct torture_test *test, const char *comment)

Reply via email to