VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTPath.cpp@ 85383

Last change on this file since 85383 was 85383, checked in by vboxsync, 5 years ago

iprt/path.h: RTPathFindCommon[Ex] doc & testcase update. Testcase moved into tstRTPath.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 60.1 KB
Line 
1/* $Id: tstRTPath.cpp 85383 2020-07-18 15:26:42Z vboxsync $ */
2/** @file
3 * IPRT Testcase - Test various path functions.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <iprt/path.h>
32
33#include <iprt/err.h>
34#include <iprt/initterm.h>
35#include <iprt/param.h>
36#include <iprt/process.h>
37#include <iprt/stream.h>
38#include <iprt/string.h>
39#include <iprt/test.h>
40
41
42static void testParserAndSplitter(RTTEST hTest)
43{
44 static struct
45 {
46 uint16_t cComps;
47 uint16_t cchPath;
48 uint16_t offSuffix;
49 int16_t offName; /**< RTPathParseSimple */
50 uint16_t cchDir; /**< RTPathParseSimple */
51 const char *pszPath;
52 uint16_t fProps;
53 uint32_t fFlags;
54 } const s_aTests[] =
55 {
56 { 2, 5, 5, -1, 4, "/bin/", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_DIR_SLASH, RTPATH_STR_F_STYLE_UNIX },
57 { 2, 13, 9, 3, 3, "C:/Config.sys", RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX, RTPATH_STR_F_STYLE_DOS },
58 { 2, 13, 10, 4, 4, "C://Config.sys", RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX | RTPATH_PROP_EXTRA_SLASHES, RTPATH_STR_F_STYLE_DOS },
59 { 2, 12, 8, 2, 2, "C:Config.sys", RTPATH_PROP_VOLUME | RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX, RTPATH_STR_F_STYLE_DOS },
60 { 1, 10, 6, 0, 0, "Config.sys", RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX, RTPATH_STR_F_STYLE_DOS },
61 { 3, 15, 11, 7, 6, "C:/Win/file.ext", RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX , RTPATH_STR_F_STYLE_DOS },
62 { 1, 4, 4, -1, 4, "//./", RTPATH_PROP_UNC | RTPATH_PROP_SPECIAL_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE, RTPATH_STR_F_STYLE_DOS },
63 { 2, 5, 5, 4, 4, "//./f", RTPATH_PROP_UNC | RTPATH_PROP_SPECIAL_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_DOS },
64 { 2, 5, 6, 5, 5, "//.//f", RTPATH_PROP_UNC | RTPATH_PROP_SPECIAL_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_EXTRA_SLASHES, RTPATH_STR_F_STYLE_DOS },
65 { 3, 7, 7, 6, 5, "//././f", RTPATH_PROP_UNC | RTPATH_PROP_SPECIAL_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOT_REFS, RTPATH_STR_F_STYLE_DOS },
66 { 3, 8, 8, 7, 6, "//.././f", RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOT_REFS, RTPATH_STR_F_STYLE_DOS },
67 { 3, 9, 9, 8, 7, "//../../f", RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOTDOT_REFS, RTPATH_STR_F_STYLE_DOS },
68 { 1, 1, 1, -1, 1, "/", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE, RTPATH_STR_F_STYLE_UNIX },
69 { 2, 4, 4, 1, 1, "/bin", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
70 { 2, 5, 5, -1, 4, "/bin/", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_DIR_SLASH, RTPATH_STR_F_STYLE_UNIX },
71 { 3, 7, 7, 5, 4, "/bin/ls", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
72 { 3, 12, 7, 5, 4, "/etc/rc.conf", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX, RTPATH_STR_F_STYLE_UNIX },
73 { 1, 1, 2, -1, 2, "//", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES, RTPATH_STR_F_STYLE_UNIX },
74 { 1, 1, 3, -1, 3, "///", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES, RTPATH_STR_F_STYLE_UNIX },
75 { 3, 6, 7, 4, 2, "/.//bin", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_DOT_REFS | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
76 { 1, 3, 3, 0, 0, "bin", RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
77 { 1, 4, 4, -1, 3, "bin/", RTPATH_PROP_RELATIVE | RTPATH_PROP_DIR_SLASH, RTPATH_STR_F_STYLE_UNIX },
78 { 1, 4, 7, -1, 3, "bin////", RTPATH_PROP_RELATIVE | RTPATH_PROP_DIR_SLASH | RTPATH_PROP_EXTRA_SLASHES, RTPATH_STR_F_STYLE_UNIX },
79 { 3, 10, 10, 7, 6, "bin/../usr", RTPATH_PROP_RELATIVE | RTPATH_PROP_DOTDOT_REFS | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
80 { 4, 11, 11, 8, 7, "/bin/../usr", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE | RTPATH_PROP_DOTDOT_REFS | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
81 { 4, 8, 8, 7, 6, "/a/.../u", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
82 { 4, 8, 8, 7, 6, "/a/.b./u", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
83 { 4, 8, 8, 7, 6, "/a/..c/u", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
84 { 4, 8, 8, 7, 6, "/a/d../u", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
85 { 4, 8, 8, 6, 5, "/a/.e/.u", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
86 { 4, 8, 8, 6, 5, "/a/.f/.u", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
87 { 4, 11, 7, 6, 5, "/a/.f/u.ext", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX, RTPATH_STR_F_STYLE_UNIX },
88 { 4, 8, 8, 6, 5, "/a/.g/u.", RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
89 { 3, 9, 10, 5, 4, "/a/h/u.ext", RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_RELATIVE, RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_MIDDLE },
90 { 3, 9, 9, 5, 3, "a/h/u.ext", RTPATH_PROP_RELATIVE, RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_MIDDLE },
91 { 3, 9, 10, -1, 10, "a/h/u.ext/", RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_RELATIVE, RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_MIDDLE },
92 };
93
94 char szPath1[RTPATH_MAX];
95 union
96 {
97 RTPATHPARSED Parsed;
98 RTPATHSPLIT Split;
99 uint8_t ab[4096];
100 } u;
101
102 RTTestSub(hTest, "RTPathParse");
103 for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
104 {
105 memset(&u, i & 1 ? 0xff : 0, sizeof(u));
106 int rc = RTPathParse(s_aTests[i].pszPath, &u.Parsed, sizeof(u), s_aTests[i].fFlags);
107 if ( rc != VINF_SUCCESS
108 || s_aTests[i].cComps != u.Parsed.cComps
109 || s_aTests[i].fProps != u.Parsed.fProps
110 || s_aTests[i].offSuffix != u.Parsed.offSuffix
111 || s_aTests[i].cchPath != u.Parsed.cchPath)
112 {
113 RTTestFailed(hTest, "i=%d rc=%Rrc %s", i, rc, s_aTests[i].pszPath);
114 RTTestFailureDetails(hTest,
115 " cComps %u, got %u\n"
116 " fProps %#x, got %#x, xor=>%#x\n"
117 " offSuffix %u, got %u\n"
118 " cchPath %u, got %u\n"
119 ,
120 s_aTests[i].cComps, u.Parsed.cComps,
121 s_aTests[i].fProps, u.Parsed.fProps, s_aTests[i].fProps ^ u.Parsed.fProps,
122 s_aTests[i].offSuffix, u.Parsed.offSuffix,
123 s_aTests[i].cchPath, u.Parsed.cchPath);
124 }
125 else
126 {
127 rc = RTPathParsedReassemble(s_aTests[i].pszPath, &u.Parsed, s_aTests[i].fFlags & ~RTPATH_STR_F_MIDDLE,
128 szPath1, sizeof(szPath1));
129 if (rc == VINF_SUCCESS)
130 {
131 RTTESTI_CHECK_MSG(strlen(szPath1) == s_aTests[i].cchPath, ("%s\n", szPath1));
132 if ( !(u.Parsed.fProps & RTPATH_PROP_EXTRA_SLASHES)
133 && (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_DOS)
134 RTTESTI_CHECK_MSG(strcmp(szPath1, s_aTests[i].pszPath) == 0, ("%s\n", szPath1));
135 }
136 else
137 RTTestIFailed("RTPathParsedReassemble -> %Rrc", rc);
138 }
139 }
140
141 RTTestSub(hTest, "RTPathSplit");
142 for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
143 {
144 memset(&u, i & 1 ? 0xff : 0, sizeof(u));
145 int rc = RTPathSplit(s_aTests[i].pszPath, &u.Split, sizeof(u), s_aTests[i].fFlags);
146 if ( rc != VINF_SUCCESS
147 || s_aTests[i].cComps != u.Split.cComps
148 || s_aTests[i].fProps != u.Split.fProps
149 || s_aTests[i].cchPath != u.Split.cchPath)
150 {
151 RTTestFailed(hTest, "i=%d rc=%Rrc %s", i, rc, s_aTests[i].pszPath);
152 RTTestFailureDetails(hTest,
153 " cComps %u, got %u\n"
154 " fProps %#x, got %#x, xor=>%#x\n"
155 " cchPath %u, got %u\n"
156 ,
157 s_aTests[i].cComps, u.Split.cComps,
158 s_aTests[i].fProps, u.Split.fProps, s_aTests[i].fProps ^ u.Split.fProps,
159 s_aTests[i].cchPath, u.Split.cchPath);
160 }
161 else
162 {
163 RTTESTI_CHECK_MSG(*u.Split.pszSuffix == '\0' || *u.Split.pszSuffix == '.', ("%s", u.Split.pszSuffix));
164 for (uint32_t idxComp = RTPATH_PROP_HAS_ROOT_SPEC(u.Split.fProps); idxComp < u.Split.cComps; idxComp++)
165 if ( (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) == RTPATH_STR_F_STYLE_DOS
166 ? strpbrk(u.Split.apszComps[idxComp], "/\\")
167 : strchr(u.Split.apszComps[idxComp], RTPATH_SLASH) )
168 RTTestFailed(hTest, "i=%d idxComp=%d '%s'", i, idxComp, u.Split.apszComps[idxComp]);
169
170 PRTPATHSPLIT pSplit = NULL;
171 RTTESTI_CHECK_RC(rc = RTPathSplitA(s_aTests[i].pszPath, &pSplit, s_aTests[i].fFlags), VINF_SUCCESS);
172 if (RT_SUCCESS(rc))
173 {
174 RTTESTI_CHECK(pSplit);
175 RTTESTI_CHECK(pSplit->cComps == u.Split.cComps);
176 RTTESTI_CHECK(pSplit->fProps == u.Split.fProps);
177 RTTESTI_CHECK(pSplit->cchPath == u.Split.cchPath);
178 RTTESTI_CHECK(pSplit->cbNeeded == u.Split.cbNeeded);
179 RTTESTI_CHECK(!strcmp(pSplit->pszSuffix, u.Split.pszSuffix));
180 for (uint32_t idxComp = 0; idxComp < u.Split.cComps; idxComp++)
181 RTTESTI_CHECK(!strcmp(pSplit->apszComps[idxComp], u.Split.apszComps[idxComp]));
182 RTPathSplitFree(pSplit);
183 }
184
185 rc = RTPathSplitReassemble(&u.Split, s_aTests[i].fFlags & ~RTPATH_STR_F_MIDDLE, szPath1, sizeof(szPath1));
186 if (rc == VINF_SUCCESS)
187 {
188 RTTESTI_CHECK_MSG(strlen(szPath1) == s_aTests[i].cchPath, ("%s\n", szPath1));
189 if ( !(u.Parsed.fProps & RTPATH_PROP_EXTRA_SLASHES)
190 && (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_DOS)
191 RTTESTI_CHECK_MSG(strcmp(szPath1, s_aTests[i].pszPath) == 0, ("%s\n", szPath1));
192 }
193 else
194 RTTestIFailed("RTPathSplitReassemble -> %Rrc", rc);
195 }
196 }
197
198 RTTestSub(hTest, "RTPathParseSimple");
199 for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
200 {
201 if ( (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_HOST
202 && (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) != RTPATH_STYLE)
203 continue;
204 if (s_aTests[i].fFlags & ~RTPATH_STR_F_STYLE_MASK)
205 continue;
206
207 size_t const cchPathIn = strlen(s_aTests[i].pszPath);
208 size_t cchDir = ~(size_t)1;
209 ssize_t offName = -97;
210 ssize_t offSuff = -99;
211 size_t cchPath = RTPathParseSimple(s_aTests[i].pszPath, &cchDir, &offName, &offSuff);
212 if ( cchPath != cchPathIn
213 || offSuff != (s_aTests[i].offSuffix >= cchPathIn ? -1 : s_aTests[i].offSuffix)
214 || offName != s_aTests[i].offName
215 || cchDir != s_aTests[i].cchDir)
216 {
217 RTTestFailed(hTest, "i=%u %s", i, s_aTests[i].pszPath);
218 RTTestFailureDetails(hTest,
219 " cchPath %zu, got %zu\n"
220 " cchDir %u, got %zu\n"
221 " offName %d, got %zd\n"
222 " offSuff %d, got %zd\n"
223 ,
224 cchPathIn, cchPath,
225 s_aTests[i].cchDir, cchDir,
226 s_aTests[i].offName, offName,
227 (s_aTests[i].offSuffix >= cchPathIn ? -1 : s_aTests[i].offSuffix), offSuff);
228 }
229 }
230}
231
232
233static void testParentLength(RTTEST hTest)
234{
235 static struct
236 {
237 const char *pszPath;
238 uint32_t cchNonParent;
239 uint32_t fFlags;
240 } const s_aTests[] =
241 {
242 { "/usr/bin", 3, RTPATH_STR_F_STYLE_UNIX },
243 { "/usr/bin", 3, RTPATH_STR_F_STYLE_DOS },
244 { "\\usr\\bin", 3, RTPATH_STR_F_STYLE_DOS },
245 { "/usr/bin/", 4, RTPATH_STR_F_STYLE_UNIX },
246 { "/usr/bin/", 4, RTPATH_STR_F_STYLE_DOS },
247 { "\\usr\\bin\\", 4, RTPATH_STR_F_STYLE_DOS },
248 { "A:\\usr\\bin\\", 4, RTPATH_STR_F_STYLE_DOS },
249 { "/bin", 3, RTPATH_STR_F_STYLE_UNIX },
250 { "/bin", 3, RTPATH_STR_F_STYLE_DOS },
251 { "\\bin", 3, RTPATH_STR_F_STYLE_DOS },
252 { "A:\\bin", 3, RTPATH_STR_F_STYLE_DOS },
253 { "A:/bin", 3, RTPATH_STR_F_STYLE_DOS },
254 { "A:bin", 3, RTPATH_STR_F_STYLE_DOS },
255 { "/bin/", 4, RTPATH_STR_F_STYLE_UNIX },
256 { "/bin/", 4, RTPATH_STR_F_STYLE_DOS },
257 { "A:\\bin\\", 4, RTPATH_STR_F_STYLE_DOS },
258 { "A:/bin\\", 4, RTPATH_STR_F_STYLE_DOS },
259 { "A:bin\\", 4, RTPATH_STR_F_STYLE_DOS },
260 { "/", 0, RTPATH_STR_F_STYLE_UNIX },
261 { "/", 0, RTPATH_STR_F_STYLE_DOS },
262 { "\\", 0, RTPATH_STR_F_STYLE_DOS },
263 { "A:\\", 0, RTPATH_STR_F_STYLE_DOS },
264 { "A:", 0, RTPATH_STR_F_STYLE_DOS },
265 { "bin", 3, RTPATH_STR_F_STYLE_UNIX },
266 { "bin", 3, RTPATH_STR_F_STYLE_DOS },
267 { "//unc/bin/bin", 3, RTPATH_STR_F_STYLE_DOS },
268 { "//unc/bin/bin/", 4, RTPATH_STR_F_STYLE_DOS },
269 { "//unc/bin", 3, RTPATH_STR_F_STYLE_DOS },
270 { "//unc/bin/", 4, RTPATH_STR_F_STYLE_DOS },
271 { "//unc/", 0, RTPATH_STR_F_STYLE_DOS },
272 { "//unc", 0, RTPATH_STR_F_STYLE_DOS },
273 };
274
275 RTTestSub(hTest, "RTPathParentLength");
276 for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
277 {
278 size_t const cchParent = RTPathParentLengthEx(s_aTests[i].pszPath, s_aTests[i].fFlags);
279 size_t const cchExpected = strlen(s_aTests[i].pszPath) - s_aTests[i].cchNonParent;
280 if (cchParent != cchExpected)
281 RTTestFailed(hTest, "sub-test #%u: got %u, expected %u (%s)",
282 i, cchParent, cchExpected, s_aTests[i].pszPath);
283 if (s_aTests[i].fFlags == RTPATH_STYLE)
284 {
285 size_t const cchParent2 = RTPathParentLength(s_aTests[i].pszPath);
286 if (cchParent2 != cchExpected)
287 RTTestFailed(hTest, "sub-test #%u: RTPathParentLength returned %u, expected %u (%s)",
288 i, cchParent2, cchExpected, s_aTests[i].pszPath);
289 }
290 }
291}
292
293
294static void testPurgeFilename(RTTEST hTest)
295{
296 static struct
297 {
298 const char *pszIn, *pszOut;
299 uint32_t fFlags;
300 } const s_aTests[] =
301 {
302 { "start///end", "start___end", RTPATH_STR_F_STYLE_UNIX },
303 { "start///end", "start___end", RTPATH_STR_F_STYLE_DOS },
304 { "start///end", "start___end", RTPATH_STR_F_STYLE_HOST },
305 { "1:<>\\9", "1:<>\\9", RTPATH_STR_F_STYLE_UNIX },
306 { "1:<>\\9", "1____9", RTPATH_STR_F_STYLE_DOS },
307 { "\t\r\n", "\t\r\n", RTPATH_STR_F_STYLE_UNIX },
308 { "\t\r\n", "___", RTPATH_STR_F_STYLE_DOS },
309 };
310 RTTestSub(hTest, "RTPathPurgeFilename");
311 for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
312 {
313 char szPath[RTPATH_MAX];
314 strcpy(szPath, s_aTests[i].pszIn);
315 char *pszRet = RTPathPurgeFilename(szPath, s_aTests[i].fFlags);
316 RTTEST_CHECK(hTest, pszRet == &szPath[0]);
317 if (strcmp(szPath, s_aTests[i].pszOut) != 0)
318 RTTestFailed(hTest, "sub-test #%u: got '%s', expected '%s' (style %#x)",
319 i, szPath, s_aTests[i].pszOut, s_aTests[i].fFlags);
320 }
321}
322
323
324static void testEnsureTrailingSeparator(RTTEST hTest)
325{
326 static struct
327 {
328 const char *pszIn, *pszOut;
329 uint32_t fFlags;
330 } const s_aTests[] =
331 {
332 { "/foo", "/foo/", RTPATH_STR_F_STYLE_UNIX },
333 { "/foo\\", "/foo\\/", RTPATH_STR_F_STYLE_UNIX },
334 { "/foo:", "/foo:/", RTPATH_STR_F_STYLE_UNIX },
335 { "/foo/", "/foo/", RTPATH_STR_F_STYLE_UNIX },
336 { "D:/foo", "D:/foo\\", RTPATH_STR_F_STYLE_DOS },
337 { "D:/foo\\", "D:/foo\\", RTPATH_STR_F_STYLE_DOS },
338 { "", "./", RTPATH_STR_F_STYLE_UNIX},
339 { "", ".\\", RTPATH_STR_F_STYLE_DOS },
340 { "", "." RTPATH_SLASH_STR, RTPATH_STR_F_STYLE_HOST },
341 { ".", "." RTPATH_SLASH_STR, RTPATH_STR_F_STYLE_HOST },
342 { "x", "x" RTPATH_SLASH_STR, RTPATH_STR_F_STYLE_HOST },
343 { "y" RTPATH_SLASH_STR, "y" RTPATH_SLASH_STR, RTPATH_STR_F_STYLE_HOST },
344 };
345 RTTestSub(hTest, "RTPathEnsureTrailingSeparatorEx");
346 for (uint32_t i = 0; i < RT_ELEMENTS(s_aTests); i++)
347 {
348 char szPath[RTPATH_MAX];
349 strcpy(szPath, s_aTests[i].pszIn);
350 size_t cchRet = RTPathEnsureTrailingSeparatorEx(szPath, sizeof(szPath), s_aTests[i].fFlags);
351 RTTEST_CHECK(hTest, cchRet == strlen(s_aTests[i].pszOut));
352 if (strcmp(szPath, s_aTests[i].pszOut) != 0)
353 RTTestFailed(hTest, "sub-test #%u: got '%s', expected '%s' (style %#x)",
354 i, szPath, s_aTests[i].pszOut, s_aTests[i].fFlags);
355 }
356}
357
358
359static void testFindCommon(RTTEST hTest)
360{
361 RTTestSub(hTest, "RTPathFindCommon");
362
363 static struct
364 {
365 char const *apszPaths[4];
366 uint32_t fFlags;
367 char const *pszCommon;
368 } const aTests[] =
369 {
370 /* Simple stuff first. */
371 { { "", "", "", NULL, }, RTPATH_STR_F_STYLE_UNIX,
372 "" },
373 { { "none", "none", "", NULL, }, RTPATH_STR_F_STYLE_UNIX,
374 "" },
375 /* Missing start slash. */
376 { { "/path/to/stuff1", "path/to/stuff2", NULL, NULL, }, RTPATH_STR_F_STYLE_UNIX,
377 "" },
378 /* Working stuff. */
379 { { "/path/to/stuff1", "/path/to/stuff2", "/path/to/stuff3", NULL, }, RTPATH_STR_F_STYLE_UNIX,
380 "/path/to/" },
381 { { "/path/to/stuff1", "/path/to/", "/path/", NULL, }, RTPATH_STR_F_STYLE_UNIX,
382 "/path/" },
383 { { "/path/to/stuff1", "/", "/path/", NULL, }, RTPATH_STR_F_STYLE_UNIX,
384 "" },
385 { { "/path/to/../stuff1", "./../", "/path/to/stuff2/..", NULL, }, RTPATH_STR_F_STYLE_UNIX,
386 "" },
387
388#if 0 /** @todo */
389 /* Things that should be working that aren't: */
390 { { "a/single/path", NULL, NULL, NULL, }, RTPATH_STR_F_STYLE_UNIX,
391 "a/single/path" },
392 { { "a/single\\path", NULL, NULL, NULL, }, RTPATH_STR_F_STYLE_DOS,
393 "a/single\\path" },
394 { { "C:\\Windows", NULL, NULL, NULL, }, RTPATH_STR_F_STYLE_DOS,
395 "C:\\Windows" },
396 { { "c:/windows", "c:\\program files", "C:\\AppData", NULL, }, RTPATH_STR_F_STYLE_DOS,
397 "c:/" },
398 { { "//usr/bin/env", "/usr//bin/env", "/usr/bin///env", "/usr/bin/env", }, RTPATH_STR_F_STYLE_UNIX,
399 "//usr/bin/env" },
400 { { "//usr/bin/env", "/usr//./././bin/env", "/usr/bin///env", "/usr/bin/env", }, RTPATH_STR_F_STYLE_UNIX,
401 "//usr/bin/env" },
402 { { "//./what/ever", "\\\\.\\what\\is\\up", "\\\\.\\\\what\\is\\up", NULL, }, RTPATH_STR_F_STYLE_DOS,
403 "//./what/" },
404 { { "//./unc/is/weird", "///./unc/is/weird", NULL, NULL, }, RTPATH_STR_F_STYLE_DOS,
405 "" },
406 { { "/path/to/stuff1", "path/to/stuff2", NULL, NULL, }, RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_NO_START,
407 "/path/to/" },
408 { { "path/to/stuff1", "//path\\/to\\stuff2", NULL, NULL, }, RTPATH_STR_F_STYLE_DOS | RTPATH_STR_F_NO_START,
409 "path/to/" },
410
411 /* '..' elements are not supported for now and leads to zero return. */
412 { { "/usr/bin/env", "/usr/../usr/bin/env", "/usr/bin/../bin/env", NULL, }, RTPATH_STR_F_STYLE_UNIX,
413 "" },
414 { { "/lib/", "/lib/amd64/../lib.so", "/lib/i386/../libdl.so", NULL, }, RTPATH_STR_F_STYLE_UNIX,
415 "" },
416#endif
417 };
418
419 for (size_t i = 0; i < RT_ELEMENTS(aTests); i++)
420 {
421 size_t cPaths = RT_ELEMENTS(aTests[i].apszPaths);
422 while (cPaths > 0 && aTests[i].apszPaths[cPaths - 1] == NULL)
423 cPaths--;
424
425 size_t const cchCommon = RTPathFindCommonEx(cPaths, aTests[i].apszPaths, aTests[i].fFlags);
426 size_t const cchExpect = strlen(aTests[i].pszCommon);
427 if (cchCommon != cchExpect)
428 RTTestFailed(hTest,
429 "Test %zu failed: got %zu, expected %zu (cPaths=%zu: '%s' '%s' '%s' '%s', fFlags=%#x)", i, cchCommon,
430 cchExpect, cPaths, aTests[i].apszPaths[0], aTests[i].apszPaths[1], aTests[i].apszPaths[2],
431 aTests[i].apszPaths[3], aTests[i].fFlags);
432 }
433}
434
435
436int main()
437{
438 char szPath[RTPATH_MAX];
439
440 /*
441 * Init RT+Test.
442 */
443 RTTEST hTest;
444 int rc = RTTestInitAndCreate("tstRTPath", &hTest);
445 if (rc)
446 return rc;
447 RTTestBanner(hTest);
448
449 RTTestSub(hTest, "Environment");
450#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
451 RTTESTI_CHECK(RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS);
452# if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
453# else
454 RTTestIFailed("#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS");
455# endif
456 RTTESTI_CHECK(strcmp(RTPATH_SLASH_STR, "\\") == 0);
457 RTTESTI_CHECK(RTPATH_SLASH == '\\');
458 RTTESTI_CHECK(RTPATH_IS_SEP('/'));
459 RTTESTI_CHECK(RTPATH_IS_SEP('\\'));
460 RTTESTI_CHECK(RTPATH_IS_SEP(':'));
461
462#else
463 RTTESTI_CHECK(RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX);
464# if RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
465# else
466 RTTestIFailed("#if RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX");
467# endif
468 RTTESTI_CHECK(strcmp(RTPATH_SLASH_STR, "/") == 0);
469 RTTESTI_CHECK(RTPATH_SLASH == '/');
470 RTTESTI_CHECK(RTPATH_IS_SEP('/'));
471 RTTESTI_CHECK(!RTPATH_IS_SEP('\\'));
472 RTTESTI_CHECK(!RTPATH_IS_SEP(':'));
473#endif
474
475 /*
476 * RTPathExecDir, RTPathUserHome and RTProcGetExecutablePath.
477 */
478 RTTestSub(hTest, "RTPathExecDir");
479 RTTESTI_CHECK_RC(rc = RTPathExecDir(szPath, sizeof(szPath)), VINF_SUCCESS);
480 if (RT_SUCCESS(rc))
481 RTTestIPrintf(RTTESTLVL_INFO, "ExecDir={%s}\n", szPath);
482
483 RTTestSub(hTest, "RTProcGetExecutablePath");
484 if (RTProcGetExecutablePath(szPath, sizeof(szPath)) == szPath)
485 RTTestIPrintf(RTTESTLVL_INFO, "ExecutableName={%s}\n", szPath);
486 else
487 RTTestIFailed("RTProcGetExecutablePath -> NULL");
488
489 RTTestSub(hTest, "RTPathUserHome");
490 RTTESTI_CHECK_RC(rc = RTPathUserHome(szPath, sizeof(szPath)), VINF_SUCCESS);
491 if (RT_SUCCESS(rc))
492 RTTestIPrintf(RTTESTLVL_INFO, "UserHome={%s}\n", szPath);
493
494 RTTestSub(hTest, "RTPathUserDocuments");
495 RTTESTI_CHECK_RC(rc = RTPathUserDocuments(szPath, sizeof(szPath)), VINF_SUCCESS);
496 if (RT_SUCCESS(rc))
497 RTTestIPrintf(RTTESTLVL_INFO, "UserDocuments={%s}\n", szPath);
498
499 RTTestSub(hTest, "RTPathTemp");
500 RTTESTI_CHECK_RC(rc = RTPathTemp(szPath, sizeof(szPath)), VINF_SUCCESS);
501 if (RT_SUCCESS(rc))
502 RTTestIPrintf(RTTESTLVL_INFO, "PathTemp={%s}\n", szPath);
503 size_t cch = strlen(szPath);
504 RTTESTI_CHECK_RC(RTPathTemp(szPath, cch), VERR_BUFFER_OVERFLOW);
505 RTTESTI_CHECK_RC(RTPathTemp(szPath, cch+1), VINF_SUCCESS);
506 RTTESTI_CHECK_RC(RTPathTemp(szPath, cch+2), VINF_SUCCESS);
507
508
509 /*
510 * RTPathAbsEx.
511 */
512 RTTestSub(hTest, "RTPathAbsEx");
513 static const struct
514 {
515 uint32_t fFlags;
516 const char *pcszInputBase;
517 const char *pcszInputPath;
518 int rc;
519 const char *pcszOutput;
520 }
521 s_aRTPathAbsExTests[] =
522 {
523 { RTPATH_STR_F_STYLE_HOST, NULL, "", VERR_PATH_ZERO_LENGTH, NULL },
524 { RTPATH_STR_F_STYLE_HOST, NULL, ".", VINF_SUCCESS, "%p" },
525#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
526 { RTPATH_STR_F_STYLE_DOS, NULL, "\\", VINF_SUCCESS, "%d\\" },
527 { RTPATH_STR_F_STYLE_DOS, NULL, "\\..", VINF_SUCCESS, "%d\\" },
528 { RTPATH_STR_F_STYLE_DOS, NULL, "/absolute/..", VINF_SUCCESS, "%d\\" },
529 { RTPATH_STR_F_STYLE_DOS, NULL, "/absolute\\\\../..", VINF_SUCCESS, "%d\\" },
530 { RTPATH_STR_F_STYLE_DOS, NULL, "/absolute//../path\\", VINF_SUCCESS, "%d\\path\\" },
531 { RTPATH_STR_F_STYLE_DOS, NULL, "/absolute/../../path", VINF_SUCCESS, "%d\\path" },
532 { RTPATH_STR_F_STYLE_DOS, NULL, "relative/../dir\\.\\.\\.\\file.txt", VINF_SUCCESS, "%p\\dir\\file.txt" },
533 { RTPATH_STR_F_STYLE_DOS, NULL, "\\data\\", VINF_SUCCESS, "%d\\data\\" },
534 { RTPATH_STR_F_STYLE_DOS, "relative_base/dir\\", "\\from_root", VINF_SUCCESS, "%d\\from_root" },
535 { RTPATH_STR_F_STYLE_DOS, "relative_base/dir/", "relative_also", VINF_SUCCESS, "%p\\relative_base\\dir\\relative_also" },
536#else
537 { RTPATH_STR_F_STYLE_UNIX, NULL, ".", VINF_SUCCESS, "%p" },
538 { RTPATH_STR_F_STYLE_UNIX, NULL, "relative/../dir/./././file.txt", VINF_SUCCESS, "%p/dir/file.txt" },
539 { RTPATH_STR_F_STYLE_UNIX, NULL, "relative/../dir\\.\\.\\.\\file.txt", VINF_SUCCESS, "%p/dir\\.\\.\\.\\file.txt" }, /* linux-specific */
540 { RTPATH_STR_F_STYLE_UNIX, "relative_base/dir/", "/from_root", VINF_SUCCESS, "/from_root" },
541 { RTPATH_STR_F_STYLE_UNIX, "relative_base/dir/", "relative_also", VINF_SUCCESS, "%p/relative_base/dir/relative_also" },
542#endif
543 { RTPATH_STR_F_STYLE_UNIX, NULL, "/", VINF_SUCCESS, "/" },
544 { RTPATH_STR_F_STYLE_UNIX, NULL, "/..", VINF_SUCCESS, "/" },
545 { RTPATH_STR_F_STYLE_UNIX, NULL, "/absolute/..", VINF_SUCCESS, "/" },
546 { RTPATH_STR_F_STYLE_UNIX, NULL, "/absolute\\\\../..", VINF_SUCCESS, "/" },
547 { RTPATH_STR_F_STYLE_UNIX, NULL, "/absolute//../path/", VINF_SUCCESS, "/path/" },
548 { RTPATH_STR_F_STYLE_UNIX, NULL, "/absolute/../../path", VINF_SUCCESS, "/path" },
549 { RTPATH_STR_F_STYLE_UNIX, NULL, "/data/", VINF_SUCCESS, "/data/" },
550#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
551 { RTPATH_STR_F_STYLE_DOS, NULL, "C:\\", VINF_SUCCESS, "C:\\" },
552 { RTPATH_STR_F_STYLE_DOS, "C:\\", "..", VINF_SUCCESS, "C:\\" },
553 { RTPATH_STR_F_STYLE_DOS, "C:\\temp", "..", VINF_SUCCESS, "C:\\" },
554 { RTPATH_STR_F_STYLE_DOS, "C:\\VirtualBox/Machines", "..\\VirtualBox.xml", VINF_SUCCESS, "C:\\VirtualBox\\VirtualBox.xml" },
555 { RTPATH_STR_F_STYLE_DOS, "C:\\MustDie", "\\from_root/dir/..", VINF_SUCCESS, "C:\\from_root" },
556 { RTPATH_STR_F_STYLE_DOS, "C:\\temp", "D:\\data", VINF_SUCCESS, "D:\\data" },
557 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\server\\..\\share", VINF_SUCCESS, "\\\\server\\..\\share" /* kind of strange */ },
558 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\server/", VINF_SUCCESS, "\\\\server\\" },
559 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\", VINF_SUCCESS, "\\\\" },
560 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\\\something", VINF_SUCCESS, "\\\\\\something" /* kind of strange */ },
561 { RTPATH_STR_F_STYLE_DOS, "\\\\server\\share_as_base", "/from_root", VINF_SUCCESS, "\\\\server\\share_as_base\\from_root" },
562 { RTPATH_STR_F_STYLE_DOS, "\\\\just_server", "/from_root", VINF_SUCCESS, "\\\\just_server\\from_root" },
563 { RTPATH_STR_F_STYLE_DOS, "\\\\server\\share_as_base", "relative\\data", VINF_SUCCESS, "\\\\server\\share_as_base\\relative\\data" },
564 { RTPATH_STR_F_STYLE_DOS, "base", "\\\\?\\UNC\\relative/edwef/..", VINF_SUCCESS, "\\\\?\\UNC\\relative" },
565 { RTPATH_STR_F_STYLE_DOS, "\\\\?\\UNC\\base", "/from_root", VINF_SUCCESS, "\\\\?\\from_root" },
566 { RTPATH_STR_F_STYLE_DOS, "\\\\?\\UNC\\base", "./..", VINF_SUCCESS, "\\\\?\\UNC" },
567 { RTPATH_STR_F_STYLE_DOS | RTPATHABS_F_STOP_AT_BASE, "\\\\?\\UNC\\base", "./..", VINF_SUCCESS, "\\\\?\\UNC\\base" },
568 { RTPATH_STR_F_STYLE_DOS | RTPATHABS_F_STOP_AT_BASE, "\\\\?\\UNC\\base", "/..", VINF_SUCCESS, "\\\\?\\" },
569 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\.\\asdf\\..", VINF_SUCCESS, "\\\\.\\" },
570 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\?\\asdf\\..", VINF_SUCCESS, "\\\\?\\" },
571 { RTPATH_STR_F_STYLE_DOS, NULL, "\\\\x\\asdf\\..", VINF_SUCCESS, "\\\\x\\asdf" },
572#else
573 { RTPATH_STR_F_STYLE_UNIX, "\\temp", "\\data", VINF_SUCCESS, "%p/\\temp/\\data" },
574#endif
575 { RTPATH_STR_F_STYLE_UNIX, "/VirtualBox/Machines", "../VirtualBox.xml", VINF_SUCCESS, "/VirtualBox/VirtualBox.xml" },
576 { RTPATH_STR_F_STYLE_UNIX, "/MustDie", "/from_root/dir/..", VINF_SUCCESS, "/from_root" },
577 { RTPATH_STR_F_STYLE_UNIX, "/temp", "..", VINF_SUCCESS, "/" },
578 };
579
580 char *pszGuardedBuf = NULL;
581 rc = RTTestGuardedAlloc(hTest, RTPATH_MAX, 0, false /*fHead*/, (void **)&pszGuardedBuf);
582 if (RT_FAILURE(rc))
583 pszGuardedBuf = szPath;
584
585 for (unsigned i = 0; i < RT_ELEMENTS(s_aRTPathAbsExTests); ++ i)
586 {
587 if (RT_FAILURE(s_aRTPathAbsExTests[i].rc))
588 RTTestDisableAssertions(hTest);
589
590 size_t cbAbsPath = sizeof(szPath);
591 rc = RTPathAbsEx(s_aRTPathAbsExTests[i].pcszInputBase,
592 s_aRTPathAbsExTests[i].pcszInputPath,
593 s_aRTPathAbsExTests[i].fFlags,
594 szPath, &cbAbsPath);
595
596 if (RT_FAILURE(s_aRTPathAbsExTests[i].rc))
597 RTTestRestoreAssertions(hTest);
598
599 if (rc != s_aRTPathAbsExTests[i].rc)
600 {
601 RTTestIFailed("#%u: unexpected result code!\n"
602 " flags: %#x\n"
603 " input base: '%s'\n"
604 " input path: '%s'\n"
605 " output: '%s'\n"
606 " rc: %Rrc\n"
607 " expected rc: %Rrc",
608 i,
609 s_aRTPathAbsExTests[i].fFlags,
610 s_aRTPathAbsExTests[i].pcszInputBase,
611 s_aRTPathAbsExTests[i].pcszInputPath,
612 szPath, rc,
613 s_aRTPathAbsExTests[i].rc);
614 continue;
615 }
616
617 char szTmp[RTPATH_MAX];
618 char *pszExpected = NULL;
619 if (s_aRTPathAbsExTests[i].pcszOutput != NULL)
620 {
621 if (s_aRTPathAbsExTests[i].pcszOutput[0] == '%')
622 {
623 RTTESTI_CHECK_RC(rc = RTPathGetCurrent(szTmp, sizeof(szTmp)), VINF_SUCCESS);
624 if (RT_FAILURE(rc))
625 break;
626
627 pszExpected = szTmp;
628
629 if (s_aRTPathAbsExTests[i].pcszOutput[1] == 'p')
630 {
631 cch = strlen(szTmp);
632 if (cch + strlen(s_aRTPathAbsExTests[i].pcszOutput) - 2 <= sizeof(szTmp))
633 strcpy(szTmp + cch, s_aRTPathAbsExTests[i].pcszOutput + 2);
634 }
635#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
636 else if (s_aRTPathAbsExTests[i].pcszOutput[1] == 'd')
637 {
638 if (2 + strlen(s_aRTPathAbsExTests[i].pcszOutput) - 2 <= sizeof(szTmp))
639 strcpy(szTmp + 2, s_aRTPathAbsExTests[i].pcszOutput + 2);
640 }
641#endif
642 }
643 else
644 {
645 strcpy(szTmp, s_aRTPathAbsExTests[i].pcszOutput);
646 pszExpected = szTmp;
647 }
648
649 if ( strcmp(szPath, pszExpected)
650 || strlen(szPath) != cbAbsPath)
651 {
652 RTTestIFailed("#%u: Unexpected result\n"
653 " flags: %#x\n"
654 " input base: '%s'\n"
655 " input path: '%s'\n"
656 " output: '%s'\n"
657 " expected: '%s' ('%s')\n"
658 " cchResult: %#x, actual %#x",
659 i,
660 s_aRTPathAbsExTests[i].fFlags,
661 s_aRTPathAbsExTests[i].pcszInputBase,
662 s_aRTPathAbsExTests[i].pcszInputPath,
663 szPath,
664 pszExpected, s_aRTPathAbsExTests[i].pcszOutput,
665 cbAbsPath, strlen(szPath));
666 continue;
667 }
668
669 if (RT_SUCCESS(s_aRTPathAbsExTests[i].rc))
670 {
671 /* Test the RTPATHABS_F_ENSURE_TRAILING_SLASH flag: */
672 cbAbsPath = sizeof(szPath);
673 rc = RTPathAbsEx(s_aRTPathAbsExTests[i].pcszInputBase,
674 s_aRTPathAbsExTests[i].pcszInputPath,
675 s_aRTPathAbsExTests[i].fFlags | RTPATHABS_F_ENSURE_TRAILING_SLASH,
676 szPath, &cbAbsPath);
677 char chSlash = (s_aRTPathAbsExTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) == RTPATH_STR_F_STYLE_DOS ? '\\'
678 : (s_aRTPathAbsExTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) == RTPATH_STR_F_STYLE_UNIX ? '/'
679 : RTPATH_SLASH;
680 if ( RT_FAILURE(rc)
681 || strlen(szPath) != cbAbsPath
682 || szPath[cbAbsPath - 1] != chSlash)
683 RTTestIFailed("#%u: Unexpected RTPATHABS_F_ENSURE_TRAILING_SLASH result: %Rrc\n"
684 " flags: %#x | RTPATHABS_F_ENSURE_TRAILING_SLASH\n"
685 " input base: '%s'\n"
686 " input path: '%s'\n"
687 " output: '%s' ('%c' vs '%c')\n"
688 " cchResult: %#x, actual %#x",
689 i, rc,
690 s_aRTPathAbsExTests[i].fFlags,
691 s_aRTPathAbsExTests[i].pcszInputBase,
692 s_aRTPathAbsExTests[i].pcszInputPath,
693 szPath, szPath[cbAbsPath - 1], chSlash,
694 cbAbsPath, strlen(szPath));
695
696 /* Do overflow testing: */
697 size_t const cbNeeded = strlen(pszExpected) + 1;
698 for (size_t cbBuf = 0; cbBuf < cbNeeded + 64; cbBuf++)
699 {
700 char *pszBuf = &pszGuardedBuf[RTPATH_MAX - cbBuf];
701 memset(pszBuf, 0x33, cbBuf);
702 cbAbsPath = cbBuf;
703 rc = RTPathAbsEx(s_aRTPathAbsExTests[i].pcszInputBase, s_aRTPathAbsExTests[i].pcszInputPath,
704 s_aRTPathAbsExTests[i].fFlags, pszBuf, &cbAbsPath);
705 if ( cbBuf < cbNeeded
706 && ( rc != VERR_BUFFER_OVERFLOW
707 || cbAbsPath < cbNeeded))
708 RTTestIFailed("#%u: Unexpected overflow result: %Rrc%s\n"
709 " flags: %#x\n"
710 " input base: '%s'\n"
711 " input path: '%s'\n"
712 " cbBuf[in]: %#x\n"
713 " cbBuf[out]: %#x\n"
714 " cbNeeded: %#x\n",
715 i, rc, rc != VERR_BUFFER_OVERFLOW ? " - expected VERR_BUFFER_OVERFLOW" : "",
716 s_aRTPathAbsExTests[i].fFlags,
717 s_aRTPathAbsExTests[i].pcszInputBase,
718 s_aRTPathAbsExTests[i].pcszInputPath,
719 cbBuf,
720 cbAbsPath,
721 cbNeeded);
722 else if ( cbBuf >= cbNeeded
723 && ( rc != s_aRTPathAbsExTests[i].rc
724 || cbAbsPath != cbNeeded - 1
725 || strcmp(pszBuf, pszExpected)
726 || strlen(pszBuf) != cbAbsPath))
727 RTTestIFailed("#%u: Unexpected result: %Rrc (expected %Rrc)\n"
728 " flags: %#x\n"
729 " input base: '%s'\n"
730 " input path: '%s'\n"
731 " cbBuf[in]: %#x\n"
732 " cbBuf[out]: %#x\n"
733 " cbNeeded: %#x\n",
734 i, rc, s_aRTPathAbsExTests[i].rc,
735 s_aRTPathAbsExTests[i].fFlags,
736 s_aRTPathAbsExTests[i].pcszInputBase,
737 s_aRTPathAbsExTests[i].pcszInputPath,
738 cbBuf,
739 cbAbsPath,
740 cbNeeded);
741
742 }
743 }
744
745 /* RTPathAbsExDup */
746 char *pszDup = RTPathAbsExDup(s_aRTPathAbsExTests[i].pcszInputBase,
747 s_aRTPathAbsExTests[i].pcszInputPath,
748 s_aRTPathAbsExTests[i].fFlags);
749 if ( (RT_SUCCESS(s_aRTPathAbsExTests[i].rc) ? pszDup == NULL : pszDup != NULL)
750 || RTStrCmp(pszDup, pszExpected))
751 RTTestIFailed("#%u: Unexpected RTPathAbsExDup result: %p%s\n"
752 " flags: %#x\n"
753 " input base: '%s'\n"
754 " input path: '%s'\n"
755 " output: '%s'\n"
756 " expected: '%s' ('%s')\n",
757 i, pszDup,
758 (RT_SUCCESS(s_aRTPathAbsExTests[i].rc) ? pszDup == NULL : pszDup != NULL) ? pszDup ? "NULL" : "!NULL" : "",
759 s_aRTPathAbsExTests[i].fFlags,
760 s_aRTPathAbsExTests[i].pcszInputBase,
761 s_aRTPathAbsExTests[i].pcszInputPath,
762 pszDup,
763 pszExpected, s_aRTPathAbsExTests[i].pcszOutput);
764 RTStrFree(pszDup);
765 }
766 }
767
768 if (pszGuardedBuf != szPath)
769 RTTestGuardedFree(hTest, pszGuardedBuf);
770
771
772 /*
773 * RTPathStripFilename
774 */
775 RTTestSub(hTest, "RTPathStripFilename");
776 static const char *s_apszStripFilenameTests[] =
777 {
778 "/usr/include///", "/usr/include//",
779 "/usr/include/", "/usr/include",
780 "/usr/include", "/usr",
781 "/usr", "/",
782 "usr", ".",
783#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
784 "c:/windows", "c:/",
785 "c:/", "c:/",
786 "D:", "D:",
787 "C:\\OS2\\DLLS", "C:\\OS2",
788#endif
789 };
790 for (unsigned i = 0; i < RT_ELEMENTS(s_apszStripFilenameTests); i += 2)
791 {
792 const char *pszInput = s_apszStripFilenameTests[i];
793 const char *pszExpect = s_apszStripFilenameTests[i + 1];
794 strcpy(szPath, pszInput);
795 RTPathStripFilename(szPath);
796 if (strcmp(szPath, pszExpect))
797 {
798 RTTestIFailed("Unexpected result\n"
799 " input: '%s'\n"
800 " output: '%s'\n"
801 "expected: '%s'",
802 pszInput, szPath, pszExpect);
803 }
804 }
805
806 /*
807 * RTPathAppend.
808 */
809 RTTestSub(hTest, "RTPathAppend");
810 static const char *s_apszAppendTests[] =
811 {
812 /* base append result */
813 "/", "", "/",
814 "", "/", "/",
815 "/", "/", "/",
816 "/x", "", "/x",
817 "/x", "/", "/x/",
818 "/", "x", "/x",
819 "dir", "file", "dir" RTPATH_SLASH_STR "file",
820 "dir", "/file", "dir/file",
821 "dir", "//file", "dir/file",
822 "dir", "///file", "dir/file",
823 "dir/", "/file", "dir/file",
824 "dir/", "//file", "dir/file",
825 "dir/", "///file", "dir/file",
826 "dir//", "file", "dir/file",
827 "dir//", "/file", "dir/file",
828 "dir//", "//file", "dir/file",
829 "dir///", "///file", "dir/file",
830 "/bin/testcase", "foo.r0", "/bin/testcase" RTPATH_SLASH_STR "foo.r0",
831#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
832 "/", "\\", "/",
833 "\\", "/", "\\",
834 "\\\\srv\\shr", "dir//", "\\\\srv\\shr" RTPATH_SLASH_STR "dir//",
835 "\\\\srv\\shr", "dir//file", "\\\\srv\\shr" RTPATH_SLASH_STR "dir//file",
836 "\\\\srv\\shr", "//dir//", "\\\\srv\\shr/dir//",
837 "\\\\srv\\shr", "/\\dir//", "\\\\srv\\shr\\dir//",
838 "\\\\", "not-srv/not-shr/file", "\\not-srv/not-shr/file",
839 "C:", "autoexec.bat", "C:autoexec.bat",
840 "C:", "/autoexec.bat", "C:/autoexec.bat",
841 "C:", "\\autoexec.bat", "C:\\autoexec.bat",
842 "C:\\", "/autoexec.bat", "C:\\autoexec.bat",
843 "C:\\\\", "autoexec.bat", "C:\\autoexec.bat",
844 "E:\\bin\\testcase", "foo.r0", "E:\\bin\\testcase" RTPATH_SLASH_STR "foo.r0",
845#endif
846 };
847 for (unsigned i = 0; i < RT_ELEMENTS(s_apszAppendTests); i += 3)
848 {
849 const char *pszInput = s_apszAppendTests[i];
850 const char *pszAppend = s_apszAppendTests[i + 1];
851 const char *pszExpect = s_apszAppendTests[i + 2];
852 strcpy(szPath, pszInput);
853 RTTESTI_CHECK_RC(rc = RTPathAppend(szPath, sizeof(szPath), pszAppend), VINF_SUCCESS);
854 if (RT_FAILURE(rc))
855 continue;
856 if (strcmp(szPath, pszExpect))
857 {
858 RTTestIFailed("Unexpected result\n"
859 " input: '%s'\n"
860 " append: '%s'\n"
861 " output: '%s'\n"
862 "expected: '%s'",
863 pszInput, pszAppend, szPath, pszExpect);
864 }
865 else
866 {
867 size_t const cchResult = strlen(szPath);
868
869 strcpy(szPath, pszInput);
870 RTTESTI_CHECK_RC(rc = RTPathAppend(szPath, cchResult + 2, pszAppend), VINF_SUCCESS);
871 RTTESTI_CHECK(RT_FAILURE(rc) || !strcmp(szPath, pszExpect));
872
873 strcpy(szPath, pszInput);
874 RTTESTI_CHECK_RC(rc = RTPathAppend(szPath, cchResult + 1, pszAppend), VINF_SUCCESS);
875 RTTESTI_CHECK(RT_FAILURE(rc) || !strcmp(szPath, pszExpect));
876
877 if (strlen(pszInput) < cchResult)
878 {
879 strcpy(szPath, pszInput);
880 RTTESTI_CHECK_RC(RTPathAppend(szPath, cchResult, pszAppend), VERR_BUFFER_OVERFLOW);
881 }
882 }
883 }
884
885 /*
886 * RTPathJoin - reuse the append tests.
887 */
888 RTTestSub(hTest, "RTPathJoin");
889 for (unsigned i = 0; i < RT_ELEMENTS(s_apszAppendTests); i += 3)
890 {
891 const char *pszInput = s_apszAppendTests[i];
892 const char *pszAppend = s_apszAppendTests[i + 1];
893 const char *pszExpect = s_apszAppendTests[i + 2];
894
895 memset(szPath, 'a', sizeof(szPath)); szPath[sizeof(szPath) - 1] = '\0';
896
897 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, sizeof(szPath), pszInput, pszAppend), VINF_SUCCESS);
898 if (RT_FAILURE(rc))
899 continue;
900 if (strcmp(szPath, pszExpect))
901 {
902 RTTestIFailed("Unexpected result\n"
903 " input: '%s'\n"
904 " append: '%s'\n"
905 " output: '%s'\n"
906 "expected: '%s'",
907 pszInput, pszAppend, szPath, pszExpect);
908 }
909 else
910 {
911 size_t const cchResult = strlen(szPath);
912
913 memset(szPath, 'a', sizeof(szPath)); szPath[sizeof(szPath) - 1] = '\0';
914 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, cchResult + 2, pszInput, pszAppend), VINF_SUCCESS);
915 RTTESTI_CHECK(RT_FAILURE(rc) || !strcmp(szPath, pszExpect));
916
917 memset(szPath, 'a', sizeof(szPath)); szPath[sizeof(szPath) - 1] = '\0';
918 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, cchResult + 1, pszInput, pszAppend), VINF_SUCCESS);
919 RTTESTI_CHECK(RT_FAILURE(rc) || !strcmp(szPath, pszExpect));
920
921 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, cchResult, pszInput, pszAppend), VERR_BUFFER_OVERFLOW);
922 }
923 }
924
925 /*
926 * RTPathJoinA - reuse the append tests.
927 */
928 RTTestSub(hTest, "RTPathJoinA");
929 for (unsigned i = 0; i < RT_ELEMENTS(s_apszAppendTests); i += 3)
930 {
931 const char *pszInput = s_apszAppendTests[i];
932 const char *pszAppend = s_apszAppendTests[i + 1];
933 const char *pszExpect = s_apszAppendTests[i + 2];
934
935 char *pszPathDst;
936 RTTESTI_CHECK(pszPathDst = RTPathJoinA(pszInput, pszAppend));
937 if (!pszPathDst)
938 continue;
939 if (strcmp(pszPathDst, pszExpect))
940 {
941 RTTestIFailed("Unexpected result\n"
942 " input: '%s'\n"
943 " append: '%s'\n"
944 " output: '%s'\n"
945 "expected: '%s'",
946 pszInput, pszAppend, pszPathDst, pszExpect);
947 }
948 RTStrFree(pszPathDst);
949 }
950
951 /*
952 * RTPathStripTrailingSlash
953 */
954 static const char *s_apszStripTrailingSlash[] =
955 {
956 /* input result */
957 "/", "/",
958 "//", "/",
959 "////////////////////", "/",
960 "/tmp", "/tmp",
961 "/tmp////////////////", "/tmp",
962 "tmp", "tmp",
963 "tmp////////////////", "tmp",
964 "./", ".",
965#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
966 "////////////////////", "/",
967 "D:", "D:",
968 "D:/", "D:/",
969 "D:\\", "D:\\",
970 "D:\\/\\", "D:\\",
971 "D:/\\/\\", "D:/",
972 "C:/Temp", "C:/Temp",
973 "C:/Temp/", "C:/Temp",
974 "C:/Temp\\/", "C:/Temp",
975#endif
976 };
977 for (unsigned i = 0; i < RT_ELEMENTS(s_apszStripTrailingSlash); i += 2)
978 {
979 const char *pszInput = s_apszStripTrailingSlash[i];
980 const char *pszExpect = s_apszStripTrailingSlash[i + 1];
981
982 strcpy(szPath, pszInput);
983 cch = RTPathStripTrailingSlash(szPath);
984 if (strcmp(szPath, pszExpect))
985 RTTestIFailed("Unexpected result\n"
986 " input: '%s'\n"
987 " output: '%s'\n"
988 "expected: '%s'",
989 pszInput, szPath, pszExpect);
990 else
991 RTTESTI_CHECK(cch == strlen(szPath));
992 }
993
994 /*
995 * RTPathCountComponents
996 */
997 RTTestSub(hTest, "RTPathCountComponents");
998 RTTESTI_CHECK(RTPathCountComponents("") == 0);
999 RTTESTI_CHECK(RTPathCountComponents("/") == 1);
1000 RTTESTI_CHECK(RTPathCountComponents("//") == 1);
1001 RTTESTI_CHECK(RTPathCountComponents("//////////////") == 1);
1002 RTTESTI_CHECK(RTPathCountComponents("//////////////bin") == 2);
1003 RTTESTI_CHECK(RTPathCountComponents("//////////////bin/") == 2);
1004 RTTESTI_CHECK(RTPathCountComponents("//////////////bin/////") == 2);
1005 RTTESTI_CHECK(RTPathCountComponents("..") == 1);
1006 RTTESTI_CHECK(RTPathCountComponents("../") == 1);
1007 RTTESTI_CHECK(RTPathCountComponents("../..") == 2);
1008 RTTESTI_CHECK(RTPathCountComponents("../../") == 2);
1009#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
1010 RTTESTI_CHECK(RTPathCountComponents("d:") == 1);
1011 RTTESTI_CHECK(RTPathCountComponents("d:/") == 1);
1012 RTTESTI_CHECK(RTPathCountComponents("d:/\\") == 1);
1013 RTTESTI_CHECK(RTPathCountComponents("d:\\") == 1);
1014 RTTESTI_CHECK(RTPathCountComponents("c:\\config.sys") == 2);
1015 RTTESTI_CHECK(RTPathCountComponents("c:\\windows") == 2);
1016 RTTESTI_CHECK(RTPathCountComponents("c:\\windows\\") == 2);
1017 RTTESTI_CHECK(RTPathCountComponents("c:\\windows\\system32") == 3);
1018 RTTESTI_CHECK(RTPathCountComponents("//./C$") == 1);
1019 RTTESTI_CHECK(RTPathCountComponents("\\\\.\\C$") == 1);
1020 RTTESTI_CHECK(RTPathCountComponents("/\\.\\C$") == 1);
1021 RTTESTI_CHECK(RTPathCountComponents("//myserver") == 1);
1022 RTTESTI_CHECK(RTPathCountComponents("//myserver/") == 1);
1023 RTTESTI_CHECK(RTPathCountComponents("//myserver/share") == 1);
1024 RTTESTI_CHECK(RTPathCountComponents("//myserver/share/") == 1);
1025 RTTESTI_CHECK(RTPathCountComponents("//myserver/share\\") == 1);
1026 RTTESTI_CHECK(RTPathCountComponents("//myserver/share\\x") == 2);
1027 RTTESTI_CHECK(RTPathCountComponents("//myserver/share\\x\\y") == 3);
1028 RTTESTI_CHECK(RTPathCountComponents("//myserver/share\\x\\y\\") == 3);
1029#endif
1030
1031 /*
1032 * RTPathCopyComponents
1033 */
1034 struct
1035 {
1036 const char *pszSrc;
1037 size_t cComponents;
1038 const char *pszResult;
1039 } s_aCopyComponents[] =
1040 {
1041 { "", 0, "" },
1042 { "", 5, "" },
1043 { "/", 0, "" },
1044 { "/", 1, "/" },
1045 { "/", 2, "/" },
1046 { "/usr/bin/sed", 0, "" },
1047 { "/usr/bin/sed", 1, "/" },
1048 { "/usr/bin/sed", 2, "/usr/" },
1049 { "/usr/bin/sed", 3, "/usr/bin/" },
1050 { "/usr/bin/sed", 4, "/usr/bin/sed" },
1051 { "/usr/bin/sed", 5, "/usr/bin/sed" },
1052 { "/usr/bin/sed", 6, "/usr/bin/sed" },
1053 { "/usr///bin/sed", 2, "/usr///" },
1054 };
1055 for (unsigned i = 0; i < RT_ELEMENTS(s_aCopyComponents); i++)
1056 {
1057 const char *pszInput = s_aCopyComponents[i].pszSrc;
1058 size_t cComponents = s_aCopyComponents[i].cComponents;
1059 const char *pszResult = s_aCopyComponents[i].pszResult;
1060
1061 memset(szPath, 'a', sizeof(szPath));
1062 rc = RTPathCopyComponents(szPath, sizeof(szPath), pszInput, cComponents);
1063 RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
1064 if (RT_SUCCESS(rc) && strcmp(szPath, pszResult))
1065 RTTestIFailed("Unexpected result\n"
1066 " input: '%s' cComponents=%u\n"
1067 " output: '%s'\n"
1068 "expected: '%s'",
1069 pszInput, cComponents, szPath, pszResult);
1070 else if (RT_SUCCESS(rc))
1071 {
1072 RTTESTI_CHECK_RC(RTPathCopyComponents(szPath, strlen(pszResult) + 1, pszInput, cComponents), VINF_SUCCESS);
1073 RTTESTI_CHECK_RC(RTPathCopyComponents(szPath, strlen(pszResult), pszInput, cComponents), VERR_BUFFER_OVERFLOW);
1074 }
1075 }
1076
1077
1078 /*
1079 * RTPathStripSuffix
1080 */
1081 RTTestSub(hTest, "RTPathStripSuffix");
1082 struct
1083 {
1084 const char *pszSrc;
1085 const char *pszResult;
1086 } s_aStripExt[] =
1087 {
1088 { "filename.ext", "filename" },
1089 { "filename.ext1.ext2.ext3", "filename.ext1.ext2" },
1090 { "filename..ext", "filename." },
1091 { "filename.ext.", "filename.ext." },
1092 };
1093 for (unsigned i = 0; i < RT_ELEMENTS(s_aStripExt); i++)
1094 {
1095 const char *pszInput = s_aStripExt[i].pszSrc;
1096 const char *pszResult = s_aStripExt[i].pszResult;
1097
1098 strcpy(szPath, pszInput);
1099 RTPathStripSuffix(szPath);
1100 if (strcmp(szPath, pszResult))
1101 RTTestIFailed("Unexpected result\n"
1102 " input: '%s'\n"
1103 " output: '%s'\n"
1104 "expected: '%s'",
1105 pszInput, szPath, pszResult);
1106 }
1107
1108 /*
1109 * RTPathCalcRelative
1110 */
1111 RTTestSub(hTest, "RTPathCalcRelative");
1112 struct
1113 {
1114 const char *pszFrom;
1115 bool fFromFile;
1116 const char *pszTo;
1117 int rc;
1118 const char *pszExpected;
1119 } s_aRelPath[] =
1120 {
1121 { "/home/test.ext", true, "/home/test2.ext", VINF_SUCCESS, "test2.ext" },
1122 { "/dir/test.ext", true, "/dir/dir2/test2.ext", VINF_SUCCESS, "dir2/test2.ext" },
1123 { "/dir/dir2/test.ext", true, "/dir/test2.ext", VINF_SUCCESS, ".." RTPATH_SLASH_STR "test2.ext" },
1124 { "/dir/dir2/test.ext", true, "/dir/dir3/test2.ext", VINF_SUCCESS, ".." RTPATH_SLASH_STR "dir3/test2.ext" },
1125 { "/dir/dir2", false, "/dir/dir3/test2.ext", VINF_SUCCESS, ".." RTPATH_SLASH_STR "dir3/test2.ext" },
1126 { "/dir/dir2", false, "/dir/dir3//test2.ext", VINF_SUCCESS, ".." RTPATH_SLASH_STR "dir3//test2.ext" },
1127 { "/dir/dir2/", false, "/dir/dir3/test2.ext", VINF_SUCCESS, ".." RTPATH_SLASH_STR "dir3/test2.ext" },
1128 { "/dir/dir2////", false, "/dir//dir3/test2.ext", VINF_SUCCESS, ".." RTPATH_SLASH_STR "dir3/test2.ext" },
1129 { "/include/iprt", false, "/include/iprt/cdefs.h", VINF_SUCCESS, "cdefs.h" },
1130 { "/include/iprt/", false, "/include/iprt/cdefs.h", VINF_SUCCESS, "cdefs.h" },
1131 { "/include/iprt/tt.h", true, "/include/iprt/cdefs.h", VINF_SUCCESS, "cdefs.h" },
1132#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
1133 { "\\\\server\\share\\test.ext", true, "\\\\server\\share2\\test2.ext", VERR_NOT_SUPPORTED, "" },
1134 { "c:\\dir\\test.ext", true, "f:\\dir\\test.ext", VERR_NOT_SUPPORTED, "" },
1135 { "F:\\dir\\test.ext", false, "f:/dir//test.ext", VINF_SUCCESS, "." } ,
1136 { "F:\\diR\\Test.exT", true, "f:/dir//test.ext", VINF_SUCCESS, "Test.exT" } ,
1137 { "F:\\K\xc3\x85RE\\Test.exT", true, "f:/k\xc3\xa5re//test.ext", VINF_SUCCESS, "Test.exT" } ,
1138#endif
1139 };
1140 for (unsigned i = 0; i < RT_ELEMENTS(s_aRelPath); i++)
1141 {
1142 const char *pszFrom = s_aRelPath[i].pszFrom;
1143 bool fFromFile = s_aRelPath[i].fFromFile;
1144 const char *pszTo = s_aRelPath[i].pszTo;
1145
1146 rc = RTPathCalcRelative(szPath, sizeof(szPath), pszFrom, fFromFile, pszTo);
1147 if (rc != s_aRelPath[i].rc)
1148 RTTestIFailed("Unexpected return code for %s .. %s\n"
1149 " got: %Rrc\n"
1150 "expected: %Rrc",
1151 pszFrom, pszTo, rc, s_aRelPath[i].rc);
1152 else if ( RT_SUCCESS(rc)
1153 && strcmp(szPath, s_aRelPath[i].pszExpected))
1154 RTTestIFailed("Unexpected result\n"
1155 " from: '%s' (%s)\n"
1156 " to: '%s'\n"
1157 " output: '%s'\n"
1158 "expected: '%s'",
1159 pszFrom, fFromFile ? "file" : "dir", pszTo, szPath, s_aRelPath[i].pszExpected);
1160 }
1161
1162 testParserAndSplitter(hTest);
1163 testParentLength(hTest);
1164 testPurgeFilename(hTest);
1165 testEnsureTrailingSeparator(hTest);
1166 testFindCommon(hTest);
1167
1168 /*
1169 * Summary.
1170 */
1171 return RTTestSummaryAndDestroy(hTest);
1172}
1173
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette