diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-03-31 02:57:47 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-03-31 02:57:47 +0200 |
commit | 31094b0e8ca73e3150de9de689f4c5c38b2e9f1f (patch) | |
tree | 5095475c46abfc5bd0ccb8c147c9e6279ba96b84 /lib/torture | |
parent | 197c98292bd838e27da6692ba8e7984f12a66fef (diff) | |
download | samba-31094b0e8ca73e3150de9de689f4c5c38b2e9f1f.tar.gz samba-31094b0e8ca73e3150de9de689f4c5c38b2e9f1f.tar.bz2 samba-31094b0e8ca73e3150de9de689f4c5c38b2e9f1f.zip |
smbtorture: Report number of available tests in a testsuite using subunit.
Diffstat (limited to 'lib/torture')
-rw-r--r-- | lib/torture/subunit.c | 24 | ||||
-rw-r--r-- | lib/torture/torture.c | 21 | ||||
-rw-r--r-- | lib/torture/torture.h | 9 |
3 files changed, 53 insertions, 1 deletions
diff --git a/lib/torture/subunit.c b/lib/torture/subunit.c index 832f11fafc..86b3dd0e60 100644 --- a/lib/torture/subunit.c +++ b/lib/torture/subunit.c @@ -81,10 +81,32 @@ static void subunit_warning(struct torture_context *test, fprintf(stderr, "WARNING!: %s\n", comment); } +static void subunit_progress(struct torture_context *tctx, int offset, enum torture_progress_whence whence) +{ + switch (whence) { + case TORTURE_PROGRESS_SET: + printf("progress: %d\n", offset); + break; + case TORTURE_PROGRESS_CUR: + printf("progress: %+-d\n", offset); + break; + case TORTURE_PROGRESS_POP: + printf("progress: pop\n"); + break; + case TORTURE_PROGRESS_PUSH: + printf("progress: push\n"); + break; + default: + fprintf(stderr, "Invalid call to progress()\n"); + break; + } +} + const struct torture_ui_ops torture_subunit_ui_ops = { .comment = subunit_comment, .warning = subunit_warning, .test_start = subunit_test_start, .test_result = subunit_test_result, - .suite_start = subunit_suite_start + .suite_start = subunit_suite_start, + .progress = subunit_progress, }; diff --git a/lib/torture/torture.c b/lib/torture/torture.c index 672726ebf2..9adf6816b8 100644 --- a/lib/torture/torture.c +++ b/lib/torture/torture.c @@ -245,6 +245,23 @@ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite, return tcase; } +int torture_suite_children_count(const struct torture_suite *suite) +{ + int ret = 0; + struct torture_tcase *tcase; + struct torture_test *test; + struct torture_suite *tsuite; + for (tcase = suite->testcases; tcase; tcase = tcase->next) { + for (test = tcase->tests; test; test = test->next) { + ret++; + } + } + for (tsuite = suite->children; tsuite; tsuite = tsuite->next) { + ret ++; + } + return ret; +} + /** * Run a torture test suite. */ @@ -259,6 +276,8 @@ bool torture_run_suite(struct torture_context *context, if (context->results->ui_ops->suite_start) context->results->ui_ops->suite_start(context, suite); + context->results->ui_ops->progress(context, + torture_suite_children_count(suite), TORTURE_PROGRESS_SET); old_testname = context->active_testname; if (old_testname != NULL) context->active_testname = talloc_asprintf(context, "%s-%s", @@ -271,7 +290,9 @@ bool torture_run_suite(struct torture_context *context, } for (tsuite = suite->children; tsuite; tsuite = tsuite->next) { + context->results->ui_ops->progress(context, 0, TORTURE_PROGRESS_PUSH); ret &= torture_run_suite(context, tsuite); + context->results->ui_ops->progress(context, 0, TORTURE_PROGRESS_POP); } talloc_free(context->active_testname); diff --git a/lib/torture/torture.h b/lib/torture/torture.h index ad3668fbe8..cb2c02ba3e 100644 --- a/lib/torture/torture.h +++ b/lib/torture/torture.h @@ -34,6 +34,13 @@ enum torture_result { TORTURE_SKIP=3 }; +enum torture_progress_whence { + TORTURE_PROGRESS_SET, + TORTURE_PROGRESS_CUR, + TORTURE_PROGRESS_POP, + TORTURE_PROGRESS_PUSH, +}; + /* * These callbacks should be implemented by any backend that wishes * to listen to reports from the torture tests. @@ -52,6 +59,7 @@ struct torture_ui_ops struct torture_test *); void (*test_result) (struct torture_context *, enum torture_result, const char *reason); + void (*progress) (struct torture_context *, int offset, enum torture_progress_whence whence); }; void torture_ui_test_start(struct torture_context *context, @@ -465,6 +473,7 @@ struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase, bool torture_suite_init_tcase(struct torture_suite *suite, struct torture_tcase *tcase, const char *name); +int torture_suite_children_count(const struct torture_suite *suite); struct torture_context *torture_context_init(struct tevent_context *event_ctx, struct torture_results *results); |