summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/tls/tls.c10
-rw-r--r--source4/lib/torture/config.mk2
-rw-r--r--source4/lib/torture/subunit.c96
-rw-r--r--source4/lib/torture/torture.c37
-rw-r--r--source4/lib/torture/torture.h2
-rw-r--r--source4/param/loadparm.c31
-rw-r--r--source4/param/param.h10
-rw-r--r--source4/torture/smbtorture.c76
8 files changed, 170 insertions, 94 deletions
diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c
index f72aafe542..24e4632a49 100644
--- a/source4/lib/tls/tls.c
+++ b/source4/lib/tls/tls.c
@@ -357,11 +357,11 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *
struct tls_params *params;
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
- const char *keyfile = private_path(tmp_ctx, lp_ctx, lp_tls_keyfile(lp_ctx));
- const char *certfile = private_path(tmp_ctx, lp_ctx, lp_tls_certfile(lp_ctx));
- const char *cafile = private_path(tmp_ctx, lp_ctx, lp_tls_cafile(lp_ctx));
- const char *crlfile = private_path(tmp_ctx, lp_ctx, lp_tls_crlfile(lp_ctx));
- const char *dhpfile = private_path(tmp_ctx, lp_ctx, lp_tls_dhpfile(lp_ctx));
+ const char *keyfile = lp_tls_keyfile(tmp_ctx, lp_ctx);
+ const char *certfile = lp_tls_certfile(tmp_ctx, lp_ctx);
+ const char *cafile = lp_tls_cafile(tmp_ctx, lp_ctx);
+ const char *crlfile = lp_tls_crlfile(tmp_ctx, lp_ctx);
+ const char *dhpfile = lp_tls_dhpfile(tmp_ctx, lp_ctx);
void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *);
params = talloc(mem_ctx, struct tls_params);
if (params == NULL) {
diff --git a/source4/lib/torture/config.mk b/source4/lib/torture/config.mk
index 49e7b1a171..8a7f2a3b6b 100644
--- a/source4/lib/torture/config.mk
+++ b/source4/lib/torture/config.mk
@@ -9,6 +9,6 @@ torture_VERSION = 0.0.1
torture_SOVERSION = 0
PC_FILES += $(libtorturesrcdir)/torture.pc
-torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o)
+torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o subunit.o)
PUBLIC_HEADERS += $(libtorturesrcdir)/torture.h
diff --git a/source4/lib/torture/subunit.c b/source4/lib/torture/subunit.c
new file mode 100644
index 0000000000..40d9b9731d
--- /dev/null
+++ b/source4/lib/torture/subunit.c
@@ -0,0 +1,96 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ 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 "lib/torture/torture.h"
+
+static void subunit_init(struct torture_context *ctx)
+{
+ /* FIXME: register segv and bus handler */
+}
+
+static void subunit_suite_start(struct torture_context *ctx,
+ struct torture_suite *suite)
+{
+}
+
+static void subunit_print_testname(struct torture_context *ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ if (!strcmp(tcase->name, test->name)) {
+ printf("%s", test->name);
+ } else {
+ printf("%s.%s", tcase->name, test->name);
+ }
+}
+
+static void subunit_test_start(struct torture_context *ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ printf("test: ");
+ subunit_print_testname(ctx, tcase, test);
+ printf("\n");
+}
+
+static void subunit_test_result(struct torture_context *context,
+ enum torture_result res, const char *reason)
+{
+ switch (res) {
+ case TORTURE_OK:
+ printf("success: ");
+ break;
+ case TORTURE_FAIL:
+ printf("failure: ");
+ break;
+ case TORTURE_ERROR:
+ printf("error: ");
+ break;
+ case TORTURE_SKIP:
+ printf("skip: ");
+ break;
+ }
+ subunit_print_testname(context, context->active_tcase, context->active_test);
+
+ if (reason)
+ printf(" [\n%s\n]", reason);
+ printf("\n");
+}
+
+static void subunit_comment(struct torture_context *test,
+ const char *comment)
+{
+ fprintf(stderr, "%s", comment);
+}
+
+static void subunit_warning(struct torture_context *test,
+ const char *comment)
+{
+ fprintf(stderr, "WARNING!: %s\n", comment);
+}
+
+const struct torture_ui_ops torture_subunit_ui_ops = {
+ .init = subunit_init,
+ .comment = subunit_comment,
+ .warning = subunit_warning,
+ .test_start = subunit_test_start,
+ .test_result = subunit_test_result,
+ .suite_start = subunit_suite_start
+};
diff --git a/source4/lib/torture/torture.c b/source4/lib/torture/torture.c
index ba7168f3fe..54ddc79be7 100644
--- a/source4/lib/torture/torture.c
+++ b/source4/lib/torture/torture.c
@@ -24,8 +24,11 @@
#include "param/param.h"
#include "system/filesys.h"
+/**
+ * Initialize a torture context
+ */
struct torture_context *torture_context_init(struct event_context *event_ctx,
- const struct torture_ui_ops *ui_ops)
+ const struct torture_ui_ops *ui_ops)
{
struct torture_context *torture = talloc_zero(event_ctx,
struct torture_context);
@@ -59,6 +62,9 @@ _PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
return NT_STATUS_OK;
}
+/**
+ * Comment on the status/progress of a test
+ */
void torture_comment(struct torture_context *context, const char *comment, ...)
{
va_list ap;
@@ -75,6 +81,9 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
talloc_free(tmp);
}
+/**
+ * Print a warning about the current test
+ */
void torture_warning(struct torture_context *context, const char *comment, ...)
{
va_list ap;
@@ -91,6 +100,9 @@ void torture_warning(struct torture_context *context, const char *comment, ...)
talloc_free(tmp);
}
+/**
+ * Store the result of a torture test.
+ */
void torture_result(struct torture_context *context,
enum torture_result result, const char *fmt, ...)
{
@@ -108,6 +120,9 @@ void torture_result(struct torture_context *context,
va_end(ap);
}
+/**
+ * Create a new torture suite
+ */
struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
{
struct torture_suite *suite = talloc_zero(ctx, struct torture_suite);
@@ -119,6 +134,9 @@ struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
return suite;
}
+/**
+ * Set 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 *))
@@ -140,6 +158,9 @@ static bool wrap_test_with_testcase_const(struct torture_context *torture_ctx,
return fn(torture_ctx, tcase->data, test->data);
}
+/**
+ * Add a test that uses const data to a testcase
+ */
struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase,
const char *name,
bool (*run) (struct torture_context *, const void *tcase_data,
@@ -160,7 +181,9 @@ struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase,
return test;
}
-
+/**
+ * Add a new testcase
+ */
bool torture_suite_init_tcase(struct torture_suite *suite,
struct torture_tcase *tcase,
const char *name)
@@ -189,6 +212,9 @@ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite,
return tcase;
}
+/**
+ * Run a torture test suite.
+ */
bool torture_run_suite(struct torture_context *context,
struct torture_suite *suite)
{
@@ -472,6 +498,9 @@ struct torture_tcase *torture_suite_add_simple_test(
return tcase;
}
+/**
+ * Add a child testsuite to a testsuite.
+ */
bool torture_suite_add_suite(struct torture_suite *suite,
struct torture_suite *child)
{
@@ -486,7 +515,9 @@ bool torture_suite_add_suite(struct torture_suite *suite,
return true;
}
-
+/**
+ * Find the child testsuite with the specified name.
+ */
struct torture_suite *torture_find_suite(struct torture_suite *parent,
const char *name)
{
diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h
index 0f966a52d1..ea5cd70961 100644
--- a/source4/lib/torture/torture.h
+++ b/source4/lib/torture/torture.h
@@ -393,4 +393,6 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
struct torture_context *torture_context_init(struct event_context *event_ctx,
const struct torture_ui_ops *ui_ops);
+extern const struct torture_ui_ops torture_subunit_ui_ops;
+
#endif /* __TORTURE_UI_H__ */
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 0c29de64c3..2808cb9f28 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -616,11 +616,6 @@ _PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, kpasswd_port)
_PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, web_port)
_PUBLIC_ FN_GLOBAL_STRING(lp_swat_directory, swat_directory)
_PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, tls_enabled)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, tls_keyfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, tls_certfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_cafile, tls_cafile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile)
_PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend)
_PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL)
_PUBLIC_ FN_GLOBAL_STRING(lp_idmap_url, szIDMAP_URL)
@@ -2638,3 +2633,29 @@ void lp_smbcli_session_options(struct loadparm_context *lp_ctx,
options->ntlmv2_auth = lp_client_ntlmv2_auth(lp_ctx);
options->plaintext_auth = lp_client_plaintext_auth(lp_ctx);
}
+
+_PUBLIC_ const char *lp_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+ return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
+}
+
+_PUBLIC_ const char *lp_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+ return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
+}
+
+_PUBLIC_ const char *lp_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+ return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
+}
+
+_PUBLIC_ const char *lp_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+ return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
+}
+
+_PUBLIC_ const char *lp_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+ return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
+}
+
diff --git a/source4/param/param.h b/source4/param/param.h
index 4c6e8b79a2..9c20931186 100644
--- a/source4/param/param.h
+++ b/source4/param/param.h
@@ -78,11 +78,11 @@ int lp_kpasswd_port(struct loadparm_context *);
int lp_web_port(struct loadparm_context *);
const char *lp_swat_directory(struct loadparm_context *);
bool lp_tls_enabled(struct loadparm_context *);
-const char *lp_tls_keyfile(struct loadparm_context *);
-const char *lp_tls_certfile(struct loadparm_context *);
-const char *lp_tls_cafile(struct loadparm_context *);
-const char *lp_tls_crlfile(struct loadparm_context *);
-const char *lp_tls_dhpfile(struct loadparm_context *);
+const char *lp_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
const char *lp_share_backend(struct loadparm_context *);
const char *lp_sam_url(struct loadparm_context *);
const char *lp_idmap_url(struct loadparm_context *);
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 8d195f1253..19f1d1ae35 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -365,80 +365,6 @@ const static struct torture_ui_ops std_ui_ops = {
.test_result = simple_test_result
};
-static void subunit_init(struct torture_context *ctx)
-{
- /* FIXME: register segv and bus handler */
-}
-
-static void subunit_suite_start(struct torture_context *ctx,
- struct torture_suite *suite)
-{
-}
-
-static void subunit_print_testname(struct torture_context *ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- if (!strcmp(tcase->name, test->name)) {
- printf("%s", test->name);
- } else {
- printf("%s.%s", tcase->name, test->name);
- }
-}
-
-static void subunit_test_start(struct torture_context *ctx,
- struct torture_tcase *tcase,
- struct torture_test *test)
-{
- printf("test: ");
- subunit_print_testname(ctx, tcase, test);
- printf("\n");
-}
-
-static void subunit_test_result(struct torture_context *context,
- enum torture_result res, const char *reason)
-{
- switch (res) {
- case TORTURE_OK:
- printf("success: ");
- break;
- case TORTURE_FAIL:
- printf("failure: ");
- break;
- case TORTURE_ERROR:
- printf("error: ");
- break;
- case TORTURE_SKIP:
- printf("skip: ");
- break;
- }
- subunit_print_testname(context, context->active_tcase, context->active_test);
-
- if (reason)
- printf(" [\n%s\n]", reason);
- printf("\n");
-}
-
-static void subunit_comment(struct torture_context *test,
- const char *comment)
-{
- fprintf(stderr, "%s", comment);
-}
-
-static void subunit_warning(struct torture_context *test,
- const char *comment)
-{
- fprintf(stderr, "WARNING!: %s\n", comment);
-}
-
-const static struct torture_ui_ops subunit_ui_ops = {
- .init = subunit_init,
- .comment = subunit_comment,
- .warning = subunit_warning,
- .test_start = subunit_test_start,
- .test_result = subunit_test_result,
- .suite_start = subunit_suite_start
-};
static void quiet_suite_start(struct torture_context *ctx,
struct torture_suite *suite)
@@ -693,7 +619,7 @@ int main(int argc,char *argv[])
if (!strcmp(ui_ops_name, "simple")) {
ui_ops = &std_ui_ops;
} else if (!strcmp(ui_ops_name, "subunit")) {
- ui_ops = &subunit_ui_ops;
+ ui_ops = &torture_subunit_ui_ops;
} else if (!strcmp(ui_ops_name, "quiet")) {
ui_ops = &quiet_ui_ops;
} else {