libwbclient: Add "goto fail" test macros
authorVolker Lendecke <vl@samba.org>
Thu, 14 Jan 2016 20:42:04 +0000 (21:42 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 4 Feb 2016 08:29:17 +0000 (09:29 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
nsswitch/libwbclient/tests/wbclient.c

index 4d04ca9c780543614e263bd270df6095cdb703ab..e011efed0221f844fe8acc2f333d46ce2ed255d0 100644 (file)
 #define torture_assert_wbc_ok(torture_ctx,expr,cmt,cmt_arg)                    \
        torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt,cmt_arg)
 
+#define torture_assert_wbc_equal_goto_fail(torture_ctx, got, expected, cmt, cmt_arg)   \
+       do { wbcErr __got = got, __expected = expected; \
+       if (!WBC_ERROR_EQUAL(__got, __expected)) { \
+               torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: " cmt, wbcErrorString(__got), wbcErrorString(__expected), cmt_arg); \
+               goto fail;                                              \
+       } \
+       } while (0)
+
+#define torture_assert_wbc_ok_goto_fail(torture_ctx,expr,cmt,cmt_arg)                  \
+       torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt,cmt_arg)
+
+#define torture_assert_str_equal_goto_fail(torture_ctx,got,expected,cmt)\
+       do { const char *__got = (got), *__expected = (expected); \
+       if (strcmp(__got, __expected) != 0) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %s, expected %s: %s", \
+                       __got, __expected, cmt); \
+               goto fail;;                      \
+       } \
+       } while(0)
+
 static bool test_wbc_ping(struct torture_context *tctx)
 {
        torture_assert_wbc_ok(tctx, wbcPing(),