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/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/10663
Change subject: measurement: add unit tests for is_meas_complete()
......................................................................
measurement: add unit tests for is_meas_complete()
We do not test is_meas_complete() individually yet, but it is an
integral part of the measurement processings since this function decides
where a measurement interval ends.
- Add unit tests that test TCH/F, TCH/H, SDCCH/4 and STDCH/8
Change-Id: I8f89d9e7092cd65ba4d5c5649140692dcc20bdd6
Related: OS#2987
---
M include/osmo-bts/measurement.h
M src/common/measurement.c
M tests/meas/meas_test.c
M tests/meas/meas_test.ok
4 files changed, 184 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/63/10663/1
diff --git a/include/osmo-bts/measurement.h b/include/osmo-bts/measurement.h
index 57eeef5..5c3def0 100644
--- a/include/osmo-bts/measurement.h
+++ b/include/osmo-bts/measurement.h
@@ -12,6 +12,8 @@
void lchan_meas_reset(struct gsm_lchan *lchan);
+int is_meas_complete(struct gsm_lchan *lchan, uint32_t fn);
+
bool is_meas_overdue(struct gsm_lchan *lchan, uint32_t *fn_missed_end, uint32_t fn);
#endif
diff --git a/src/common/measurement.c b/src/common/measurement.c
index cb45e6e..2dc60d5 100644
--- a/src/common/measurement.c
+++ b/src/common/measurement.c
@@ -245,7 +245,7 @@
}
/* determine if a measurement period ends at the given frame number */
-static int is_meas_complete(struct gsm_lchan *lchan, uint32_t fn)
+int is_meas_complete(struct gsm_lchan *lchan, uint32_t fn)
{
unsigned int fn_mod = -1;
const uint8_t *tbl;
diff --git a/tests/meas/meas_test.c b/tests/meas/meas_test.c
index ec89df9..0166771 100644
--- a/tests/meas/meas_test.c
+++ b/tests/meas/meas_test.c
@@ -484,6 +484,182 @@
OSMO_ASSERT(fn_missed_end == LCHAN_FN_DUMMY);
}
+static void test_is_meas_complete_single(struct gsm_lchan *lchan,
+ uint32_t fn_end, uint8_t intv_len)
+{
+ unsigned int i;
+ unsigned int k;
+ int rc;
+ uint32_t offset;
+
+ /* Walk through multiple measurement intervals and make sure that the
+ * interval end is detected only in the expected location */
+ for (k = 0; k < 100; k++) {
+ offset = intv_len * k;
+ for (i = 0; i < intv_len; i++) {
+ rc = is_meas_complete(lchan, i + offset);
+ if (rc)
+ OSMO_ASSERT(i + offset == fn_end + offset);
+ }
+ }
+}
+
+static void test_is_meas_complete(void)
+{
+ struct gsm_lchan *lchan;
+ printf("\n\n");
+ printf("===========================================================\n");
+ printf("Testing is_meas_complete()\n");
+
+ /* Test interval end detection on TCH/F TS0-TS7 */
+ lchan = &trx->ts[0].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 12, 104);
+
+ lchan = &trx->ts[1].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 25, 104);
+
+ lchan = &trx->ts[2].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 38, 104);
+
+ lchan = &trx->ts[3].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 51, 104);
+
+ lchan = &trx->ts[4].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 64, 104);
+
+ lchan = &trx->ts[5].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 77, 104);
+
+ lchan = &trx->ts[6].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 90, 104);
+
+ lchan = &trx->ts[7].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_F;
+ test_is_meas_complete_single(lchan, 103, 104);
+
+ /* Test interval end detection on TCH/H TS0-TS7 */
+ lchan = &trx->ts[0].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 12, 104);
+
+ lchan = &trx->ts[1].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 12, 104);
+
+ lchan = &trx->ts[0].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 25, 104);
+
+ lchan = &trx->ts[1].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 25, 104);
+
+ lchan = &trx->ts[2].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 38, 104);
+
+ lchan = &trx->ts[3].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 38, 104);
+
+ lchan = &trx->ts[2].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 51, 104);
+
+ lchan = &trx->ts[3].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 51, 104);
+
+ lchan = &trx->ts[4].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 64, 104);
+
+ lchan = &trx->ts[5].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 64, 104);
+
+ lchan = &trx->ts[4].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 77, 104);
+
+ lchan = &trx->ts[5].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 77, 104);
+
+ lchan = &trx->ts[6].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 90, 104);
+
+ lchan = &trx->ts[7].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 90, 104);
+
+ lchan = &trx->ts[6].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 103, 104);
+
+ lchan = &trx->ts[7].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_TCH_H;
+ test_is_meas_complete_single(lchan, 103, 104);
+
+ /* Test interval end detection on SDCCH/8 SS0-SS7 */
+ lchan = &trx->ts[0].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 66, 102);
+
+ lchan = &trx->ts[0].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 70, 102);
+
+ lchan = &trx->ts[0].lchan[2];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 74, 102);
+
+ lchan = &trx->ts[0].lchan[3];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 78, 102);
+
+ lchan = &trx->ts[0].lchan[4];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 98, 102);
+
+ lchan = &trx->ts[0].lchan[5];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 0, 102);
+
+ lchan = &trx->ts[0].lchan[6];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 4, 102);
+
+ lchan = &trx->ts[0].lchan[7];
+ lchan->ts->pchan = GSM_PCHAN_SDCCH8_SACCH8C;
+ test_is_meas_complete_single(lchan, 8, 102);
+
+ /* Test interval end detection on SDCCH/4 SS0-SS3 */
+ lchan = &trx->ts[0].lchan[0];
+ lchan->ts->pchan = GSM_PCHAN_CCCH_SDCCH4;
+ test_is_meas_complete_single(lchan, 88, 102);
+
+ lchan = &trx->ts[0].lchan[1];
+ lchan->ts->pchan = GSM_PCHAN_CCCH_SDCCH4;
+ test_is_meas_complete_single(lchan, 92, 102);
+
+ lchan = &trx->ts[0].lchan[2];
+ lchan->ts->pchan = GSM_PCHAN_CCCH_SDCCH4;
+ test_is_meas_complete_single(lchan, 6, 102);
+
+ lchan = &trx->ts[0].lchan[3];
+ lchan->ts->pchan = GSM_PCHAN_CCCH_SDCCH4;
+ test_is_meas_complete_single(lchan, 10, 102);
+}
+
/* This tests the robustness of lchan_meas_process_measurement(). This is the
* function that is called from l1_sap.c each time a measurement indication is
* received. The process must still go on when measurement indications (blocks)
@@ -604,6 +780,7 @@
printf("***************************************************\n");
test_is_meas_overdue();
+ test_is_meas_complete();
test_lchan_meas_process_measurement(false, false);
test_lchan_meas_process_measurement(true, false);
test_lchan_meas_process_measurement(false, true);
diff --git a/tests/meas/meas_test.ok b/tests/meas/meas_test.ok
index 77b652e..d8f8174 100644
--- a/tests/meas/meas_test.ok
+++ b/tests/meas/meas_test.ok
@@ -584,6 +584,10 @@
===========================================================
+Testing is_meas_complete()
+
+
+===========================================================
Testing lchan_meas_process_measurement()
(leaving out measurement sample for SACCH block)
(leaving out measurement sample for SACCH block)
--
To view, visit https://gerrit.osmocom.org/10663
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f89d9e7092cd65ba4d5c5649140692dcc20bdd6
Gerrit-Change-Number: 10663
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180828/5d13da75/attachment.htm>