|
@@ -69,12 +69,12 @@ test_md_cache(void *data)
|
|
time3 = time(NULL) - 15*24*60*60;
|
|
time3 = time(NULL) - 15*24*60*60;
|
|
|
|
|
|
/* Possibly, turn this into a test setup/cleanup pair */
|
|
/* Possibly, turn this into a test setup/cleanup pair */
|
|
- tor_free(options->DataDirectory);
|
|
|
|
- options->DataDirectory = tor_strdup(get_fname("md_datadir_test"));
|
|
|
|
|
|
+ tor_free(options->CacheDirectory);
|
|
|
|
+ options->CacheDirectory = tor_strdup(get_fname("md_datadir_test"));
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
- tt_int_op(0, OP_EQ, mkdir(options->DataDirectory));
|
|
|
|
|
|
+ tt_int_op(0, OP_EQ, mkdir(options->CacheDirectory));
|
|
#else
|
|
#else
|
|
- tt_int_op(0, OP_EQ, mkdir(options->DataDirectory, 0700));
|
|
|
|
|
|
+ tt_int_op(0, OP_EQ, mkdir(options->CacheDirectory, 0700));
|
|
#endif
|
|
#endif
|
|
|
|
|
|
tt_assert(!strcmpstart(test_md3_noannotation, "onion-key"));
|
|
tt_assert(!strcmpstart(test_md3_noannotation, "onion-key"));
|
|
@@ -152,7 +152,7 @@ test_md_cache(void *data)
|
|
strlen(test_md3_noannotation));
|
|
strlen(test_md3_noannotation));
|
|
|
|
|
|
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs.new",
|
|
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs.new",
|
|
- options->DataDirectory);
|
|
|
|
|
|
+ options->CacheDirectory);
|
|
s = read_file_to_str(fn, RFTS_BIN, NULL);
|
|
s = read_file_to_str(fn, RFTS_BIN, NULL);
|
|
tt_assert(s);
|
|
tt_assert(s);
|
|
tt_mem_op(md1->body, OP_EQ, s + md1->off, md1->bodylen);
|
|
tt_mem_op(md1->body, OP_EQ, s + md1->off, md1->bodylen);
|
|
@@ -180,7 +180,7 @@ test_md_cache(void *data)
|
|
|
|
|
|
/* read the cache. */
|
|
/* read the cache. */
|
|
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs",
|
|
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs",
|
|
- options->DataDirectory);
|
|
|
|
|
|
+ options->CacheDirectory);
|
|
s = read_file_to_str(fn, RFTS_BIN, NULL);
|
|
s = read_file_to_str(fn, RFTS_BIN, NULL);
|
|
tt_mem_op(md1->body, OP_EQ, s + md1->off, strlen(test_md1));
|
|
tt_mem_op(md1->body, OP_EQ, s + md1->off, strlen(test_md1));
|
|
tt_mem_op(md2->body, OP_EQ, s + md2->off, strlen(test_md2));
|
|
tt_mem_op(md2->body, OP_EQ, s + md2->off, strlen(test_md2));
|
|
@@ -234,7 +234,7 @@ test_md_cache(void *data)
|
|
|
|
|
|
done:
|
|
done:
|
|
if (options)
|
|
if (options)
|
|
- tor_free(options->DataDirectory);
|
|
|
|
|
|
+ tor_free(options->CacheDirectory);
|
|
microdesc_free_all();
|
|
microdesc_free_all();
|
|
|
|
|
|
smartlist_free(added);
|
|
smartlist_free(added);
|
|
@@ -266,17 +266,17 @@ test_md_cache_broken(void *data)
|
|
|
|
|
|
options = get_options_mutable();
|
|
options = get_options_mutable();
|
|
tt_assert(options);
|
|
tt_assert(options);
|
|
- tor_free(options->DataDirectory);
|
|
|
|
- options->DataDirectory = tor_strdup(get_fname("md_datadir_test2"));
|
|
|
|
|
|
+ tor_free(options->CacheDirectory);
|
|
|
|
+ options->CacheDirectory = tor_strdup(get_fname("md_datadir_test2"));
|
|
|
|
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
- tt_int_op(0, OP_EQ, mkdir(options->DataDirectory));
|
|
|
|
|
|
+ tt_int_op(0, OP_EQ, mkdir(options->CacheDirectory));
|
|
#else
|
|
#else
|
|
- tt_int_op(0, OP_EQ, mkdir(options->DataDirectory, 0700));
|
|
|
|
|
|
+ tt_int_op(0, OP_EQ, mkdir(options->CacheDirectory, 0700));
|
|
#endif
|
|
#endif
|
|
|
|
|
|
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs",
|
|
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs",
|
|
- options->DataDirectory);
|
|
|
|
|
|
+ options->CacheDirectory);
|
|
|
|
|
|
write_str_to_file(fn, truncated_md, 1);
|
|
write_str_to_file(fn, truncated_md, 1);
|
|
|
|
|
|
@@ -285,7 +285,7 @@ test_md_cache_broken(void *data)
|
|
|
|
|
|
done:
|
|
done:
|
|
if (options)
|
|
if (options)
|
|
- tor_free(options->DataDirectory);
|
|
|
|
|
|
+ tor_free(options->CacheDirectory);
|
|
tor_free(fn);
|
|
tor_free(fn);
|
|
microdesc_free_all();
|
|
microdesc_free_all();
|
|
}
|
|
}
|
|
@@ -754,8 +754,8 @@ test_md_reject_cache(void *arg)
|
|
or_options_t *options = get_options_mutable();
|
|
or_options_t *options = get_options_mutable();
|
|
char buf[DIGEST256_LEN];
|
|
char buf[DIGEST256_LEN];
|
|
|
|
|
|
- tor_free(options->DataDirectory);
|
|
|
|
- options->DataDirectory = tor_strdup(get_fname("md_datadir_test_rej"));
|
|
|
|
|
|
+ tor_free(options->CacheDirectory);
|
|
|
|
+ options->CacheDirectory = tor_strdup(get_fname("md_datadir_test_rej"));
|
|
mock_rgsbd_val_a = tor_malloc_zero(sizeof(routerstatus_t));
|
|
mock_rgsbd_val_a = tor_malloc_zero(sizeof(routerstatus_t));
|
|
mock_rgsbd_val_b = tor_malloc_zero(sizeof(routerstatus_t));
|
|
mock_rgsbd_val_b = tor_malloc_zero(sizeof(routerstatus_t));
|
|
mock_ns_val = tor_malloc_zero(sizeof(networkstatus_t));
|
|
mock_ns_val = tor_malloc_zero(sizeof(networkstatus_t));
|
|
@@ -765,9 +765,9 @@ test_md_reject_cache(void *arg)
|
|
mock_ns_val->flavor = FLAV_MICRODESC;
|
|
mock_ns_val->flavor = FLAV_MICRODESC;
|
|
|
|
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
- tt_int_op(0, OP_EQ, mkdir(options->DataDirectory));
|
|
|
|
|
|
+ tt_int_op(0, OP_EQ, mkdir(options->CacheDirectory));
|
|
#else
|
|
#else
|
|
- tt_int_op(0, OP_EQ, mkdir(options->DataDirectory, 0700));
|
|
|
|
|
|
+ tt_int_op(0, OP_EQ, mkdir(options->CacheDirectory, 0700));
|
|
#endif
|
|
#endif
|
|
|
|
|
|
MOCK(router_get_mutable_consensus_status_by_descriptor_digest,
|
|
MOCK(router_get_mutable_consensus_status_by_descriptor_digest,
|
|
@@ -802,7 +802,7 @@ test_md_reject_cache(void *arg)
|
|
done:
|
|
done:
|
|
UNMOCK(networkstatus_get_latest_consensus_by_flavor);
|
|
UNMOCK(networkstatus_get_latest_consensus_by_flavor);
|
|
UNMOCK(router_get_mutable_consensus_status_by_descriptor_digest);
|
|
UNMOCK(router_get_mutable_consensus_status_by_descriptor_digest);
|
|
- tor_free(options->DataDirectory);
|
|
|
|
|
|
+ tor_free(options->CacheDirectory);
|
|
microdesc_free_all();
|
|
microdesc_free_all();
|
|
smartlist_free(added);
|
|
smartlist_free(added);
|
|
SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
|
|
SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
|