From 8773e743c518578584d07d35ffdafdd598af88b0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 13:06:41 +0000 Subject: r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218) --- source4/torture/local/util_file.c | 51 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'source4/torture/local/util_file.c') diff --git a/source4/torture/local/util_file.c b/source4/torture/local/util_file.c index 3c11d3d94e..87d25b222e 100644 --- a/source4/torture/local/util_file.c +++ b/source4/torture/local/util_file.c @@ -31,66 +31,65 @@ #define TEST_DATA TEST_LINE1 "\n" TEST_LINE2 "\n" TEST_LINE3 -static BOOL test_file_load_save(struct torture_context *test, const void *_data) +static bool test_file_load_save(struct torture_context *tctx) { size_t len; char *data; + TALLOC_CTX *mem_ctx = tctx; - torture_assert(test, - file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)), + torture_assert(tctx, file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)), "saving file"); - data = file_load(TEST_FILENAME, &len, test); - torture_assert(test, data, "loading file"); + data = file_load(TEST_FILENAME, &len, mem_ctx); + torture_assert(tctx, data, "loading file"); - torture_assert(test, len == strlen(TEST_DATA), "Length"); + torture_assert(tctx, len == strlen(TEST_DATA), "Length"); - torture_assert(test, memcmp(data, TEST_DATA, len) == 0, "Contents"); + torture_assert(tctx, memcmp(data, TEST_DATA, len) == 0, "Contents"); unlink(TEST_FILENAME); - - return True; + return true; } -static BOOL test_afdgets(struct torture_context *test, const void *data) + +static bool test_afdgets(struct torture_context *tctx) { int fd; char *line; + TALLOC_CTX *mem_ctx = tctx; - torture_assert(test, - file_save(TEST_FILENAME, (const void *)TEST_DATA, + torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA, strlen(TEST_DATA)), "saving file"); fd = open(TEST_FILENAME, O_RDONLY); - torture_assert(test, fd != -1, "opening file"); + torture_assert(tctx, fd != -1, "opening file"); - line = afdgets(fd, test, 8); - torture_assert(test, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch"); + line = afdgets(fd, mem_ctx, 8); + torture_assert(tctx, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch"); - line = afdgets(fd, test, 8); - torture_assert(test, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch"); + line = afdgets(fd, mem_ctx, 8); + torture_assert(tctx, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch"); - line = afdgets(fd, test, 8); - torture_assert(test, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch"); + line = afdgets(fd, mem_ctx, 8); + torture_assert(tctx, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch"); close(fd); unlink(TEST_FILENAME); - - return True; + return true; } struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-FILE"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "FILE"); - torture_suite_add_simple_tcase(suite, "file_load_save", - test_file_load_save, NULL); + torture_suite_add_simple_test(suite, "file_load_save", + test_file_load_save); - torture_suite_add_simple_tcase(suite, "afdgets", - test_afdgets, NULL); + torture_suite_add_simple_test(suite, "afdgets", + test_afdgets); return suite; } -- cgit