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