From patchwork Wed Oct 8 10:05:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Erlbeck X-Patchwork-Id: 397584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 27EBE140077 for ; Wed, 8 Oct 2014 21:10:33 +1100 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1XboCA-0001MQ-JJ; Wed, 08 Oct 2014 12:10:11 +0200 Received: from mail.sysmocom.de ([144.76.43.93]) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1Xbo8G-0001K6-Hs for openbsc@lists.osmocom.org; Wed, 08 Oct 2014 12:06:10 +0200 Received: from sysmocom-tmp.lan (e178216153.adsl.alicedsl.de [85.178.216.153]) by mail.sysmocom.de (Postfix) with ESMTPSA id 306817DD4D; Wed, 8 Oct 2014 10:06:08 +0000 (UTC) From: Jacob Erlbeck To: openbsc@lists.osmocom.org Subject: [PATCH 3/6] gprs-ns/test: Add expire_nsvc_timer Date: Wed, 8 Oct 2014 12:05:15 +0200 Message-Id: <1412762718-31961-3-git-send-email-jerlbeck@sysmocom.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> References: <1412762718-31961-1-git-send-email-jerlbeck@sysmocom.de> X-Spam-Score: 0.0 (/) Cc: Jacob Erlbeck X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org 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);