This source file includes following definitions.
- setup
- teardown
- START_PARAMETRIZED_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #define TEST_SUITE_NAME "/lib/vfs"
27
28 #include "tests/mctest.h"
29
30 #include "lib/strutil.h"
31 #include "lib/vfs/xdirentry.h"
32 #include "lib/vfs/path.c"
33
34 #include "src/vfs/local/local.c"
35
36 static struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
37
38
39
40
41 static void
42 setup (void)
43 {
44 str_init_strings (NULL);
45
46 vfs_init ();
47 vfs_init_localfs ();
48 vfs_setup_work_dir ();
49
50 vfs_init_class (&vfs_test_ops1, "testfs1", VFSF_NOLINKS | VFSF_REMOTE, "test1");
51 vfs_register_class (&vfs_test_ops1);
52
53 vfs_init_class (&vfs_test_ops2, "testfs2", VFSF_UNKNOWN, "test2");
54 vfs_register_class (&vfs_test_ops2);
55
56 vfs_init_class (&vfs_test_ops3, "testfs3", VFSF_UNKNOWN, "test3");
57 vfs_register_class (&vfs_test_ops3);
58 }
59
60
61
62
63 static void
64 teardown (void)
65 {
66 vfs_shut ();
67 str_uninit_strings ();
68 }
69
70
71
72
73 static const struct test_vfs_split_ds
74 {
75 const char *input_string;
76 const char *expected_path;
77 const char *expected_local;
78 const char *expected_op;
79 const struct vfs_class *expected_result;
80 } test_vfs_split_ds[] = {
81 {
82
83 "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/#test3:/qqq/www/eee.rr",
84 "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/",
85 "qqq/www/eee.rr",
86 "test3:",
87 &vfs_test_ops3,
88 },
89 {
90
91 "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/",
92 "#test1:/bla-bla/some/path/",
93 "bla-bla/some/path2/",
94 "test2:",
95 &vfs_test_ops2,
96 },
97 {
98
99 "#test1:/bla-bla/some/path/",
100 "",
101 "bla-bla/some/path/",
102 "test1:",
103 &vfs_test_ops1,
104 },
105 {
106
107 "",
108 "",
109 NULL,
110 NULL,
111 NULL,
112 },
113 {
114
115 "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2#test3:/qqq/www/eee.rr",
116 "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2",
117 "qqq/www/eee.rr",
118 "test3:",
119 &vfs_test_ops3,
120 },
121 {
122
123 "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2",
124 "/local/path/#test1:/bla-bla/some/path/",
125 "bla-bla/some/path2",
126 "test2:",
127 &vfs_test_ops2,
128 },
129 {
130
131 "/local/path/#test1:/bla-bla/some/path/",
132 "/local/path/",
133 "bla-bla/some/path/",
134 "test1:",
135 &vfs_test_ops1,
136 },
137 {
138
139 "/local/path/",
140 "/local/path/",
141 NULL,
142 NULL,
143 NULL,
144 },
145 {
146
147 "#test2:username:passwd@somehost.net/bla-bla/some/path2",
148 "",
149 "bla-bla/some/path2",
150 "test2:username:passwd@somehost.net",
151 &vfs_test_ops2,
152 },
153 {
154
155 "/local/path/#test1:/bla-bla/some/path/#test2:username:p!a@s#s$w%d@somehost.net/bla-bla/"
156 "some/"
157 "path2",
158 "/local/path/#test1:/bla-bla/some/path/",
159 "bla-bla/some/path2",
160 "test2:username:p!a@s#s$w%d@somehost.net",
161 &vfs_test_ops2,
162 },
163 {
164
165 "#test2:/bl#a-bl#a/so#me/pa#th2",
166 "",
167 "bl#a-bl#a/so#me/pa#th2",
168 "test2:",
169 &vfs_test_ops2,
170 }
171 };
172
173
174 START_PARAMETRIZED_TEST (test_vfs_split, test_vfs_split_ds)
175 {
176
177 const char *local = NULL, *op = NULL;
178 struct vfs_class *actual_result;
179 char *path;
180
181 path = g_strdup (data->input_string);
182
183
184 actual_result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
185
186
187 mctest_assert_ptr_eq (actual_result, data->expected_result);
188 mctest_assert_str_eq (path, data->expected_path);
189 mctest_assert_str_eq (local, data->expected_local);
190 mctest_assert_str_eq (op, data->expected_op);
191 g_free (path);
192 }
193 END_PARAMETRIZED_TEST
194
195
196
197 int
198 main (void)
199 {
200 TCase *tc_core;
201
202 tc_core = tcase_create ("Core");
203
204 tcase_add_checked_fixture (tc_core, setup, teardown);
205
206
207 mctest_add_parameterized_test (tc_core, test_vfs_split, test_vfs_split_ds);
208
209
210 return mctest_run_all (tc_core);
211 }
212
213