Add new unit-test for transmit power computation code
This tests the computations of the tx_power.c code using sysmoBTS 1002, 1020, 1100 and 2050 values, as well as the power ramping code. Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5
This commit is contained in:
parent
df5ac9aa11
commit
69d297ce75
|
@ -48,6 +48,7 @@ tests/sysmobts/sysmobts_test
|
||||||
tests/misc/misc_test
|
tests/misc/misc_test
|
||||||
tests/bursts/bursts_test
|
tests/bursts/bursts_test
|
||||||
tests/handover/handover_test
|
tests/handover/handover_test
|
||||||
|
tests/tx_power/tx_power_test
|
||||||
tests/testsuite
|
tests/testsuite
|
||||||
tests/testsuite.log
|
tests/testsuite.log
|
||||||
|
|
||||||
|
|
|
@ -144,4 +144,5 @@ AC_OUTPUT(
|
||||||
tests/misc/Makefile
|
tests/misc/Makefile
|
||||||
tests/bursts/Makefile
|
tests/bursts/Makefile
|
||||||
tests/handover/Makefile
|
tests/handover/Makefile
|
||||||
|
tests/tx_power/Makefile
|
||||||
Makefile)
|
Makefile)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SUBDIRS = paging cipher agch misc bursts handover
|
SUBDIRS = paging cipher agch misc bursts handover tx_power
|
||||||
|
|
||||||
if ENABLE_SYSMOBTS
|
if ENABLE_SYSMOBTS
|
||||||
SUBDIRS += sysmobts
|
SUBDIRS += sysmobts
|
||||||
|
|
|
@ -36,3 +36,10 @@ AT_KEYWORDS([handover])
|
||||||
cat $abs_srcdir/handover/handover_test.ok > expout
|
cat $abs_srcdir/handover/handover_test.ok > expout
|
||||||
AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore])
|
AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore])
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
AT_SETUP([tx_power])
|
||||||
|
AT_KEYWORDS([tx_power])
|
||||||
|
cat $abs_srcdir/tx_power/tx_power_test.ok > expout
|
||||||
|
cat $abs_srcdir/tx_power/tx_power_test.err > experr
|
||||||
|
AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [experr])
|
||||||
|
AT_CLEANUP
|
||||||
|
|
|
@ -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.err
|
||||||
|
|
||||||
|
tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c
|
||||||
|
tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD)
|
|
@ -0,0 +1,239 @@
|
||||||
|
/* Test cases for tx_power.c Transmit Power Computation */
|
||||||
|
|
||||||
|
/* (C) 2017 by Harald Welte <laforge@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/bts.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,
|
||||||
|
},
|
||||||
|
.ramp = {
|
||||||
|
.step_size_mdB = to_mdB(2),
|
||||||
|
.step_interval_sec = 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
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),
|
||||||
|
},
|
||||||
|
.user_pa = {
|
||||||
|
.nominal_gain_mdB = 0,
|
||||||
|
},
|
||||||
|
.ramp = {
|
||||||
|
.step_size_mdB = to_mdB(2),
|
||||||
|
.step_interval_sec = 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
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),
|
||||||
|
},
|
||||||
|
.user_pa = {
|
||||||
|
.nominal_gain_mdB = 0,
|
||||||
|
},
|
||||||
|
.ramp = {
|
||||||
|
.step_size_mdB = to_mdB(2),
|
||||||
|
.step_interval_sec = 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
.ramp = {
|
||||||
|
.step_size_mdB = to_mdB(2),
|
||||||
|
.step_interval_sec = 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
struct trx_power_params *tpp = &trx->power_params;
|
||||||
|
|
||||||
|
printf("CHANGE_POWER(%d)\n", p_trxout_mdBm);
|
||||||
|
|
||||||
|
if (tpp->ramp.attenuation_mdB == 0)
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
power_trx_change_compl(trx, p_trxout_mdBm);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_power_ramp(struct gsm_bts_trx *trx, int dBm)
|
||||||
|
{
|
||||||
|
printf("Testing tx_power ramping for sysmoBTS 1020\n");
|
||||||
|
trx->power_params = tpp_1020;
|
||||||
|
trx->max_power_red = 0;
|
||||||
|
|
||||||
|
power_ramp_start(trx, to_mdB(dBm), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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[DL1C].loglevel = LOGL_DEBUG;
|
||||||
|
log_set_print_filename(osmo_stderr_target, 0);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* test error case / excess power (40 dBm is too much) */
|
||||||
|
test_power_ramp(trx, 40);
|
||||||
|
/* test actaul ramping to full 33 dBm */
|
||||||
|
test_power_ramp(trx, 33);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
osmo_select_main(0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
power_ramp_start(cur=0, tgt=40000)
|
||||||
|
[0;mAsked to ramp power up to 40000 mdBm, which exceeds P_max_out (33000)
|
||||||
|
[0;mpower_ramp_start(cur=0, tgt=33000)
|
||||||
|
[0;mramp_timer_cb(cur_pout=2000, tgt_pout=33000, ramp_att=31000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to -8000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=4000, tgt_pout=33000, ramp_att=29000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to -6000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=6000, tgt_pout=33000, ramp_att=27000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to -4000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=8000, tgt_pout=33000, ramp_att=25000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to -2000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=10000, tgt_pout=33000, ramp_att=23000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 0 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=12000, tgt_pout=33000, ramp_att=21000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 2000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=14000, tgt_pout=33000, ramp_att=19000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 4000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=16000, tgt_pout=33000, ramp_att=17000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 6000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=18000, tgt_pout=33000, ramp_att=15000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 8000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=20000, tgt_pout=33000, ramp_att=13000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 10000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=22000, tgt_pout=33000, ramp_att=11000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 12000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=24000, tgt_pout=33000, ramp_att=9000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 14000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=26000, tgt_pout=33000, ramp_att=7000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 16000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=28000, tgt_pout=33000, ramp_att=5000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 18000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=30000, tgt_pout=33000, ramp_att=3000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 20000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=32000, tgt_pout=33000, ramp_att=1000, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 22000 mdBm.
|
||||||
|
[0;mramp_timer_cb(cur_pout=33000, tgt_pout=33000, ramp_att=0, therm_att=0, user_gain=0)
|
||||||
|
[0;mramping TRX board output power to 23000 mdBm.
|
||||||
|
[0;m
|
|
@ -0,0 +1,23 @@
|
||||||
|
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
|
||||||
|
Testing tx_power ramping for sysmoBTS 1020
|
||||||
|
Testing tx_power ramping for sysmoBTS 1020
|
||||||
|
CHANGE_POWER(-8000)
|
||||||
|
CHANGE_POWER(-6000)
|
||||||
|
CHANGE_POWER(-4000)
|
||||||
|
CHANGE_POWER(-2000)
|
||||||
|
CHANGE_POWER(0)
|
||||||
|
CHANGE_POWER(2000)
|
||||||
|
CHANGE_POWER(4000)
|
||||||
|
CHANGE_POWER(6000)
|
||||||
|
CHANGE_POWER(8000)
|
||||||
|
CHANGE_POWER(10000)
|
||||||
|
CHANGE_POWER(12000)
|
||||||
|
CHANGE_POWER(14000)
|
||||||
|
CHANGE_POWER(16000)
|
||||||
|
CHANGE_POWER(18000)
|
||||||
|
CHANGE_POWER(20000)
|
||||||
|
CHANGE_POWER(22000)
|
||||||
|
CHANGE_POWER(23000)
|
Loading…
Reference in New Issue