summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2020-11-10 17:10:27 +0100
committerGünther Deschner <gd@samba.org>2020-11-13 17:47:33 +0000
commita8ec83049176fdebe086be8c03c7d058c58f48d8 (patch)
treea5a6089d552f9ccebe947042b067f72ce0f8a087
parentae4dd2ab82eae1ddffbb00e7a753521a0879341b (diff)
downloadsamba-a8ec83049176fdebe086be8c03c7d058c58f48d8.tar.gz
s4-torture: test file_line_parse as well
Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Fri Nov 13 17:47:33 UTC 2020 on sn-devel-184
-rw-r--r--lib/util/tests/file.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/util/tests/file.c b/lib/util/tests/file.c
index 55c9d4cec9a..3501c7e135f 100644
--- a/lib/util/tests/file.c
+++ b/lib/util/tests/file.c
@@ -243,6 +243,34 @@ done:
return ret;
}
+static bool test_file_lines_parse(struct torture_context *tctx)
+{
+ char **lines;
+ int numlines;
+ TALLOC_CTX *mem_ctx = tctx;
+ char *buf;
+ size_t size;
+
+ torture_assert(tctx, file_save(TEST_FILENAME,
+ (const void *)TEST_DATA,
+ strlen(TEST_DATA)),
+ "saving file");
+
+ buf = file_load(TEST_FILENAME, &size, 0, mem_ctx);
+ torture_assert(tctx, buf, "failed to load file");
+ unlink(TEST_FILENAME);
+
+ lines = file_lines_parse(buf,
+ size,
+ &numlines,
+ mem_ctx);
+ torture_assert(tctx, lines, "failed to parse lines");
+
+ TALLOC_FREE(lines);
+ TALLOC_FREE(buf);
+ return true;
+}
+
struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "file");
@@ -256,5 +284,8 @@ struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx)
torture_suite_add_simple_test(suite, "afdgets", test_afdgets);
+ torture_suite_add_simple_test(suite, "file_lines_parse",
+ test_file_lines_parse);
+
return suite;
}