Change in osmo-ttcn3-hacks[master]: cbch: Refactor code to support mixed DEFAULT + NORMAL and EXTENDED CBCH

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/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon May 20 18:15:31 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/14107


Change subject: cbch: Refactor code to support mixed DEFAULT + NORMAL and EXTENDED CBCH
......................................................................

cbch: Refactor code to support mixed DEFAULT + NORMAL and EXTENDED CBCH

The existing code structure could only test for normal messages with a
NULL default, but didn't handle situations where normal and/or schedule
messages were superimposed on top of DEFAULT messages.

Also, prepare the infrastructure for testing both CBCH BASIC and CBCH
EXTENDED.

No new tests are introduced, the code should behave identical before
and after this patch.

Change-Id: I144c7d833b79c648b1ac69a6155f3603025ede5c
Related: OS#4011
---
M bts/BTS_Tests_SMSCB.ttcn
1 file changed, 209 insertions(+), 62 deletions(-)



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

diff --git a/bts/BTS_Tests_SMSCB.ttcn b/bts/BTS_Tests_SMSCB.ttcn
index 9ea60dd..24f5fd2 100644
--- a/bts/BTS_Tests_SMSCB.ttcn
+++ b/bts/BTS_Tests_SMSCB.ttcn
@@ -30,9 +30,28 @@
  * Cell Broadcast related tests
  ***********************************************************************/
 
+/* Test parameters for one channel (e.g. Basic, Extended) */
+type record CbchTestParsChan {
+	/* list of "normal" (sent-once) SMSCB messages */
+	CbchTestMsgs	msgs,
+	/* default message, if any */
+	CbchTestMsg	default_msg optional
+}
+
+private template (value) CbchTestParsChan
+t_CbchPC(template (value) CbchTestMsgs msgs, template (omit) CbchTestMsg def := omit) := {
+	msgs := msgs,
+	default_msg := def
+}
+
+/* CBCH test parameters for most of our tests */
 type record CbchTestPars {
+	/* should we execute on SDCCH4 (true) or SDCCH8 (false) ? */
 	boolean		use_sdcch4,
-	CbchTestMsgs	msgs
+	/* Parameters for BASIC CBCH */
+	CbchTestParsChan basic,
+	/* Parameters for EXTENDED CBCH */
+	CbchTestParsChan extended optional
 };
 
 type record CbchTestMsg {
@@ -56,12 +75,18 @@
 
 /* compute the expected blocks for given test parameters */
 private function f_cbch_compute_exp_blocks(inout CbchTestPars pars) {
-	var integer i;
-
-	for (i := 0; i < lengthof(pars.msgs); i := i+1) {
-		pars.msgs[i].blocks := f_comp_blocks(pars.msgs[i]);
+	f_cbch_compute_exp_blocks_chan(pars.basic);
+	if (ispresent(pars.extended)) {
+		f_cbch_compute_exp_blocks_chan(pars.extended);
 	}
 }
+private function f_cbch_compute_exp_blocks_chan(inout CbchTestParsChan pars_chan) {
+	var integer i;
+	for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) {
+		pars_chan.msgs[i].blocks := f_comp_blocks(pars_chan.msgs[i]);
+	}
+	pars_chan.default_msg.blocks := f_comp_blocks(pars_chan.default_msg);
+}
 private function f_comp_blocks(in CbchTestMsg msg) return CbchBlocks {
 	var CbchBlocks blocks := {};
 	var integer i;
@@ -120,9 +145,34 @@
 	}
 }
 
-private function f_smscb_setup(inout CbchTestPars pars) runs on test_CT {
+private function f_rsl_smscb_default_null() runs on test_CT
+{
+	var RSL_IE_CbCommandType cmd_type :=
+				valueof(ts_RSL_IE_CbCmdType(RSL_CB_CMD_DEFAULT, 1, true));
+	RSL_CCHAN.send(ts_RSL_UD(ts_RSL_SMSCB_CMD(cmd_type, ''O)));
+}
+
+private function f_smscb_setup_rsl_chan(inout CbchTestParsChan pars_chan) runs on test_CT {
 	var integer i;
 
+	/* send SMSCB[s] via RSL */
+	for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) {
+		var CbchTestMsg msg := pars_chan.msgs[i];
+		var uint2_t rsl_last_block := f_cbch_block_nr2rsl(msg.last_block);
+		var RSL_IE_CbCommandType cmd_type :=
+					valueof(ts_RSL_IE_CbCmdType(msg.rsl_cb_cmd, rsl_last_block));
+		RSL_CCHAN.send(ts_RSL_UD(ts_RSL_SMSCB_CMD(cmd_type, msg.payload)));
+	}
+	if (ispresent(pars_chan.default_msg)) {
+		var CbchTestMsg msg := pars_chan.default_msg;
+		var uint2_t rsl_last_block := f_cbch_block_nr2rsl(msg.last_block);
+		var RSL_IE_CbCommandType cmd_type :=
+			valueof(ts_RSL_IE_CbCmdType(msg.rsl_cb_cmd, rsl_last_block, false));
+		RSL_CCHAN.send(ts_RSL_UD(ts_RSL_SMSCB_CMD(cmd_type, msg.payload)));
+	}
+}
+private function f_smscb_setup(inout CbchTestPars pars) runs on test_CT {
+
 	f_cbch_compute_exp_blocks(pars);
 
 	f_init_vty_bsc();
@@ -146,12 +196,9 @@
 	f_l1_tune(L1CTL);
 
 	/* send SMSCB[s] via RSL */
-	for (i := 0; i < lengthof(pars.msgs); i := i+1) {
-		var CbchTestMsg msg := pars.msgs[i];
-		var uint2_t rsl_last_block := f_cbch_block_nr2rsl(msg.last_block);
-		var RSL_IE_CbCommandType cmd_type :=
-					valueof(ts_RSL_IE_CbCmdType(msg.rsl_cb_cmd, rsl_last_block));
-		RSL_CCHAN.send(ts_RSL_UD(ts_RSL_SMSCB_CMD(cmd_type, msg.payload)));
+	f_smscb_setup_rsl_chan(pars.basic);
+	if (ispresent(pars.extended)) {
+		f_smscb_setup_rsl_chan(pars.extended);
 	}
 }
 
@@ -163,58 +210,140 @@
 				"phys_chan_config SDCCH8");
 }
 
+/* construct a receive/match template for given block_nr in given msg */
+private function f_get_block_template(CbchTestMsg msg, integer block_nr) return template CBCH_Block {
+	var template CBCH_Block tr;
+	if (block_nr < lengthof(msg.blocks)) {
+		var CbchBlock b := msg.blocks[block_nr];
+		tr := tr_CBCH_Block(b.seq_nr, b.is_last, b.payload);
+	} else {
+		tr := tr_CBCH_Block(15, ?, ?);
+	}
+	return tr;
+}
+
+/* the heart of the CBCH test case matching engine for one channel (basic, extended) */
+private function f_cbch_match(inout CbchTestParsChan pars_chan, CBCH_Block cb, integer tb)
+{
+	var integer block_nr := tb mod 4;
+	var integer i;
+
+	if (not match(cb, tr_CBCH_Block)) {
+		setverdict(fail, "Illegal CBCH Block received: ", cb);
+	} else {
+		var boolean matched := false;
+		/* check if it's any of our expected blocks */
+		for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) {
+			if (block_nr < lengthof(pars_chan.msgs[i].blocks)) {
+				if (match(cb, f_get_block_template(pars_chan.msgs[i], block_nr))) {
+					log("Found block_nr ", block_nr, " of msg ", i);
+					if (not pars_chan.msgs[i].blocks[block_nr].seen_once) {
+						pars_chan.msgs[i].blocks[block_nr].seen_once := true;
+						setverdict(pass);
+					} else {
+						setverdict(fail, "Received SMSCB twice! ", cb);
+					}
+					matched := true;
+					break;
+				}
+			}
+		}
+		if (not matched) {
+			var template CBCH_Block tr;
+			if (ispresent(pars_chan.default_msg)) {
+				/* it must be a block of the default message */
+				tr := f_get_block_template(pars_chan.default_msg, block_nr);
+			} else {
+				/* it must be a NULL block */
+				tr := tr_CBCH_Block(15, ?, ?);
+			}
+			if (not match(cb, tr)) {
+				setverdict(fail, "Received unexpected CBCH block: ", cb);
+			} else {
+				log("Found block_nr ", block_nr, " of DEFAULT/NULL");
+				if (ispresent(pars_chan.default_msg) and
+				    block_nr < lengthof(pars_chan.default_msg.blocks)) {
+					pars_chan.default_msg.blocks[block_nr].seen_once := true;
+				}
+			}
+		}
+	}
+}
+
+/* Report/Evaluate the per-channel CBCH test results */
+private function f_cbch_report(CbchTestParsChan pars_chan, charstring id)
+{
+	var integer i, j;
+
+	/* verify that each block of each message has been seen once */
+	for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) {
+		for (j := 0; j < lengthof(pars_chan.msgs[i].blocks); j := j+1) {
+			var CbchBlock b := pars_chan.msgs[i].blocks[j];
+			if (not b.seen_once) {
+				setverdict(fail, "Timeout waiting for ", id, " CBCH block ",
+					   j, " of msg ", i);
+			}
+		}
+	}
+	if (ispresent(pars_chan.default_msg)) {
+		/* verify that each block of default message has been seen at least once */
+		for (j := 0; j < lengthof(pars_chan.default_msg.blocks); j := j+1) {
+			var CbchBlock b := pars_chan.default_msg.blocks[j];
+			if (not b.seen_once) {
+				setverdict(fail, "Timeout waiting for at leaset one instance of ",
+					   "CBCH block ", j, " of DEFAULT msg");
+			}
+		}
+	}
+}
+
 /* shared function doing the heavy lifting for most CBCH tests */
 private function f_TC_smscb(CbchTestPars pars) runs on test_CT {
 	var L1ctlDlMessage dl;
-	var integer i, j;
-	timer T := 5.0 * int2float(lengthof(pars.msgs));
+	var integer msg_count;
+	timer T;
+
+	msg_count := lengthof(pars.basic.msgs);
+	if (ispresent(pars.basic.default_msg)) {
+		msg_count := msg_count + 1;
+	}
+	if (ispresent(pars.extended)) {
+		msg_count := msg_count + lengthof(pars.extended.msgs);
+		if (ispresent(pars.extended.default_msg)) {
+			msg_count := msg_count + 1;
+		}
+	}
 
 	f_smscb_setup(pars);
 
-	T.start;
+	/* dynamically adjust timeout based on number of messages */
+	T.start(5.0 + 3.0 * int2float(msg_count));
 	/* Expect this to show up exactly once on the basic CBCH (four blocks) */
 	alt {
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_CBCH(0))) -> value dl {
-		log("CBCH: ", dl);
+		var integer tb := f_cbch_fn2tb(dl.dl_info.frame_nr);
 		var CBCH_Block cb := dec_CBCH_Block(dl.payload.data_ind.payload);
+		log("Tb=", tb, ", CBCH: ", dl, ", block: ", cb);
+
 		/* detect the proper CBCH messages; check frame number */
 		f_cbch_fn_verify(dl.dl_info.frame_nr, cb);
-		if (not match(cb, tr_CBCH_Block)) {
-			setverdict(fail, "Illegal CBCH Block received: ", cb);
+
+		if (tb < 4) {
+			f_cbch_match(pars.basic, cb, tb);
 		} else {
-			var boolean matched := false;
-			/* ignore NULL messages */
-			if (match(cb, tr_CBCH_Block(15, ?, ?))) { repeat; }
-			for (i := 0; i < lengthof(pars.msgs); i := i+1) {
-				for (j := 0; j < lengthof(pars.msgs[i].blocks); j := j+1) {
-					var CbchBlock b := pars.msgs[i].blocks[j];
-					if (match(cb, tr_CBCH_Block(b.seq_nr, b.is_last, b.payload))) {
-						if (not pars.msgs[i].blocks[j].seen_once) {
-							pars.msgs[i].blocks[j].seen_once := true;
-							setverdict(pass);
-						} else {
-							setverdict(fail, "Received SMSCB twice! ", cb);
-						}
-						matched := true;
-						continue;
-					}
-				}
+			if (not ispresent(pars.extended)) {
+				/* no parameters for ext. BCCH given: ignore */
+				repeat;
 			}
-			if (not matched) {
-				setverdict(fail, "Received unexpected CBCH block: ", cb);
-			}
-			repeat;
+			f_cbch_match(pars.extended, cb, tb);
 		}
+		repeat;
 		}
 	[] L1CTL.receive { repeat; }
 	[] T.timeout {
-		for (i := 0; i < lengthof(pars.msgs); i := i+1) {
-			for (j := 0; j < lengthof(pars.msgs[i].blocks); j := j+1) {
-				var CbchBlock b := pars.msgs[i].blocks[j];
-				if (not b.seen_once) {
-					setverdict(fail, "Timeout waiting for CBCH");
-				}
-			}
+		f_cbch_report(pars.basic, "Basic");
+		if (ispresent(pars.extended)) {
+			f_cbch_report(pars.extended, "Extended");
 		}
 		}
 	}
@@ -250,8 +379,8 @@
 		} else {
 			var uint4_t rx_seq_nr := cb.block_type.seq_nr;
 			var template CBCH_Block tr;
-			if (rx_seq_nr < lengthof(pars.msgs[0].blocks)) {
-				var CbchBlock b := pars.msgs[0].blocks[rx_seq_nr];
+			if (rx_seq_nr < lengthof(pars.basic.msgs[0].blocks)) {
+				var CbchBlock b := pars.basic.msgs[0].blocks[rx_seq_nr];
 				tr := tr_CBCH_Block(b.seq_nr, b.is_last, b.payload);
 			} else {
 				tr := tr_CBCH_Block(15, ?, ?);
@@ -329,19 +458,25 @@
 				'101112131415161718191a1b1c1d1e1f202223242526'O,
 	  omit }
 }
+private const CbchTestMsg msg_default := {
+	RSL_CB_CMD_DEFAULT, 0, '010203040506070708090a0b0c0d0e0f101112131415'O,
+	omit
+}
 
 /* transmit single-block SMSCB COMMAND */
 testcase TC_sms_cb_cmd_sdcch4_1block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_1b_norm
+		basic := valueof(t_CbchPC(msgs_1m_1b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
 testcase TC_sms_cb_cmd_sdcch8_1block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := false,
-		msgs := msgs_1m_1b_norm
+		basic := valueof(t_CbchPC(msgs_1m_1b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
@@ -350,14 +485,16 @@
 testcase TC_sms_cb_cmd_sdcch4_2block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_2b_norm
+		basic := valueof(t_CbchPC(msgs_1m_2b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
 testcase TC_sms_cb_cmd_sdcch8_2block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := false,
-		msgs := msgs_1m_2b_norm
+		basic := valueof(t_CbchPC(msgs_1m_2b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
@@ -366,14 +503,16 @@
 testcase TC_sms_cb_cmd_sdcch4_3block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_3b_norm
+		basic := valueof(t_CbchPC(msgs_1m_3b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
 testcase TC_sms_cb_cmd_sdcch8_3block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := false,
-		msgs := msgs_1m_3b_norm
+		basic := valueof(t_CbchPC(msgs_1m_3b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
@@ -382,14 +521,16 @@
 testcase TC_sms_cb_cmd_sdcch4_4block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_4b_norm
+		basic := valueof(t_CbchPC(msgs_1m_4b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
 testcase TC_sms_cb_cmd_sdcch8_4block() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := false,
-		msgs := msgs_1m_4b_norm
+		basic := valueof(t_CbchPC(msgs_1m_4b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
@@ -398,14 +539,16 @@
 testcase TC_sms_cb_cmd_sdcch4_multi() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_3m_4b_norm
+		basic := valueof(t_CbchPC(msgs_3m_4b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
 testcase TC_sms_cb_cmd_sdcch8_multi() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := false,
-		msgs := msgs_3m_4b_norm
+		basic := valueof(t_CbchPC(msgs_3m_4b_norm)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
@@ -414,14 +557,16 @@
 testcase TC_sms_cb_cmd_sdcch4_schedule() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_4b_sched
+		basic := valueof(t_CbchPC(msgs_1m_4b_sched)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
 testcase TC_sms_cb_cmd_sdcch8_schedule() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := false,
-		msgs := msgs_1m_4b_sched
+		basic := valueof(t_CbchPC(msgs_1m_4b_sched)),
+		extended := omit
 	};
 	f_TC_smscb(pars);
 }
@@ -430,7 +575,8 @@
 testcase TC_sms_cb_cmd_sdcch4_default_only() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_3b_default
+		basic := valueof(t_CbchPC(msgs_1m_3b_default)),
+		extended := omit
 	};
 	f_TC_smscb_default_only(pars);
 	Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass);
@@ -438,7 +584,8 @@
 testcase TC_sms_cb_cmd_sdcch8_default_only() runs on test_CT {
 	var CbchTestPars pars := {
 		use_sdcch4 := true,
-		msgs := msgs_1m_3b_default
+		basic := valueof(t_CbchPC(msgs_1m_3b_default)),
+		extended := omit
 	};
 	f_TC_smscb_default_only(pars);
 	Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass);

-- 
To view, visit https://gerrit.osmocom.org/14107
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I144c7d833b79c648b1ac69a6155f3603025ede5c
Gerrit-Change-Number: 14107
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190520/16294b73/attachment.htm>


More information about the gerrit-log mailing list