torture: Simplify torture suite running, call restricted test suite runner.
[samba.git] / lib / torture / torture.h
index 7f387cc1f2b2b9bd53213054503e472c285397a0..931937c1182b7e27a2b4e92ca9a9679fdbc4607c 100644 (file)
@@ -34,6 +34,13 @@ enum torture_result {
        TORTURE_SKIP=3
 };
 
+enum torture_progress_whence {
+       TORTURE_PROGRESS_SET,
+       TORTURE_PROGRESS_CUR,
+       TORTURE_PROGRESS_POP,
+       TORTURE_PROGRESS_PUSH,
+};
+
 /* 
  * These callbacks should be implemented by any backend that wishes 
  * to listen to reports from the torture tests.
@@ -52,6 +59,7 @@ struct torture_ui_ops
                                                struct torture_test *);
        void (*test_result) (struct torture_context *, 
                                                 enum torture_result, const char *reason);
+       void (*progress) (struct torture_context *, int offset, enum torture_progress_whence whence);
 };
 
 void torture_ui_test_start(struct torture_context *context,
@@ -210,6 +218,11 @@ bool torture_suite_add_suite(struct torture_suite *suite,
 bool torture_run_suite(struct torture_context *context,
                                           struct torture_suite *suite);
 
+/* Run the specified testsuite recursively, but only the specified 
+ * tests */
+bool torture_run_suite_restricted(struct torture_context *context, 
+                      struct torture_suite *suite, char **restricted);
+
 /* Run the specified testcase */
 bool torture_run_tcase(struct torture_context *context,
                                           struct torture_tcase *tcase);
@@ -230,6 +243,13 @@ void torture_result(struct torture_context *test,
                return false; \
        }
 
+#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) \
+       if (!(expr)) { \
+               torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
+               ret = false; \
+               goto label; \
+       }
+
 #define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
        do { WERROR __got = got, __expected = expected; \
        if (!W_ERROR_EQUAL(__got, __expected)) { \
@@ -357,8 +377,8 @@ void torture_result(struct torture_context *test,
        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); \
+                       __location__": "#got" was %d (0x%X), expected %d (0x%X): %s", \
+                       __got, __got, __expected, __expected, cmt); \
                return false; \
        } \
        } while(0)
@@ -367,8 +387,8 @@ void torture_result(struct torture_context *test,
        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); \
+                       __location__": "#got" was %d (0x%X), expected %d (0x%X): %s", \
+                       __got, __got, __expected, __expected, cmt); \
                ret = false; \
                goto label; \
        } \
@@ -378,8 +398,10 @@ void torture_result(struct torture_context *test,
        do { uint64_t __got = (got), __expected = (expected); \
        if (__got != __expected) { \
                torture_result(torture_ctx, TORTURE_FAIL, \
-                       __location__": "#got" was %llu, expected %llu: %s", \
-                       (unsigned long long)__got, (unsigned long long)__expected, cmt); \
+                       __location__": "#got" was %llu (0x%llX), expected %llu (0x%llX): %s", \
+                       (unsigned long long)__got, (unsigned long long)__got, \
+                       (unsigned long long)__expected, (unsigned long long)__expected, \
+                       cmt); \
                return false; \
        } \
        } while(0)
@@ -449,6 +471,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);
@@ -461,6 +487,7 @@ struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
 bool torture_suite_init_tcase(struct torture_suite *suite, 
                              struct torture_tcase *tcase, 
                              const char *name);
+int torture_suite_children_count(const struct torture_suite *suite);
 
 struct torture_context *torture_context_init(struct tevent_context *event_ctx, struct torture_results *results);