summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/torture/subunit.c24
-rw-r--r--lib/torture/torture.c21
-rw-r--r--lib/torture/torture.h9
-rwxr-xr-xselftest/selftest.pl2
-rw-r--r--source4/torture/smbtorture.c8
5 files changed, 61 insertions, 3 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);
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 68a2b2d671..634db92c92 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -274,7 +274,7 @@ sub run_testsuite($$$$$)
my $exitcode = $ret >> 8;
Subunit::report_time(time());
- Subuit::progress_pop();
+ Subunit::progress_pop();
if ($exitcode == 0) {
Subunit::end_testsuite($name, "success");
} else {
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 53e860a144..2aa340ee36 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -354,12 +354,18 @@ static void simple_warning(struct torture_context *test,
fprintf(stderr, "WARNING: %s\n", comment);
}
+static void simple_progress(struct torture_context *test,
+ int offset, enum torture_progress_whence whence)
+{
+}
+
const static struct torture_ui_ops std_ui_ops = {
.comment = simple_comment,
.warning = simple_warning,
.suite_start = simple_suite_start,
.suite_finish = simple_suite_finish,
- .test_result = simple_test_result
+ .test_result = simple_test_result,
+ .progress = simple_progress,
};