summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-10-07 14:03:44 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-10-09 07:44:47 +0200
commitf1bcbb0f8a92429ae086bef0064ce5a5cebd75d0 (patch)
tree178772c9686443b79aea8316217b684ad12e85f0
parent2381fded689d5e2d19f4ed2e8ab7d7b83788b8b5 (diff)
gprs-ns/test: Add expire_nsvc_timer
This function forces the expiration of the timer within struct gprs_nsvc. It is meant to be used for controlled (and faster) timer expiration in unit tests. The timer_mode of the expired timer is returned (or -1 if the timer wasn't active). Sponsored-by: On-Waves ehf
-rw-r--r--tests/gb/gprs_ns_test.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index 0b3a76c4..d56bf9ae 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -451,6 +451,21 @@ static void gprs_dump_nsi(struct gprs_ns_inst *nsi)
printf("\n");
}
+static int expire_nsvc_timer(struct gprs_nsvc *nsvc)
+{
+ int rc;
+
+ if (!osmo_timer_pending(&nsvc->timer))
+ return -1;
+
+ rc = nsvc->timer_mode;
+ osmo_timer_del(&nsvc->timer);
+
+ nsvc->timer.cb(nsvc->timer.data);
+
+ return rc;
+}
+
static void test_nsvc()
{
struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);