summaryrefslogtreecommitdiff
path: root/lib/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-22 21:03:05 -0700
committerJelmer Vernooij <jelmer@samba.org>2010-09-22 22:29:09 -0700
commit136aa0d5ac8d3105cdebb579edf4a8043b5cc83f (patch)
tree688ff8cca2fee167e87dcbb5ed730e4036c00c09 /lib/torture
parenta15a33a9a8806426955fb3cab6b798ab4173cc67 (diff)
downloadsamba-136aa0d5ac8d3105cdebb579edf4a8043b5cc83f.tar.gz
samba-136aa0d5ac8d3105cdebb579edf4a8043b5cc83f.tar.bz2
samba-136aa0d5ac8d3105cdebb579edf4a8043b5cc83f.zip
smbtorture: Report times.
Diffstat (limited to 'lib/torture')
-rw-r--r--lib/torture/subunit.c31
-rw-r--r--lib/torture/torture.c10
-rw-r--r--lib/torture/torture.h3
3 files changed, 39 insertions, 5 deletions
diff --git a/lib/torture/subunit.c b/lib/torture/subunit.c
index 0b63cca053..a190975a08 100644
--- a/lib/torture/subunit.c
+++ b/lib/torture/subunit.c
@@ -37,12 +37,37 @@ static char *torture_subunit_test_name(struct torture_context *ctx,
}
}
-static void torture_subunit_test_start(struct torture_context *ctx,
+static void torture_subunit_report_time(struct torture_context *tctx)
+{
+ struct timespec tp;
+ struct tm *tmp;
+ char timestr[200];
+ if (clock_gettime(CLOCK_REALTIME, &tp) != 0) {
+ perror("clock_gettime");
+ return;
+ }
+
+ tmp = localtime(&tp.tv_sec);
+ if (!tmp) {
+ perror("localtime");
+ return;
+ }
+
+ if (strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", tmp) <= 0) {
+ perror("strftime");
+ return;
+ }
+
+ printf("time: %s.%06ld\n", timestr, tp.tv_nsec / 1000);
+}
+
+static void torture_subunit_test_start(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test)
{
- char *fullname = torture_subunit_test_name(ctx, ctx->active_tcase, ctx->active_test);
+ char *fullname = torture_subunit_test_name(context, context->active_tcase, context->active_test);
subunit_test_start(fullname);
+ torture_subunit_report_time(context);
talloc_free(fullname);
}
@@ -50,6 +75,7 @@ static void torture_subunit_test_result(struct torture_context *context,
enum torture_result res, const char *reason)
{
char *fullname = torture_subunit_test_name(context, context->active_tcase, context->active_test);
+ torture_subunit_report_time(context);
switch (res) {
case TORTURE_OK:
subunit_test_pass(fullname);
@@ -107,4 +133,5 @@ const struct torture_ui_ops torture_subunit_ui_ops = {
.test_result = torture_subunit_test_result,
.suite_start = torture_subunit_suite_start,
.progress = torture_subunit_progress,
+ .report_time = torture_subunit_report_time,
};
diff --git a/lib/torture/torture.c b/lib/torture/torture.c
index d6f893eb0f..379f1dd954 100644
--- a/lib/torture/torture.c
+++ b/lib/torture/torture.c
@@ -277,7 +277,6 @@ bool torture_run_suite_restricted(struct torture_context *context,
bool ret = true;
struct torture_tcase *tcase;
struct torture_suite *tsuite;
- char *old_testname;
if (context->results->ui_ops->suite_start)
context->results->ui_ops->suite_start(context, suite);
@@ -346,7 +345,7 @@ static bool internal_torture_run_test(struct torture_context *context,
if (tcase == NULL || strcmp(test->name, tcase->name) != 0) {
subunit_testname = talloc_asprintf(context, "%s.%s", tcase->name, test->name);
} else {
- subunit_testname = test->name;
+ subunit_testname = talloc_strdup(context, test->name);
}
if (!test_needs_running(subunit_testname, restricted))
@@ -410,7 +409,6 @@ bool torture_run_tcase_restricted(struct torture_context *context,
struct torture_tcase *tcase, const char **restricted)
{
bool ret = true;
- char *old_testname;
struct torture_test *test;
bool setup_succeeded = true;
const char * setup_reason = "Setup failed";
@@ -684,3 +682,9 @@ struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
return test;
}
+
+void torture_ui_report_time(struct torture_context *context)
+{
+ if (context->results->ui_ops->report_time)
+ context->results->ui_ops->report_time(context);
+}
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index 90513b723d..01947e773d 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -60,6 +60,7 @@ struct torture_ui_ops
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 (*report_time) (struct torture_context *);
};
void torture_ui_test_start(struct torture_context *context,
@@ -70,6 +71,8 @@ void torture_ui_test_result(struct torture_context *context,
enum torture_result result,
const char *comment);
+void torture_ui_report_time(struct torture_context *context);
+
/*
* Holds information about a specific run of the testsuite.
* The data in this structure should be considered private to