[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add unit test for #13290
commit b3bc8712140b8268cb3714b17b9678eefe66e90e
Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date: Fri Feb 6 20:39:10 2015 +0100
Add unit test for #13290
---
src/or/circuitstats.c | 2 +-
src/test/test.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index 18cb1c8..7b3ad56 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -1074,7 +1074,7 @@ circuit_build_times_update_alpha(circuit_build_times_t *cbt)
* random_sample_from_Pareto_distribution
* That's right. I'll cite wikipedia all day long.
*
- * Return value is in milliseconds.
+ * Return value is in milliseconds, clamped to INT32_MAX.
*/
STATIC double
circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
diff --git a/src/test/test.c b/src/test/test.c
index 85a7ad6..7995af3 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -442,6 +442,14 @@ test_circuit_timeout(void *arg)
tt_assert(circuit_build_times_network_check_live(&final));
circuit_build_times_count_timeout(&final, 1);
+
+ /* Ensure return value for degenerate cases are clamped correctly */
+ initial.alpha = INT32_MAX;
+ tt_assert(circuit_build_times_calculate_timeout(&initial, .99999999) <=
+ INT32_MAX);
+ initial.alpha = 0;
+ tt_assert(circuit_build_times_calculate_timeout(&initial, .5) <=
+ INT32_MAX);
}
done:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits