r15819: Use updated API in smbtorture, use UI tools in registry tests.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 22 May 2006 18:59:56 +0000 (18:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:08:27 +0000 (14:08 -0500)
(This used to be commit 4c452090fbcf9b17acd8473cf018b09f445009b2)

source4/torture/local/registry.c
source4/torture/smbtorture.c

index 623d30a5d85463f1de54ba52b9c634717d3b1814..49f019ba7a437eacc91866c9a6f87dd1556a230d 100644 (file)
 #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", ".");
-
-       talloc_free(mem_ctx);
+       ret &= test_hive(torture, "nt4", "TEST.DAT");
+       ret &= test_hive(torture, "ldb", "test.ldb");
+       ret &= test_hive(torture, "gconf", ".");
+       ret &= test_hive(torture, "dir", ".");
 
        return ret;
 }
index 271444ed9c8d67d6790151d29a15d4908cf019db..3ac7e2a762954d1e246f0cc934dc189b0036923d 100644 (file)
@@ -235,9 +235,9 @@ static void simple_test_start (struct torture_test *test)
        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)