r16328: Wrap all existing tests in simple single-function testsuites.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 17 Jun 2006 00:17:50 +0000 (00:17 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:09:10 +0000 (14:09 -0500)
(This used to be commit 7e811adf59841936b7e634fca4e95630f890c5af)

19 files changed:
source4/torture/auth/ntlmssp.c
source4/torture/auth/pac.c
source4/torture/local/binding_string.c
source4/torture/local/event.c
source4/torture/local/idtree.c
source4/torture/local/irpc.c
source4/torture/local/messaging.c
source4/torture/local/ndr.c
source4/torture/local/registry.c
source4/torture/local/resolve.c
source4/torture/local/sddl.c
source4/torture/local/socket.c
source4/torture/local/util_file.c
source4/torture/local/util_strlist.c
source4/torture/smbtorture.c
source4/torture/torture.c
source4/torture/torture.h
source4/torture/ui.c
source4/torture/ui.h

index 5c75a5b028c3ff4ed647d77026dd2df61fe2e62b..978610ec515ca9cf7957ce4d71c89549a3d82046 100644 (file)
@@ -23,7 +23,6 @@
 #include "auth/ntlmssp/ntlmssp.h"
 #include "lib/cmdline/popt_common.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 static BOOL torture_ntlmssp_self_check(struct torture_context *test, 
                                                                const void *_data) 
@@ -129,12 +128,13 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
        return True;
 }
 
-BOOL torture_ntlmssp(struct torture_context *torture)
+struct torture_suite *torture_ntlmssp(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "AUTH-NTLMSSP");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, 
+                                                                                                          "LOCAL-NTLMSSP");
 
        torture_suite_add_simple_tcase(suite, "NTLMSSP self check",
                                                                   torture_ntlmssp_self_check, NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index 316a67acb0e4d72d3daa6f91407c12b7d34f8ca8..ecba5d1cc8f1b41d2e211fe9d8b479251a8af1ef 100644 (file)
@@ -29,7 +29,6 @@
 #include "samba3/samba3.h"
 #include "libcli/security/security.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 static BOOL torture_pac_self_check(struct torture_context *test, 
                                                                   const void *_data) 
@@ -662,9 +661,9 @@ static BOOL torture_pac_saved_check(struct torture_context *test,
        return True;
 }
 
-BOOL torture_pac(struct torture_context *torture) 
+struct torture_suite *torture_pac(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "AUTH-PAC");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "AUTH-PAC");
 
        torture_suite_add_simple_tcase(suite, "self check", 
                                                                   torture_pac_self_check, NULL);
@@ -672,5 +671,5 @@ BOOL torture_pac(struct torture_context *torture)
        torture_suite_add_simple_tcase(suite, "saved check",
                                                                   torture_pac_saved_check, NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index a7b6cd14b49eddd9b9aa1a50f8a9745ff7fe983c..3c38183ec994f1a0d48322b27954b5c87c0f79dc 100644 (file)
@@ -24,7 +24,6 @@
 #include "librpc/gen_ndr/epmapper.h"
 #include "librpc/rpc/dcerpc.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 static BOOL test_BindingString(struct torture_context *torture, 
                                                           const void *_binding)
@@ -111,10 +110,10 @@ static const char *test_strings[] = {
        "ncacn_unix_stream:[/tmp/epmapper,sign]",
 };
 
-BOOL torture_local_binding_string(struct torture_context *torture) 
+struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx)
 {
        int i;
-       struct torture_suite *suite = torture_suite_create(torture
+       struct torture_suite *suite = torture_suite_create(mem_ctx
                                                                                                           "LOCAL-BINDING");
 
        for (i = 0; i < ARRAY_SIZE(test_strings); i++) {
@@ -122,5 +121,5 @@ BOOL torture_local_binding_string(struct torture_context *torture)
                                                test_BindingString, test_strings[i]);
        }
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index d886519220569967b0ff3561e2654fe66e9e3d33..f55cd8d4668ac7809ae86f5fda5fa58870f2ece1 100644 (file)
@@ -24,7 +24,6 @@
 #include "lib/events/events.h"
 #include "system/filesys.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 const struct event_ops *event_standard_get_ops(void);
 const struct event_ops *event_liboop_get_ops(void);
@@ -113,10 +112,9 @@ static BOOL test_event_context(struct torture_context *torture, const void *_dat
        return True;
 }
 
-BOOL torture_local_event(struct torture_context *torture) 
+struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx)
 {
-       BOOL retv = True;
-       struct torture_suite *suite = torture_suite_create(torture, "LOCAL-EVENT");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-EVENT");
 
        torture_suite_add_simple_tcase(suite, "standard with select",
                                                                   test_event_context,
@@ -126,5 +124,5 @@ BOOL torture_local_event(struct torture_context *torture)
                                                                   test_event_context,
                                                                   (void *)True);
 
-       return retv;
+       return suite;
 }
index a81eddedc306463f08f5130c6e83a7a4d012c2a9..1d317dbce3f188ed58dc3d3247c02a9aab641ea7 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "includes.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 static BOOL torture_local_idtree_simple(struct torture_context *test, 
                                                                 const void *_data) 
@@ -93,10 +92,10 @@ static BOOL torture_local_idtree_simple(struct torture_context *test,
        return True;
 }
 
-BOOL torture_local_idtree(struct torture_context *torture)
+struct torture_suite *torture_local_idtree(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "LOCAL-IDTREE");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-IDTREE");
        torture_suite_add_simple_tcase(suite, "idtree", torture_local_idtree_simple,
                                                                   NULL);
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index b90f91d19ba40b73e5f1bb2ce507f5a0aee5d792..219cf0bcdb5974924d7876a8b30518a9fbef6849 100644 (file)
@@ -25,7 +25,6 @@
 #include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_echo.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 const uint32_t MSG_ID1 = 1, MSG_ID2 = 2;
 
@@ -238,9 +237,9 @@ static BOOL irpc_setup(struct torture_context *test, void **_data)
        return True;
 }
 
-BOOL torture_local_irpc(struct torture_context *torture) 
+struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "LOCAL-IRPC");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-IRPC");
        struct torture_tcase *tcase = torture_suite_add_tcase(suite, "irpc");
        int i;
        uint32_t values[] = {0, 0x7FFFFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 
@@ -255,5 +254,5 @@ BOOL torture_local_irpc(struct torture_context *torture)
        torture_tcase_add_test(tcase, "echodata", test_echodata, NULL);
        torture_tcase_add_test(tcase, "speed", test_speed, NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index 38d3056f6e6288e8d8b9f0ae9c69c06cd813e195..8161c3ea4fa9cd7efd562f4e51023f0db69237eb 100644 (file)
@@ -24,7 +24,6 @@
 #include "lib/events/events.h"
 #include "lib/messaging/irpc.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 
 static uint32_t msg_pong;
@@ -145,9 +144,9 @@ static BOOL test_ping_speed(struct torture_context *torture, const void *_data)
        return True;
 }
 
-BOOL torture_local_messaging(struct torture_context *torture) 
+struct torture_suite *torture_local_messaging(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *s = torture_suite_create(torture, "LOCAL-MESSAGING");
+       struct torture_suite *s = torture_suite_create(mem_ctx, "LOCAL-MESSAGING");
        torture_suite_add_simple_tcase(s, "ping_speed", test_ping_speed, NULL);
-       return torture_run_suite(torture, s);
+       return s;
 }
index 4f743b522900d0f0030562cd46ca86931511d3bd..a24c64746a67015b091e6ea02d2842dca29b1041 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "includes.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 #include "librpc/ndr/libndr.h"
 
 static BOOL test_check_string_terminator(struct torture_context *test,
@@ -75,13 +74,13 @@ static BOOL test_check_string_terminator(struct torture_context *test,
        return True;
 }
 
-BOOL torture_local_ndr(struct torture_context *torture)
+struct torture_suite *torture_local_ndr(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "LOCAL-NDR");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-NDR");
 
        torture_suite_add_simple_tcase(suite, "string terminator", 
                                                                   test_check_string_terminator,
                                                                   NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index 4c8d773a44c8ae2dc0b6757ca55a04b18156886a..0e72c11aebc9b06364d71f51b3452b6be6af820a 100644 (file)
@@ -24,7 +24,6 @@
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 const static struct test_backend_settings {
        const char *name;
@@ -77,9 +76,9 @@ static BOOL test_hive(struct torture_context *ctx, const void *_backend)
        return True;
 }
 
-BOOL torture_registry(struct torture_context *torture
+struct torture_suite *torture_registry(TALLOC_CTX *mem_ctx
 {
-       struct torture_suite *suite = torture_suite_create(torture
+       struct torture_suite *suite = torture_suite_create(mem_ctx
                                                                                                           "LOCAL-REGISTRY");
        int i;
 
@@ -89,5 +88,5 @@ BOOL torture_registry(struct torture_context *torture)
                torture_suite_add_simple_tcase(suite, backends[i].name, test_hive, &backends[i]);
        }
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index da83b453416f0c11712d842af90c594a54c1154b..a9878e88ee523616782549758a2cabbade42fbc8 100644 (file)
@@ -24,7 +24,6 @@
 #include "lib/events/events.h"
 #include "libcli/resolve/resolve.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 static BOOL test_async_resolve(struct torture_context *test, const void *_data)
 {
@@ -81,13 +80,13 @@ static BOOL test_sync_resolve(struct torture_context *test, const void *_data)
 }
 
 
-BOOL torture_local_resolve(struct torture_context *torture) 
+struct torture_suite *torture_local_resolve(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, 
+       struct torture_suite *suite = torture_suite_create(mem_ctx,
                                                                                                           "LOCAL-RESOLVE");
 
        torture_suite_add_simple_tcase(suite, "async", test_async_resolve, NULL);
        torture_suite_add_simple_tcase(suite, "sync", test_sync_resolve, NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index cb5919283f8b29c47fb30ad3b090784f595bd2c6..2db10063803866a9227b560d1dd2cc4ea897eb36 100644 (file)
@@ -24,7 +24,6 @@
 #include "libcli/security/security.h"
 #include "torture/torture.h"
 #include "librpc/gen_ndr/ndr_security.h"
-#include "torture/ui.h"
 
 
 /*
@@ -98,9 +97,9 @@ static const char *examples[] = {
 };
 
 /* test a set of example SDDL strings */
-BOOL torture_local_sddl(struct torture_context *torture) 
+struct torture_suite *torture_local_sddl(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "LOCAL-SDDL");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-SDDL");
        int i;
 
        for (i = 0; i < ARRAY_SIZE(examples); i++) {
@@ -109,5 +108,5 @@ BOOL torture_local_sddl(struct torture_context *torture)
                                                                test_sddl, examples[i]);
        }
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index 47fb98f96c1b91f86a152ceece9e2f57591814b7..67728ab69bfc1049df35e98a00db578abfe66158 100644 (file)
@@ -26,7 +26,6 @@
 #include "system/network.h"
 #include "netif/netif.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 /*
   basic testing of udp routines
@@ -135,7 +134,6 @@ static BOOL test_tcp(struct torture_context *test, const void *data)
        size_t size = 100 + (random() % 100);
        DATA_BLOB blob, blob2;
        size_t sent, nread;
-       BOOL ret = True;
        struct event_context *ev = event_context_init(test);
 
        status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
@@ -207,13 +205,13 @@ static BOOL test_tcp(struct torture_context *test, const void *data)
        return True;
 }
 
-BOOL torture_local_socket(struct torture_context *torture) 
+struct torture_suite *torture_local_socket(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture
+       struct torture_suite *suite = torture_suite_create(mem_ctx
                                                                                                           "LOCAL-SOCKET");
 
        torture_suite_add_simple_tcase(suite, "udp", test_udp, NULL);
        torture_suite_add_simple_tcase(suite, "tcp", test_tcp, NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index f6152fe4c0af75223d95d3d55cb1604fa41ed03a..c950e68c6e7b830149805c035572bf0cc2c7e0fd 100644 (file)
@@ -23,7 +23,6 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 #define TEST_FILENAME "utilfile.test"
 #define TEST_LINE1 "This is list line 1..."
@@ -83,9 +82,9 @@ static BOOL test_afdgets(struct torture_context *test, const void *data)
        return True;
 }
 
-BOOL torture_local_util_file(struct torture_context *torture) 
+struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "util_file");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "util_file");
 
        torture_suite_add_simple_tcase(suite, "file_load_save", 
                                                                   test_file_load_save, NULL);
@@ -93,5 +92,5 @@ BOOL torture_local_util_file(struct torture_context *torture)
        torture_suite_add_simple_tcase(suite, "afdgets", 
                                                                   test_afdgets, NULL);
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index 5887c01c6a6656ab87b8a719675ce963ac18a86f..29886df995c883be83fb7bcd09925aac1990eb84 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "includes.h"
 #include "torture/torture.h"
-#include "torture/ui.h"
 
 static const char *test_lists_shell_strings[] = {
        "",
@@ -67,9 +66,9 @@ static BOOL test_lists_shell(struct torture_context *test, const void *_data)
        return True;
 }
 
-BOOL torture_local_util_strlist(struct torture_context *torture) 
+struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx)
 {
-       struct torture_suite *suite = torture_suite_create(torture, "util_strlist");
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "util_strlist");
        int i;
 
        for (i = 0; test_lists_shell_strings[i]; i++) {
@@ -78,5 +77,5 @@ BOOL torture_local_util_strlist(struct torture_context *torture)
                                                                           &test_lists_shell_strings[i]);
        }
 
-       return torture_run_suite(torture, suite);
+       return suite;
 }
index ab462f1d08a4c52a0e6f83ba6e4904a603b8b093..6d1bd1cca94a72f7af218016c07db588511cf8fb 100644 (file)
@@ -29,7 +29,6 @@
 #include "lib/events/events.h"
 
 #include "torture/torture.h"
-#include "torture/ui.h"
 #include "build.h"
 #include "dlinklist.h"
 #include "librpc/rpc/dcerpc.h"
@@ -42,42 +41,21 @@ run a specified test or "ALL"
 static BOOL run_test(struct torture_context *torture, const char *name)
 {
        BOOL ret = True;
-       struct torture_op *o;
+       struct torture_suite_list *o;
        BOOL matched = False;
 
        if (strequal(name,"ALL")) {
-               for (o = torture_ops; o; o = o->next) {
-                       if (!run_test(torture, o->name)) {
-                               ret = False;
-                       }
+               for (o = torture_suites; o; o = o->next) {
+                       ret &= torture_run_suite(torture, o->suite);
                }
                return ret;
        }
 
-       for (o = torture_ops; o; o = o->next) {
-               if (gen_fnmatch(name, o->name) == 0) {
-                       double t;
+       for (o = torture_suites; o; o = o->next) {
+               if (gen_fnmatch(name, o->suite->name) == 0) {
                        matched = True;
                        init_iconv();
-                       printf("Running %s\n", o->name);
-                       if (o->multi_fn) {
-                               BOOL result = False;
-                               t = torture_create_procs(o->multi_fn, 
-                                                        &result);
-                               if (!result) { 
-                                       ret = False;
-                                       printf("TEST %s FAILED!\n", o->name);
-                               }
-                                        
-                       } else {
-                               struct timeval tv = timeval_current();
-                               if (!o->fn(torture)) {
-                                       ret = False;
-                                       printf("TEST %s FAILED!\n", o->name);
-                               }
-                               t = timeval_elapsed(&tv);
-                       }
-                       printf("%s took %g secs\n\n", o->name, t);
+                       ret &= torture_run_suite(torture, o->suite);
                }
        }
 
@@ -131,7 +109,7 @@ static void parse_dns(const char *dns)
 
 static void usage(poptContext pc)
 {
-       struct torture_op *o;
+       struct torture_suite_list *o;
        char last_prefix[64];
        int i;
 
@@ -189,24 +167,24 @@ static void usage(poptContext pc)
 
        i = 0;
        last_prefix[0] = '\0';
-       for (o = torture_ops; o; o = o->next) {
+       for (o = torture_suites; o; o = o->next) {
                const char * sep;
 
-               if ((sep = strchr(o->name, '-'))) {
-                       if (strncmp(o->name, last_prefix, sep - o->name) != 0) {
-                               strncpy(last_prefix, o->name,
+               if ((sep = strchr(o->suite->name, '-'))) {
+                       if (strncmp(o->suite->name, last_prefix, sep-o->suite->name) != 0) {
+                               strncpy(last_prefix, o->suite->name,
                                        MIN(sizeof(last_prefix),
-                                           sep - o->name));
+                                           sep - o->suite->name));
                                printf("\n\n  ");
                                i = 0;
                        }
                }
 
-               if (i + strlen(o->name) >= (MAX_COLS - 2)) {
+               if (i + strlen(o->suite->name) >= (MAX_COLS - 2)) {
                        printf("\n  ");
                        i = 0;
                }
-               i+=printf("%s ", o->name);
+               i+=printf("%s ", o->suite->name);
        }
        printf("\n\n");
 
@@ -233,17 +211,21 @@ static void max_runtime_handler(int sig)
        exit(1);
 }
 
-static void simple_tcase_start (struct torture_context *ctx, 
-                                                          struct torture_tcase *tcase)
+struct timeval last_suite_started;
+
+static void simple_suite_start(struct torture_context *ctx,
+                                                          struct torture_suite *suite)
 {
-       printf("Testing %s\n", tcase->name);
+       last_suite_started = timeval_current();
+       printf("Running %s\n", suite->name);
 }
 
-static void simple_test_start (struct torture_context *ctx, 
-                                                          struct torture_tcase *tcase,
-                                                          struct torture_test *test)
+static void simple_suite_finish(struct torture_context *ctx,
+                                                          struct torture_suite *suite)
 {
-       printf("Testing %s/%s\n", tcase->name, test->name);
+
+       printf("%s took %g secs\n\n", suite->name, 
+                  timeval_elapsed(&last_suite_started));
 }
 
 static void simple_test_result (struct torture_context *context, 
@@ -255,7 +237,7 @@ static void simple_test_result (struct torture_context *context,
                        printf("OK: %s\n", reason);
                break;
        case TORTURE_FAIL:
-               printf("ERROR: %s - %s\n", context->active_test->name, reason);
+               printf("TEST %s FAILED! - %s\n", context->active_test->name, reason);
                break;
        case TORTURE_TODO:
                printf("TODO: %s - %s\n", context->active_test->name, reason);
@@ -274,8 +256,8 @@ static void simple_comment (struct torture_context *test, const char *comment)
 
 const static struct torture_ui_ops std_ui_ops = {
        .comment = simple_comment,
-       .test_start = simple_test_start,
-       .tcase_start = simple_tcase_start,
+       .suite_start = simple_suite_start,
+       .suite_finish = simple_suite_finish,
        .test_result = simple_test_result
 };
 
@@ -353,15 +335,33 @@ const static struct torture_ui_ops harness_ui_ops = {
        .test_result = harness_test_result
 };
 
-static void quiet_test_start (struct torture_context *ctx, 
-                                                           struct torture_tcase *tcase,
-                                                               struct torture_test *test)
+static void quiet_suite_start(struct torture_context *ctx,
+                                                 struct torture_suite *suite)
 {
-       putchar('.');
+       printf("%s: ", suite->name);
+}
+
+static void quiet_suite_finish(struct torture_context *ctx,
+                                                 struct torture_suite *suite)
+{
+       putchar('\n');
+}
+
+static void quiet_test_result (struct torture_context *context, 
+                                                               enum torture_result res, const char *reason)
+{
+       switch (res) {
+       case TORTURE_OK: putchar('.'); break;
+       case TORTURE_FAIL: putchar('E'); break;
+       case TORTURE_TODO: putchar('T'); break;
+       case TORTURE_SKIP: putchar('S'); break;
+       }
 }
 
 const static struct torture_ui_ops quiet_ui_ops = {
-       .test_start = quiet_test_start,
+       .suite_start = quiet_suite_start,
+       .suite_finish = quiet_suite_finish,
+       .test_result = quiet_test_result
 };
 
 
index 6080b8cb825a8b6aa07568fee001477e98dc626d..265f05aedb43a76ee168596671e32b2616960f7c 100644 (file)
@@ -637,22 +637,8 @@ static struct {
        {"SCAN-EAMAX", torture_max_eas, 0},
 
        /* local (no server) testers */
-       {"LOCAL-NTLMSSP", torture_ntlmssp, 0},
        {"LOCAL-ICONV", torture_local_iconv, 0},
        {"LOCAL-TALLOC", torture_local_talloc, 0},
-       {"LOCAL-MESSAGING", torture_local_messaging, 0},
-       {"LOCAL-IRPC",  torture_local_irpc, 0},
-       {"LOCAL-BINDING", torture_local_binding_string, 0},
-       {"LOCAL-STRLIST", torture_local_util_strlist, 0},
-       {"LOCAL-FILE", torture_local_util_file, 0},
-       {"LOCAL-IDTREE", torture_local_idtree, 0},
-       {"LOCAL-SOCKET", torture_local_socket, 0},
-       {"LOCAL-PAC", torture_pac, 0},
-       {"LOCAL-REGISTRY", torture_registry, 0},
-       {"LOCAL-RESOLVE", torture_local_resolve, 0},
-       {"LOCAL-SDDL", torture_local_sddl, 0},
-       {"LOCAL-NDR", torture_local_ndr, 0},
-       {"LOCAL-EVENT", torture_local_event, 0},
 
        /* ldap testers */
        {"LDAP-BASIC", torture_ldap_basic, 0},
@@ -668,47 +654,113 @@ static struct {
        {"NBT-WINSREPLICATION-REPLICA", torture_nbt_winsreplication_replica, 0},
        {"NBT-WINSREPLICATION-OWNED", torture_nbt_winsreplication_owned, 0},
        
-       {NULL, NULL, 0}};
+       {NULL, NULL, 0}
+};
+
+/* ignore me */ static struct torture_suite *
+       (*suite_generators[]) (TALLOC_CTX *mem_ctx) =
+{ 
+       torture_local_binding_string, 
+       torture_ntlmssp, 
+       torture_local_messaging, 
+       torture_local_irpc, 
+       torture_local_util_strlist, 
+       torture_local_util_file, 
+       torture_local_idtree, 
+       torture_local_socket, 
+       torture_pac, 
+       torture_registry, 
+       torture_local_resolve,
+       torture_local_sddl,
+       torture_local_ndr, 
+       torture_local_event, 
+       NULL
+};
 
 static void register_builtin_ops(void)
 {
        int i;
+       TALLOC_CTX *mem_ctx = talloc_autofree_context();
+
        for (i = 0; builtin_torture_ops[i].name; i++) {
                register_torture_op(builtin_torture_ops[i].name, 
                                                        builtin_torture_ops[i].fn, 
                                                        builtin_torture_ops[i].multi_fn);
        }
+
+       for (i = 0; suite_generators[i]; i++)
+               torture_register_suite(suite_generators[i](mem_ctx));
 }
 
-struct torture_op *torture_ops = NULL;
+struct torture_suite_list *torture_suites = NULL;
 
-_PUBLIC_ NTSTATUS register_torture_op(const char *name, BOOL (*fn)(struct torture_context *), BOOL (*multi_fn)(struct smbcli_state *, int ))
+NTSTATUS torture_register_suite(struct torture_suite *suite)
 {
-       struct torture_op *op, *p;
-       
-       op = talloc(talloc_autofree_context(), struct torture_op);
+       struct torture_suite_list *p, *n;
 
-       op->name = talloc_strdup(op, name);
-       op->fn = fn;
-       op->multi_fn = multi_fn;
+       n = talloc(talloc_autofree_context(), struct torture_suite_list);
+       n->suite = suite;
 
-       for (p = torture_ops; p; p = p->next) {
-               if (strcmp(p->name, op->name) == 0) {
+       for (p = torture_suites; p; p = p->next) {
+               if (strcmp(p->suite->name, suite->name) == 0) {
                        /* Check for duplicates */
-                       DEBUG(0,("There already is a torture op registered with the name %s!\n", name));
-                       talloc_free(op);
+                       DEBUG(0,("There already is a suite registered with the name %s!\n", suite->name));
                        return NT_STATUS_OBJECT_NAME_COLLISION;
                }
 
-               if (strcmp(p->name, op->name) < 0 && 
-                       (!p->next || strcmp(p->next->name, op->name) > 0)) {
-                       DLIST_ADD_AFTER(torture_ops, op, p);
+               if (strcmp(p->suite->name, suite->name) < 0 && 
+                       (!p->next || strcmp(p->next->suite->name, suite->name) > 0)) {
+                       DLIST_ADD_AFTER(torture_suites, n, p);
                        return NT_STATUS_OK;
                }
        }
 
-       DLIST_ADD(torture_ops, op);
-       
+       DLIST_ADD(torture_suites, n);
+
+       return NT_STATUS_OK;
+}
+
+static BOOL wrap_old_torture_fn(struct torture_context *torture,
+                                                               const void *_fn)
+{
+       BOOL (*fn)(struct torture_context *) = _fn;
+       return fn(torture);
+}
+
+static BOOL wrap_old_torture_multifn(struct torture_context *torture,
+                                                               const void *_fn)
+{
+       BOOL (*fn)(struct smbcli_state *, int ) = _fn;
+       BOOL result;
+
+       torture_create_procs(fn, &result);
+
+       return result;
+}
+
+_PUBLIC_ NTSTATUS register_torture_op(const char *name, BOOL (*fn)(struct torture_context *), BOOL (*multi_fn)(struct smbcli_state *, int ))
+{
+       struct torture_suite *suite;
+
+       if (fn != NULL) {
+               suite = torture_suite_create(talloc_autofree_context(), name);
+
+               torture_suite_add_simple_tcase(suite, name, 
+                                                                          wrap_old_torture_fn,
+                                                                          fn);
+               torture_register_suite(suite);
+       }
+
+       if (multi_fn != NULL) {
+               suite = torture_suite_create(talloc_autofree_context(), name);
+
+               torture_suite_add_simple_tcase(suite, name, 
+                                                                          wrap_old_torture_multifn,
+                                                                          multi_fn);
+               torture_register_suite(suite);
+       }
+
+
        return NT_STATUS_OK;
 }
 
index ce55ac037dc4abbde9fe606a89956ab043b3a9ac..1a1cd7aba92ebe3f4a5c224d265444e978ec08ab 100644 (file)
 #ifndef __TORTURE_H__
 #define __TORTURE_H__
 
+#include "torture/ui.h"
+
 struct smbcli_state;
-struct torture_context;
-struct torture_op {
-       const char *name;
-       BOOL (*fn)(struct torture_context *);
-       BOOL (*multi_fn)(struct smbcli_state *, int );
-       struct torture_op *prev, *next;
+
+struct torture_suite_list {
+       struct torture_suite *suite;
+       struct torture_suite_list *prev, *next;
 };
 
-extern struct torture_op * torture_ops;
+extern struct torture_suite_list * torture_suites;
 
 extern BOOL use_oplocks;
 extern BOOL torture_showall;
index 7ceb4ec428bd44b67da4765c5f522ec76a3e7c5b..1878058a72a0102dacd7ff468bb333a5ae375db0 100644 (file)
@@ -39,51 +39,25 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
        talloc_free(tmp);
 }
 
-void torture_ok(struct torture_context *context)
-{
-       context->success++;
-
-       if (!context->ui_ops->test_result)
-               return;
-
-       context->ui_ops->test_result(context, TORTURE_OK, NULL);
-}
-
 void torture_fail(struct torture_context *context, const char *fmt, ...) _PRINTF_ATTRIBUTE(2,3)
 {
        va_list ap;
-       char *reason;
-       context->failed++;
-
-       if (!context->ui_ops->test_result)
-               return;
 
        va_start(ap, fmt);
-       reason = talloc_vasprintf(context, fmt, ap);
+       context->last_reason = talloc_vasprintf(context, fmt, ap);
        va_end(ap);
-       context->ui_ops->test_result(context, TORTURE_FAIL, reason);
-       talloc_free(reason);
+       context->last_result = TORTURE_FAIL;
 }
 
 void torture_skip(struct torture_context *context, const char *fmt, ...) _PRINTF_ATTRIBUTE(2,3)
 {
        va_list ap;
-       char *reason;
        context->skipped++;
 
-       if (!context->ui_ops->test_result)
-               return;
-
        va_start(ap, fmt);
-       reason = talloc_vasprintf(context, fmt, ap);
+       context->last_result = TORTURE_SKIP;
+       context->last_reason = talloc_vasprintf(context, fmt, ap);
        va_end(ap);
-       context->ui_ops->test_result(context, TORTURE_SKIP, reason);
-       talloc_free(reason);
-}
-
-void torture_register_suite(struct torture_suite *suite)
-{
-       /* FIXME */
 }
 
 struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
@@ -179,10 +153,29 @@ static BOOL internal_torture_run_test(struct torture_context *context,
 
        context->active_tcase = tcase;
        context->active_test = test;
+
        if (context->ui_ops->test_start)
                context->ui_ops->test_start(context, tcase, test);
 
+       context->last_reason = NULL;
+       context->last_result = TORTURE_OK;
+
        ret = test->run(context, tcase->setup?data:tcase->data, test->data);
+
+       if (context->ui_ops->test_result)
+               context->ui_ops->test_result(context, context->last_result, 
+                                                                        context->last_reason);
+
+
+       switch (context->last_result) {
+               case TORTURE_SKIP: context->success++; break;
+               case TORTURE_FAIL: context->failed++; break;
+               case TORTURE_TODO: context->todo++; break;
+               case TORTURE_OK: context->success++; break;
+       }
+
+       talloc_free(context->last_reason);
+
        context->active_test = NULL;
        context->active_tcase = NULL;
 
index 1dfe89e82fa156bcacda19afaa05e1ba608af82c..ea6fe4460975fecc7ae6a7ebcc8bb4359ba8bee1 100644 (file)
@@ -60,6 +60,9 @@ struct torture_context
        int todo;
        int success;
        int failed;
+
+       enum torture_result last_result;
+       char *last_reason;
 };
 
 struct torture_suite
@@ -87,7 +90,6 @@ struct torture_suite
        } *testcases;
 };
 
-void torture_register_suite(struct torture_suite *suite);
 struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name);
 void torture_tcase_set_fixture(struct torture_tcase *tcase, 
                BOOL (*setup) (struct torture_context *, void **),
@@ -160,7 +162,6 @@ BOOL torture_run_test(struct torture_context *context,
                torture_assert_werr_equal(ctx,expr,WERR_OK,string)
 
 void torture_comment(struct torture_context *test, const char *comment, ...) _PRINTF_ATTRIBUTE(2,3);
-void torture_ok(struct torture_context *test);
 void torture_fail(struct torture_context *test, const char *reason, ...) _PRINTF_ATTRIBUTE(2,3);
 void torture_skip(struct torture_context *test, const char *reason, ...) _PRINTF_ATTRIBUTE(2,3);
 const char *torture_setting(struct torture_context *test, const char *name,