summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-06-17 00:17:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:10 -0500
commit920c1ca95c499194430a18a9f2186670c6861cc4 (patch)
tree4fc108e421b6448ed756c5b7dd8b5db9f6d88c27
parent5b7ee5e7d69f73618d7cc7a4229b98c429506084 (diff)
downloadsamba-920c1ca95c499194430a18a9f2186670c6861cc4.tar.gz
samba-920c1ca95c499194430a18a9f2186670c6861cc4.tar.bz2
samba-920c1ca95c499194430a18a9f2186670c6861cc4.zip
r16328: Wrap all existing tests in simple single-function testsuites.
(This used to be commit 7e811adf59841936b7e634fca4e95630f890c5af)
-rw-r--r--source4/torture/auth/ntlmssp.c8
-rw-r--r--source4/torture/auth/pac.c7
-rw-r--r--source4/torture/local/binding_string.c7
-rw-r--r--source4/torture/local/event.c8
-rw-r--r--source4/torture/local/idtree.c7
-rw-r--r--source4/torture/local/irpc.c7
-rw-r--r--source4/torture/local/messaging.c7
-rw-r--r--source4/torture/local/ndr.c7
-rw-r--r--source4/torture/local/registry.c7
-rw-r--r--source4/torture/local/resolve.c7
-rw-r--r--source4/torture/local/sddl.c7
-rw-r--r--source4/torture/local/socket.c8
-rw-r--r--source4/torture/local/util_file.c7
-rw-r--r--source4/torture/local/util_strlist.c7
-rw-r--r--source4/torture/smbtorture.c102
-rw-r--r--source4/torture/torture.c116
-rw-r--r--source4/torture/torture.h14
-rw-r--r--source4/torture/ui.c53
-rw-r--r--source4/torture/ui.h5
19 files changed, 211 insertions, 180 deletions
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 5c75a5b028..978610ec51 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -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;
}
diff --git a/source4/torture/auth/pac.c b/source4/torture/auth/pac.c
index 316a67acb0..ecba5d1cc8 100644
--- a/source4/torture/auth/pac.c
+++ b/source4/torture/auth/pac.c
@@ -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;
}
diff --git a/source4/torture/local/binding_string.c b/source4/torture/local/binding_string.c
index a7b6cd14b4..3c38183ec9 100644
--- a/source4/torture/local/binding_string.c
+++ b/source4/torture/local/binding_string.c
@@ -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;
}
diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c
index d886519220..f55cd8d466 100644
--- a/source4/torture/local/event.c
+++ b/source4/torture/local/event.c
@@ -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;
}
diff --git a/source4/torture/local/idtree.c b/source4/torture/local/idtree.c
index a81eddedc3..1d317dbce3 100644
--- a/source4/torture/local/idtree.c
+++ b/source4/torture/local/idtree.c
@@ -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;
}
diff --git a/source4/torture/local/irpc.c b/source4/torture/local/irpc.c
index b90f91d19b..219cf0bcdb 100644
--- a/source4/torture/local/irpc.c
+++ b/source4/torture/local/irpc.c
@@ -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;
}
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
index 38d3056f6e..8161c3ea4f 100644
--- a/source4/torture/local/messaging.c
+++ b/source4/torture/local/messaging.c
@@ -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;
}
diff --git a/source4/torture/local/ndr.c b/source4/torture/local/ndr.c
index 4f743b5229..a24c64746a 100644
--- a/source4/torture/local/ndr.c
+++ b/source4/torture/local/ndr.c
@@ -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;
}
diff --git a/source4/torture/local/registry.c b/source4/torture/local/registry.c
index 4c8d773a44..0e72c11aeb 100644
--- a/source4/torture/local/registry.c
+++ b/source4/torture/local/registry.c
@@ -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;
}
diff --git a/source4/torture/local/resolve.c b/source4/torture/local/resolve.c
index da83b45341..a9878e88ee 100644
--- a/source4/torture/local/resolve.c
+++ b/source4/torture/local/resolve.c
@@ -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;
}
diff --git a/source4/torture/local/sddl.c b/source4/torture/local/sddl.c
index cb5919283f..2db1006380 100644
--- a/source4/torture/local/sddl.c
+++ b/source4/torture/local/sddl.c
@@ -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;
}
diff --git a/source4/torture/local/socket.c b/source4/torture/local/socket.c
index 47fb98f96c..67728ab69b 100644
--- a/source4/torture/local/socket.c
+++ b/source4/torture/local/socket.c
@@ -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;
}
diff --git a/source4/torture/local/util_file.c b/source4/torture/local/util_file.c
index f6152fe4c0..c950e68c6e 100644
--- a/source4/torture/local/util_file.c
+++ b/source4/torture/local/util_file.c
@@ -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;
}
diff --git a/source4/torture/local/util_strlist.c b/source4/torture/local/util_strlist.c
index 5887c01c6a..29886df995 100644
--- a/source4/torture/local/util_strlist.c
+++ b/source4/torture/local/util_strlist.c
@@ -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;
}
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index ab462f1d08..6d1bd1cca9 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -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
};
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 6080b8cb82..265f05aedb 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -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;
}
diff --git a/source4/torture/torture.h b/source4/torture/torture.h
index ce55ac037d..1a1cd7aba9 100644
--- a/source4/torture/torture.h
+++ b/source4/torture/torture.h
@@ -22,16 +22,16 @@
#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;
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index 7ceb4ec428..1878058a72 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -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;
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index 1dfe89e82f..ea6fe44609 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -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,