1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

smbtorture: Report number of available tests in a testsuite using subunit.

This commit is contained in:
Jelmer Vernooij 2010-03-31 02:57:47 +02:00
parent 197c98292b
commit 31094b0e8c
5 changed files with 61 additions and 3 deletions

View File

@ -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,
};

View File

@ -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);

View File

@ -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);

View File

@ -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 {

View File

@ -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,
};