r15819: Use updated API in smbtorture, use UI tools in registry tests.
[Samba.git] / source / torture / local / util_strlist.c
blob78ebcf44fb093c29ecd415069bf2b0e44c4f7895
1 /*
2 Unix SMB/CIFS implementation.
4 util_strlist testing
6 Copyright (C) Jelmer Vernooij 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "includes.h"
24 #include "torture/torture.h"
26 static const char *test_lists_shell_strings[] = {
27 "",
28 "foo",
29 "foo bar",
30 "foo bar \"bla \"",
31 "foo \"\" bla",
32 "bla \"\"\"\" blie",
33 NULL
36 static BOOL test_lists_shell(TALLOC_CTX *mem_ctx)
38 int i;
39 for (i = 0; test_lists_shell_strings[i]; i++) {
40 const char **ret1, **ret2, *tmp;
41 BOOL match = True;
43 ret1 = str_list_make_shell(mem_ctx, test_lists_shell_strings[i], " ");
44 tmp = str_list_join_shell(mem_ctx, ret1, ' ');
45 ret2 = str_list_make_shell(mem_ctx, tmp, " ");
47 if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
48 match = False;
49 } else {
50 int j;
51 for (j = 0; ret1[j] && ret2[j]; j++) {
52 if (strcmp(ret1[j], ret2[j]) != 0) {
53 match = False;
54 break;
58 if (ret1[j] || ret2[j])
59 match = False;
62 if (!match) {
63 printf("str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s\n",
64 test_lists_shell_strings[i],
65 tmp);
66 return False;
70 return True;
73 BOOL torture_local_util_strlist(struct torture_context *torture)
75 BOOL ret = True;
76 TALLOC_CTX *mem_ctx = talloc_init("test_util_strlist");
78 ret &= test_lists_shell(mem_ctx);
79 talloc_free(mem_ctx);
81 return ret;