Make power test more verbose

Power control loop test outputs next to nothing which is not very
helpful. Make it more verbose. While at it, also move duplicated code
into static function to make test cases less cluttered.

Change-Id: I0a5e65e23e62442ef8758ecbcf8e7820b4f15d7b
Related: OS#2223
This commit is contained in:
Max 2017-10-11 17:16:38 +02:00
parent fe291a97c2
commit bf9298eb0f
2 changed files with 20 additions and 16 deletions

View File

@ -23,6 +23,15 @@
#include <stdio.h>
static inline void apply_power_test(struct gsm_lchan *lchan, int rxlev, int exp_ret, uint8_t exp_current)
{
int ret = lchan_ms_pwr_ctrl(lchan, lchan->ms_power_ctrl.current, rxlev);
printf("power control [%d]: MS current power %u\n", ret, lchan->ms_power_ctrl.current);
OSMO_ASSERT(ret == exp_ret);
OSMO_ASSERT(lchan->ms_power_ctrl.current == exp_current);
}
static void test_power_loop(void)
{
struct gsm_bts bts;
@ -46,39 +55,29 @@ static void test_power_loop(void)
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);
/* Simply clamping */
apply_power_test(lchan, -60, 0, 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);
apply_power_test(lchan, -90, 1, 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);
apply_power_test(lchan, -100, 1, 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);
apply_power_test(lchan, -60, 0, 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);
apply_power_test(lchan, -40, 1, 15);
}
int main(int argc, char **argv)

View File

@ -1,2 +1,7 @@
Testing power loop...
power control [0]: MS current power 15
power control [1]: MS current power 7
power control [1]: MS current power 0
power control [0]: MS current power 0
power control [1]: MS current power 15
Power loop test OK