svn commit: samba r19377 - in branches/SAMBA_4_0/source/torture: .
local
jelmer at samba.org
jelmer at samba.org
Tue Oct 17 19:06:50 GMT 2006
Author: jelmer
Date: 2006-10-17 19:06:50 +0000 (Tue, 17 Oct 2006)
New Revision: 19377
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19377
Log:
Simplify report functions.
Modified:
branches/SAMBA_4_0/source/torture/local/dbspeed.c
branches/SAMBA_4_0/source/torture/local/event.c
branches/SAMBA_4_0/source/torture/smbtorture.c
branches/SAMBA_4_0/source/torture/ui.c
branches/SAMBA_4_0/source/torture/ui.h
Changeset:
Modified: branches/SAMBA_4_0/source/torture/local/dbspeed.c
===================================================================
--- branches/SAMBA_4_0/source/torture/local/dbspeed.c 2006-10-17 18:22:38 UTC (rev 19376)
+++ branches/SAMBA_4_0/source/torture/local/dbspeed.c 2006-10-17 19:06:50 UTC (rev 19377)
@@ -73,13 +73,13 @@
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 @@
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 @@
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 @@
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;
}
Modified: branches/SAMBA_4_0/source/torture/local/event.c
===================================================================
--- branches/SAMBA_4_0/source/torture/local/event.c 2006-10-17 18:22:38 UTC (rev 19376)
+++ branches/SAMBA_4_0/source/torture/local/event.c 2006-10-17 19:06:50 UTC (rev 19377)
@@ -46,7 +46,8 @@
(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;
Modified: branches/SAMBA_4_0/source/torture/smbtorture.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smbtorture.c 2006-10-17 18:22:38 UTC (rev 19376)
+++ branches/SAMBA_4_0/source/torture/smbtorture.c 2006-10-17 19:06:50 UTC (rev 19377)
@@ -291,9 +291,6 @@
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 @@
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 @@
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 @@
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;
}
}
Modified: branches/SAMBA_4_0/source/torture/ui.c
===================================================================
--- branches/SAMBA_4_0/source/torture/ui.c 2006-10-17 18:22:38 UTC (rev 19376)
+++ branches/SAMBA_4_0/source/torture/ui.c 2006-10-17 19:06:50 UTC (rev 19377)
@@ -41,28 +41,14 @@
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 @@
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 @@
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;
}
Modified: branches/SAMBA_4_0/source/torture/ui.h
===================================================================
--- branches/SAMBA_4_0/source/torture/ui.h 2006-10-17 18:22:38 UTC (rev 19376)
+++ branches/SAMBA_4_0/source/torture/ui.h 2006-10-17 19:06:50 UTC (rev 19377)
@@ -30,8 +30,7 @@
enum torture_result {
TORTURE_OK=0,
TORTURE_FAIL=1,
- TORTURE_TODO=2,
- TORTURE_SKIP=3
+ TORTURE_SKIP=2
};
/*
@@ -190,23 +189,20 @@
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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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 @@
#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)
More information about the samba-cvs
mailing list