diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-10-23 21:30:41 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-23 21:30:41 +0200 |
commit | 6b5d0b32b68a65121b05ca4f250807576a9ff23e (patch) | |
tree | cef365f90066b5ff050c576d78e575f1e5545194 /source4 | |
parent | 22f566c39b564c39eca40a76bf1dfece96d7ece5 (diff) | |
download | samba-6b5d0b32b68a65121b05ca4f250807576a9ff23e.tar.gz samba-6b5d0b32b68a65121b05ca4f250807576a9ff23e.tar.bz2 samba-6b5d0b32b68a65121b05ca4f250807576a9ff23e.zip |
Move subunit ui ops out of smbtorture to the torture library.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/torture/config.mk | 2 | ||||
-rw-r--r-- | source4/lib/torture/subunit.c | 96 | ||||
-rw-r--r-- | source4/lib/torture/torture.c | 37 | ||||
-rw-r--r-- | source4/lib/torture/torture.h | 2 | ||||
-rw-r--r-- | source4/torture/smbtorture.c | 76 |
5 files changed, 134 insertions, 79 deletions
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/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 { |