diff options
author | Mike Perry <mikeperry-git@fscked.org> | 2010-05-12 15:31:22 -0700 |
---|---|---|
committer | Mike Perry <mikeperry-git@fscked.org> | 2010-05-12 15:31:22 -0700 |
commit | d9be6f38450fd4c20f5c3711e68676547997b23c (patch) | |
tree | 4083408446228ba747216e40d46eb6b37b77de66 /src/or | |
parent | 8ada0011f9a019ecabffc1d154447e6cb34c7567 (diff) | |
download | tor-d9be6f38450fd4c20f5c3711e68676547997b23c.tar tor-d9be6f38450fd4c20f5c3711e68676547997b23c.tar.gz |
Fix CBT unit tests.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/circuitbuild.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 1d4d267b7..97e7c1c0f 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -84,22 +84,26 @@ static void entry_guards_changed(void); static int circuit_build_times_disabled(void) { - int consensus_disabled = networkstatus_get_param(NULL, "cbtdisabled", - 0); - int config_disabled = !get_options()->LearnCircuitBuildTimeout; - int dirauth_disabled = get_options()->AuthoritativeDir; - int state_disabled = (get_or_state()->LastWritten == -1); - - if (consensus_disabled || config_disabled || dirauth_disabled || - state_disabled) { - log_info(LD_CIRC, - "CircuitBuildTime learning is disabled. " - "Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d", - consensus_disabled, config_disabled, dirauth_disabled, - state_disabled); - return 1; - } else { + if (unit_tests) { return 0; + } else { + int consensus_disabled = networkstatus_get_param(NULL, "cbtdisabled", + 0); + int config_disabled = !get_options()->LearnCircuitBuildTimeout; + int dirauth_disabled = get_options()->AuthoritativeDir; + int state_disabled = (get_or_state()->LastWritten == -1); + + if (consensus_disabled || config_disabled || dirauth_disabled || + state_disabled) { + log_info(LD_CIRC, + "CircuitBuildTime learning is disabled. " + "Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d", + consensus_disabled, config_disabled, dirauth_disabled, + state_disabled); + return 1; + } else { + return 0; + } } } @@ -1104,6 +1108,12 @@ circuit_build_times_filter_timeouts(circuit_build_times_t *cbt) return 0; } + /* Do not filter for unit tests. They expect the distribution to be + * unchanged from run to run. */ + if (unit_tests) { + return 0; + } + timeout_rate = circuit_build_times_timeout_rate(cbt); max_timeout = (build_time_t)tor_lround(circuit_build_times_calculate_timeout(cbt, circuit_build_times_max_synthetic_quantile())); |