[PATCH 3/6] gprs-ns/test: Add expire_nsvc_timer

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Wed Oct 8 10:05:15 UTC 2014


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
---
 tests/gb/gprs_ns_test.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index 0b3a76c..d56bf9a 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);
-- 
1.9.1





More information about the OpenBSC mailing list