[PATCH] osmo-bts[master]: Move power loop to generic tests

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/.

Max gerrit-no-reply at lists.osmocom.org
Wed Oct 11 15:18:40 UTC 2017


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

Move power loop to generic tests

There's nothing sysmobts specific in this test so let's move them into
separate directory and run unconditionally. The test itself is unaltered
except for intro text.

Change-Id: I0d1957cd9cf5497826be095c7a42b7bb4fa10397
Related: OS#2223
---
M .gitignore
M configure.ac
M tests/Makefile.am
A tests/power/Makefile.am
A tests/power/power_test.c
A tests/power/power_test.ok
M tests/sysmobts/sysmobts_test.c
M tests/sysmobts/sysmobts_test.ok
M tests/testsuite.at
9 files changed, 114 insertions(+), 63 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/22/4222/1

diff --git a/.gitignore b/.gitignore
index a8c0ece..2e8c884 100644
--- a/.gitignore
+++ b/.gitignore
@@ -72,3 +72,4 @@
 debian/osmo-bts-trx-dbg/
 debian/osmo-bts-trx/
 debian/tmp/
+/tests/power/power_test
diff --git a/configure.ac b/configure.ac
index a41f7ec..bda30b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -178,5 +178,6 @@
     tests/misc/Makefile
     tests/handover/Makefile
     tests/tx_power/Makefile
+    tests/power/Makefile
     tests/meas/Makefile
     Makefile)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d2b4181..18b8ce6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = paging cipher agch misc handover tx_power meas
+SUBDIRS = paging cipher agch misc handover tx_power power meas
 
 if ENABLE_SYSMOBTS
 SUBDIRS += sysmobts
diff --git a/tests/power/Makefile.am b/tests/power/Makefile.am
new file mode 100644
index 0000000..3cb8d15
--- /dev/null
+++ b/tests/power/Makefile.am
@@ -0,0 +1,9 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(ORTP_CFLAGS)
+LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(ORTP_LIBS)
+
+noinst_PROGRAMS = power_test
+EXTRA_DIST = power_test.ok
+
+power_test_SOURCES = power_test.c $(srcdir)/../stubs.c
+power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LIBOSMOABIS_LIBS) $(LDADD)
diff --git a/tests/power/power_test.c b/tests/power/power_test.c
new file mode 100644
index 0000000..c1d6a5a
--- /dev/null
+++ b/tests/power/power_test.c
@@ -0,0 +1,93 @@
+/*
+ * (C) 2013,2014 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <osmo-bts/bts.h>
+#include <osmo-bts/l1sap.h>
+#include <osmo-bts/power_control.h>
+
+#include <stdio.h>
+
+static void test_power_loop(void)
+{
+	struct gsm_bts bts;
+	struct gsm_bts_role_bts btsb;
+	struct gsm_bts_trx trx;
+	struct gsm_bts_trx_ts ts;
+	struct gsm_lchan *lchan;
+	int ret;
+
+	memset(&bts, 0, sizeof(bts));
+	memset(&btsb, 0, sizeof(btsb));
+	memset(&trx, 0, sizeof(trx));
+	memset(&ts, 0, sizeof(ts));
+
+	lchan = &ts.lchan[0];
+	lchan->ts = &ts;
+	ts.trx = &trx;
+	trx.bts = &bts;
+	bts.role = &btsb;
+	bts.band = GSM_BAND_1800;
+	trx.ms_power_control = 1;
+	btsb.ul_power_target = -75;
+
+	/* Simply clamping */
+	lchan->state = LCHAN_S_NONE;
+	lchan->ms_power_ctrl.current = ms_pwr_ctl_lvl(GSM_BAND_1800, 0);
+	OSMO_ASSERT(lchan->ms_power_ctrl.current == 15);
+	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -60);
+	OSMO_ASSERT(ret == 0);
+	OSMO_ASSERT(lchan->ms_power_ctrl.current == 15);
+
+
+	/*
+	 * Now 15 dB too little and we should power it up. Could be a
+	 * power level of 7 or 8 for 15 dBm
+	 */
+	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -90);
+	OSMO_ASSERT(ret == 1);
+	OSMO_ASSERT(lchan->ms_power_ctrl.current == 7);
+
+	/* It should be clamped to level 0 and 30 dBm */
+	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -100);
+	OSMO_ASSERT(ret == 1);
+	OSMO_ASSERT(lchan->ms_power_ctrl.current == 0);
+
+	/* Fix it and jump down */
+	lchan->ms_power_ctrl.fixed = 1;
+	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -60);
+	OSMO_ASSERT(ret == 0);
+	OSMO_ASSERT(lchan->ms_power_ctrl.current == 0);
+
+	/* And leave it again */
+	lchan->ms_power_ctrl.fixed = 0;
+	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -40);
+	OSMO_ASSERT(ret == 1);
+	OSMO_ASSERT(lchan->ms_power_ctrl.current == 15);
+}
+
+int main(int argc, char **argv)
+{
+	printf("Testing power loop...\n");
+
+	test_power_loop();
+
+	printf("Power loop test OK\n");
+
+	return 0;
+}
diff --git a/tests/power/power_test.ok b/tests/power/power_test.ok
new file mode 100644
index 0000000..6bf508b
--- /dev/null
+++ b/tests/power/power_test.ok
@@ -0,0 +1,2 @@
+Testing power loop...
+Power loop test OK
diff --git a/tests/sysmobts/sysmobts_test.c b/tests/sysmobts/sysmobts_test.c
index 6ae7623..32d6e95 100644
--- a/tests/sysmobts/sysmobts_test.c
+++ b/tests/sysmobts/sysmobts_test.c
@@ -182,72 +182,12 @@
 	 * this happens asynchronously on the other side of the l1sap queue */
 }
 
-static void test_sysmobts_loop(void)
-{
-	struct gsm_bts bts;
-	struct gsm_bts_role_bts btsb;
-	struct gsm_bts_trx trx;
-	struct gsm_bts_trx_ts ts;
-	struct gsm_lchan *lchan;
-	int ret;
-
-	memset(&bts, 0, sizeof(bts));
-	memset(&btsb, 0, sizeof(btsb));
-	memset(&trx, 0, sizeof(trx));
-	memset(&ts, 0, sizeof(ts));
-
-	lchan = &ts.lchan[0];
-	lchan->ts = &ts;
-	ts.trx = &trx;
-	trx.bts = &bts;
-	bts.role = &btsb;
-	bts.band = GSM_BAND_1800;
-	trx.ms_power_control = 1;
-	btsb.ul_power_target = -75;
-
-	printf("Testing sysmobts power control\n");
-
-	/* Simply clamping */
-	lchan->state = LCHAN_S_NONE;
-	lchan->ms_power_ctrl.current = ms_pwr_ctl_lvl(GSM_BAND_1800, 0);
-	OSMO_ASSERT(lchan->ms_power_ctrl.current == 15);
-	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -60);
-	OSMO_ASSERT(ret == 0);
-	OSMO_ASSERT(lchan->ms_power_ctrl.current == 15);
-
-
-	/*
-	 * Now 15 dB too little and we should power it up. Could be a
-	 * power level of 7 or 8 for 15 dBm
-	 */
-	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -90);
-	OSMO_ASSERT(ret == 1);
-	OSMO_ASSERT(lchan->ms_power_ctrl.current == 7);
-
-	/* It should be clamped to level 0 and 30 dBm */
-	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -100);
-	OSMO_ASSERT(ret == 1);
-	OSMO_ASSERT(lchan->ms_power_ctrl.current == 0);
-
-	/* Fix it and jump down */
-	lchan->ms_power_ctrl.fixed = 1;
-	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -60);
-	OSMO_ASSERT(ret == 0);
-	OSMO_ASSERT(lchan->ms_power_ctrl.current == 0);
-
-	/* And leave it again */
-	lchan->ms_power_ctrl.fixed = 0;
-	ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, -40);
-	OSMO_ASSERT(ret == 1);
-	OSMO_ASSERT(lchan->ms_power_ctrl.current == 15);
-}
-
 int main(int argc, char **argv)
 {
 	printf("Testing sysmobts routines\n");
 	test_sysmobts_auto_band();
 	test_sysmobts_cipher();
-	test_sysmobts_loop();
+
 	return 0;
 }
 
diff --git a/tests/sysmobts/sysmobts_test.ok b/tests/sysmobts/sysmobts_test.ok
index 07d79fd..1f53417 100644
--- a/tests/sysmobts/sysmobts_test.ok
+++ b/tests/sysmobts/sysmobts_test.ok
@@ -17,4 +17,3 @@
 PCS to PCS band(1) arfcn(512) want(3) got(3)
 PCS to PCS band(8) arfcn(128) want(0) got(0)
 PCS to PCS band(2) arfcn(438) want(-1) got(-1)
-Testing sysmobts power control
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 0efd333..2d1cefd 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -31,6 +31,12 @@
 AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore])
 AT_CLEANUP
 
+AT_SETUP([power])
+AT_KEYWORDS([power])
+cat $abs_srcdir/power/power_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/power/power_test], [], [expout], [ignore])
+AT_CLEANUP
+
 AT_SETUP([tx_power])
 AT_KEYWORDS([tx_power])
 cat $abs_srcdir/tx_power/tx_power_test.ok > expout

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d1957cd9cf5497826be095c7a42b7bb4fa10397
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list