mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r16321: Add suite_start/suite_finish hooks, support --format=quiet
(This used to be commit 6da39533d7
)
This commit is contained in:
parent
324583b28f
commit
5b7ee5e7d6
@ -234,17 +234,16 @@ static void max_runtime_handler(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void simple_tcase_start (struct torture_context *ctx,
|
static void simple_tcase_start (struct torture_context *ctx,
|
||||||
struct torture_tcase *tcase,
|
struct torture_tcase *tcase)
|
||||||
struct torture_test *test)
|
|
||||||
{
|
{
|
||||||
printf("Testing %s...\n", tcase->name);
|
printf("Testing %s\n", tcase->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void simple_test_start (struct torture_context *ctx,
|
static void simple_test_start (struct torture_context *ctx,
|
||||||
struct torture_tcase *tcase,
|
struct torture_tcase *tcase,
|
||||||
struct torture_test *test)
|
struct torture_test *test)
|
||||||
{
|
{
|
||||||
printf("Testing %s/%s...\n", tcase->name, test->name);
|
printf("Testing %s/%s\n", tcase->name, test->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void simple_test_result (struct torture_context *context,
|
static void simple_test_result (struct torture_context *context,
|
||||||
@ -354,6 +353,18 @@ const static struct torture_ui_ops harness_ui_ops = {
|
|||||||
.test_result = harness_test_result
|
.test_result = harness_test_result
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void quiet_test_start (struct torture_context *ctx,
|
||||||
|
struct torture_tcase *tcase,
|
||||||
|
struct torture_test *test)
|
||||||
|
{
|
||||||
|
putchar('.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const static struct torture_ui_ops quiet_ui_ops = {
|
||||||
|
.test_start = quiet_test_start,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
main program
|
main program
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -509,6 +520,8 @@ const static struct torture_ui_ops harness_ui_ops = {
|
|||||||
torture->ui_ops = &subunit_ui_ops;
|
torture->ui_ops = &subunit_ui_ops;
|
||||||
} else if (!strcmp(ui_ops_name, "harness")) {
|
} else if (!strcmp(ui_ops_name, "harness")) {
|
||||||
torture->ui_ops = &harness_ui_ops;
|
torture->ui_ops = &harness_ui_ops;
|
||||||
|
} else if (!strcmp(ui_ops_name, "quiet")) {
|
||||||
|
torture->ui_ops = &quiet_ui_ops;
|
||||||
} else {
|
} else {
|
||||||
printf("Unknown output format '%s'\n", ui_ops_name);
|
printf("Unknown output format '%s'\n", ui_ops_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -27,6 +27,10 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
|
if (!context->ui_ops->comment)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(ap, comment);
|
va_start(ap, comment);
|
||||||
tmp = talloc_vasprintf(context, comment, ap);
|
tmp = talloc_vasprintf(context, comment, ap);
|
||||||
|
|
||||||
@ -35,36 +39,46 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
|
|||||||
talloc_free(tmp);
|
talloc_free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void torture_ok(struct torture_context *context)
|
void torture_ok(struct torture_context *context)
|
||||||
{
|
{
|
||||||
context->ui_ops->test_result(context, TORTURE_OK, NULL);
|
|
||||||
context->success++;
|
context->success++;
|
||||||
|
|
||||||
|
if (!context->ui_ops->test_result)
|
||||||
|
return;
|
||||||
|
|
||||||
|
context->ui_ops->test_result(context, TORTURE_OK, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void torture_fail(struct torture_context *context, const char *fmt, ...) _PRINTF_ATTRIBUTE(2,3)
|
void torture_fail(struct torture_context *context, const char *fmt, ...) _PRINTF_ATTRIBUTE(2,3)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *reason;
|
char *reason;
|
||||||
|
context->failed++;
|
||||||
|
|
||||||
|
if (!context->ui_ops->test_result)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
reason = talloc_vasprintf(context, fmt, ap);
|
reason = talloc_vasprintf(context, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
context->ui_ops->test_result(context, TORTURE_FAIL, reason);
|
context->ui_ops->test_result(context, TORTURE_FAIL, reason);
|
||||||
talloc_free(reason);
|
talloc_free(reason);
|
||||||
|
|
||||||
context->failed++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void torture_skip(struct torture_context *context, const char *fmt, ...) _PRINTF_ATTRIBUTE(2,3)
|
void torture_skip(struct torture_context *context, const char *fmt, ...) _PRINTF_ATTRIBUTE(2,3)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *reason;
|
char *reason;
|
||||||
|
context->skipped++;
|
||||||
|
|
||||||
|
if (!context->ui_ops->test_result)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
reason = talloc_vasprintf(context, fmt, ap);
|
reason = talloc_vasprintf(context, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
context->ui_ops->test_result(context, TORTURE_SKIP, reason);
|
context->ui_ops->test_result(context, TORTURE_SKIP, reason);
|
||||||
talloc_free(reason);
|
talloc_free(reason);
|
||||||
context->skipped++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void torture_register_suite(struct torture_suite *suite)
|
void torture_register_suite(struct torture_suite *suite)
|
||||||
@ -133,17 +147,23 @@ BOOL torture_run_suite(struct torture_context *context,
|
|||||||
BOOL ret = True;
|
BOOL ret = True;
|
||||||
struct torture_tcase *tcase;
|
struct torture_tcase *tcase;
|
||||||
|
|
||||||
|
if (context->ui_ops->suite_start)
|
||||||
|
context->ui_ops->suite_start(context, suite);
|
||||||
|
|
||||||
for (tcase = suite->testcases; tcase; tcase = tcase->next) {
|
for (tcase = suite->testcases; tcase; tcase = tcase->next) {
|
||||||
ret &= torture_run_tcase(context, tcase);
|
ret &= torture_run_tcase(context, tcase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context->ui_ops->suite_finish)
|
||||||
|
context->ui_ops->suite_finish(context, suite);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL internal_torture_run_test(struct torture_context *context,
|
static BOOL internal_torture_run_test(struct torture_context *context,
|
||||||
struct torture_tcase *tcase,
|
struct torture_tcase *tcase,
|
||||||
struct torture_test *test,
|
struct torture_test *test,
|
||||||
void *tcase_data)
|
const void *tcase_data)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
@ -159,6 +179,7 @@ static BOOL internal_torture_run_test(struct torture_context *context,
|
|||||||
|
|
||||||
context->active_tcase = tcase;
|
context->active_tcase = tcase;
|
||||||
context->active_test = test;
|
context->active_test = test;
|
||||||
|
if (context->ui_ops->test_start)
|
||||||
context->ui_ops->test_start(context, tcase, test);
|
context->ui_ops->test_start(context, tcase, test);
|
||||||
|
|
||||||
ret = test->run(context, tcase->setup?data:tcase->data, test->data);
|
ret = test->run(context, tcase->setup?data:tcase->data, test->data);
|
||||||
@ -183,8 +204,10 @@ BOOL torture_run_tcase(struct torture_context *context,
|
|||||||
context->ui_ops->tcase_start(context, tcase);
|
context->ui_ops->tcase_start(context, tcase);
|
||||||
|
|
||||||
if (tcase->fixture_persistent && tcase->setup
|
if (tcase->fixture_persistent && tcase->setup
|
||||||
&& !tcase->setup(context, &data))
|
&& !tcase->setup(context, &data)) {
|
||||||
return False;
|
ret = False;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
for (test = tcase->tests; test; test = test->next) {
|
for (test = tcase->tests; test; test = test->next) {
|
||||||
ret &= internal_torture_run_test(context, tcase, test,
|
ret &= internal_torture_run_test(context, tcase, test,
|
||||||
@ -193,10 +216,14 @@ BOOL torture_run_tcase(struct torture_context *context,
|
|||||||
|
|
||||||
if (tcase->fixture_persistent && tcase->teardown &&
|
if (tcase->fixture_persistent && tcase->teardown &&
|
||||||
!tcase->teardown(context, data))
|
!tcase->teardown(context, data))
|
||||||
return False;
|
ret = False;
|
||||||
|
|
||||||
|
done:
|
||||||
context->active_tcase = NULL;
|
context->active_tcase = NULL;
|
||||||
|
|
||||||
|
if (context->ui_ops->tcase_finish)
|
||||||
|
context->ui_ops->tcase_finish(context, tcase);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
struct torture_test;
|
struct torture_test;
|
||||||
struct torture_context;
|
struct torture_context;
|
||||||
|
struct torture_suite;
|
||||||
struct torture_tcase;
|
struct torture_tcase;
|
||||||
|
|
||||||
enum torture_result {
|
enum torture_result {
|
||||||
@ -36,6 +37,8 @@ enum torture_result {
|
|||||||
struct torture_ui_ops
|
struct torture_ui_ops
|
||||||
{
|
{
|
||||||
void (*comment) (struct torture_context *, const char *);
|
void (*comment) (struct torture_context *, const char *);
|
||||||
|
void (*suite_start) (struct torture_context *, struct torture_suite *);
|
||||||
|
void (*suite_finish) (struct torture_context *, struct torture_suite *);
|
||||||
void (*tcase_start) (struct torture_context *, struct torture_tcase *);
|
void (*tcase_start) (struct torture_context *, struct torture_tcase *);
|
||||||
void (*tcase_finish) (struct torture_context *, struct torture_tcase *);
|
void (*tcase_finish) (struct torture_context *, struct torture_tcase *);
|
||||||
void (*test_start) (struct torture_context *,
|
void (*test_start) (struct torture_context *,
|
||||||
|
Loading…
Reference in New Issue
Block a user