diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/torture/torture.c | 24 | ||||
-rw-r--r-- | source4/lib/torture/torture.h | 26 |
2 files changed, 46 insertions, 4 deletions
diff --git a/source4/lib/torture/torture.c b/source4/lib/torture/torture.c index 54ddc79be7..15e5198fc9 100644 --- a/source4/lib/torture/torture.c +++ b/source4/lib/torture/torture.c @@ -32,6 +32,10 @@ struct torture_context *torture_context_init(struct event_context *event_ctx, { struct torture_context *torture = talloc_zero(event_ctx, struct torture_context); + + if (torture == NULL) + return NULL; + torture->ui_ops = ui_ops; torture->returncode = true; torture->ev = event_ctx; @@ -43,6 +47,26 @@ struct torture_context *torture_context_init(struct event_context *event_ctx, } /** + * Create a sub torture context + */ +struct torture_context *torture_context_child(struct torture_context *parent) +{ + struct torture_context *subtorture = talloc_zero(parent, struct torture_context); + + if (subtorture == NULL) + return NULL; + + subtorture->ui_ops = parent->ui_ops; + subtorture->level = parent->level+1; + subtorture->ev = talloc_reference(subtorture, parent->ev); + subtorture->lp_ctx = talloc_reference(subtorture, parent->lp_ctx); + subtorture->ui_data = parent->ui_data; + subtorture->outputdir = talloc_reference(subtorture, parent->outputdir); + + return subtorture; +} + +/** create a temporary directory. */ _PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx, diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h index ea5cd70961..0a84cef84a 100644 --- a/source4/lib/torture/torture.h +++ b/source4/lib/torture/torture.h @@ -80,17 +80,24 @@ struct torture_context struct torture_test *active_test; struct torture_tcase *active_tcase; - bool quiet; /* Whether tests should avoid writing output to stdout */ + /** Whether tests should avoid writing output to stdout */ + bool quiet; enum torture_result last_result; char *last_reason; bool returncode; + /** Directory used for temporary test data */ const char *outputdir; + + /** Indentation level */ int level; + + /** Event context */ struct event_context *ev; + /** Loadparm context (will go away in favor of torture_setting_ at some point) */ struct loadparm_context *lp_ctx; }; @@ -98,19 +105,28 @@ struct torture_context * Describes a particular torture test */ struct torture_test { + /** Short unique name for the test. */ const char *name; + + /** Long description for the test. */ const char *description; + + /** Whether this is a dangerous test + * (can corrupt the remote servers data or bring it down). */ bool dangerous; - /* Function to call to run this test */ + + /** Function to call to run this test */ bool (*run) (struct torture_context *torture_ctx, struct torture_tcase *tcase, struct torture_test *test); struct torture_test *prev, *next; - /* Pointer to the actual test function. This is run by the - * run() function above. */ + /** Pointer to the actual test function. This is run by the + * run() function above. */ void *fn; + + /** Use data for this test */ const void *data; }; @@ -393,6 +409,8 @@ bool torture_suite_init_tcase(struct torture_suite *suite, struct torture_context *torture_context_init(struct event_context *event_ctx, const struct torture_ui_ops *ui_ops); +struct torture_context *torture_context_child(struct torture_context *tctx); + extern const struct torture_ui_ops torture_subunit_ui_ops; #endif /* __TORTURE_UI_H__ */ |