summaryrefslogtreecommitdiff
path: root/src/test/test_config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-12-15 14:04:00 -0500
committerNick Mathewson <nickm@torproject.org>2015-12-15 14:04:00 -0500
commit6ba8afe5f87a1edd16f4c61cbb59a29f9126c6c6 (patch)
treeb8d2a7644c9c0e5599e982fcc38769038defe943 /src/test/test_config.c
parenta56fb58d6e1e93b95e2a060b61f3d00eab95a298 (diff)
parent4c1c2a313dcd3638eededd4a1a83ed5f0b8b9fed (diff)
downloadtor-6ba8afe5f87a1edd16f4c61cbb59a29f9126c6c6.tar.gz
tor-6ba8afe5f87a1edd16f4c61cbb59a29f9126c6c6.zip
Merge remote-tracking branch 'teor/feature15775-fallback-v9-squashed'
Diffstat (limited to 'src/test/test_config.c')
-rw-r--r--src/test/test_config.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 0137d1c49a..53fc693a33 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -1692,9 +1692,9 @@ test_config_adding_dir_servers(void *arg)
);
/* We need to know if add_default_fallback_dir_servers is called,
+ * whatever the size of the list in fallback_dirs.inc,
* so we use a version of add_default_fallback_dir_servers that adds
- * one known default fallback directory.
- * There doesn't appear to be any need to test it unmocked. */
+ * one known default fallback directory. */
MOCK(add_default_fallback_dir_servers,
add_default_fallback_dir_servers_known_default);
@@ -3492,6 +3492,33 @@ test_config_use_multiple_directories(void *arg)
tor_free(options);
}
+static void
+test_config_default_fallback_dirs(void *arg)
+{
+ const char *fallback[] = {
+#include "../or/fallback_dirs.inc"
+ NULL
+ };
+
+ int n_included_fallback_dirs = 0;
+ int n_added_fallback_dirs = 0;
+
+ (void)arg;
+ clear_dir_servers();
+
+ while (fallback[n_included_fallback_dirs])
+ n_included_fallback_dirs++;
+
+ add_default_fallback_dir_servers();
+
+ n_added_fallback_dirs = smartlist_len(router_get_fallback_dir_servers());
+
+ tt_assert(n_included_fallback_dirs == n_added_fallback_dirs);
+
+ done:
+ clear_dir_servers();
+}
+
#define CONFIG_TEST(name, flags) \
{ #name, test_config_ ## name, flags, NULL, NULL }
@@ -3503,6 +3530,7 @@ struct testcase_t config_tests[] = {
CONFIG_TEST(adding_default_trusted_dir_servers, TT_FORK),
CONFIG_TEST(adding_dir_servers, TT_FORK),
CONFIG_TEST(default_dir_servers, TT_FORK),
+ CONFIG_TEST(default_fallback_dirs, 0),
CONFIG_TEST(resolve_my_address, TT_FORK),
CONFIG_TEST(addressmap, 0),
CONFIG_TEST(parse_bridge_line, 0),