Test probe burst, second-level admission and complete-cycle timing boundaries
This commit is contained in:
1 parent
c6bf960eec
commit
fcbdbd6002
1 file changed
+22
@@ -6,6 +6,7 @@
|
||||
#include "../src/stream/stream_source.h"
|
||||
#include "../src/stream/stream_metrics.h"
|
||||
#include "../src/stream/stream_load.h"
|
||||
#include "../src/stream/stream_optimizer.h"
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "test_clock.h"
|
||||
@@ -381,6 +382,26 @@ static void test_source_timer(void) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "[PASS] source: 100ms timer, immediate full batch, padding, finish and cancellation on destroy");
|
||||
}
|
||||
|
||||
static void test_probe_schedule(void) {
|
||||
struct stream_probe_schedule schedule = {0};
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 0, 40, 0) == 32 && schedule.cycle == 1);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 999, 8, 32) == 0);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 1000, 8, 32) == 1 && schedule.cycle == 1);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 1001, 7, 32) == 0);
|
||||
for (uint64_t now = 2000; now <= 29000; now += 1000)
|
||||
CHECK(stream_probe_schedule_tick(&schedule, now, 0, 0) == 1 && schedule.cycle == 1);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 29999, 1, 0) == 0); /* Новая запись не добавляет второй burst. */
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 30000, 1, 0) == 1 && schedule.cycle == 1);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 31000, 0, 1) == 1 && schedule.cycle == 1); /* Ещё идёт старая проба. */
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 32000, 0, 0) == 1 && schedule.cycle == 2 && schedule.started_ms == 32000);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 32001, 40, 0) == 0);
|
||||
memset(&schedule, 0, sizeof(schedule));
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 0, 0, 0) == 32);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 30000, 0, 0) == 1 && schedule.cycle == 2);
|
||||
CHECK(stream_probe_schedule_tick(&schedule, 60000, 0, 0) == 1 && schedule.cycle == 3);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "[PASS] probe schedule: one 32-node burst, 1/s, new peers, 30s minimum and unfinished cycles");
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
debug_config_init();
|
||||
debug_set_level(DEBUG_LEVEL_ERROR);
|
||||
@@ -392,6 +413,7 @@ int main(void) {
|
||||
test_signed_blocks(); CHECK(u_get_allocated_count() == allocations);
|
||||
test_wire(); CHECK(u_get_allocated_count() == allocations);
|
||||
test_load(); CHECK(u_get_allocated_count() == allocations);
|
||||
test_probe_schedule(); CHECK(u_get_allocated_count() == allocations);
|
||||
test_fec_and_padding(); CHECK(u_get_allocated_count() == allocations);
|
||||
test_ring_and_conflicts(); CHECK(u_get_allocated_count() == allocations);
|
||||
test_relative_metrics(); CHECK(u_get_allocated_count() == allocations);
|
||||
|
||||
Reference in new issue
Block a user