mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
lib/torture: fix subunit names of nested suites
E.g. passing 'smb2.multichannel.generic' to smbtorture results in - interface_info - num_channels While passing 'smb2.multichannel' to smbtorture results in: - generic.interface_info - genetic.num_channels - oplocks.test1 ... - leases.test1 ... Before we got this: - interface_info - num_channels - test1 ... - test1 That made it impossible to add knownfail entries for leases.test1 vs. oplocks.test1 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
@ -54,6 +54,11 @@ struct torture_context *torture_context_init(struct tevent_context *event_ctx,
|
||||
torture->ev = event_ctx;
|
||||
torture->results = talloc_reference(torture, results);
|
||||
|
||||
/*
|
||||
* We start with an empty subunit prefix
|
||||
*/
|
||||
torture_subunit_prefix_reset(torture, NULL);
|
||||
|
||||
return torture;
|
||||
}
|
||||
|
||||
@ -319,12 +324,70 @@ char *torture_subunit_test_name(struct torture_context *ctx,
|
||||
struct torture_test *test)
|
||||
{
|
||||
if (!strcmp(tcase->name, test->name)) {
|
||||
return talloc_strdup(ctx, test->name);
|
||||
return talloc_asprintf(ctx, "%s%s",
|
||||
ctx->active_prefix->subunit_prefix,
|
||||
test->name);
|
||||
} else {
|
||||
return talloc_asprintf(ctx, "%s.%s", tcase->name, test->name);
|
||||
return talloc_asprintf(ctx, "%s%s.%s",
|
||||
ctx->active_prefix->subunit_prefix,
|
||||
tcase->name, test->name);
|
||||
}
|
||||
}
|
||||
|
||||
void torture_subunit_prefix_reset(struct torture_context *ctx,
|
||||
const char *name)
|
||||
{
|
||||
struct torture_subunit_prefix *prefix = &ctx->_initial_prefix;
|
||||
|
||||
ZERO_STRUCTP(prefix);
|
||||
|
||||
if (name != NULL) {
|
||||
int ret;
|
||||
|
||||
ret = snprintf(prefix->subunit_prefix,
|
||||
sizeof(prefix->subunit_prefix),
|
||||
"%s.", name);
|
||||
if (ret < 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
ctx->active_prefix = prefix;
|
||||
}
|
||||
|
||||
static void torture_subunit_prefix_push(struct torture_context *ctx,
|
||||
struct torture_subunit_prefix *prefix,
|
||||
const char *name)
|
||||
{
|
||||
*prefix = (struct torture_subunit_prefix) {
|
||||
.parent = ctx->active_prefix,
|
||||
};
|
||||
|
||||
if (ctx->active_prefix->parent != NULL ||
|
||||
ctx->active_prefix->subunit_prefix[0] != '\0') {
|
||||
/*
|
||||
* We need a new component for the prefix.
|
||||
*/
|
||||
int ret;
|
||||
|
||||
ret = snprintf(prefix->subunit_prefix,
|
||||
sizeof(prefix->subunit_prefix),
|
||||
"%s%s.",
|
||||
ctx->active_prefix->subunit_prefix,
|
||||
name);
|
||||
if (ret < 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
ctx->active_prefix = prefix;
|
||||
}
|
||||
|
||||
static void torture_subunit_prefix_pop(struct torture_context *ctx)
|
||||
{
|
||||
ctx->active_prefix = ctx->active_prefix->parent;
|
||||
}
|
||||
|
||||
int torture_suite_children_count(const struct torture_suite *suite)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -354,10 +417,13 @@ bool torture_run_suite(struct torture_context *context,
|
||||
bool torture_run_suite_restricted(struct torture_context *context,
|
||||
struct torture_suite *suite, const char **restricted)
|
||||
{
|
||||
struct torture_subunit_prefix _prefix_stack;
|
||||
bool ret = true;
|
||||
struct torture_tcase *tcase;
|
||||
struct torture_suite *tsuite;
|
||||
|
||||
torture_subunit_prefix_push(context, &_prefix_stack, suite->name);
|
||||
|
||||
if (context->results->ui_ops->suite_start)
|
||||
context->results->ui_ops->suite_start(context, suite);
|
||||
|
||||
@ -378,6 +444,8 @@ bool torture_run_suite_restricted(struct torture_context *context,
|
||||
if (context->results->ui_ops->suite_finish)
|
||||
context->results->ui_ops->suite_finish(context, suite);
|
||||
|
||||
torture_subunit_prefix_pop(context);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,19 @@ void torture_ui_report_time(struct torture_context *context);
|
||||
* specified below.
|
||||
*/
|
||||
|
||||
struct torture_subunit_prefix {
|
||||
const struct torture_subunit_prefix *parent;
|
||||
char subunit_prefix[256];
|
||||
};
|
||||
|
||||
struct torture_context
|
||||
{
|
||||
struct torture_results *results;
|
||||
|
||||
struct torture_test *active_test;
|
||||
struct torture_tcase *active_tcase;
|
||||
struct torture_subunit_prefix _initial_prefix;
|
||||
const struct torture_subunit_prefix *active_prefix;
|
||||
|
||||
enum torture_result last_result;
|
||||
char *last_reason;
|
||||
@ -225,6 +232,8 @@ bool torture_suite_add_suite(struct torture_suite *suite,
|
||||
char *torture_subunit_test_name(struct torture_context *ctx,
|
||||
struct torture_tcase *tcase,
|
||||
struct torture_test *test);
|
||||
void torture_subunit_prefix_reset(struct torture_context *ctx,
|
||||
const char *name);
|
||||
|
||||
/* Run the specified testsuite recursively */
|
||||
bool torture_run_suite(struct torture_context *context,
|
||||
|
@ -83,8 +83,8 @@
|
||||
^samba4.raw.rename.*.osxrename
|
||||
^samba4.raw.rename.*.directory rename
|
||||
^samba4.rpc.winreg.*security
|
||||
^samba4.local.registry.(dir|ldb).check hive security
|
||||
^samba4.local.registry.local.security
|
||||
^samba4.local.registry.*.(dir|ldb).check hive security
|
||||
^samba4.local.registry.*.local.security
|
||||
^samba4.rpc.wkssvc
|
||||
^samba4.rpc.handles.*.lsarpc-shared
|
||||
^samba4.rpc.epmapper
|
||||
|
Reference in New Issue
Block a user