summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-10-17 19:06:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:20 -0500
commit1e818c463af84b6aeb462a7faa4c15603b7b90d7 (patch)
tree7c17f81a16688c767b9b11e7f3509a8d685c14a7
parent67abfc498142f3ea16f682ddf335042be900438a (diff)
downloadsamba-1e818c463af84b6aeb462a7faa4c15603b7b90d7.tar.gz
samba-1e818c463af84b6aeb462a7faa4c15603b7b90d7.tar.bz2
samba-1e818c463af84b6aeb462a7faa4c15603b7b90d7.zip
r19377: Simplify report functions.
(This used to be commit 0061f3c47e95f07461837c4051cf129b18961b56)
-rw-r--r--source4/torture/local/dbspeed.c12
-rw-r--r--source4/torture/local/event.c3
-rw-r--r--source4/torture/smbtorture.c14
-rw-r--r--source4/torture/ui.c26
-rw-r--r--source4/torture/ui.h41
5 files changed, 35 insertions, 61 deletions
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 3f9607eb81..4eac7c9499 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -73,13 +73,13 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
if (!tdb_add_record(tdbw,
"S-1-5-21-53173311-3623041448-2049097239-%u",
"UID %u", i)) {
- _torture_fail_ext(torture, "Failed to add SID %d", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to add SID %d", i);
goto failed;
}
if (!tdb_add_record(tdbw,
"UID %u",
"S-1-5-21-53173311-3623041448-2049097239-%u", i)) {
- _torture_fail_ext(torture, "Failed to add UID %d", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to add UID %d", i);
goto failed;
}
}
@@ -95,7 +95,7 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
key.dsize = strlen((char *)key.dptr)+1;
data = tdb_fetch(tdbw->tdb, key);
if (data.dptr == NULL) {
- _torture_fail_ext(torture, "Failed to fetch SID %d", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to fetch SID %d", i);
goto failed;
}
free(data.dptr);
@@ -103,7 +103,7 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data)
key.dsize = strlen((char *)key.dptr)+1;
data = tdb_fetch(tdbw->tdb, key);
if (data.dptr == NULL) {
- _torture_fail_ext(torture, "Failed to fetch UID %d", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to fetch UID %d", i);
goto failed;
}
free(data.dptr);
@@ -186,13 +186,13 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data)
for (i=0;i<torture_entries;i++) {
if (!ldb_add_record(ldb, i)) {
- _torture_fail_ext(torture, "Failed to add SID %d", i);
+ torture_result(torture, TORTURE_FAIL, "Failed to add SID %d", i);
goto failed;
}
}
if (talloc_total_blocks(torture) > 100) {
- _torture_fail_ext(torture, "memory leak in ldb add");
+ torture_result(torture, TORTURE_FAIL, "memory leak in ldb add");
goto failed;
}
diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c
index 6579b1b277..a03f07bf33 100644
--- a/source4/torture/local/event.c
+++ b/source4/torture/local/event.c
@@ -46,7 +46,8 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f,
(flags & EVENT_FD_WRITE)?" EVENT_FD_WRITE":"");
if (fde_count > 5) {
- _torture_fail_ext(test, "got more than fde 5 events - bug!");
+ torture_result(test, TORTURE_FAIL,
+ __location__": got more than fde 5 events - bug!");
talloc_free(fde);
fde = NULL;
return;
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index d83d1310ae..ae4cfeb1de 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -291,9 +291,6 @@ static void simple_test_result (struct torture_context *context,
case TORTURE_FAIL:
printf("TEST %s FAILED! - %s\n", context->active_test->name, reason);
break;
- case TORTURE_TODO:
- printf("TODO: %s - %s\n", context->active_test->name, reason);
- break;
case TORTURE_SKIP:
printf("SKIP: %s - %s\n", context->active_test->name, reason);
break;
@@ -332,9 +329,6 @@ static void subunit_test_result (struct torture_context *context,
case TORTURE_FAIL:
printf("failure: %s", context->active_test->name);
break;
- case TORTURE_TODO:
- printf("todo: %s", context->active_test->name);
- break;
case TORTURE_SKIP:
printf("skip: %s", context->active_test->name);
break;
@@ -372,9 +366,6 @@ static void harness_test_result (struct torture_context *context,
case TORTURE_FAIL:
printf("not ok %s - %s\n", context->active_test->name, reason);
break;
- case TORTURE_TODO:
- printf("todo %s - %s\n", context->active_test->name, reason);
- break;
case TORTURE_SKIP:
printf("skip %s - %s\n", context->active_test->name, reason);
break;
@@ -415,9 +406,8 @@ static void quiet_test_result (struct torture_context *context,
fflush(stdout);
switch (res) {
case TORTURE_OK: putchar('.'); break;
- case TORTURE_FAIL: putchar('E'); break;
- case TORTURE_TODO: putchar('T'); break;
- case TORTURE_SKIP: putchar('S'); break;
+ case TORTURE_FAIL: putchar('F'); break;
+ case TORTURE_SKIP: putchar('I'); break;
}
}
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index 3769643a0c..24e229e873 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -41,28 +41,14 @@ void torture_comment(struct torture_context *context,
talloc_free(tmp);
}
-void _torture_fail_ext(struct torture_context *context,
- const char *fmt, ...)
+void torture_result(struct torture_context *context,
+ enum torture_result result, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- context->last_reason = talloc_vasprintf(context, fmt, ap);
- /* make sure the reason for the failure is displayed */
- if (context->ui_ops->comment)
- context->ui_ops->comment(context, context->last_reason);
- va_end(ap);
- context->last_result = TORTURE_FAIL;
-}
-void _torture_skip_ext(struct torture_context *context,
- const char *fmt, ...)
-{
- va_list ap;
- context->skipped++;
-
- va_start(ap, fmt);
- context->last_result = TORTURE_SKIP;
+ context->last_result = result;
context->last_reason = talloc_vasprintf(context, fmt, ap);
va_end(ap);
}
@@ -182,11 +168,11 @@ void torture_ui_test_result(struct torture_context *context,
if (context->ui_ops->test_result)
context->ui_ops->test_result(context, result, comment);
+ /* FIXME: */
switch (result) {
- case TORTURE_SKIP: context->success++; break;
+ case TORTURE_SKIP: context->skipped++; break;
case TORTURE_FAIL: context->failed++; break;
- case TORTURE_TODO: context->todo++; break;
case TORTURE_OK: context->success++; break;
}
}
@@ -199,7 +185,7 @@ static BOOL internal_torture_run_test(struct torture_context *context,
BOOL ret;
if (test->dangerous && !torture_setting_bool(context, "dangerous", False)) {
- _torture_skip_ext(context,
+ torture_result(context, TORTURE_SKIP,
"disabled %s - enable dangerous tests to use", test->name);
return True;
}
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index 64127fa8d0..c8a8d09a24 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -30,8 +30,7 @@ struct torture_tcase;
enum torture_result {
TORTURE_OK=0,
TORTURE_FAIL=1,
- TORTURE_TODO=2,
- TORTURE_SKIP=3
+ TORTURE_SKIP=2
};
/*
@@ -190,23 +189,20 @@ bool torture_run_test(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test);
-void _torture_fail_ext(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3);
void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
-void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3);
+void torture_result(struct torture_context *test,
+ enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
#define torture_assert(torture_ctx,expr,cmt) \
if (!(expr)) { \
- torture_comment(torture_ctx, __location__": Expression `%s' failed\n", __STRING(expr)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
return false; \
}
#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
do { WERROR __got = got, __expected = expected; \
if (!W_ERROR_EQUAL(__got, __expected)) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", \
- win_errstr(__got), win_errstr(__expected)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", win_errstr(__got), win_errstr(__expected), cmt); \
return false; \
} \
} while (0)
@@ -214,9 +210,7 @@ void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PR
#define torture_assert_ntstatus_equal(torture_ctx,got,expected,cmt) \
do { NTSTATUS __got = got, __expected = expected; \
if (!NT_STATUS_EQUAL(__got, __expected)) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", \
- nt_errstr(__got), nt_errstr(__expected)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \
return false; \
}\
} while(0)
@@ -225,8 +219,7 @@ void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PR
#define torture_assert_casestr_equal(torture_ctx,got,expected,cmt) \
do { const char *__got = (got), *__expected = (expected); \
if (!strequal(__got, __expected)) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", __got, __expected); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", __got, __expected, cmt); \
return false; \
} \
} while(0)
@@ -234,8 +227,9 @@ void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PR
#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\
do { const char *__got = (got), *__expected = (expected); \
if (strcmp_safe(__got, __expected) != 0) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", __got, __expected); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
return false; \
} \
} while(0)
@@ -243,8 +237,9 @@ void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PR
#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
do { int __got = (got), __expected = (expected); \
if (__got != __expected) { \
- torture_comment(torture_ctx, __location__": "#got" was %d, expected %d\n", __got, __expected); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d, expected %d: %s", \
+ __got, __expected, cmt); \
return false; \
} \
} while(0)
@@ -252,8 +247,10 @@ void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PR
#define torture_assert_errno_equal(torture_ctx,expected,cmt)\
do { int __expected = (expected); \
if (errno != __expected) { \
- torture_comment(torture_ctx, __location__": errno was %d, expected %s\n", errno, strerror(__expected)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": errno was %d (%s), expected %d: %s: %s", \
+ errno, strerror(errno), __expected, \
+ strerror(__expected), cmt); \
return false; \
} \
} while(0)
@@ -261,11 +258,11 @@ void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PR
#define torture_skip(torture_ctx,cmt) do {\
- _torture_skip_ext(torture_ctx, __location__": %s", cmt);\
+ torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
return true; \
} while(0)
#define torture_fail(torture_ctx,cmt) do {\
- _torture_fail_ext(torture_ctx, __location__": %s", cmt);\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \
} while (0)