summaryrefslogtreecommitdiff
path: root/lib/torture
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-04-14 11:25:26 +1200
committerAndrew Bartlett <abartlet@samba.org>2022-06-17 01:28:30 +0000
commitd0d18934fa0660f85225f6a9387a4583f77bb780 (patch)
tree5ec400b354451d254d479a4b8110926f1953a32e /lib/torture
parent937c2cd38a6365924e0eaaa34b60815eced6126c (diff)
downloadsamba-d0d18934fa0660f85225f6a9387a4583f77bb780.tar.gz
torture: add torture_assertf()
Often we go 'torture_assert(tctx, expr, talloc_asprintf(tctx, "foo %s", foo));' which is just a pain. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15040 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/torture')
-rw-r--r--lib/torture/torture.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index c95103072d2..ea34c15e0e9 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -273,6 +273,20 @@ void torture_result(struct torture_context *test,
} \
} while(0)
+#define torture_assertf(torture_ctx, expr, format, ...) do { \
+ if (!(expr)) { \
+ char *_msg = talloc_asprintf(torture_ctx, \
+ format, \
+ __VA_ARGS__); \
+ torture_result(torture_ctx, \
+ TORTURE_FAIL, \
+ __location__": Expression `%s' failed: %s", \
+ __STRING(expr), _msg); \
+ talloc_free(_msg); \
+ return false; \
+ } \
+} while(0)
+
#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) do { \
if (!(expr)) { \
torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \