summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-08-11 17:08:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:01:38 -0500
commita43b026ef0e9c1ffd24130c35275f02326bfc9c7 (patch)
tree8e5df8add310843ba482434d2246041ba0149077 /source4/torture
parent1317d8e6942500d4caef5d7856b663d40d5043a7 (diff)
downloadsamba-a43b026ef0e9c1ffd24130c35275f02326bfc9c7.tar.gz
samba-a43b026ef0e9c1ffd24130c35275f02326bfc9c7.tar.bz2
samba-a43b026ef0e9c1ffd24130c35275f02326bfc9c7.zip
r24333: Add convenience function for checking the contents of a file in tests.
(This used to be commit 4e304101241ea7bcb9111b757bb51b16665d492d)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/ui.c2
-rw-r--r--source4/torture/ui.h27
2 files changed, 26 insertions, 3 deletions
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index aa0e06d401..003582179e 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -56,7 +56,7 @@ void torture_warning(struct torture_context *context, const char *comment, ...)
}
void torture_result(struct torture_context *context,
- enum torture_result result, const char *fmt, ...)
+ enum torture_result result, const char *fmt, ...)
{
va_list ap;
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index fe35c8362c..4dd5e45300 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -235,12 +235,35 @@ 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_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)