From 1afda7bdde90948027e3230c19753280afb16e96 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Mar 2007 14:53:09 +0000 Subject: r21656: Move tests a bit closer to the things they test, should make syncing with samba3 easier. (This used to be commit 4d755fb5d7adedd1dd8bad917b921324411bfd59) --- source4/lib/util/tests/strlist.c | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 source4/lib/util/tests/strlist.c (limited to 'source4/lib/util/tests/strlist.c') diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c new file mode 100644 index 0000000000..7dbb5f8ce6 --- /dev/null +++ b/source4/lib/util/tests/strlist.c @@ -0,0 +1,80 @@ +/* + Unix SMB/CIFS implementation. + + util_strlist testing + + Copyright (C) Jelmer Vernooij 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "torture/torture.h" + +static const char *test_lists_shell_strings[] = { + "", + "foo", + "foo bar", + "foo bar \"bla \"", + "foo \"\" bla", + "bla \"\"\"\" blie", + NULL +}; + +static bool test_lists_shell(struct torture_context *tctx, + const void *test_data) +{ + const char *data = test_data; + const char **ret1, **ret2, *tmp; + BOOL match = True; + TALLOC_CTX *mem_ctx = tctx; + + ret1 = str_list_make_shell(mem_ctx, data, " "); + tmp = str_list_join_shell(mem_ctx, ret1, ' '); + ret2 = str_list_make_shell(mem_ctx, tmp, " "); + + if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) { + match = False; + } else { + int j; + for (j = 0; ret1[j] && ret2[j]; j++) { + if (strcmp(ret1[j], ret2[j]) != 0) { + match = False; + break; + } + } + + if (ret1[j] || ret2[j]) + match = False; + } + + torture_assert(tctx, match, talloc_asprintf(tctx, + "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", data, tmp)); + return true; +} + +struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST"); + int i; + + for (i = 0; test_lists_shell_strings[i]; i++) { + torture_suite_add_simple_tcase(suite, + "lists_shell", test_lists_shell, + &test_lists_shell_strings[i]); + } + + return suite; +} -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/util/tests/strlist.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/util/tests/strlist.c') diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c index 7dbb5f8ce6..689e03e54a 100644 --- a/source4/lib/util/tests/strlist.c +++ b/source4/lib/util/tests/strlist.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 4fb038b0b8e7a4bb69ac0d9022684eeaca8a491a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 17:21:16 +0000 Subject: r24710: Use standard boolean type for easier use by external users. (This used to be commit 99f4124137d4a61216e8189f26d4da32882c0f4a) --- source4/lib/util/tests/strlist.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/util/tests/strlist.c') diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c index 689e03e54a..41accd4bd2 100644 --- a/source4/lib/util/tests/strlist.c +++ b/source4/lib/util/tests/strlist.c @@ -37,7 +37,7 @@ static bool test_lists_shell(struct torture_context *tctx, { const char *data = test_data; const char **ret1, **ret2, *tmp; - BOOL match = True; + bool match = true; TALLOC_CTX *mem_ctx = tctx; ret1 = str_list_make_shell(mem_ctx, data, " "); @@ -45,18 +45,18 @@ static bool test_lists_shell(struct torture_context *tctx, ret2 = str_list_make_shell(mem_ctx, tmp, " "); if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) { - match = False; + match = false; } else { int j; for (j = 0; ret1[j] && ret2[j]; j++) { if (strcmp(ret1[j], ret2[j]) != 0) { - match = False; + match = false; break; } } if (ret1[j] || ret2[j]) - match = False; + match = false; } torture_assert(tctx, match, talloc_asprintf(tctx, -- cgit From 98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 16:46:30 +0000 Subject: r25035: Fix some more warnings, use service pointer rather than service number in more places. (This used to be commit df9cebcb97e20564359097148665bd519f31bc6f) --- source4/lib/util/tests/strlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/util/tests/strlist.c') diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c index 41accd4bd2..437d9d741a 100644 --- a/source4/lib/util/tests/strlist.c +++ b/source4/lib/util/tests/strlist.c @@ -35,7 +35,7 @@ static const char *test_lists_shell_strings[] = { static bool test_lists_shell(struct torture_context *tctx, const void *test_data) { - const char *data = test_data; + const char *data = (const char *)test_data; const char **ret1, **ret2, *tmp; bool match = true; TALLOC_CTX *mem_ctx = tctx; -- cgit From 80b62dae14ce067fa9f13145d4ad8a8fef8b17a3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 12 Dec 2007 14:09:15 +0100 Subject: r26417: Make str_list_copy(mem_ctx, NULL) return NULL rather than an empty list. (This used to be commit cf8636c8b77c745812376d0ea6f0fb6246a2e4fb) --- source4/lib/util/tests/strlist.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source4/lib/util/tests/strlist.c') diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c index 437d9d741a..3ecb982e24 100644 --- a/source4/lib/util/tests/strlist.c +++ b/source4/lib/util/tests/strlist.c @@ -64,6 +64,29 @@ static bool test_lists_shell(struct torture_context *tctx, return true; } +static bool test_list_copy(struct torture_context *tctx) +{ + const char **result; + const char *list[] = { "foo", "bar", NULL }; + const char *empty_list[] = { NULL }; + const char **null_list = NULL; + + result = str_list_copy(tctx, list); + torture_assert_int_equal(tctx, str_list_length(result), 2, "list length"); + torture_assert_str_equal(tctx, result[0], "foo", "element 0"); + torture_assert_str_equal(tctx, result[1], "bar", "element 1"); + torture_assert_str_equal(tctx, result[2], NULL, "element 2"); + + result = str_list_copy(tctx, empty_list); + torture_assert_int_equal(tctx, str_list_length(result), 0, "list length"); + torture_assert_str_equal(tctx, result[0], NULL, "element 0"); + + result = str_list_copy(tctx, null_list); + torture_assert(tctx, result == NULL, "result NULL"); + + return true; +} + struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST"); @@ -75,5 +98,7 @@ struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) &test_lists_shell_strings[i]); } + torture_suite_add_simple_test(suite, "list_copy", test_list_copy); + return suite; } -- cgit From 3c744ddd2c33a9a06013f357261b8ea86804e8e8 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 24 Dec 2007 13:04:56 -0600 Subject: r26588: Janitorial: Rename torture_*_add_*test to torture_*_add_*test_const. Also rename the corresponding wrap_ functions. (This used to be commit e59c2eaf681f076d175b9779d1c27b5f74a57c96) --- source4/lib/util/tests/strlist.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/util/tests/strlist.c') diff --git a/source4/lib/util/tests/strlist.c b/source4/lib/util/tests/strlist.c index 3ecb982e24..9af26f9e71 100644 --- a/source4/lib/util/tests/strlist.c +++ b/source4/lib/util/tests/strlist.c @@ -93,9 +93,8 @@ struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) int i; for (i = 0; test_lists_shell_strings[i]; i++) { - torture_suite_add_simple_tcase(suite, - "lists_shell", test_lists_shell, - &test_lists_shell_strings[i]); + torture_suite_add_simple_tcase_const(suite, "lists_shell", + test_lists_shell, &test_lists_shell_strings[i]); } torture_suite_add_simple_test(suite, "list_copy", test_list_copy); -- cgit