mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Address some issues with unit tests.
Histogram conversion causes accuracy loss, and there are some boundary conditions when we hit 1000 circuits that cause false negative test results.
This commit is contained in:
parent
38770dd6a5
commit
e3d5b516c6
@ -495,13 +495,12 @@ test_circuit_timeout(void)
|
|||||||
CBT_DEFAULT_QUANTILE_CUTOFF/100.0);
|
CBT_DEFAULT_QUANTILE_CUTOFF/100.0);
|
||||||
circuit_build_times_set_timeout(&estimate);
|
circuit_build_times_set_timeout(&estimate);
|
||||||
log_warn(LD_CIRC, "Timeout1 is %lf, Xm is %d", timeout1, estimate.Xm);
|
log_warn(LD_CIRC, "Timeout1 is %lf, Xm is %d", timeout1, estimate.Xm);
|
||||||
/* XXX: 5% distribution error may not be the right metric */
|
|
||||||
} while (fabs(circuit_build_times_cdf(&initial, timeout0) -
|
} while (fabs(circuit_build_times_cdf(&initial, timeout0) -
|
||||||
circuit_build_times_cdf(&initial, timeout1)) > 0.05
|
circuit_build_times_cdf(&initial, timeout1)) > 0.02
|
||||||
/* 5% error */
|
/* 2% error */
|
||||||
&& estimate.total_build_times < CBT_NCIRCUITS_TO_OBSERVE);
|
&& estimate.total_build_times < CBT_NCIRCUITS_TO_OBSERVE);
|
||||||
|
|
||||||
test_assert(estimate.total_build_times < CBT_NCIRCUITS_TO_OBSERVE);
|
test_assert(estimate.total_build_times <= CBT_NCIRCUITS_TO_OBSERVE);
|
||||||
|
|
||||||
circuit_build_times_update_state(&estimate, &state);
|
circuit_build_times_update_state(&estimate, &state);
|
||||||
test_assert(circuit_build_times_parse_state(&final, &state, &msg) == 0);
|
test_assert(circuit_build_times_parse_state(&final, &state, &msg) == 0);
|
||||||
@ -513,6 +512,7 @@ test_circuit_timeout(void)
|
|||||||
circuit_build_times_set_timeout(&final);
|
circuit_build_times_set_timeout(&final);
|
||||||
log_warn(LD_CIRC, "Timeout2 is %lf, Xm is %d", timeout2, final.Xm);
|
log_warn(LD_CIRC, "Timeout2 is %lf, Xm is %d", timeout2, final.Xm);
|
||||||
|
|
||||||
|
/* 5% here because some accuracy is lost due to histogram conversion */
|
||||||
test_assert(fabs(circuit_build_times_cdf(&initial, timeout0) -
|
test_assert(fabs(circuit_build_times_cdf(&initial, timeout0) -
|
||||||
circuit_build_times_cdf(&initial, timeout2)) < 0.05);
|
circuit_build_times_cdf(&initial, timeout2)) < 0.05);
|
||||||
|
|
||||||
@ -581,7 +581,10 @@ test_circuit_timeout(void)
|
|||||||
|
|
||||||
/* Check rollback index. Should match top of loop. */
|
/* Check rollback index. Should match top of loop. */
|
||||||
test_assert(build_times_idx == estimate.build_times_idx);
|
test_assert(build_times_idx == estimate.build_times_idx);
|
||||||
test_assert(total_build_times == estimate.total_build_times);
|
// This can fail if estimate.total_build_times == 1000, because
|
||||||
|
// in that case, rewind actually causes us to lose timeouts
|
||||||
|
if (total_build_times != CBT_NCIRCUITS_TO_OBSERVE)
|
||||||
|
test_assert(total_build_times == estimate.total_build_times);
|
||||||
|
|
||||||
/* Now simulate that the network has become live and we need
|
/* Now simulate that the network has become live and we need
|
||||||
* a change */
|
* a change */
|
||||||
|
Loading…
Reference in New Issue
Block a user