add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.
Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 6879c70..18845d4 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -556,7 +556,7 @@
if (osmo_timer_pending(&nsvc->timer))
osmo_timer_del(&nsvc->timer);
- gettimeofday(&nsvc->timer_started, NULL);
+ osmo_gettimeofday(&nsvc->timer_started, NULL);
nsvc->timer_mode = mode;
osmo_timer_schedule(&nsvc->timer, seconds, 0);
}
@@ -564,7 +564,7 @@
static int nsvc_timer_elapsed_ms(struct gprs_nsvc *nsvc)
{
struct timeval now, elapsed;
- gettimeofday(&now, NULL);
+ osmo_gettimeofday(&now, NULL);
timersub(&now, &nsvc->timer_started, &elapsed);
return 1000 * elapsed.tv_sec + elapsed.tv_usec / 1000;