[PATCH] osmo-ttcn3-hacks[master]: bts: Introduce f_rsl_transceive() and reduce code duplication

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Feb 25 11:50:49 UTC 2018


Review at  https://gerrit.osmocom.org/6895

bts: Introduce f_rsl_transceive() and reduce code duplication

Change-Id: I56de61e08bd1508a0531f720561ead84d1075de3
---
M bts/BTS_Tests.ttcn
1 file changed, 23 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/95/6895/1

diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 9deb377..77c1560 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -213,33 +213,35 @@
 	fn.apply(id);
 }
 
-
-function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on ConnHdlr {
-	RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, mode));
+function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id)
+runs on ConnHdlr {
+	timer T := 3.0;
+	RSL.send(tx);
+	T.start;
 	alt {
-	[] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
-		g_Tmeas_exp.start;
+	[] RSL.receive(exp_rx) {
+		T.stop;
+		setverdict(pass);
 		}
-	[] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
-		setverdict(fail, "Unexpected RF CHAN ACT NACK");
+	[] T.timeout {
+		setverdict(fail, "Timeout expecting " & id);
+		self.stop;
+		}
+	[] RSL.receive {
+		setverdict(fail, "Unexpected RSL message received");
 		}
 	}
+}
+
+function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on ConnHdlr {
+	f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
+			 "RSL CHAN ACT");
 }
 
 function f_rsl_chan_deact() runs on ConnHdlr {
-	timer T := 3.0;
-	RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
-	T.start;
-	alt {
-	[] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
-		g_Tmeas_exp.stop;
-		}
-	[] T.timeout {
-		setverdict(fail, "Timeout waiting for RF CHAN REL ACK");
-		}
-	}
+	f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
+			"RF CHAN REL");
 }
-
 
 private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
 					template RSL_IE_ChannelMode chan_mode,
@@ -1000,20 +1002,8 @@
 
 /* Send IPA DLCX to inactive lchan */
 function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
-	timer T := 3.0;
-	RSL.send(ts_RSL_IPA_DLCX(g_chan_nr));
-	T.start;
-	alt {
-	[] RSL.receive(tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?)) {
-		setverdict(pass);
-		}
-	[] RSL.receive(tr_RSL_IPA_DLCX_NACK(g_chan_nr, ?)) {
-		setverdict(fail);
-		}
-	[] T.timeout {
-		setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
-		}
-	}
+	f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
+			 "IPA DLCX ACK");
 }
 testcase TC_ipa_dlcx_not_active() runs on test_CT {
 	var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));

-- 
To view, visit https://gerrit.osmocom.org/6895
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56de61e08bd1508a0531f720561ead84d1075de3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>


More information about the gerrit-log mailing list