aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-20 10:10:02 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-20 10:10:02 -0400
commitf9155ff416851e1a5523df92457fbc31a11141a8 (patch)
treed638322763ac77a5b77eb9c83d2860d96a863b49 /src/test/test_dir.c
parentff0aabc35d3688410846d7fee1a0dc9220b189ef (diff)
downloadtor-f9155ff416851e1a5523df92457fbc31a11141a8.tar.gz
tor-f9155ff416851e1a5523df92457fbc31a11141a8.zip
Unit test to make sure that our platform string is parseable
Closes 22109.
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 2d48cfc3c4..b920655db5 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -6140,6 +6140,29 @@ test_dir_post_parsing(void *arg)
;
}
+static void
+test_dir_platform_str(void *arg)
+{
+ char platform[256];
+ (void)arg;
+ platform[0] = 0;
+ get_platform_str(platform, sizeof(platform));
+ tt_int_op((int)strlen(platform), OP_GT, 0);
+ tt_assert(!strcmpstart(platform, "Tor "));
+
+ tor_version_t ver;
+ // make sure this is a tor version, a real actual tor version.
+ tt_int_op(tor_version_parse_platform(platform, &ver, 1), OP_EQ, 1);
+
+ TT_BLATHER(("%d.%d.%d.%d", ver.major, ver.minor, ver.micro, ver.patchlevel));
+
+ // Handle an example version.
+ tt_int_op(tor_version_parse_platform(
+ "Tor 0.3.3.3 (foo) (git-xyzzy) on a potato", &ver, 1), OP_EQ, 1);
+ done:
+ ;
+}
+
#define DIR_LEGACY(name) \
{ #name, test_dir_ ## name , TT_FORK, NULL, NULL }
@@ -6205,6 +6228,7 @@ struct testcase_t dir_tests[] = {
DIR_ARG(find_dl_schedule, TT_FORK, "car"),
DIR(assumed_flags, 0),
DIR(networkstatus_compute_bw_weights_v10, 0),
+ DIR(platform_str, 0),
END_OF_TESTCASES
};