mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Add comments in torture code, allow creating subcontexts.
This commit is contained in:
parent
161cb81911
commit
c7cedd3a67
@ -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;
|
||||
@ -42,6 +46,26 @@ struct torture_context *torture_context_init(struct event_context *event_ctx,
|
||||
return torture;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user