summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/base.c2
-rw-r--r--source4/torture/basic/locking.c3
-rw-r--r--source4/torture/basic/misc.c2
-rw-r--r--source4/torture/config.mk26
-rw-r--r--source4/torture/ldap/common.c2
-rw-r--r--source4/torture/libnet/libnet.c2
-rw-r--r--source4/torture/local/dbspeed.c2
-rw-r--r--source4/torture/local/local.c2
-rw-r--r--source4/torture/nbench/nbench.c3
-rw-r--r--source4/torture/nbt/nbt.c2
-rw-r--r--source4/torture/ndr/ndr.c2
-rw-r--r--source4/torture/rap/rap.c2
-rw-r--r--source4/torture/raw/lookuprate.c2
-rw-r--r--source4/torture/raw/raw.c4
-rw-r--r--source4/torture/rpc/rpc.c2
-rw-r--r--source4/torture/rpc/rpc.h2
-rw-r--r--source4/torture/rpc/samba3rpc.c2
-rw-r--r--source4/torture/rpc/spoolss_notify.c1
-rw-r--r--source4/torture/rpc/spoolss_win.c1
-rw-r--r--source4/torture/smb2/smb2.c2
-rw-r--r--source4/torture/smbtorture.c2
-rw-r--r--source4/torture/smbtorture.h (renamed from source4/torture/torture.h)9
-rw-r--r--source4/torture/torture.pc.in12
-rw-r--r--source4/torture/ui.c580
-rw-r--r--source4/torture/ui.h396
-rw-r--r--source4/torture/unix/unix.c2
-rw-r--r--source4/torture/util.h5
-rw-r--r--source4/torture/util_smb.c1
-rw-r--r--source4/torture/winbind/struct_based.c2
-rw-r--r--source4/torture/winbind/winbind.c2
30 files changed, 40 insertions, 1037 deletions
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 966d436935..2ab3f9ca91 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/basic/proto.h"
#include "libcli/libcli.h"
#include "libcli/raw/raw_proto.h"
diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c
index 2e2585b976..3f399c97ef 100644
--- a/source4/torture/basic/locking.c
+++ b/source4/torture/basic/locking.c
@@ -23,9 +23,8 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
-#include "torture/ui.h"
+#include "torture/smbtorture.h"
#include "torture/util.h"
-#include "torture/torture.h"
#include "system/time.h"
#include "system/filesys.h"
diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c
index 188fc1bc69..24e0324bc3 100644
--- a/source4/torture/basic/misc.c
+++ b/source4/torture/basic/misc.c
@@ -30,7 +30,7 @@
#include "libcli/resolve/resolve.h"
#include "auth/credentials/credentials.h"
#include "librpc/gen_ndr/ndr_nbt.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/util.h"
#include "libcli/smb_composite/smb_composite.h"
#include "libcli/composite/composite.h"
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 1565797609..4113cab064 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -1,17 +1,3 @@
-# TORTURE subsystem
-[LIBRARY::torture]
-PRIVATE_PROTO_HEADER = proto.h
-PUBLIC_DEPENDENCIES = \
- LIBSAMBA-HOSTCONFIG \
- LIBSAMBA-UTIL \
- LIBTALLOC \
- LIBPOPT
-
-PC_FILES += torture/torture.pc
-torture_OBJ_FILES = $(addprefix torture/, torture.o ui.o)
-
-PUBLIC_HEADERS += torture/torture.h torture/ui.h
-
[SUBSYSTEM::TORTURE_UTIL]
PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls PROVISION
PUBLIC_DEPENDENCIES = POPT_CREDENTIALS
@@ -255,8 +241,9 @@ PRIVATE_DEPENDENCIES = \
# End BINARY smbtorture
#################################
-smbtorture_OBJ_FILES = torture/smbtorture.o
+smbtorture_OBJ_FILES = torture/smbtorture.o torture/torture.o
+PUBLIC_HEADERS += torture/smbtorture.h
MANPAGES += torture/man/smbtorture.1
#################################
@@ -340,9 +327,14 @@ gcov: test
do $(GCOV) -p -o $$I $$I/*.c; \
done
-lcov: test
+samba.info: test
-rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
lcov --base-directory `pwd` --directory . --capture --output-file samba.info
- genhtml -o coverage samba.info
+
+lcov: samba.info
+ genhtml -o coverage $<
testcov-html:: lcov
+
+clean::
+ @rm -f samba.info
diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c
index 5913163822..2c11de729c 100644
--- a/source4/torture/ldap/common.c
+++ b/source4/torture/ldap/common.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "libcli/ldap/ldap_client.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/ldap/proto.h"
NTSTATUS torture_ldap_bind(struct ldap_connection *conn, const char *userdn, const char *password)
diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c
index 3a75ffcae3..8c8353e8d6 100644
--- a/source4/torture/libnet/libnet.c
+++ b/source4/torture/libnet/libnet.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/lsa.h"
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index bf88c00e35..017c8568f4 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -26,7 +26,7 @@
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb_wrap.h"
#include "lib/tdb_wrap.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "param/param.h"
float tdb_speed;
diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c
index e4dfadd3d1..1c3274adcd 100644
--- a/source4/torture/local/local.c
+++ b/source4/torture/local/local.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/local/proto.h"
#include "torture/ndr/ndr.h"
#include "torture/ndr/proto.h"
diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index e9bd32cce0..96144c4773 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -19,9 +19,8 @@
#include "includes.h"
#include "libcli/libcli.h"
-#include "torture/ui.h"
#include "torture/util.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "system/filesys.h"
#include "system/locale.h"
#include "pstring.h"
diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c
index d27a26eb30..422261884f 100644
--- a/source4/torture/nbt/nbt.c
+++ b/source4/torture/nbt/nbt.c
@@ -21,7 +21,7 @@
#include "libcli/nbt/libnbt.h"
#include "torture/torture.h"
#include "torture/nbt/proto.h"
-#include "torture/ui.h"
+#include "torture/smbtorture.h"
#include "libcli/resolve/resolve.h"
#include "param/param.h"
diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c
index 55b00d1fb8..63636f8c5f 100644
--- a/source4/torture/ndr/ndr.c
+++ b/source4/torture/ndr/ndr.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "torture/ndr/ndr.h"
#include "torture/ndr/proto.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
#include "util/dlinklist.h"
#include "param/param.h"
diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c
index 4b5f4b582c..1ccd1254dd 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/rap/rap.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "libcli/libcli.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/util.h"
#include "libcli/rap/rap.h"
#include "libcli/raw/libcliraw.h"
diff --git a/source4/torture/raw/lookuprate.c b/source4/torture/raw/lookuprate.c
index 0e8f002efb..782cb1b31b 100644
--- a/source4/torture/raw/lookuprate.c
+++ b/source4/torture/raw/lookuprate.c
@@ -20,7 +20,7 @@
#include "includes.h"
#include "param/param.h"
#include "system/filesys.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/basic/proto.h"
#include "libcli/libcli.h"
#include "torture/util.h"
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index 262ed1384b..c6133081b0 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -18,10 +18,10 @@
*/
#include "includes.h"
-#include "torture/torture.h"
#include "libcli/raw/libcliraw.h"
-#include "torture/raw/proto.h"
#include "torture/util.h"
+#include "torture/smbtorture.h"
+#include "torture/raw/proto.h"
NTSTATUS torture_raw_init(void)
{
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 7c8e78b160..fdb88b13dc 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -23,7 +23,7 @@
#include "lib/cmdline/popt_common.h"
#include "librpc/rpc/dcerpc.h"
#include "torture/rpc/rpc.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "librpc/ndr/ndr_table.h"
#include "lib/util/dlinklist.h"
diff --git a/source4/torture/rpc/rpc.h b/source4/torture/rpc/rpc.h
index d0a0727787..48db814b7a 100644
--- a/source4/torture/rpc/rpc.h
+++ b/source4/torture/rpc/rpc.h
@@ -28,7 +28,7 @@
#include "librpc/rpc/dcerpc.h"
#include "libcli/raw/libcliraw.h"
#include "torture/rpc/proto.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
struct torture_rpc_tcase {
struct torture_tcase tcase;
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 1103acaefa..17342f9b86 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -426,7 +426,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
"builtin") ? 1:0;
l.in.connect_handle = &conn_handle;
- domain_name.string = enumdom.out.sam->entries[0].name.string;
+ domain_name.string = enumdom.out.sam->entries[dom_idx].name.string;
*domain = talloc_strdup(mem_ctx, domain_name.string);
l.in.domain_name = &domain_name;
diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c
index 19cff53d84..ab6309d55f 100644
--- a/source4/torture/rpc/spoolss_notify.c
+++ b/source4/torture/rpc/spoolss_notify.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "torture/torture.h"
-#include "torture/ui.h"
#include "torture/rpc/rpc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/dcerpc_server.h"
diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c
index 9e2921d406..9ce9fb7526 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -20,7 +20,6 @@
#include "includes.h"
#include "torture/torture.h"
-#include "torture/ui.h"
#include "torture/rpc/rpc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/dcerpc_server.h"
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index f406b7d6e8..37eadcf7fd 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -21,7 +21,7 @@
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/smb2/proto.h"
#include "lib/util/dlinklist.h"
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 5c5f96c505..418f933993 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -30,7 +30,7 @@
#include "lib/events/events.h"
#include "dynconfig.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "lib/util/dlinklist.h"
#include "librpc/rpc/dcerpc.h"
#include "param/param.h"
diff --git a/source4/torture/torture.h b/source4/torture/smbtorture.h
index 26ecdb567b..3b5a573d83 100644
--- a/source4/torture/torture.h
+++ b/source4/torture/smbtorture.h
@@ -18,10 +18,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __TORTURE_H__
-#define __TORTURE_H__
+#ifndef __SMBTORTURE_H__
+#define __SMBTORTURE_H__
-#include "torture/ui.h"
+#include "torture/torture.h"
struct smbcli_state;
@@ -37,5 +37,4 @@ struct torture_test;
int torture_init(void);
bool torture_register_suite(struct torture_suite *suite);
-
-#endif /* __TORTURE_H__ */
+#endif /* __SMBTORTURE_H__ */
diff --git a/source4/torture/torture.pc.in b/source4/torture/torture.pc.in
deleted file mode 100644
index 6582816cb5..0000000000
--- a/source4/torture/torture.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-modulesdir=${prefix}/modules/torture
-
-Name: torture
-Description: Samba torture (test) suite
-Requires: talloc
-Version: 0.0.1
-Libs: -L${libdir} -ltorture
-Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
deleted file mode 100644
index abbd814747..0000000000
--- a/source4/torture/ui.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB torture UI functions
-
- Copyright (C) Jelmer Vernooij 2006
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "torture/ui.h"
-#include "torture/torture.h"
-#include "lib/util/dlinklist.h"
-#include "param/param.h"
-#include "system/filesys.h"
-#include "auth/credentials/credentials.h"
-#include "lib/cmdline/popt_common.h"
-
-struct torture_context *torture_context_init(struct event_context *event_ctx,
- const struct torture_ui_ops *ui_ops)
-{
- struct torture_context *torture = talloc_zero(event_ctx,
- struct torture_context);
- torture->ui_ops = ui_ops;
- torture->returncode = true;
- torture->ev = event_ctx;
-
- if (ui_ops->init)
- ui_ops->init(torture);
-
- return torture;
-}
-
-/**
- create a temporary directory.
-*/
-_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
- const char *prefix,
- char **tempdir)
-{
- SMB_ASSERT(tctx->outputdir != NULL);
-
- *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir,
- prefix);
- NT_STATUS_HAVE_NO_MEMORY(*tempdir);
-
- if (mkdtemp(*tempdir) == NULL) {
- return map_nt_error_from_unix(errno);
- }
-
- return NT_STATUS_OK;
-}
-
-void torture_comment(struct torture_context *context, const char *comment, ...)
-{
- va_list ap;
- char *tmp;
-
- if (!context->ui_ops->comment)
- return;
-
- va_start(ap, comment);
- tmp = talloc_vasprintf(context, comment, ap);
-
- context->ui_ops->comment(context, tmp);
-
- talloc_free(tmp);
-}
-
-void torture_warning(struct torture_context *context, const char *comment, ...)
-{
- va_list ap;
- char *tmp;
-
- if (!context->ui_ops->warning)
- return;
-
- va_start(ap, comment);
- tmp = talloc_vasprintf(context, comment, ap);
-
- context->ui_ops->warning(context, tmp);
-
- talloc_free(tmp);
-}
-
-void torture_result(struct torture_context *context,
- enum torture_result result, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
-
- if (context->last_reason) {
- torture_warning(context, "%s", context->last_reason);
- talloc_free(context->last_reason);
- }
-
- context->last_result = result;
- context->last_reason = talloc_vasprintf(context, fmt, ap);
- va_end(ap);
-}
-
-struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
-{
- struct torture_suite *suite = talloc_zero(ctx, struct torture_suite);
-
- suite->name = talloc_strdup(suite, name);
- suite->testcases = NULL;
- suite->children = NULL;
-
- return suite;
-}
-
-void torture_tcase_set_fixture(struct torture_tcase *tcase,
- bool (*setup) (struct torture_context *, void **),
- bool (*teardown) (struct torture_context *, void *))
-{
- tcase->setup = setup;
- tcase->teardown = teardown;
-}
-
-static bool wrap_test_with_testcase_const(struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- bool (*fn) (struct torture_context *,
- const void *tcase_data,
- const void *test_data);
-
- fn = test->fn;
-
- return fn(torture_ctx, tcase->data, test->data);
-}
-
-struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase,
- const char *name,
- bool (*run) (struct torture_context *, const void *tcase_data,
- const void *test_data),
- const void *data)
-{
- struct torture_test *test = talloc(tcase, struct torture_test);
-
- test->name = talloc_strdup(test, name);
- test->description = NULL;
- test->run = wrap_test_with_testcase_const;
- test->fn = run;
- test->dangerous = false;
- test->data = data;
-
- DLIST_ADD_END(tcase->tests, test, struct torture_test *);
-
- return test;
-}
-
-
-bool torture_suite_init_tcase(struct torture_suite *suite,
- struct torture_tcase *tcase,
- const char *name)
-{
- tcase->name = talloc_strdup(tcase, name);
- tcase->description = NULL;
- tcase->setup = NULL;
- tcase->teardown = NULL;
- tcase->fixture_persistent = true;
- tcase->tests = NULL;
-
- DLIST_ADD_END(suite->testcases, tcase, struct torture_tcase *);
-
- return true;
-}
-
-
-struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite,
- const char *name)
-{
- struct torture_tcase *tcase = talloc(suite, struct torture_tcase);
-
- if (!torture_suite_init_tcase(suite, tcase, name))
- return NULL;
-
- return tcase;
-}
-
-bool torture_run_suite(struct torture_context *context,
- struct torture_suite *suite)
-{
- bool ret = true;
- struct torture_tcase *tcase;
- struct torture_suite *tsuite;
- char *old_testname;
-
- context->level++;
- if (context->ui_ops->suite_start)
- context->ui_ops->suite_start(context, suite);
-
- old_testname = context->active_testname;
- if (old_testname != NULL)
- context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, suite->name);
- else
- context->active_testname = talloc_strdup(context, suite->name);
-
- for (tcase = suite->testcases; tcase; tcase = tcase->next) {
- ret &= torture_run_tcase(context, tcase);
- }
-
- for (tsuite = suite->children; tsuite; tsuite = tsuite->next) {
- ret &= torture_run_suite(context, tsuite);
- }
-
- talloc_free(context->active_testname);
- context->active_testname = old_testname;
-
- if (context->ui_ops->suite_finish)
- context->ui_ops->suite_finish(context, suite);
-
- context->level--;
-
- return ret;
-}
-
-void torture_ui_test_start(struct torture_context *context,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- if (context->ui_ops->test_start)
- context->ui_ops->test_start(context, tcase, test);
-}
-
-int str_list_match(const char *name, char **list)
-{
- int i, ret = 0;
- if (list == NULL)
- return 0;
-
- for (i = 0; list[i]; i++) {
- if (gen_fnmatch(list[i], name) == 0)
- ret++;
- }
- return ret;
-}
-
-void torture_ui_test_result(struct torture_context *context,
- enum torture_result result,
- const char *comment)
-{
- if (context->ui_ops->test_result)
- context->ui_ops->test_result(context, result, comment);
-
- if (result == TORTURE_ERROR || result == TORTURE_FAIL)
- context->returncode = false;
-}
-
-static bool internal_torture_run_test(struct torture_context *context,
- struct torture_tcase *tcase,
- struct torture_test *test,
- bool already_setup)
-{
- bool success;
- char *old_testname;
-
- if (tcase == NULL || strcmp(test->name, tcase->name) != 0) {
- old_testname = context->active_testname;
- context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name);
- }
-
- context->active_tcase = tcase;
- context->active_test = test;
-
- torture_ui_test_start(context, tcase, test);
-
- context->last_reason = NULL;
- context->last_result = TORTURE_OK;
-
- if (!already_setup && tcase->setup &&
- !tcase->setup(context, &(tcase->data))) {
- if (context->last_reason == NULL)
- context->last_reason = talloc_strdup(context, "Setup failure");
- context->last_result = TORTURE_ERROR;
- success = false;
- } else if (test->dangerous &&
- !torture_setting_bool(context, "dangerous", false)) {
- context->last_result = TORTURE_SKIP;
- context->last_reason = talloc_asprintf(context,
- "disabled %s - enable dangerous tests to use", test->name);
- success = true;
- } else {
- success = test->run(context, tcase, test);
-
- if (!success && context->last_result == TORTURE_OK) {
- if (context->last_reason == NULL)
- context->last_reason = talloc_strdup(context, "Unknown error/failure");
- context->last_result = TORTURE_ERROR;
- }
- }
-
- if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) {
- if (context->last_reason == NULL)
- context->last_reason = talloc_strdup(context, "Setup failure");
- context->last_result = TORTURE_ERROR;
- success = false;
- }
-
- torture_ui_test_result(context, context->last_result,
- context->last_reason);
-
- talloc_free(context->last_reason);
-
- if (tcase == NULL || strcmp(test->name, tcase->name) != 0) {
- talloc_free(context->active_testname);
- context->active_testname = old_testname;
- }
- context->active_test = NULL;
- context->active_tcase = NULL;
-
- return success;
-}
-
-bool torture_run_tcase(struct torture_context *context,
- struct torture_tcase *tcase)
-{
- bool ret = true;
- char *old_testname;
- struct torture_test *test;
-
- context->level++;
-
- context->active_tcase = tcase;
- if (context->ui_ops->tcase_start)
- context->ui_ops->tcase_start(context, tcase);
-
- if (tcase->fixture_persistent && tcase->setup
- && !tcase->setup(context, &tcase->data)) {
- /* FIXME: Use torture ui ops for reporting this error */
- fprintf(stderr, "Setup failed: ");
- if (context->last_reason != NULL)
- fprintf(stderr, "%s", context->last_reason);
- fprintf(stderr, "\n");
- ret = false;
- goto done;
- }
-
- old_testname = context->active_testname;
- context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, tcase->name);
- for (test = tcase->tests; test; test = test->next) {
- ret &= internal_torture_run_test(context, tcase, test,
- tcase->fixture_persistent);
- }
- talloc_free(context->active_testname);
- context->active_testname = old_testname;
-
- if (tcase->fixture_persistent && tcase->teardown &&
- !tcase->teardown(context, tcase->data))
- ret = false;
-
-done:
- context->active_tcase = NULL;
-
- if (context->ui_ops->tcase_finish)
- context->ui_ops->tcase_finish(context, tcase);
-
- context->level--;
-
- return ret;
-}
-
-bool torture_run_test(struct torture_context *context,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- return internal_torture_run_test(context, tcase, test, false);
-}
-
-int torture_setting_int(struct torture_context *test, const char *name,
- int default_value)
-{
- return lp_parm_int(test->lp_ctx, NULL, "torture", name, default_value);
-}
-
-double torture_setting_double(struct torture_context *test, const char *name,
- double default_value)
-{
- return lp_parm_double(test->lp_ctx, NULL, "torture", name, default_value);
-}
-
-bool torture_setting_bool(struct torture_context *test, const char *name,
- bool default_value)
-{
- return lp_parm_bool(test->lp_ctx, NULL, "torture", name, default_value);
-}
-
-const char *torture_setting_string(struct torture_context *test,
- const char *name,
- const char *default_value)
-{
- const char *ret;
-
- SMB_ASSERT(test != NULL);
- SMB_ASSERT(test->lp_ctx != NULL);
-
- ret = lp_parm_string(test->lp_ctx, NULL, "torture", name);
-
- if (ret == NULL)
- return default_value;
-
- return ret;
-}
-
-static bool wrap_test_with_simple_tcase_const (
- struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- bool (*fn) (struct torture_context *, const void *tcase_data);
-
- fn = test->fn;
-
- return fn(torture_ctx, test->data);
-}
-
-struct torture_tcase *torture_suite_add_simple_tcase_const(
- struct torture_suite *suite, const char *name,
- bool (*run) (struct torture_context *test, const void *),
- const void *data)
-{
- struct torture_tcase *tcase;
- struct torture_test *test;
-
- tcase = torture_suite_add_tcase(suite, name);
-
- test = talloc(tcase, struct torture_test);
-
- test->name = talloc_strdup(test, name);
- test->description = NULL;
- test->run = wrap_test_with_simple_tcase_const;
- test->fn = run;
- test->data = data;
- test->dangerous = false;
-
- DLIST_ADD_END(tcase->tests, test, struct torture_test *);
-
- return tcase;
-}
-
-static bool wrap_simple_test(struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- bool (*fn) (struct torture_context *);
-
- fn = test->fn;
-
- return fn(torture_ctx);
-}
-
-struct torture_tcase *torture_suite_add_simple_test(
- struct torture_suite *suite,
- const char *name,
- bool (*run) (struct torture_context *test))
-{
- struct torture_test *test;
- struct torture_tcase *tcase;
-
- tcase = torture_suite_add_tcase(suite, name);
-
- test = talloc(tcase, struct torture_test);
-
- test->name = talloc_strdup(test, name);
- test->description = NULL;
- test->run = wrap_simple_test;
- test->fn = run;
- test->dangerous = false;
-
- DLIST_ADD_END(tcase->tests, test, struct torture_test *);
-
- return tcase;
-}
-
-bool torture_suite_add_suite(struct torture_suite *suite,
- struct torture_suite *child)
-{
- if (child == NULL)
- return false;
-
- DLIST_ADD_END(suite->children, child, struct torture_suite *);
-
- /* FIXME: Check for duplicates and return false if the
- * added suite already exists as a child */
-
- return true;
-}
-
-
-struct torture_suite *torture_find_suite(struct torture_suite *parent,
- const char *name)
-{
- struct torture_suite *child;
-
- for (child = parent->children; child; child = child->next)
- if (!strcmp(child->name, name))
- return child;
-
- return NULL;
-}
-
-static bool wrap_test_with_simple_test_const(struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- bool (*fn) (struct torture_context *, const void *tcase_data);
-
- fn = test->fn;
-
- return fn(torture_ctx, tcase->data);
-}
-
-struct torture_test *torture_tcase_add_simple_test_const(
- struct torture_tcase *tcase,
- const char *name,
- bool (*run) (struct torture_context *test,
- const void *tcase_data))
-{
- struct torture_test *test;
-
- test = talloc(tcase, struct torture_test);
-
- test->name = talloc_strdup(test, name);
- test->description = NULL;
- test->run = wrap_test_with_simple_test_const;
- test->fn = run;
- test->data = NULL;
- test->dangerous = false;
-
- DLIST_ADD_END(tcase->tests, test, struct torture_test *);
-
- return test;
-}
-
-static bool wrap_test_with_simple_test(struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- bool (*fn) (struct torture_context *, void *tcase_data);
-
- fn = test->fn;
-
- return fn(torture_ctx, tcase->data);
-}
-
-struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
- const char *name,
- bool (*run) (struct torture_context *test, void *tcase_data))
-{
- struct torture_test *test;
-
- test = talloc(tcase, struct torture_test);
-
- test->name = talloc_strdup(test, name);
- test->description = NULL;
- test->run = wrap_test_with_simple_test;
- test->fn = run;
- test->data = NULL;
- test->dangerous = false;
-
- DLIST_ADD_END(tcase->tests, test, struct torture_test *);
-
- return test;
-}
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
deleted file mode 100644
index 15b04c2397..0000000000
--- a/source4/torture/ui.h
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB torture UI functions
-
- Copyright (C) Jelmer Vernooij 2006
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __TORTURE_UI_H__
-#define __TORTURE_UI_H__
-
-struct torture_test;
-struct torture_context;
-struct torture_suite;
-struct torture_tcase;
-
-enum torture_result {
- TORTURE_OK=0,
- TORTURE_FAIL=1,
- TORTURE_ERROR=2,
- TORTURE_SKIP=3
-};
-
-/*
- * These callbacks should be implemented by any backend that wishes
- * to listen to reports from the torture tests.
- */
-struct torture_ui_ops
-{
- void (*init) (struct torture_context *);
- void (*comment) (struct torture_context *, const char *);
- void (*warning) (struct torture_context *, const char *);
- void (*suite_start) (struct torture_context *, struct torture_suite *);
- void (*suite_finish) (struct torture_context *, struct torture_suite *);
- void (*tcase_start) (struct torture_context *, struct torture_tcase *);
- void (*tcase_finish) (struct torture_context *, struct torture_tcase *);
- void (*test_start) (struct torture_context *,
- struct torture_tcase *,
- struct torture_test *);
- void (*test_result) (struct torture_context *,
- enum torture_result, const char *reason);
-};
-
-void torture_ui_test_start(struct torture_context *context,
- struct torture_tcase *tcase,
- struct torture_test *test);
-
-void torture_ui_test_result(struct torture_context *context,
- enum torture_result result,
- const char *comment);
-
-/*
- * Holds information about a specific run of the testsuite.
- * The data in this structure should be considered private to
- * the torture tests and should only be used directly by the torture
- * code and the ui backends.
- *
- * Torture tests should instead call the torture_*() macros and functions
- * specified below.
- */
-
-struct torture_context
-{
- const struct torture_ui_ops *ui_ops;
- void *ui_data;
-
- char *active_testname;
- struct torture_test *active_test;
- struct torture_tcase *active_tcase;
-
- bool quiet; /* Whether tests should avoid writing output to stdout */
-
- enum torture_result last_result;
- char *last_reason;
-
- bool returncode;
-
- const char *outputdir;
- int level;
- struct event_context *ev;
-
- struct loadparm_context *lp_ctx;
-};
-
-/*
- * Describes a particular torture test
- */
-struct torture_test {
- const char *name;
- const char *description;
- bool dangerous;
- /* Function to call to run this test */
- bool (*run) (struct torture_context *torture_ctx,
- struct torture_tcase *tcase,
- struct torture_test *test);
-
- struct torture_test *prev, *next;
-
- /* Pointer to the actual test function. This is run by the
- * run() function above. */
- void *fn;
- const void *data;
-};
-
-/*
- * Describes a particular test case.
- */
-struct torture_tcase {
- const char *name;
- const char *description;
- bool (*setup) (struct torture_context *tcase, void **data);
- bool (*teardown) (struct torture_context *tcase, void *data);
- bool fixture_persistent;
- void *data;
- struct torture_test *tests;
- struct torture_tcase *prev, *next;
-};
-
-struct torture_suite
-{
- const char *name;
- const char *description;
- struct torture_tcase *testcases;
- struct torture_suite *children;
-
- /* Pointers to siblings of this torture suite */
- struct torture_suite *prev, *next;
-};
-
-/** Create a new torture suite */
-struct torture_suite *torture_suite_create(TALLOC_CTX *mem_ctx,
- const char *name);
-
-/** Change the setup and teardown functions for a testcase */
-void torture_tcase_set_fixture(struct torture_tcase *tcase,
- bool (*setup) (struct torture_context *, void **),
- bool (*teardown) (struct torture_context *, void *));
-
-/* Add another test to run for a particular testcase */
-struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase,
- const char *name,
- bool (*run) (struct torture_context *test,
- const void *tcase_data, const void *test_data),
- const void *test_data);
-
-/* Add a testcase to a testsuite */
-struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite,
- const char *name);
-
-/* Convenience wrapper that adds a testcase against only one
- * test will be run */
-struct torture_tcase *torture_suite_add_simple_tcase_const(
- struct torture_suite *suite,
- const char *name,
- bool (*run) (struct torture_context *test,
- const void *test_data),
- const void *data);
-
-/* Convenience function that adds a test which only
- * gets the test case data */
-struct torture_test *torture_tcase_add_simple_test_const(
- struct torture_tcase *tcase,
- const char *name,
- bool (*run) (struct torture_context *test,
- const void *tcase_data));
-
-/* Convenience wrapper that adds a test that doesn't need any
- * testcase data */
-struct torture_tcase *torture_suite_add_simple_test(
- struct torture_suite *suite,
- const char *name,
- bool (*run) (struct torture_context *test));
-
-/* Add a child testsuite to an existing testsuite */
-bool torture_suite_add_suite(struct torture_suite *suite,
- struct torture_suite *child);
-
-/* Run the specified testsuite recursively */
-bool torture_run_suite(struct torture_context *context,
- struct torture_suite *suite);
-
-/* Run the specified testcase */
-bool torture_run_tcase(struct torture_context *context,
- struct torture_tcase *tcase);
-
-/* Run the specified test */
-bool torture_run_test(struct torture_context *context,
- struct torture_tcase *tcase,
- struct torture_test *test);
-
-void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
-void torture_warning(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
-void torture_result(struct torture_context *test,
- enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
-
-#define torture_assert(torture_ctx,expr,cmt) \
- if (!(expr)) { \
- torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
- return false; \
- }
-
-#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
- do { WERROR __got = got, __expected = expected; \
- if (!W_ERROR_EQUAL(__got, __expected)) { \
- torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", win_errstr(__got), win_errstr(__expected), cmt); \
- return false; \
- } \
- } while (0)
-
-#define torture_assert_ntstatus_equal(torture_ctx,got,expected,cmt) \
- do { NTSTATUS __got = got, __expected = expected; \
- if (!NT_STATUS_EQUAL(__got, __expected)) { \
- torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \
- return false; \
- }\
- } while(0)
-
-#define torture_assert_ndr_err_equal(torture_ctx,got,expected,cmt) \
- do { enum ndr_err_code __got = got, __expected = expected; \
- if (__got != __expected) { \
- torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %d, expected %d (%s): %s", __got, __expected, __STRING(expected), cmt); \
- return false; \
- }\
- } while(0)
-
-#define torture_assert_casestr_equal(torture_ctx,got,expected,cmt) \
- do { const char *__got = (got), *__expected = (expected); \
- if (!strequal(__got, __expected)) { \
- torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", __got, __expected, cmt); \
- return false; \
- } \
- } while(0)
-
-#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\
- do { const char *__got = (got), *__expected = (expected); \
- if (strcmp_safe(__got, __expected) != 0) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" was %s, expected %s: %s", \
- __got, __expected, cmt); \
- return false; \
- } \
- } while(0)
-
-#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
- do { const void *__got = (got), *__expected = (expected); \
- if (memcmp(__got, __expected, len) != 0) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" of len %d did not match"#expected": %s", len, cmt); \
- return false; \
- } \
- } while(0)
-
-#define torture_assert_file_contains_text(torture_ctx,filename,expected,cmt)\
- do { \
- char *__got; \
- const char *__expected = (expected); \
- size_t __size; \
- __got = file_load(filename, &__size, torture_ctx); \
- if (__got == NULL) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": unable to open %s: %s\n", \
- filename, cmt); \
- return false; \
- } \
- \
- if (strcmp_safe(__got, __expected) != 0) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": %s contained:\n%sExpected: %s%s\n", \
- filename, __got, __expected, cmt); \
- talloc_free(__got); \
- return false; \
- } \
- talloc_free(__got); \
- } while(0)
-
-#define torture_assert_file_contains(torture_ctx,filename,expected,cmt)\
- do { const char *__got, *__expected = (expected); \
- size_t __size; \
- __got = file_load(filename, *size, torture_ctx); \
- if (strcmp_safe(__got, __expected) != 0) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": %s contained:\n%sExpected: %s%s\n", \
- __got, __expected, cmt); \
- talloc_free(__got); \
- return false; \
- } \
- talloc_free(__got); \
- } while(0)
-
-#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
- do { int __got = (got), __expected = (expected); \
- if (__got != __expected) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" was %d, expected %d: %s", \
- __got, __expected, cmt); \
- return false; \
- } \
- } while(0)
-
-#define torture_assert_u64_equal(torture_ctx,got,expected,cmt)\
- do { uint64_t __got = (got), __expected = (expected); \
- if (__got != __expected) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" was %llu, expected %llu: %s", \
- (unsigned long long)__got, (unsigned long long)__expected, cmt); \
- return false; \
- } \
- } while(0)
-
-#define torture_assert_errno_equal(torture_ctx,expected,cmt)\
- do { int __expected = (expected); \
- if (errno != __expected) { \
- torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": errno was %d (%s), expected %d: %s: %s", \
- errno, strerror(errno), __expected, \
- strerror(__expected), cmt); \
- return false; \
- } \
- } while(0)
-
-
-
-#define torture_skip(torture_ctx,cmt) do {\
- torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
- return true; \
- } while(0)
-#define torture_fail(torture_ctx,cmt) do {\
- torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
- return false; \
- } while (0)
-#define torture_fail_goto(torture_ctx,label,cmt) do {\
- torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
- goto label; \
- } while (0)
-
-#define torture_out stderr
-
-/* Convenience macros */
-#define torture_assert_ntstatus_ok(torture_ctx,expr,cmt) \
- torture_assert_ntstatus_equal(torture_ctx,expr,NT_STATUS_OK,cmt)
-
-#define torture_assert_werr_ok(torture_ctx,expr,cmt) \
- torture_assert_werr_equal(torture_ctx,expr,WERR_OK,cmt)
-
-#define torture_assert_ndr_success(torture_ctx,expr,cmt) \
- torture_assert_ndr_err_equal(torture_ctx,expr,NDR_ERR_SUCCESS,cmt)
-
-/* Getting settings */
-const char *torture_setting_string(struct torture_context *test, \
- const char *name,
- const char *default_value);
-
-int torture_setting_int(struct torture_context *test,
- const char *name,
- int default_value);
-
-double torture_setting_double(struct torture_context *test,
- const char *name,
- double default_value);
-
-bool torture_setting_bool(struct torture_context *test,
- const char *name,
- bool default_value);
-
-struct torture_suite *torture_find_suite(struct torture_suite *parent,
- const char *name);
-
-NTSTATUS torture_temp_dir(struct torture_context *tctx,
- const char *prefix,
- char **tempdir);
-
-struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
- const char *name,
- bool (*run) (struct torture_context *test, void *tcase_data));
-
-
-bool torture_suite_init_tcase(struct torture_suite *suite,
- struct torture_tcase *tcase,
- const char *name);
-
-struct torture_context *torture_context_init(struct event_context *event_ctx,
- const struct torture_ui_ops *ui_ops);
-
-#endif /* __TORTURE_UI_H__ */
diff --git a/source4/torture/unix/unix.c b/source4/torture/unix/unix.c
index 05ea27db02..661e337270 100644
--- a/source4/torture/unix/unix.c
+++ b/source4/torture/unix/unix.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/unix/proto.h"
NTSTATUS torture_unix_init(void)
diff --git a/source4/torture/util.h b/source4/torture/util.h
index 1009fcf9f1..9dc948ade5 100644
--- a/source4/torture/util.h
+++ b/source4/torture/util.h
@@ -20,6 +20,11 @@
#ifndef _TORTURE_PROVISION_H_
#define _TORTURE_PROVISION_H_
+#include "torture/torture.h"
+
+struct smbcli_state;
+struct smbcli_tree;
+
/**
setup a directory ready for a test
*/
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index c1a20094f3..938e7d6c03 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -28,7 +28,6 @@
#include "system/shmem.h"
#include "system/wait.h"
#include "system/time.h"
-#include "torture/ui.h"
#include "torture/torture.h"
#include "util/dlinklist.h"
#include "auth/credentials/credentials.h"
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index 87378aadb8..31c5b8cf96 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -26,7 +26,7 @@
#include "libcli/security/security.h"
#include "librpc/gen_ndr/netlogon.h"
#include "param/param.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
#define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \
NSS_STATUS __got, __expected = (expected); \
diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c
index e283602337..b12e92552e 100644
--- a/source4/torture/winbind/winbind.c
+++ b/source4/torture/winbind/winbind.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/winbind/proto.h"
NTSTATUS torture_winbind_init(void)