MCPcopy Create free account
hub / github.com/apple/foundationdb / testPathOps

Function testPathOps

fdbmonitor/fdbmonitor.cpp:1242–1337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1240}
1241
1242void testPathOps() {
1243 int errors = 0;
1244
1245 errors += testPathFunction("popPath", popPath, "a", "");
1246 errors += testPathFunction("popPath", popPath, "a/", "");
1247 errors += testPathFunction("popPath", popPath, "a///", "");
1248 errors += testPathFunction("popPath", popPath, "a///..", "a/");
1249 errors += testPathFunction("popPath", popPath, "a///../", "a/");
1250 errors += testPathFunction("popPath", popPath, "a///..//", "a/");
1251 errors += testPathFunction("popPath", popPath, "/", "/");
1252 errors += testPathFunction("popPath", popPath, "/a", "/");
1253 errors += testPathFunction("popPath", popPath, "/a/b", "/a/");
1254 errors += testPathFunction("popPath", popPath, "/a/b/", "/a/");
1255 errors += testPathFunction("popPath", popPath, "/a/b/..", "/a/b/");
1256
1257 errors += testPathFunction("cleanPath", cleanPath, "/", "/");
1258 errors += testPathFunction("cleanPath", cleanPath, "..", "..");
1259 errors += testPathFunction("cleanPath", cleanPath, "../.././", "../..");
1260 errors += testPathFunction("cleanPath", cleanPath, "///.///", "/");
1261 errors += testPathFunction("cleanPath", cleanPath, "/a/b/.././../c/./././////./d/..//", "/c");
1262 errors += testPathFunction("cleanPath", cleanPath, "a/b/.././../c/./././////./d/..//", "c");
1263 errors += testPathFunction("cleanPath", cleanPath, "a/b/.././../c/./././////./d/..//..", ".");
1264 errors += testPathFunction("cleanPath", cleanPath, "a/b/.././../c/./././////./d/..//../..", "..");
1265 errors += testPathFunction("cleanPath", cleanPath, "../a/b/..//", "../a");
1266 errors += testPathFunction("cleanPath", cleanPath, "/..", "/");
1267 errors += testPathFunction("cleanPath", cleanPath, "/../foo/bar///", "/foo/bar");
1268 errors += testPathFunction("cleanPath", cleanPath, "/a/b/../.././../", "/");
1269 errors += testPathFunction("cleanPath", cleanPath, ".", ".");
1270
1271 mkdir("simfdb/backups/one/two/three");
1272 std::string cwd = abspath(".", true);
1273
1274 // Create some symlinks and test resolution (or non-resolution) of them
1275 [[maybe_unused]] int rc;
1276 // Ignoring return codes, if symlinks fail tests below will fail
1277 rc = unlink("simfdb/backups/four");
1278 rc = unlink("simfdb/backups/five");
1279 rc = symlink("one/two", "simfdb/backups/four") == 0 ? 0 : 1;
1280 rc = symlink("../backups/four", "simfdb/backups/five") ? 0 : 1;
1281
1282 errors += testPathFunction2(
1283 "abspath", abspath, "simfdb/backups/five/../two", true, joinPath(cwd, "simfdb/backups/one/two"));
1284 errors += testPathFunction2(
1285 "abspath", abspath, "simfdb/backups/five/../three", true, joinPath(cwd, "simfdb/backups/one/three"));
1286 errors += testPathFunction2(
1287 "abspath", abspath, "simfdb/backups/five/../three/../four", true, joinPath(cwd, "simfdb/backups/one/four"));
1288
1289 errors += testPathFunction2(
1290 "parentDirectory", parentDirectory, "simfdb/backups/five/../two", true, joinPath(cwd, "simfdb/backups/one/"));
1291 errors += testPathFunction2(
1292 "parentDirectory", parentDirectory, "simfdb/backups/five/../three", true, joinPath(cwd, "simfdb/backups/one/"));
1293
1294 errors += testPathFunction2("abspath", abspath, "/", false, "/");
1295 errors += testPathFunction2("abspath", abspath, "/foo//bar//baz/.././", false, "/foo/bar");
1296 errors += testPathFunction2("abspath", abspath, "/", true, "/");
1297 errors += testPathFunction2("abspath", abspath, "", true, "");
1298 errors += testPathFunction2("abspath", abspath, ".", true, cwd);
1299 errors += testPathFunction2("abspath", abspath, "/a", true, "/a");

Callers

nothing calls this directly

Calls 8

mkdirFunction · 0.85
symlinkFunction · 0.85
printfFunction · 0.85
testPathFunctionFunction · 0.70
abspathFunction · 0.70
testPathFunction2Function · 0.70
joinPathFunction · 0.70
cleanPathFunction · 0.70

Tested by

no test coverage detected