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.orgReview at https://gerrit.osmocom.org/1766 Add new unit-test about transmit power computation code Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.ok 7 files changed, 220 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/66/1766/1 diff --git a/.gitignore b/.gitignore index 224b77c..5ee9565 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/handover_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..843815c 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,9 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [ignore]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..d0645e5 --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..606fe3e --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,199 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte <laforge at gnumonks.org> + * + * 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 <stdint.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/talloc.h> +#include <osmocom/core/application.h> + +#include <osmo-bts/gsm_data.h> +#include <osmo-bts/logging.h> +#include <osmo-bts/tx_power.h> + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + .calib.gain_mdB = { to_mdB(10), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + .calib.gain_mdB = { to_mdB(17), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + printf("CHANGE_POWER(%u)\n", p_trxout_mdBm); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DHO].loglevel = LOGL_DEBUG; + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* FIXME: Test power ramping */ +} diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..e46e149 --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,4 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>