aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-14 03:59:31 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-15 15:50:43 +0700
commit8d56806c655d469b749cf0fbc3668be5890e69dc (patch)
tree69f46949acdae550ace6763f38f6e6721b17461c
parent43f211a77d13b6f8039a88c7616383874857b87a (diff)
tests/power_test: move bts/trx/ts/lchan init to init_test()
This would allow us to introduce additional test cases. Change-Id: I00569de378f7c3ca7cc6885fc2bdf25fbc637831 Related: SYS#4916
-rw-r--r--tests/power/power_test.c53
-rw-r--r--tests/power/power_test.err46
-rw-r--r--tests/power/power_test.ok2
3 files changed, 58 insertions, 43 deletions
diff --git a/tests/power/power_test.c b/tests/power/power_test.c
index 6cc06a35..0d3457a4 100644
--- a/tests/power/power_test.c
+++ b/tests/power/power_test.c
@@ -27,6 +27,32 @@
#include <stdio.h>
+static struct gsm_bts *g_bts = NULL;
+static struct gsm_bts_trx *g_trx = NULL;
+
+static void init_test(const char *name)
+{
+ if (g_trx != NULL)
+ talloc_free(g_trx);
+ if (g_bts != NULL)
+ talloc_free(g_bts);
+
+ g_bts = talloc_zero(tall_bts_ctx, struct gsm_bts);
+ OSMO_ASSERT(g_bts != NULL);
+
+ INIT_LLIST_HEAD(&g_bts->trx_list);
+ g_trx = gsm_bts_trx_alloc(g_bts);
+ OSMO_ASSERT(g_trx != NULL);
+
+ g_trx->ms_pwr_ctl_soft = true;
+
+ g_bts->ul_power_target = -75,
+ g_bts->band = GSM_BAND_1800,
+ g_bts->c0 = g_trx;
+
+ printf("\nStarting test case '%s'\n", name);
+}
+
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);
@@ -38,24 +64,11 @@ static inline void apply_power_test(struct gsm_lchan *lchan, int rxlev, int exp_
static void test_power_loop(void)
{
- struct gsm_bts bts;
- struct gsm_bts_trx trx;
- struct gsm_bts_trx_ts ts;
struct gsm_lchan *lchan;
- memset(&bts, 0, sizeof(bts));
- memset(&trx, 0, sizeof(trx));
- memset(&ts, 0, sizeof(ts));
-
- lchan = &ts.lchan[0];
- lchan->ts = &ts;
- ts.trx = &trx;
- trx.bts = &bts;
- bts.band = GSM_BAND_1800;
- trx.ms_pwr_ctl_soft = true;
- bts.ul_power_target = -75;
+ init_test(__func__);
+ lchan = &g_trx->ts[0].lchan[0];
- 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);
lchan->ms_power_ctrl.max = ms_pwr_ctl_lvl(GSM_BAND_1800, 26);
@@ -76,7 +89,7 @@ static void test_power_loop(void)
apply_power_test(lchan, -90, 1, 5);
/* Check good RSSI value keeps it at same power level: */
- apply_power_test(lchan, bts.ul_power_target, 0, 5);
+ apply_power_test(lchan, g_bts->ul_power_target, 0, 5);
apply_power_test(lchan, -90, 1, 3);
apply_power_test(lchan, -90, 1, 2); /* .max is pwr lvl 2 */
@@ -94,7 +107,7 @@ static void test_power_loop(void)
apply_power_test(lchan, -90, 0, 29);
/* Check good RSSI value keeps it at same power level: */
- apply_power_test(lchan, bts.ul_power_target, 0, 29);
+ apply_power_test(lchan, g_bts->ul_power_target, 0, 29);
/* Now go down, steps are double size in this direction: */
apply_power_test(lchan, -45, 1, 1);
@@ -102,13 +115,13 @@ static void test_power_loop(void)
apply_power_test(lchan, -45, 1, 9);
/* Go down only one level down and up: */
- apply_power_test(lchan, bts.ul_power_target + 2, 1, 10);
- apply_power_test(lchan, bts.ul_power_target - 2, 1, 9);
+ apply_power_test(lchan, g_bts->ul_power_target + 2, 1, 10);
+ apply_power_test(lchan, g_bts->ul_power_target - 2, 1, 9);
/* Check if BSC requesting a low max power is applied after loop calculation: */
lchan->ms_power_ctrl.max = ms_pwr_ctl_lvl(GSM_BAND_1800, 2);
OSMO_ASSERT(lchan->ms_power_ctrl.max == 14);
- apply_power_test(lchan, bts.ul_power_target + 2, 1, 14);
+ apply_power_test(lchan, g_bts->ul_power_target + 2, 1, 14);
/* Set back a more normal max: */
lchan->ms_power_ctrl.max = ms_pwr_ctl_lvl(GSM_BAND_1800, 30);
OSMO_ASSERT(lchan->ms_power_ctrl.max == 0);
diff --git a/tests/power/power_test.err b/tests/power/power_test.err
index 4aa03749..e4d821a8 100644
--- a/tests/power/power_test.err
+++ b/tests/power/power_test.err
@@ -1,23 +1,23 @@
-(null) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -60 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 15 (0 dBm) to 13, 4 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 13 (4 dBm) to 11, 8 dBm (rx-ms-pwr-lvl 13, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 11 (8 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 11, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 9 (12 dBm) to 7, 16 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 7 (16 dBm) to 5, 20 dBm (rx-ms-pwr-lvl 7, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Keeping MS power at control level 5, 20 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 2, rx-current -75 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 5 (20 dBm) to 3, 24 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 3 (24 dBm) to 2, 26 dBm (rx-ms-pwr-lvl 3, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Keeping MS power at control level 2, 26 dBm (rx-ms-pwr-lvl 2, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 2 (26 dBm) to 0, 30 dBm (rx-ms-pwr-lvl 2, max-ms-pwr-lvl 0, rx-current -90 dBm, rx-target -75 dBm)
-(null) Keeping MS power at control level 0, 30 dBm (rx-ms-pwr-lvl 0, max-ms-pwr-lvl 0, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 0 (30 dBm) to 30, 34 dBm (rx-ms-pwr-lvl 0, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 30 (34 dBm) to 29, 36 dBm (rx-ms-pwr-lvl 30, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
-(null) Keeping MS power at control level 29, 36 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
-(null) Keeping MS power at control level 29, 36 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -75 dBm, rx-target -75 dBm)
-(null) Lowering MS power from control level 29 (36 dBm) to 1, 28 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
-(null) Lowering MS power from control level 1 (28 dBm) to 5, 20 dBm (rx-ms-pwr-lvl 1, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
-(null) Lowering MS power from control level 5 (20 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
-(null) Lowering MS power from control level 9 (12 dBm) to 10, 10 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 29, rx-current -73 dBm, rx-target -75 dBm)
-(null) Raising MS power from control level 10 (10 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 10, max-ms-pwr-lvl 29, rx-current -77 dBm, rx-target -75 dBm)
-(null) Lowering MS power from control level 9 (12 dBm) to 14, 2 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 14, rx-current -73 dBm, rx-target -75 dBm)
-(null) Lowering MS power from control level 14 (2 dBm) to 15, 0 dBm (rx-ms-pwr-lvl 14, max-ms-pwr-lvl 0, rx-current -40 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 15, 0 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -60 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 15 (0 dBm) to 13, 4 dBm (rx-ms-pwr-lvl 15, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 13 (4 dBm) to 11, 8 dBm (rx-ms-pwr-lvl 13, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 11 (8 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 11, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 9 (12 dBm) to 7, 16 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 7 (16 dBm) to 5, 20 dBm (rx-ms-pwr-lvl 7, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 5, 20 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 2, rx-current -75 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 5 (20 dBm) to 3, 24 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 3 (24 dBm) to 2, 26 dBm (rx-ms-pwr-lvl 3, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 2, 26 dBm (rx-ms-pwr-lvl 2, max-ms-pwr-lvl 2, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 2 (26 dBm) to 0, 30 dBm (rx-ms-pwr-lvl 2, max-ms-pwr-lvl 0, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 0, 30 dBm (rx-ms-pwr-lvl 0, max-ms-pwr-lvl 0, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 0 (30 dBm) to 30, 34 dBm (rx-ms-pwr-lvl 0, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 30 (34 dBm) to 29, 36 dBm (rx-ms-pwr-lvl 30, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 29, 36 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -90 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Keeping MS power at control level 29, 36 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -75 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 29 (36 dBm) to 1, 28 dBm (rx-ms-pwr-lvl 29, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 1 (28 dBm) to 5, 20 dBm (rx-ms-pwr-lvl 1, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 5 (20 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 5, max-ms-pwr-lvl 29, rx-current -45 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 9 (12 dBm) to 10, 10 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 29, rx-current -73 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Raising MS power from control level 10 (10 dBm) to 9, 12 dBm (rx-ms-pwr-lvl 10, max-ms-pwr-lvl 29, rx-current -77 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 9 (12 dBm) to 14, 2 dBm (rx-ms-pwr-lvl 9, max-ms-pwr-lvl 14, rx-current -73 dBm, rx-target -75 dBm)
+(bts=0,trx=0,ts=0,ss=0) Lowering MS power from control level 14 (2 dBm) to 15, 0 dBm (rx-ms-pwr-lvl 14, max-ms-pwr-lvl 0, rx-current -40 dBm, rx-target -75 dBm)
diff --git a/tests/power/power_test.ok b/tests/power/power_test.ok
index 335a3d3b..e325bb78 100644
--- a/tests/power/power_test.ok
+++ b/tests/power/power_test.ok
@@ -1,4 +1,6 @@
Testing power loop...
+
+Starting test case 'test_power_loop'
power control [0]: MS current power 15
power control [1]: MS current power 13
power control [1]: MS current power 11