r24667: Finally merge the registry improvements that Wilco Baan Hofman and I have
[sfrench/samba-autobuild/.git] / source4 / torture / ui.h
index fe35c8362c49b87b7a82adbdcb1dcb11c8adfec1..c3b0092d48909e1119d1e726fa7bebaed946f1cf 100644 (file)
@@ -165,6 +165,13 @@ struct torture_tcase *torture_suite_add_simple_tcase(
                bool (*run) (struct torture_context *test, const void *test_data),
                const void *data);
 
+/* Convenience function that adds a test which only 
+ * gets the test case data */
+struct torture_test *torture_tcase_add_simple_test(
+               struct torture_tcase *tcase,
+               const char *name,
+               bool (*run) (struct torture_context *test, const void *tcase_data));
+
 /* Convenience wrapper that adds a test that doesn't need any 
  * testcase data */
 struct torture_tcase *torture_suite_add_simple_test(
@@ -235,12 +242,49 @@ void torture_result(struct torture_context *test,
        } \
        } while(0)
 
+#define torture_assert_file_contains_text(torture_ctx,filename,expected,cmt)\
+       do { \
+       char *__got; \
+       const char *__expected = (expected); \
+       size_t __size; \
+       __got = file_load(filename, &__size, torture_ctx); \
+       if (__got == NULL) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                              __location__": unable to open %s: %s\n", \
+                              filename, cmt); \
+               return false; \
+       } \
+       \
+       if (strcmp_safe(__got, __expected) != 0) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": %s contained:\n%sExpected: %s%s\n", \
+                       filename, __got, __expected, cmt); \
+               talloc_free(__got); \
+               return false; \
+       } \
+       talloc_free(__got); \
+       } while(0)
+
+#define torture_assert_file_contains(torture_ctx,filename,expected,cmt)\
+       do { const char *__got, *__expected = (expected); \
+       size_t __size; \
+       __got = file_load(filename, *size, torture_ctx); \
+       if (strcmp_safe(__got, __expected) != 0) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                                          __location__": %s contained:\n%sExpected: %s%s\n", \
+                                          __got, __expected, cmt); \
+               talloc_free(__got); \
+               return false; \
+       } \
+       talloc_free(__got); \
+       } while(0)
+
 #define torture_assert_int_equal(torture_ctx,got,expected,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); \
+                       __location__": "#got" was %d, expected %d: %s", \
+                       __got, __expected, cmt); \
                return false; \
        } \
        } while(0)