summaryrefslogtreecommitdiff
path: root/lib/torture
diff options
context:
space:
mode:
authorSteven Danneman <steven.danneman@isilon.com>2009-09-08 12:10:51 -0700
committerSteven Danneman <steven.danneman@isilon.com>2009-09-08 13:43:06 -0700
commit5975ea793a5d1367ff89e8c69099b8eac69d273d (patch)
tree7b3da8912eaf360a0129bbb33d6bfe3caf6116e7 /lib/torture
parent11bd19c0071eb0013bedcfc149199a2f1d4063db (diff)
downloadsamba-5975ea793a5d1367ff89e8c69099b8eac69d273d.tar.gz
samba-5975ea793a5d1367ff89e8c69099b8eac69d273d.tar.bz2
samba-5975ea793a5d1367ff89e8c69099b8eac69d273d.zip
s4/torture: add new torture_assert_*_todo() macros
These allow torture tests to perform cleanup after a failure, by jumping to a goto label.
Diffstat (limited to 'lib/torture')
-rw-r--r--lib/torture/torture.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index e28801e269..7f387cc1f2 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -246,6 +246,15 @@ void torture_result(struct torture_context *test,
}\
} while(0)
+#define torture_assert_ntstatus_equal_goto(torture_ctx,got,expected,ret,label,cmt) \
+ do { NTSTATUS __got = got, __expected = expected; \
+ if (!NT_STATUS_EQUAL(__got, __expected)) { \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \
+ ret = false; \
+ goto label; \
+ }\
+ } while(0)
+
#define torture_assert_ndr_err_equal(torture_ctx,got,expected,cmt) \
do { enum ndr_err_code __got = got, __expected = expected; \
if (__got != __expected) { \
@@ -272,6 +281,17 @@ void torture_result(struct torture_context *test,
} \
} while(0)
+#define torture_assert_str_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+ do { const char *__got = (got), *__expected = (expected); \
+ if (strcmp_safe(__got, __expected) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } while(0)
+
#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
do { const void *__got = (got), *__expected = (expected); \
if (memcmp(__got, __expected, len) != 0) { \
@@ -343,6 +363,17 @@ void torture_result(struct torture_context *test,
} \
} while(0)
+#define torture_assert_int_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+ do { int __got = (got), __expected = (expected); \
+ if (__got != __expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d, expected %d: %s", \
+ __got, __expected, cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } while(0)
+
#define torture_assert_u64_equal(torture_ctx,got,expected,cmt)\
do { uint64_t __got = (got), __expected = (expected); \
if (__got != __expected) { \
@@ -370,6 +401,10 @@ void torture_result(struct torture_context *test,
torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
return true; \
} while(0)
+#define torture_skip_goto(torture_ctx,label,cmt) do {\
+ torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
+ goto label; \
+ } while(0)
#define torture_fail(torture_ctx,cmt) do {\
torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \
@@ -385,6 +420,9 @@ void torture_result(struct torture_context *test,
#define torture_assert_ntstatus_ok(torture_ctx,expr,cmt) \
torture_assert_ntstatus_equal(torture_ctx,expr,NT_STATUS_OK,cmt)
+#define torture_assert_ntstatus_ok_goto(torture_ctx,expr,ret,label,cmt) \
+ torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
+
#define torture_assert_werr_ok(torture_ctx,expr,cmt) \
torture_assert_werr_equal(torture_ctx,expr,WERR_OK,cmt)