mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
Fix unit tests that depended on monotonic msec.
This commit is contained in:
parent
c3c0a05f51
commit
9c37e8c8d1
@ -222,7 +222,6 @@ test_oom_streambuf(void *arg)
|
||||
tt_int_op(buf_get_total_allocation(), OP_EQ, 0);
|
||||
|
||||
monotime_coarse_set_mock_time_nsec(start_ns);
|
||||
const uint32_t ts_start = monotime_coarse_get_stamp();
|
||||
|
||||
/* Start all circuits with a bit of data queued in cells */
|
||||
|
||||
@ -272,23 +271,27 @@ test_oom_streambuf(void *arg)
|
||||
now_ns += 1000000000;
|
||||
monotime_coarse_set_mock_time_nsec(now_ns);
|
||||
tvts = monotime_coarse_get_stamp();
|
||||
const uint32_t diff = tvts - ts_start;
|
||||
printf("\n!!!! %u\n", (unsigned) diff);
|
||||
|
||||
tt_int_op(circuit_max_queued_cell_age(c1, tvts), OP_EQ, 500);
|
||||
tt_int_op(circuit_max_queued_cell_age(c2, tvts), OP_EQ, 490);
|
||||
tt_int_op(circuit_max_queued_cell_age(c3, tvts), OP_EQ, 480);
|
||||
tt_int_op(circuit_max_queued_cell_age(c4, tvts), OP_EQ, 0);
|
||||
#define ts_is_approx(ts, val) do { \
|
||||
uint32_t x_ = (uint32_t) monotime_coarse_stamp_units_to_approx_msec(ts); \
|
||||
tt_int_op(x_, OP_GE, val - 5); \
|
||||
tt_int_op(x_, OP_LE, val + 5); \
|
||||
} while (0)
|
||||
|
||||
tt_int_op(circuit_max_queued_data_age(c1, tvts), OP_EQ, 390);
|
||||
tt_int_op(circuit_max_queued_data_age(c2, tvts), OP_EQ, 380);
|
||||
tt_int_op(circuit_max_queued_data_age(c3, tvts), OP_EQ, 0);
|
||||
tt_int_op(circuit_max_queued_data_age(c4, tvts), OP_EQ, 370);
|
||||
ts_is_approx(circuit_max_queued_cell_age(c1, tvts), 500);
|
||||
ts_is_approx(circuit_max_queued_cell_age(c2, tvts), 490);
|
||||
ts_is_approx(circuit_max_queued_cell_age(c3, tvts), 480);
|
||||
ts_is_approx(circuit_max_queued_cell_age(c4, tvts), 0);
|
||||
|
||||
tt_int_op(circuit_max_queued_item_age(c1, tvts), OP_EQ, 500);
|
||||
tt_int_op(circuit_max_queued_item_age(c2, tvts), OP_EQ, 490);
|
||||
tt_int_op(circuit_max_queued_item_age(c3, tvts), OP_EQ, 480);
|
||||
tt_int_op(circuit_max_queued_item_age(c4, tvts), OP_EQ, 370);
|
||||
ts_is_approx(circuit_max_queued_data_age(c1, tvts), 390);
|
||||
ts_is_approx(circuit_max_queued_data_age(c2, tvts), 380);
|
||||
ts_is_approx(circuit_max_queued_data_age(c3, tvts), 0);
|
||||
ts_is_approx(circuit_max_queued_data_age(c4, tvts), 370);
|
||||
|
||||
ts_is_approx(circuit_max_queued_item_age(c1, tvts), 500);
|
||||
ts_is_approx(circuit_max_queued_item_age(c2, tvts), 490);
|
||||
ts_is_approx(circuit_max_queued_item_age(c3, tvts), 480);
|
||||
ts_is_approx(circuit_max_queued_item_age(c4, tvts), 370);
|
||||
|
||||
tt_int_op(cell_queues_get_total_allocation(), OP_EQ,
|
||||
packed_cell_mem_cost() * 80);
|
||||
@ -304,7 +307,7 @@ test_oom_streambuf(void *arg)
|
||||
smartlist_add(edgeconns, ec);
|
||||
}
|
||||
tt_int_op(buf_get_total_allocation(), OP_EQ, 4096*17*2);
|
||||
tt_int_op(circuit_max_queued_item_age(c4, tvts), OP_EQ, 1000);
|
||||
ts_is_approx(circuit_max_queued_item_age(c4, tvts), 1000);
|
||||
|
||||
tt_int_op(cell_queues_check_size(), OP_EQ, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user