static void
load_tal_json(void)
{
- cache.rsync = cachent_create_root("rsync:");
- cache.https = cachent_create_root("https:");
+ cache.rsync = cachent_create_root("rsync");
+ cache.https = cachent_create_root("https");
// char *filename;
// json_t *root;
// free(filename);
}
-/*
- * Returns perfect match or NULL. @msm will point to the Most Specific Match.
- * Always consumes @path.
- */
-static struct cache_node *
-find_msm(struct cache_node *root, char *path, struct cache_node **msm)
-{
- struct cache_node *node, *child;
- char *nm, *sp; /* name, saveptr */
- size_t keylen;
-
- *msm = NULL;
- node = root;
- nm = strtok_r(path + RPKI_SCHEMA_LEN, "/", &sp); // XXX
-
- for (; nm; nm = strtok_r(NULL, "/", &sp)) {
- keylen = strlen(nm);
- HASH_FIND(hh, node->children, nm, keylen, child);
- if (child == NULL) {
- free(path);
- *msm = node;
- return NULL;
- }
- node = child;
- }
-
- free(path);
- *msm = node;
- return node;
-}
-
/*
* The "rsync module" is the component immediately after the domain.
*
return pr_val_err("Malformed URL: %s", uri);
if (download != NULL) {
+ PR_DEBUG;
if (rpp->flags & CNF_FRESH) {
+ PR_DEBUG_MSG("%s is fresh.", rpp->url);
if (rpp->dlerr)
return rpp->dlerr;
} else {
+ PR_DEBUG;
rpp->flags |= CNF_FRESH;
error = rpp->dlerr = download(rpp);
if (error)
static bool
commit_rpp_delta(struct cache_node *node, char const *path)
{
+ int error;
+
PR_DEBUG_MSG("Commiting %s", node->url);
if (node->tmpdir == NULL)
return true; /* Not updated */
- if (node->flags & CNF_VALID)
- rename(node->tmpdir, path); // XXX
- else
+ if (node->flags & CNF_VALID) {
+ error = file_merge_into(node->tmpdir, path);
+ if (error)
+ printf("rename errno: %d\n", error); // XXX
+ } else {
/* XXX same; just do remove(). */
/* XXX and rename "tmpdir" into "tmp". */
file_rm_f(node->tmpdir);
+ }
free(node->tmpdir);
node->tmpdir = NULL;
return last_week;
}
-//static void
-//cleanup_tmp(struct rpki_cache *cache, struct cache_node *node)
-//{
-// enum map_type type;
-// char const *path;
-// int error;
-//
-// type = map_get_type(node->map);
-// if (type != MAP_NOTIF && type != MAP_TMP)
-// return;
-//
-// path = map_get_path(node->map);
-// pr_op_debug("Deleting temporal file '%s'.", path);
-// error = file_rm_f(path);
-// if (error)
-// pr_op_err("Could not delete '%s': %s", path, strerror(error));
-//
-// if (type != MAP_NOTIF)
-// delete_node(cache, node);
-//}
-//
+static int
+rmf(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
+{
+ if (remove(fpath))
+ pr_op_warn("Can't remove %s: %s", fpath, strerror(errno));
+ return 0;
+}
+
+static void
+cleanup_tmp(void)
+{
+ char *tmpdir = get_cache_filename(TMPDIR, true);
+ if (nftw(tmpdir, rmf, 32, FTW_DEPTH | FTW_PHYS))
+ pr_op_warn("Cannot empty the cache's tmp directory: %s",
+ strerror(errno));
+ free(tmpdir);
+}
+
//static void
//cleanup_node(struct rpki_cache *cache, struct cache_node *node,
// time_t last_week)
nftw_remove_abandoned(const char *path, const struct stat *st,
int typeflag, struct FTW *ftw)
{
+ char const *lookup;
struct cache_node *pm; /* Perfect Match */
struct cache_node *msm; /* Most Specific Match */
struct timespec now;
- PR_DEBUG_MSG("Removing potentially abandoned %s", path);
+ // XXX
+ lookup = path + strlen(config_get_local_repository());
+ while (lookup[0] == '/')
+ lookup++;
+ PR_DEBUG_MSG("Removing if abandoned: %s", lookup);
- /* XXX node->parent has to be set */
- pm = find_msm(nftw_root, pstrdup(path), &msm);
- if (!pm && !(msm->flags & CNF_RSYNC))
+ pm = cachent_find(nftw_root, lookup, &msm);
+ if (pm == cache.rsync || pm == cache.https) {
+ PR_DEBUG_MSG("%s", "Root; skipping.");
+ return 0;
+ }
+ if (!msm) {
+ PR_DEBUG_MSG("%s", "Not matched by the tree.");
+ goto unknown;
+ }
+ if (!pm && !(msm->flags & CNF_RSYNC)) {
+ PR_DEBUG_MSG("%s", "Unknown.");
goto unknown; /* The traversal is depth-first */
+ }
if (S_ISDIR(st->st_mode)) {
/*
* rmdir() fails if the directory is not empty.
* This will happen most of the time.
*/
- if (rmdir(path) == 0)
+ if (rmdir(path) == 0) {
+ PR_DEBUG_MSG("%s", "Directory deleted; purging node.");
cachent_delete(pm);
- else if (errno == ENOENT)
+ } else if (errno == ENOENT) {
+ PR_DEBUG_MSG("%s", "Directory does not exist; purging node.");
cachent_delete(pm);
+ } else {
+ PR_DEBUG_MSG("%s", "Directory exists and has contents; skipping.");
+ }
} else if (S_ISREG(st->st_mode)) {
- if (pm->flags & (CNF_RSYNC | CNF_WITHDRAWN)) {
+ if ((msm->flags & CNF_RSYNC) || !pm || (pm->flags & CNF_WITHDRAWN)) {
clock_gettime(CLOCK_REALTIME, &now); // XXX
- if (now.tv_sec - st->st_atim.tv_sec > cfg_cache_threshold())
+ PR_DEBUG_MSG("%ld > %ld", now.tv_sec - st->st_atim.tv_sec, cfg_cache_threshold());
+ if (now.tv_sec - st->st_atim.tv_sec > cfg_cache_threshold()) {
+ PR_DEBUG_MSG("%s", "Too old.");
goto abandoned;
+ }
+ PR_DEBUG_MSG("%s", "Young; preserving.");
}
} else {
+ PR_DEBUG_MSG("%s", "Unknown type.");
goto abandoned;
}
return 0;
abandoned:
+ PR_DEBUG;
if (pm)
cachent_delete(pm);
unknown:
- remove(path); // XXX
+ PR_DEBUG;
+ if (remove(path))
+ PR_DEBUG_MSG("remove(): %s", strerror(errno)); // XXX
return 0;
}
rootpath = join_paths(config_get_local_repository(), "rsync");
nftw_root = cache.rsync;
+ PR_DEBUG_MSG("nftw(%s)", rootpath);
nftw(rootpath, nftw_remove_abandoned, 32, FTW_DEPTH | FTW_PHYS); // XXX
strcpy(rootpath + strlen(rootpath) - 5, "https");
nftw_root = cache.https;
+ PR_DEBUG_MSG("nftw(%s)", rootpath);
nftw(rootpath, nftw_remove_abandoned, 32, FTW_DEPTH | FTW_PHYS); // XXX
free(rootpath);
static void
cleanup_cache(void)
{
-// struct cache_node *node, *tmp;
-// time_t last_week;
-
pr_op_debug("Committing successful RPPs.");
cachent_traverse(cache.rsync, commit_rpp_delta);
cachent_traverse(cache.https, commit_rpp_delta);
-// pr_op_debug("Cleaning up temporal files.");
-// HASH_ITER(hh, cache->ht, node, tmp)
-// cleanup_tmp(cache, node);
+ pr_op_debug("Cleaning up temporal files.");
+ cleanup_tmp();
pr_op_debug("Cleaning up old abandoned and unknown cache files.");
remove_abandoned();
#include "alloc.c"
#include "common.c"
+#include "file.c"
//#include "json_util.c"
#include "mock.c"
#include "cache/cachent.c"
static unsigned int rsync_counter; /* Times the rsync function was called */
static unsigned int https_counter; /* Times the https function was called */
-
-struct downloaded_path {
- char *path;
- bool visited;
- SLIST_ENTRY(downloaded_path) hook;
-};
-
-
-static bool dl_mock_type; /* false = list. true = list + actual files */
static int dl_error;
-/* Paths downloaded during the test */
-static SLIST_HEAD(downloaded_paths, downloaded_path) downloaded;
-
-int
-file_exists(char const *path)
-{
- struct stat meta;
- struct downloaded_path *dp;
-
- if (dl_mock_type)
- return (stat(path, &meta) == 0) ? 0 : errno;
-
- SLIST_FOREACH(dp, &downloaded, hook)
- if (strcmp(path, dp->path) == 0)
- return 0;
- return ENOENT;
-}
-
-int
-file_rm_rf(char const *file)
-{
- struct downloaded_path *path;
-
- SLIST_FOREACH(path, &downloaded, hook)
- if (strcmp(file, path->path) == 0) {
- SLIST_REMOVE(&downloaded, path, downloaded_path, hook);
- free(path->path);
- free(path);
- if (dl_mock_type)
- ck_assert_int_eq(0, remove(file));
- return 0;
- }
-
- return ENOENT;
-}
-
-int
-file_rm_f(char const *file)
-{
- file_rm_rf(file);
- return 0;
-}
-
-MOCK_ABORT_INT(file_get_mtim, char const *file, time_t *ims)
-
static void
__delete_node_cb(struct cache_node const *node)
{
/* Nothing */
}
-static int
-pretend_download(char const *local)
+int
+rsync_download(char const *src, char const *dst, bool is_directory)
{
- struct downloaded_path *dl;
+ char cmd[64];
+
+ rsync_counter++;
if (dl_error)
return dl_error;
- if (file_exists(local) == 0)
- return 0;
- dl = pmalloc(sizeof(struct downloaded_path));
- dl->path = pstrdup(local);
- dl->visited = false;
- SLIST_INSERT_HEAD(&downloaded, dl, hook);
+ ck_assert_int_eq(0, mkdir_p(dst, true, 0777));
- if (dl_mock_type)
- ck_assert_int_eq(0, mkdir_p(local, true));
+ ck_assert(snprintf(cmd, sizeof(cmd), "touch %s/file", dst) < sizeof(cmd));
+ ck_assert_int_eq(0, system(cmd));
return 0;
}
-int
-rsync_download(char const *src, char const *dst, bool is_directory)
-{
- rsync_counter++;
- return pretend_download(dst);
-}
-
int
http_download(char const *url, char const *path, curl_off_t ims, bool *changed)
{
- int error;
+ char cmd[61];
+
https_counter++;
- error = pretend_download(path);
- if (changed != NULL)
- *changed = error ? false : true;
- return error;
+
+ if (dl_error) {
+ *changed = false;
+ return dl_error;
+ }
+
+ ck_assert_int_eq(0, mkdir_p(path, false, 0777));
+
+ ck_assert(snprintf(cmd, sizeof(cmd), "touch %s", path) < sizeof(cmd));
+ ck_assert_int_eq(0, system(cmd));
+
+ *changed = true;
+ return 0;
}
MOCK_ABORT_INT(rrdp_update, struct cache_node *notif)
__MOCK_ABORT(rrdp_notif2json, json_t *, NULL, struct cachefile_notification *notif)
MOCK_VOID(rrdp_notif_free, struct cachefile_notification *notif)
MOCK_ABORT_INT(rrdp_json2notif, json_t *json, struct cachefile_notification **result)
-MOCK(cfg_cache_threshold, time_t, get_days_ago(7), void)
+MOCK(cfg_cache_threshold, time_t, 60 * 60 * 24 * 7, void)
/* Helpers */
setup_test(bool dl_type)
{
dl_error = 0;
- dl_mock_type = dl_type;
- SLIST_INIT(&downloaded);
-
ck_assert_int_eq(0, system("rm -rf tmp/"));
cache_prepare();
+ ck_assert_int_eq(0, system("mkdir -p tmp/rsync"));
+ ck_assert_int_eq(0, system("mkdir -p tmp/https"));
}
static int
sias_cleanup(&sias);
}
-static void
-reset_visiteds(void)
-{
- struct downloaded_path *path;
- SLIST_FOREACH(path, &downloaded, hook)
- path->visited = false;
-}
-
-static struct downloaded_path *
-find_downloaded_path(struct cache_node *node)
+static bool
+ck_path(struct cache_node *node, char const *_)
{
- struct downloaded_path *path;
+ int error;
if (!node->tmpdir)
- return NULL;
-
- if (dl_mock_type && !file_exists(node->tmpdir))
- return NULL;
-
- SLIST_FOREACH(path, &downloaded, hook) {
- if (strcmp(node->tmpdir, path->path) == 0) {
- if (path->visited)
- ck_abort_msg("Looked up twice: %s", path->path);
- path->visited = true;
- return path;
- }
- }
+ return true;
- return NULL;
-}
-
-static bool
-check_path(struct cache_node *node, char const *_)
-{
- struct downloaded_path *path;
-
- PR_DEBUG_MSG("Checking %s", node->url);
-
- path = find_downloaded_path(node);
- if (node->tmpdir) {
- if (path == NULL)
- ck_abort_msg("Cached file is missing: %s",
- node->tmpdir);
- } else {
- if (path != NULL)
- ck_abort_msg("Cached file should not exist: %s",
- path->path);
- }
+ PR_DEBUG_MSG("Checking file exists in cache: %s (%s)", node->tmpdir, node->url);
+ error = file_exists(node->tmpdir);
+ if (error)
+ ck_abort_msg("Missing file in cache: %s (%s)", node->tmpdir, strerror(error));
return true;
}
-static void
-fail_if_nonvisited(void)
-{
- struct downloaded_path *path;
- SLIST_FOREACH(path, &downloaded, hook)
- if (!path->visited)
- ck_abort_msg("Unexpected cache file: %s", path->path);
-}
-
//static struct cache_node *
//cachent_find(struct cache_node *root, char const *url)
//{
{
struct cache_node *echild, *achild, *tmp;
- PR_DEBUG_MSG("Comparing %s", expected->url);
+ PR_DEBUG_MSG("Comparing %s vs %s", expected->url, actual->url);
ck_assert_str_eq(expected->url, actual->url);
ck_assert_str_eq(expected->name, actual->name);
}
}
+static int
+print_file(const char *fpath, const struct stat *sb, int typeflag,
+ struct FTW *ftwbuf)
+{
+ printf("- %s\n", fpath);
+ return 0;
+}
+
static void
ck_cache(struct cache_node *rsync, struct cache_node *https)
{
- struct downloaded_path *path;
-
printf("------------------------------\n");
printf("Expected nodes:\n");
printf("\n");
printf("Files in cache:\n");
- SLIST_FOREACH(path, &downloaded, hook)
- printf("- %s\n", path->path);
+ ck_assert_int_eq(0, nftw("tmp/", print_file, 32, FTW_PHYS));
printf("\n");
/* Compare expected and cache */
- reset_visiteds();
- cachent_traverse(rsync, check_path);
- cachent_traverse(https, check_path);
- fail_if_nonvisited();
+ // XXX fix
+ PR_DEBUG_MSG("%s", ">> Comparing expected and cache...");
+ cachent_traverse(rsync, ck_path);
+ cachent_traverse(https, ck_path);
/* Compare expected and actual */
+ PR_DEBUG_MSG("%s", ">> Comparing expected and actual...");
ck_assert_cachent_eq(rsync, cache.rsync);
ck_assert_cachent_eq(https, cache.https);
static void
ck_cache_rsync(struct cache_node *rsync)
{
- ck_cache(rsync, unode("https:", NULL));
+ ck_cache(rsync, unode("https", NULL));
}
static time_t epoch;
static bool
unfreshen(struct cache_node *node, char const *path)
{
+ PR_DEBUG_MSG("Unfreshening %s.", node->url);
node->flags &= ~CNF_FRESH;
node->mtim = epoch;
return true;
}
+static int
+nftw_unfreshen(const char *fpath, const struct stat *sb, int typeflag,
+ struct FTW *ftwbuf)
+{
+ struct timespec times[2];
+
+ times[0].tv_sec = epoch;
+ times[0].tv_nsec = 0;
+ times[1].tv_sec = epoch;
+ times[1].tv_nsec = 0;
+ PR_DEBUG_MSG("changing times of %s", fpath);
+
+ ck_assert_int_eq(0, utimensat(AT_FDCWD, fpath, times, AT_SYMLINK_NOFOLLOW));
+
+ return 0;
+}
+
static void
new_iteration(bool outdate)
{
epoch = outdate ? get_days_ago(30) : get_days_ago(1);
cachent_traverse(cache.rsync, unfreshen);
+ ck_assert_int_eq(0, nftw("tmp/rsync", nftw_unfreshen, 32, FTW_PHYS));
+ ck_assert_int_eq(0, nftw("tmp/https", nftw_unfreshen, 32, FTW_PHYS));
}
//static void
static void
cleanup_test(void)
{
- struct downloaded_path *path;
-
dl_error = 0;
cache_commit();
-
- while (!SLIST_EMPTY(&downloaded)) {
- path = SLIST_FIRST(&downloaded);
- SLIST_REMOVE_HEAD(&downloaded, hook);
- free(path->path);
- free(path);
- }
+ ck_assert_int_eq(0, system("rm -rf tmp/"));
}
/* Tests */
/* Intermediary between a downloaded and a validated node */
//static const int BRANCH = RSYNC_INHERIT;
//static const int FAILED = CNF_FRESH;
-//
+
//START_TEST(test_cache_download_rsync)
//{
// setup_test(false);
//
// run_dl_rsync("rsync://a.b.c/d", 0, 1);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0", NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0", NULL), NULL), NULL));
//
// /* Redownload same file, nothing should happen */
// run_dl_rsync("rsync://a.b.c/d", 0, 0);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0", NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0", NULL), NULL), NULL));
//
// /*
// * rsyncs are recursive, which means if we've been recently asked to
// */
// run_dl_rsync("rsync://a.b.c/d/e", 0, 0);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0",
-// ufnode("rsync://a.b.c/d/e", VALIDATED, NULL), NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0",
+// ufnode("rsync/a.b.c/d/e", VALIDATED, NULL), NULL), NULL), NULL));
//
// /*
// * rsyncs get truncated, because it results in much faster
// */
// run_dl_rsync("rsync://x.y.z/m/n/o", 0, 1);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0",
-// ufnode("rsync://a.b.c/d/e", VALIDATED, NULL), NULL), NULL),
-// unode("rsync://x.y.z",
-// uftnode("rsync://x.y.z/m", DOWNLOADED, "tmp/tmp/1",
-// ufnode("rsync://x.y.z/m/n", BRANCH,
-// ufnode("rsync://x.y.z/m/n/o", VALIDATED, NULL), NULL), NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0",
+// ufnode("rsync/a.b.c/d/e", VALIDATED, NULL), NULL), NULL),
+// unode("rsync/x.y.z",
+// uftnode("rsync/x.y.z/m", DOWNLOADED, "tmp/tmp/1",
+// ufnode("rsync/x.y.z/m/n", BRANCH,
+// ufnode("rsync/x.y.z/m/n/o", VALIDATED, NULL), NULL), NULL), NULL), NULL));
//
// /* Sibling */
// run_dl_rsync("rsync://a.b.c/e/f", 0, 1);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0",
-// ufnode("rsync://a.b.c/d/e", VALIDATED, NULL), NULL),
-// uftnode("rsync://a.b.c/e", DOWNLOADED, "tmp/tmp/2",
-// ufnode("rsync://a.b.c/e/f", VALIDATED, NULL), NULL), NULL),
-// unode("rsync://x.y.z",
-// uftnode("rsync://x.y.z/m", DOWNLOADED, "tmp/tmp/1",
-// ufnode("rsync://x.y.z/m/n", BRANCH,
-// ufnode("rsync://x.y.z/m/n/o", VALIDATED, NULL), NULL), NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0",
+// ufnode("rsync/a.b.c/d/e", VALIDATED, NULL), NULL),
+// uftnode("rsync/a.b.c/e", DOWNLOADED, "tmp/tmp/2",
+// ufnode("rsync/a.b.c/e/f", VALIDATED, NULL), NULL), NULL),
+// unode("rsync/x.y.z",
+// uftnode("rsync/x.y.z/m", DOWNLOADED, "tmp/tmp/1",
+// ufnode("rsync/x.y.z/m/n", BRANCH,
+// ufnode("rsync/x.y.z/m/n/o", VALIDATED, NULL), NULL), NULL), NULL), NULL));
//
// cleanup_test();
//}
// dl_error = -EINVAL;
// run_dl_rsync("rsync://a.b.c/e", -EINVAL, 1);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0", NULL),
-// ufnode("rsync://a.b.c/e", FAILED, NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0", NULL),
+// ufnode("rsync/a.b.c/e", FAILED, NULL), NULL), NULL));
//
// /* Regardless of error, not reattempted because same iteration */
// dl_error = EINVAL;
// run_dl_rsync("rsync://a.b.c/e", -EINVAL, 0);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0", NULL),
-// ufnode("rsync://a.b.c/e", FAILED, NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0", NULL),
+// ufnode("rsync/a.b.c/e", FAILED, NULL), NULL), NULL));
//
// dl_error = 0;
// run_dl_rsync("rsync://a.b.c/e", -EINVAL, 0);
// ck_cache_rsync(
-// unode("rsync:",
-// unode("rsync://a.b.c",
-// uftnode("rsync://a.b.c/d", FULL, "tmp/tmp/0", NULL),
-// ufnode("rsync://a.b.c/e", FAILED, NULL), NULL), NULL));
+// unode("rsync",
+// unode("rsync/a.b.c",
+// uftnode("rsync/a.b.c/d", FULL, "tmp/tmp/0", NULL),
+// ufnode("rsync/a.b.c/e", FAILED, NULL), NULL), NULL));
//
// cleanup_test();
//}
* First iteration: Tree is created. No prunes, because nothing's
* outdated.
*/
+ PR_DEBUG;
new_iteration(true);
run_dl_rsync("rsync://a.b.c/d", 0, 1);
run_dl_rsync("rsync://a.b.c/e", 0, 1);
cleanup_cache();
ck_cache_rsync(
- unode("rsync:",
- unode("rsync://a.b.c",
- ufnode("rsync://a.b.c/d", FULL, NULL),
- ufnode("rsync://a.b.c/e", FULL, NULL), NULL), NULL));
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/d", FULL, NULL),
+ ufnode("rsync/a.b.c/e", FULL, NULL), NULL), NULL));
/* One iteration with no changes, for paranoia */
+ PR_DEBUG;
new_iteration(true);
run_dl_rsync("rsync://a.b.c/d", 0, 1);
run_dl_rsync("rsync://a.b.c/e", 0, 1);
cleanup_cache();
ck_cache_rsync(
- unode("rsync:",
- unode("rsync://a.b.c",
- ufnode("rsync://a.b.c/d", FULL, NULL),
- ufnode("rsync://a.b.c/e", FULL, NULL), NULL), NULL));
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/d", FULL, NULL),
+ ufnode("rsync/a.b.c/e", FULL, NULL), NULL), NULL));
/* Add one sibling */
+ PR_DEBUG;
new_iteration(true);
run_dl_rsync("rsync://a.b.c/d", 0, 1);
run_dl_rsync("rsync://a.b.c/e", 0, 1);
run_dl_rsync("rsync://a.b.c/f", 0, 1);
cleanup_cache();
ck_cache_rsync(
- unode("rsync:",
- unode("rsync://a.b.c",
- ufnode("rsync://a.b.c/d", FULL, NULL),
- ufnode("rsync://a.b.c/e", FULL, NULL),
- ufnode("rsync://a.b.c/f", FULL, NULL), NULL), NULL));
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/d", FULL, NULL),
+ ufnode("rsync/a.b.c/e", FULL, NULL),
+ ufnode("rsync/a.b.c/f", FULL, NULL), NULL), NULL));
/* Nodes don't get updated, but they're still too young. */
+ PR_DEBUG;
new_iteration(false);
cleanup_cache();
ck_cache_rsync(
- unode("rsync:",
- unode("rsync://a.b.c",
- ufnode("rsync://a.b.c/d", STALE, NULL),
- ufnode("rsync://a.b.c/e", STALE, NULL),
- ufnode("rsync://a.b.c/f", STALE, NULL), NULL), NULL));
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/d", STALE, NULL),
+ ufnode("rsync/a.b.c/e", STALE, NULL),
+ ufnode("rsync/a.b.c/f", STALE, NULL), NULL), NULL));
/* Remove some branches */
new_iteration(true);
run_dl_rsync("rsync://a.b.c/d", 0, 1);
cleanup_cache();
ck_cache_rsync(
- unode("rsync:",
- unode("rsync://a.b.c",
- ufnode("rsync://a.b.c/d", FULL, NULL), NULL), NULL));
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/d", FULL, NULL), NULL), NULL));
+
+ /* Remove old branch and add sibling at the same time */
+ new_iteration(true);
+ run_dl_rsync("rsync://a.b.c/e", 0, 1);
+ cleanup_cache();
+ ck_cache_rsync(
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/e", FULL, NULL), NULL), NULL));
+
+ /* Try child */
+ new_iteration(true);
+ run_dl_rsync("rsync://a.b.c/e/f/g", 0, 1);
+ cleanup_cache();
+ ck_cache_rsync(
+ unode("rsync",
+ unode("rsync/a.b.c",
+ ufnode("rsync/a.b.c/e", FULL, NULL), NULL), NULL));
-// /* Remove old branch and add sibling at the same time */
-// new_iteration(true);
-// run_dl_rsync("rsync://a.b.c/e", 0, 1);
-// cleanup_cache();
-// ck_cache(NODE("rsync://a.b.c/e/", 0, 1, true), NULL);
-//
-// /* Try child */
-// new_iteration(true);
-// run_dl_rsync("rsync://a.b.c/e/f/g", 0, 1);
-// cleanup_cache();
-// ck_cache(NODE("rsync://a.b.c/e/", 0, 1, true), NULL);
-//
// /* Parent again */
// new_iteration(true);
// run_dl_rsync("rsync://a.b.c/e", 0, 1);
// cleanup_cache();
-// ck_cache(NODE("rsync://a.b.c/e/", 0, 1, true), NULL);
+// ck_cache_rsync(
+// unode("rsync",
+// unode("rsync/a.b.c",
+// ufnode("rsync/a.b.c/e", FULL, NULL), NULL), NULL));
//
// /* Empty the tree */
// new_iteration(true);
// */
// cache_reset(cache);
//
-// add_node(cache, node("rsync://a/1", 100, 0, 1, 100, 0));
-// add_node(cache, node("rsync://a/2", 100, 1, 1, 100, 0));
-// add_node(cache, node("rsync://a/3", 200, 0, 1, 100, 0));
-// add_node(cache, node("rsync://a/4", 200, 1, 1, 100, 0));
-// add_node(cache, node("rsync://a/5", 100, 0, 1, 200, 0));
-// add_node(cache, node("rsync://a/6", 100, 1, 1, 200, 0));
-// add_node(cache, node("rsync://b/1", 100, 0, 0, 100, 0));
-// add_node(cache, node("rsync://b/2", 100, 1, 0, 100, 0));
-// add_node(cache, node("rsync://b/3", 200, 0, 0, 100, 0));
-// add_node(cache, node("rsync://b/4", 200, 1, 0, 100, 0));
-// add_node(cache, node("rsync://b/5", 100, 0, 0, 200, 0));
-// add_node(cache, node("rsync://b/6", 100, 1, 0, 200, 0));
+// add_node(cache, node("rsync/a/1", 100, 0, 1, 100, 0));
+// add_node(cache, node("rsync/a/2", 100, 1, 1, 100, 0));
+// add_node(cache, node("rsync/a/3", 200, 0, 1, 100, 0));
+// add_node(cache, node("rsync/a/4", 200, 1, 1, 100, 0));
+// add_node(cache, node("rsync/a/5", 100, 0, 1, 200, 0));
+// add_node(cache, node("rsync/a/6", 100, 1, 1, 200, 0));
+// add_node(cache, node("rsync/b/1", 100, 0, 0, 100, 0));
+// add_node(cache, node("rsync/b/2", 100, 1, 0, 100, 0));
+// add_node(cache, node("rsync/b/3", 200, 0, 0, 100, 0));
+// add_node(cache, node("rsync/b/4", 200, 1, 0, 100, 0));
+// add_node(cache, node("rsync/b/5", 100, 0, 0, 200, 0));
+// add_node(cache, node("rsync/b/6", 100, 1, 0, 200, 0));
//
// /* Multiple successful caches: Prioritize the most recent one */
// PREPARE_MAP_LIST(&maps, "rsync://a/1", "rsync://a/3", "rsync://a/5");