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/charsets.h"
31 #include "lib/strutil.h"
32 #include "lib/util.h"
33 #include "lib/vfs/xdirentry.h"
34
35 #include "src/vfs/local/local.c"
36
37 static struct vfs_class vfs_test_ops;
38
39
40
41
42 static void
43 setup (void)
44 {
45 str_init_strings (NULL);
46
47 vfs_init ();
48 vfs_init_localfs ();
49 vfs_setup_work_dir ();
50
51 mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
52 load_codepages_list ();
53
54 vfs_init_class (&vfs_test_ops, "testfs", VFSF_NOLINKS | VFSF_REMOTE, "ftp");
55 vfs_register_class (&vfs_test_ops);
56 }
57
58
59
60
61 static void
62 teardown (void)
63 {
64 free_codepages_list ();
65 vfs_shut ();
66 str_uninit_strings ();
67 }
68
69
70
71
72 static const struct test_canonicalize_path_ds
73 {
74 const char *input_path;
75 const char *expected_path;
76 } test_canonicalize_path_ds[] = {
77 {
78
79 "//some_server/ww",
80 "//some_server/ww",
81 },
82 {
83
84 "///some_server/////////ww",
85 "/some_server/ww",
86 },
87 {
88
89 "//some_server//.///////ww/./././.",
90 "//some_server/ww",
91 },
92 {
93
94 "./some_server/ww",
95 "some_server/ww",
96 },
97 {
98
99 "some_server/..",
100 ".",
101 },
102 {
103
104 "/some_server/ww/some_server/../ww/../some_server/..//ww/some_server/ww",
105 "/some_server/ww/ww/some_server/ww",
106 },
107 {
108
109 "/some_server/ww/ftp://user:pass@host.net/path/",
110 "/some_server/ww/ftp://user:pass@host.net/path",
111 },
112 {
113
114 "/some_server/ww/ftp://user:pass@host.net/path/../../",
115 "/some_server/ww",
116 },
117 {
118
119 "ftp://user:pass@host.net/path/../../",
120 ".",
121 },
122 {
123
124 "ftp://user/../../",
125 "..",
126 },
127 {
128
129 "/b/#enc:utf-8/../c",
130 "/c",
131 },
132 {
133
134 "/b/#enc:aaaa/../c",
135 "/b/c",
136 },
137 {
138
139 "/b/../#enc:utf-8/c",
140 "/#enc:utf-8/c",
141 },
142 {
143
144 "/b/../#enc:aaaa/c",
145 "/#enc:aaaa/c",
146 },
147 {
148
149 "/b/c/#enc:utf-8/..",
150 "/b",
151 },
152 {
153
154 "/b/c/#enc:aaaa/..",
155 "/b/c",
156 },
157 {
158
159 "/b/c/../#enc:utf-8",
160 "/b/#enc:utf-8",
161 },
162 {
163
164 "/b/c/../#enc:aaaa",
165 "/b/#enc:aaaa",
166 },
167 };
168
169
170 START_PARAMETRIZED_TEST (test_canonicalize_path, test_canonicalize_path_ds)
171 {
172
173 char *actual_path;
174
175 actual_path = g_strdup (data->input_path);
176
177
178 canonicalize_pathname (actual_path);
179
180
181 mctest_assert_str_eq (actual_path, data->expected_path) g_free (actual_path);
182 }
183 END_PARAMETRIZED_TEST
184
185
186
187 int
188 main (void)
189 {
190 TCase *tc_core;
191
192 tc_core = tcase_create ("Core");
193
194 tcase_add_checked_fixture (tc_core, setup, teardown);
195
196
197 mctest_add_parameterized_test (tc_core, test_canonicalize_path, test_canonicalize_path_ds);
198
199
200 return mctest_run_all (tc_core);
201 }
202
203