torture: add torture_assert_mem_not_equal_goto()
authorUri Simchoni <uri@samba.org>
Thu, 23 Mar 2017 19:30:50 +0000 (21:30 +0200)
committerRalph Boehme <slow@samba.org>
Sun, 26 Mar 2017 17:42:16 +0000 (19:42 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12715

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/torture/torture.h

index b6d1301d1cb43580351178a5a9afa7312599edfb..668458a292e72a738889ba64bf39501673c4d0ef 100644 (file)
@@ -367,6 +367,16 @@ void torture_result(struct torture_context *test,
        } \
        } while(0)
 
+#define torture_assert_mem_not_equal_goto(torture_ctx,got,expected,len,ret,label,cmt) \
+       do { const void *__got = (got), *__expected = (expected); \
+       if (memcmp(__got, __expected, len) == 0) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                              __location__": "#got" of len %d unexpectedly matches "#expected": %s", (int)len, cmt); \
+               ret = false; \
+               goto label; \
+       } \
+       } while(0)
+
 static inline void torture_dump_data_str_cb(const char *buf, void *private_data)
 {
        char **dump = (char **)private_data;