tdb: fix recovery reuse after crash
[ira/wip.git] / lib / torture / torture.h
index f06ffe012b430291f5f975ef15d7de4142bfdf39..ad3668fbe87cebeff4a65090e473b6aae8c71a2a 100644 (file)
@@ -86,11 +86,8 @@ struct torture_context
        /** Directory used for temporary test data */
        const char *outputdir;
        
-       /** Indentation level */
-       int level;
-
        /** Event context */
-       struct event_context *ev;
+       struct tevent_context *ev;
 
        /** Loadparm context (will go away in favor of torture_setting_ at some point) */
        struct loadparm_context *lp_ctx;
@@ -105,8 +102,6 @@ struct torture_results
        bool quiet;
 
        bool returncode;
-
-
 };
 
 /* 
@@ -251,6 +246,15 @@ void torture_result(struct torture_context *test,
        }\
        } while(0)
 
+#define torture_assert_ntstatus_equal_goto(torture_ctx,got,expected,ret,label,cmt) \
+       do { NTSTATUS __got = got, __expected = expected; \
+       if (!NT_STATUS_EQUAL(__got, __expected)) { \
+               torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \
+               ret = false; \
+               goto label; \
+       }\
+       } while(0)
+
 #define torture_assert_ndr_err_equal(torture_ctx,got,expected,cmt) \
        do { enum ndr_err_code __got = got, __expected = expected; \
        if (__got != __expected) { \
@@ -277,11 +281,37 @@ void torture_result(struct torture_context *test,
        } \
        } while(0)
 
+#define torture_assert_str_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+       do { const char *__got = (got), *__expected = (expected); \
+       if (strcmp_safe(__got, __expected) != 0) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                                          __location__": "#got" was %s, expected %s: %s", \
+                                          __got, __expected, cmt); \
+               ret = false; \
+               goto label; \
+       } \
+       } while(0)
+
 #define torture_assert_mem_equal(torture_ctx,got,expected,len,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); \
+                              __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \
+               return false; \
+       } \
+       } while(0)
+
+#define torture_assert_data_blob_equal(torture_ctx,got,expected,cmt)\
+       do { const DATA_BLOB __got = (got), __expected = (expected); \
+       if (__got.length != __expected.length) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                              __location__": "#got".len %d did not match "#expected" len %d: %s", \
+                              (int)__got.length, (int)__expected.length, cmt); \
+               return false; \
+       } \
+       if (memcmp(__got.data, __expected.data, __got.length) != 0) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                              __location__": "#got" of len %d did not match "#expected": %s", (int)__got.length, cmt); \
                return false; \
        } \
        } while(0)
@@ -333,6 +363,17 @@ void torture_result(struct torture_context *test,
        } \
        } while(0)
 
+#define torture_assert_int_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+       do { int __got = (got), __expected = (expected); \
+       if (__got != __expected) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %d, expected %d: %s", \
+                       __got, __expected, 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) { \
@@ -360,6 +401,10 @@ void torture_result(struct torture_context *test,
                torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
                return true; \
        } while(0)
+#define torture_skip_goto(torture_ctx,label,cmt) do {\
+               torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
+               goto label; \
+       } while(0)
 #define torture_fail(torture_ctx,cmt) do {\
                torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
                return false; \
@@ -375,6 +420,9 @@ void torture_result(struct torture_context *test,
 #define torture_assert_ntstatus_ok(torture_ctx,expr,cmt) \
                torture_assert_ntstatus_equal(torture_ctx,expr,NT_STATUS_OK,cmt)
 
+#define torture_assert_ntstatus_ok_goto(torture_ctx,expr,ret,label,cmt) \
+               torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
+
 #define torture_assert_werr_ok(torture_ctx,expr,cmt) \
                torture_assert_werr_equal(torture_ctx,expr,WERR_OK,cmt)
 
@@ -401,6 +449,10 @@ bool torture_setting_bool(struct torture_context *test,
 struct torture_suite *torture_find_suite(struct torture_suite *parent, 
                                                                                 const char *name);
 
+unsigned long torture_setting_ulong(struct torture_context *test,
+                                   const char *name,
+                                   unsigned long default_value);
+
 NTSTATUS torture_temp_dir(struct torture_context *tctx, 
                                   const char *prefix, 
                                   char **tempdir);
@@ -414,7 +466,7 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
                              struct torture_tcase *tcase, 
                              const char *name);
 
-struct torture_context *torture_context_init(struct event_context *event_ctx, struct torture_results *results);
+struct torture_context *torture_context_init(struct tevent_context *event_ctx, struct torture_results *results);
 
 struct torture_results *torture_results_init(TALLOC_CTX *mem_ctx, const struct torture_ui_ops *ui_ops);