]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:torture: add torture_assert_u32_[not_]equal[_goto] macros
authorRalph Boehme <slow@samba.org>
Tue, 16 Apr 2019 14:46:43 +0000 (16:46 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 8 Aug 2019 20:24:32 +0000 (20:24 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/torture/torture.h

index 9f55c164ac1e7ee7cab79923a4cea245c8085733..3507740967c0094acb659c86f3e9f186848a8954 100644 (file)
@@ -520,6 +520,54 @@ static inline void torture_dump_data_str_cb(const char *buf, void *private_data)
        } \
        } while(0)
 
+#define torture_assert_u32_equal(torture_ctx,got,expected,cmt)\
+       do { uint32_t __got = (got), __expected = (expected); \
+       if (__got != __expected) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %ju (0x%jX), expected %ju (0x%jX): %s", \
+                       (uintmax_t)__got, (uintmax_t)__got, \
+                       (uintmax_t)__expected, (uintmax_t)__expected, \
+                       cmt); \
+               return false; \
+       } \
+       } while(0)
+
+#define torture_assert_u32_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+       do { uint32_t __got = (got), __expected = (expected); \
+       if (__got != __expected) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %ju (0x%jX), expected %ju (0x%jX): %s", \
+                       (uintmax_t)__got, (uintmax_t)__got, \
+                       (uintmax_t)__expected, (uintmax_t)__expected, \
+                       cmt); \
+               ret = false; \
+               goto label; \
+       } \
+       } while(0)
+
+#define torture_assert_u32_not_equal(torture_ctx,got,not_expected,cmt)\
+       do { uint32_t __got = (got), __not_expected = (not_expected); \
+       if (__got == __not_expected) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %ju (0x%jX), expected a different number: %s", \
+                       (uintmax_t)__got, (uintmax_t)__got, \
+                       cmt); \
+               return false; \
+       } \
+       } while(0)
+
+#define torture_assert_u32_not_equal_goto(torture_ctx,got,not_expected,ret,label,cmt)\
+       do { uint32_t __got = (got), __not_expected = (not_expected); \
+       if (__got == __not_expected) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %ju (0x%jX), expected a different number: %s", \
+                       (uintmax_t)__got, (uintmax_t)__got, \
+                       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) { \