diff options
author | Ralph Boehme <slow@samba.org> | 2019-04-16 16:46:43 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-08-08 20:24:32 +0000 |
commit | 4162ba78f8146ad9b39d0749a36fab674197c78e (patch) | |
tree | 29083053400336b6cc0486d0928153eec7aa254d /lib/torture | |
parent | b34fd5b9978904ef0b316ba11564691fdac5316c (diff) | |
download | samba-4162ba78f8146ad9b39d0749a36fab674197c78e.tar.gz |
lib:torture: add torture_assert_u32_[not_]equal[_goto] macros
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/torture')
-rw-r--r-- | lib/torture/torture.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/torture/torture.h b/lib/torture/torture.h index 9f55c164ac1..3507740967c 100644 --- a/lib/torture/torture.h +++ b/lib/torture/torture.h @@ -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) { \ |