neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/22082 )


Change subject: handover_test: add lchan wildcards to meas-rep cmd
......................................................................

handover_test: add lchan wildcards to meas-rep cmd

With 'set-ts-use', it is convenient to build a scenario of lchan usage,
but still inconvenient to send measurement reports to all lchans.

I need this for testing congestion-check, because each lchan needs to
have at least one measurement report, or congestion check is skipped.

Example:

 set-ts-use trx 0 0 states * TCH/F TCH/F - - TCH/HH TCH/HH TCH/H-
 meas-rep lchan * * * * rxlev 10 rxqual 0 ta 0

This patch adds the '*' for the lchan arguments, usually being bts idx,
trx idx, timeslot idx and subslot idx.

Use lchan wildcards at the appropriate places to shorten some tests.

Change-Id: I441f92348508d45e1069a3dfa1ff3842dbba97d6
---
M tests/handover/handover_test.c
M tests/handover/test_balance_congestion_2.ho_vty
M tests/handover/test_congestion.ho_vty
M tests/handover/test_dyn_ts_amr_tch_f_to_h_congestion_assignment.ho_vty
M tests/handover/test_dyn_ts_favor_moving_half_used_tch_h.ho_vty
M tests/handover/test_no_congestion.ho_vty
6 files changed, 72 insertions(+), 44 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/82/22082/1

diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index d422a9d..dff1390 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -741,6 +741,50 @@
        return &ts->lchan[atoi(argv[3])];
 }

+#define LCHAN_WILDCARD_ARGS "lchan (<0-255>|*) (<0-255>|*) (<0-7>|*) (<0-7>|*)"
+#define LCHAN_WILDCARD_ARGS_DOC "identify an lchan\nBTS nr\nall BTS\nTRX 
nr\nall BTS\nTimeslot nr\nall TS\nSubslot nr\nall subslots\n"
+
+static void parse_lchan_wildcard_args(const char **argv, void (*cb)(struct 
gsm_lchan*, void*), void *cb_data)
+{
+       const char *bts_str = argv[0];
+       const char *trx_str = argv[1];
+       const char *ts_str = argv[2];
+       const char *ss_str = argv[3];
+       int bts_num = (strcmp(bts_str, "*") == 0)? -1 : atoi(bts_str);
+       int trx_num = (strcmp(trx_str, "*") == 0)? -1 : atoi(trx_str);
+       int ts_num = (strcmp(ts_str, "*") == 0)? -1 : atoi(ts_str);
+       int ss_num = (strcmp(ss_str, "*") == 0)? -1 : atoi(ss_str);
+
+       int bts_i;
+       int trx_i;
+       int ts_i;
+       int ss_i;
+
+       for (bts_i = ((bts_num == -1) ? 0 : bts_num);
+            bts_i < ((bts_num == -1) ? bsc_gsmnet->num_bts : bts_num + 1);
+            bts_i++) {
+               struct gsm_bts *bts = gsm_bts_num(bsc_gsmnet, bts_i);
+
+               for (trx_i = ((trx_num == -1) ? 0 : trx_num);
+                    trx_i < ((trx_num == -1) ? bts->num_trx : trx_num + 1);
+                    trx_i++) {
+                       struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_i);
+
+                       for (ts_i = ((ts_num == -1) ? 0 : ts_num);
+                            ts_i < ((ts_num == -1) ? 8 : ts_num + 1);
+                            ts_i++) {
+                               struct gsm_bts_trx_ts *ts = &trx->ts[ts_i];
+
+                               for (ss_i = ((ss_num == -1) ? 0 : ss_num);
+                                    ss_i < ((ss_num == -1) ? 
pchan_subslots(ts->pchan_is) : ss_num + 1);
+                                    ss_i++) {
+                                       cb(&ts->lchan[ss_i], cb_data);
+                               }
+                       }
+               }
+       }
+}
+
 static int vty_step = 1;

 #define VTY_ECHO() \
@@ -814,18 +858,24 @@
        return CMD_SUCCESS;
 }

-static int _meas_rep(struct vty *vty, int argc, const char **argv)
+struct meas_rep_data {
+       int argc;
+       const char **argv;
+};
+
+static void _meas_rep_cb(struct gsm_lchan *lc, void *data)
 {
-       struct gsm_lchan *lc;
+       struct meas_rep_data *d = data;
+       int argc = d->argc;
+       const char **argv = d->argv;
        uint8_t rxlev;
        uint8_t rxqual;
        uint8_t ta;
        int i;
        struct neighbor_meas nm[6] = {};

-       lc = parse_lchan_args(argv);
-       argv += 4;
-       argc -= 4;
+       if (!lchan_state_is(lc, LCHAN_ST_ESTABLISHED))
+               return;

        rxlev = atoi(argv[0]);
        rxqual = atoi(argv[1]);
@@ -863,14 +913,24 @@
                                nm[i].rxlev);
        }
        gen_meas_rep(lc, rxlev, rxqual, ta, argc, nm);
+}
+
+static int _meas_rep(struct vty *vty, int argc, const char **argv)
+{
+       struct meas_rep_data d = {
+               .argc = argc - 4,
+               .argv = argv + 4,
+       };
+       parse_lchan_wildcard_args(argv, _meas_rep_cb, &d);
        return CMD_SUCCESS;
 }

-#define MEAS_REP_ARGS  LCHAN_ARGS " rxlev <0-255> rxqual <0-7> ta <0-255>" \
+
+#define MEAS_REP_ARGS  LCHAN_WILDCARD_ARGS " rxlev <0-255> rxqual <0-7> ta 
<0-255>" \
        " [neighbors] [<0-255>] [<0-255>] [<0-255>] [<0-255>] [<0-255>] 
[<0-255>]"
 #define MEAS_REP_DOC "Send measurement report\n"
 #define MEAS_REP_ARGS_DOC \
-      LCHAN_ARGS_DOC \
+      LCHAN_WILDCARD_ARGS_DOC \
       "rxlev\nrxlev\n" \
       "rxqual\nrxqual\n" \
       "timing advance\ntiming advance\n" \
diff --git a/tests/handover/test_balance_congestion_2.ho_vty 
b/tests/handover/test_balance_congestion_2.ho_vty
index 9c8b7f9..b157478 100644
--- a/tests/handover/test_balance_congestion_2.ho_vty
+++ b/tests/handover/test_balance_congestion_2.ho_vty
@@ -8,14 +8,9 @@
 codec tch/f FR
 set-ts-use trx 0 0 states * TCH/F TCH/F TCH/F - - - -
 set-ts-use trx 1 0 states * TCH/F - - - - - -
-meas-rep lchan 0 0 1 0 rxlev 30 rxqual 0 ta 0 neighbors 20
-expect-no-chan
+meas-rep lchan * * * * rxlev 30 rxqual 0 ta 0 neighbors 20
 meas-rep lchan 0 0 2 0 rxlev 30 rxqual 0 ta 0 neighbors 21
 expect-no-chan
-meas-rep lchan 0 0 3 0 rxlev 30 rxqual 0 ta 0 neighbors 20
-expect-no-chan
-meas-rep lchan 1 0 1 0 rxlev 30 rxqual 0 ta 0 neighbors 20
-expect-no-chan
 congestion-check
 expect-ho from lchan 0 0 2 0 to lchan 1 0 2 0
 expect-ts-use trx 0 0 states * TCH/F -     TCH/F - - - -
diff --git a/tests/handover/test_congestion.ho_vty 
b/tests/handover/test_congestion.ho_vty
index 09815e3..529b8de 100644
--- a/tests/handover/test_congestion.ho_vty
+++ b/tests/handover/test_congestion.ho_vty
@@ -9,20 +9,9 @@
  handover2 min-free-slots tch/h 2
 set-ts-use trx 0 0 states * TCH/F TCH/F TCH/F - TCH/HH - -
 set-ts-use trx 1 0 states * TCH/F -     -     - TCH/H- - -
-meas-rep lchan 0 0 1 0 rxlev 30 rxqual 0 ta 0 neighbors 20 20
-expect-no-chan
-meas-rep lchan 0 0 2 0 rxlev 30 rxqual 0 ta 0 neighbors 20 20
-expect-no-chan
+meas-rep lchan * * * * rxlev 30 rxqual 0 ta 0 neighbors 20 20
 meas-rep lchan 0 0 3 0 rxlev 30 rxqual 0 ta 0 neighbors 21 20
 expect-no-chan
-meas-rep lchan 0 0 5 0 rxlev 30 rxqual 0 ta 0 neighbors 20 20
-expect-no-chan
-meas-rep lchan 0 0 5 1 rxlev 30 rxqual 0 ta 0 neighbors 20 20
-expect-no-chan
-meas-rep lchan 1 0 1 0 rxlev 30 rxqual 0 ta 0 neighbors 20 20
-expect-no-chan
-meas-rep lchan 1 0 5 0 rxlev 30 rxqual 0 ta 0 neighbors 20 20
-expect-no-chan
 expect-ts-use trx 0 0 states * TCH/F TCH/F TCH/F - TCH/HH - -
 expect-ts-use trx 1 0 states * TCH/F -     -     - TCH/H- - -
 congestion-check
diff --git 
a/tests/handover/test_dyn_ts_amr_tch_f_to_h_congestion_assignment.ho_vty 
b/tests/handover/test_dyn_ts_amr_tch_f_to_h_congestion_assignment.ho_vty
index 3ae5997..f94ad0e 100644
--- a/tests/handover/test_dyn_ts_amr_tch_f_to_h_congestion_assignment.ho_vty
+++ b/tests/handover/test_dyn_ts_amr_tch_f_to_h_congestion_assignment.ho_vty
@@ -12,10 +12,7 @@
 set-ts-use trx 0 0 states * TCH/F TCH/F TCH/F TCH/F pdch pdch pdch

 # (there must be at leas one measurement report on each lchan for congestion 
check to work)
-meas-rep lchan 0 0 1 0 rxlev 40 rxqual 0 ta 0 neighbors 30
-meas-rep lchan 0 0 2 0 rxlev 40 rxqual 0 ta 0 neighbors 30
-meas-rep lchan 0 0 3 0 rxlev 40 rxqual 0 ta 0 neighbors 30
-meas-rep lchan 0 0 4 0 rxlev 40 rxqual 0 ta 0 neighbors 30
+meas-rep lchan * * * * rxlev 40 rxqual 0 ta 0 neighbors 30

 congestion-check
 expect-no-chan
diff --git a/tests/handover/test_dyn_ts_favor_moving_half_used_tch_h.ho_vty 
b/tests/handover/test_dyn_ts_favor_moving_half_used_tch_h.ho_vty
index 794bbef..3d1b009 100644
--- a/tests/handover/test_dyn_ts_favor_moving_half_used_tch_h.ho_vty
+++ b/tests/handover/test_dyn_ts_favor_moving_half_used_tch_h.ho_vty
@@ -8,10 +8,7 @@

 # Test with identical rxlev across lchans (trivial and unrealistic)
 set-ts-use    trx 0 0     states *    pdch  TCH/HH TCH/H- TCH/HH pdch - -
-meas-rep lchan 0 0 2 1 rxlev 30 rxqual 0 ta 0
-meas-rep lchan 0 0 3 0 rxlev 30 rxqual 0 ta 0
-meas-rep lchan 0 0 4 0 rxlev 30 rxqual 0 ta 0
-meas-rep lchan 0 0 4 1 rxlev 30 rxqual 0 ta 0
+meas-rep lchan * * * * rxlev 30 rxqual 0 ta 0
 congestion-check
 expect-ho from lchan 0 0 3 0 to lchan 0 0 1 0
 expect-ts-use trx 0 0     states *    TCH/F TCH/HH pdch TCH/HH pdch - -
diff --git a/tests/handover/test_no_congestion.ho_vty 
b/tests/handover/test_no_congestion.ho_vty
index 651d648..c8328c6 100644
--- a/tests/handover/test_no_congestion.ho_vty
+++ b/tests/handover/test_no_congestion.ho_vty
@@ -8,17 +8,7 @@
  handover2 min-free-slots tch/h 2
 set-ts-use trx 0 0 states * TCH/F TCH/F - - TCH/HH - -
 set-ts-use trx 1 0 states * TCH/F -     - - TCH/H- - -
-meas-rep lchan 0 0 1 0 rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
-expect-no-chan
-meas-rep lchan 0 0 2 0 rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
-expect-no-chan
-meas-rep lchan 0 0 5 0 rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
-expect-no-chan
-meas-rep lchan 0 0 5 1 rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
-expect-no-chan
-meas-rep lchan 1 0 1 0 rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
-expect-no-chan
-meas-rep lchan 1 0 5 0 rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
+meas-rep lchan * * * * rxlev 30 rxqual 0 ta 0 neighbors 20 1 20
 expect-no-chan
 congestion-check
 expect-no-chan

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/22082
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I441f92348508d45e1069a3dfa1ff3842dbba97d6
Gerrit-Change-Number: 22082
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofm...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to