aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-18 15:04:14 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-18 15:04:14 -0400
commitc31700d6640a10eb5e406205c2753e69efd217ec (patch)
tree93a2098efdfa0c9b6ebccdc39f6b6b586af00d5c /src/test/test_dir.c
parent28d1057d5658a47dfcaa52c163e5861b4db5670a (diff)
parent559f79fd79b7c22caac2888f82e92307be02904a (diff)
downloadtor-c31700d6640a10eb5e406205c2753e69efd217ec.tar.gz
tor-c31700d6640a10eb5e406205c2753e69efd217ec.zip
Merge branch 'maint-0.3.2' into maint-0.3.3
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 165029d232..a33b23bcc9 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -5853,6 +5853,57 @@ test_dir_networkstatus_consensus_has_ipv6(void *arg)
UNMOCK(networkstatus_get_latest_consensus_by_flavor);
}
+static void
+test_dir_format_versions_list(void *arg)
+{
+ (void)arg;
+ char *s = NULL;
+ config_line_t *lines = NULL;
+
+ setup_capture_of_logs(LOG_WARN);
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "");
+
+ tor_free(s);
+ config_line_append(&lines, "ignored", "0.3.4.1, 0.2.9.111-alpha, 4.4.4-rc");
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
+
+ tor_free(s);
+ config_line_append(&lines, "ignored", "0.1.2.3,0.2.9.10 ");
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,4.4.4-rc");
+
+ /* There should be no warnings so far. */
+ expect_no_log_entry();
+
+ /* Now try a line with a space in it. */
+ tor_free(s);
+ config_line_append(&lines, "ignored", "1.3.3.8 1.3.3.7");
+ s = format_recommended_version_list(lines, 1);
+ tt_str_op(s, OP_EQ, "0.1.2.3,0.2.9.10,0.2.9.111-alpha,0.3.4.1,"
+ "1.3.3.7,1.3.3.8,4.4.4-rc");
+
+ expect_single_log_msg_containing(
+ "Unexpected space in versions list member \"1.3.3.8 1.3.3.7\"." );
+
+ /* Start over, with a line containing a bogus version */
+ config_free_lines(lines);
+ lines = NULL;
+ tor_free(s);
+ mock_clean_saved_logs();
+ config_line_append(&lines, "ignored", "0.1.2.3, alpha-complex, 0.1.1.8-rc");
+ s = format_recommended_version_list(lines,1);
+ tt_str_op(s, OP_EQ, "0.1.1.8-rc,0.1.2.3,alpha-complex");
+ expect_single_log_msg_containing(
+ "Recommended version \"alpha-complex\" does not look valid.");
+
+ done:
+ tor_free(s);
+ config_free_lines(lines);
+ teardown_capture_of_logs();
+}
+
#define DIR_LEGACY(name) \
{ #name, test_dir_ ## name , TT_FORK, NULL, NULL }
@@ -5921,6 +5972,6 @@ struct testcase_t dir_tests[] = {
DIR(networkstatus_compute_bw_weights_v10, 0),
DIR(platform_str, 0),
DIR(networkstatus_consensus_has_ipv6, TT_FORK),
+ DIR(format_versions_list, TT_FORK),
END_OF_TESTCASES
};
-