aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjuga0 <juga@riseup.net>2018-05-08 16:23:37 +0000
committerjuga0 <juga@riseup.net>2018-05-09 15:58:25 +0000
commitdbdde76f56d0ecb2ef03ac6ec231151016ffbd88 (patch)
treee7c61b37e8ff12e69b9ee411515cbd410ef4bc11 /src
parent867fe40f91b849393b56109586d85e499a53a142 (diff)
downloadtor-dbdde76f56d0ecb2ef03ac6ec231151016ffbd88.tar.gz
tor-dbdde76f56d0ecb2ef03ac6ec231151016ffbd88.zip
Test read bandwidth measurements with empty file
Diffstat (limited to 'src')
-rw-r--r--src/test/test_dir.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb89..ad5f086434 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
return;
}
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+ char *fname=NULL;
+ (void)arg;
+
+ fname = tor_strdup(get_fname("V3BandwidthsFile"));
+ /* Test an empty file */
+ write_str_to_file(fname, "", 0);
+ setup_capture_of_logs(LOG_WARN);
+ tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+ expect_log_msg("Empty bandwidth file\n");
+
+ done:
+ tor_free(fname);
+ teardown_capture_of_logs();
+}
+
#define MBWC_INIT_TIME 1000
/** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
DIR_LEGACY(versions),
DIR_LEGACY(fp_pairs),
DIR(split_fps, 0),
+ DIR_LEGACY(dirserv_read_measured_bandwidths),
DIR_LEGACY(measured_bw_kb),
DIR_LEGACY(measured_bw_kb_cache),
DIR_LEGACY(param_voting),