summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-22 03:58:13 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-22 07:18:39 +0200
commit8e2f7e87f4d854e697c40545326a16e50614dd5c (patch)
tree4474fbe1c0fa0262167b980227efe0c7280f9280 /tests
parent13a8fb84f0d83f23e65daa528f2f392ec3b83a75 (diff)
add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
Diffstat (limited to 'tests')
-rw-r--r--tests/gb/bssgp_fc_test.c4
-rw-r--r--tests/timer/timer_test.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/gb/bssgp_fc_test.c b/tests/gb/bssgp_fc_test.c
index ad8f83d6..d77f141a 100644
--- a/tests/gb/bssgp_fc_test.c
+++ b/tests/gb/bssgp_fc_test.c
@@ -22,7 +22,7 @@ int get_centisec_diff(void)
{
struct timeval tv;
struct timeval now;
- gettimeofday(&now, NULL);
+ osmo_gettimeofday(&now, NULL);
timersub(&now, &tv_start, &tv);
@@ -73,7 +73,7 @@ static void test_fc(uint32_t bucket_size_max, uint32_t bucket_leak_rate,
bssgp_fc_init(fc, bucket_size_max, bucket_leak_rate, max_queue_depth,
fc_out_cb);
- gettimeofday(&tv_start, NULL);
+ osmo_gettimeofday(&tv_start, NULL);
for (i = 0; i < pdu_count; i++) {
fc_in(fc, pdu_len);
diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c
index 1aeab454..6308113c 100644
--- a/tests/timer/timer_test.c
+++ b/tests/timer/timer_test.c
@@ -87,7 +87,7 @@ static void main_timer_fired(void *data)
fprintf(stderr, "timer_test: OOM!\n");
return;
}
- gettimeofday(&v->start, NULL);
+ osmo_gettimeofday(&v->start, NULL);
v->timer.cb = secondary_timer_fired;
v->timer.data = v;
unsigned int seconds = (random() % 10) + 1;
@@ -108,7 +108,7 @@ static void secondary_timer_fired(void *data)
struct test_timer *v = data, *this, *tmp;
struct timeval current, res, precision = { 1, 0 };
- gettimeofday(&current, NULL);
+ osmo_gettimeofday(&current, NULL);
timersub(&current, &v->stop, &res);
if (timercmp(&res, &precision, >)) {