lib/torture: add torture_assert_mem_equal_goto
authorRalph Boehme <slow@samba.org>
Thu, 8 Dec 2016 14:44:37 +0000 (15:44 +0100)
committerUri Simchoni <uri@samba.org>
Wed, 1 Mar 2017 23:32:22 +0000 (00:32 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427

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

index 45332b2ef7c3aa0b0725fe7ba5fd0d5d90b1549a..b6d1301d1cb43580351178a5a9afa7312599edfb 100644 (file)
@@ -357,6 +357,16 @@ void torture_result(struct torture_context *test,
        } \
        } while(0)
 
+#define torture_assert_mem_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 did not match "#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;