<p>Max <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/12947">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved
  Pau Espin Pedrol: Looks good to me, but someone else must approve

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add encoding tests for Immediate Assignment<br><br>Change-Id: I63f4654b23c7c4f063f6b3254d77157fac798586<br>---<br>M tests/types/TypesTest.cpp<br>M tests/types/TypesTest.err<br>M tests/types/TypesTest.ok<br>3 files changed, 152 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp</span><br><span>index 90d3981..9c24ffe 100644</span><br><span>--- a/tests/types/TypesTest.cpp</span><br><span>+++ b/tests/types/TypesTest.cpp</span><br><span>@@ -431,6 +431,134 @@</span><br><span>         }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void check_imm_ass(struct gprs_rlcmac_tbf *tbf, bool dl, enum ph_burst_type bt, const uint8_t *exp, uint8_t len,</span><br><span style="color: hsl(120, 100%, 40%);">+                     const char *kind)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t alpha = 7, gamma = 8, ta = 35, ts = 5, tsc = 1, usf = 1, sz = sizeof(DUMMY_VEC) / 2, plen;</span><br><span style="color: hsl(120, 100%, 40%);">+    bitvec *immediate_assignment = bitvec_alloc(sz, tall_pcu_ctx);</span><br><span style="color: hsl(120, 100%, 40%);">+        struct msgb *m = msgb_alloc(80, "test");</span><br><span style="color: hsl(120, 100%, 40%);">+    bool poll = true;</span><br><span style="color: hsl(120, 100%, 40%);">+     uint16_t ra = 13, arfcn = 877;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint32_t ref_fn = 24, fn = 11;</span><br><span style="color: hsl(120, 100%, 40%);">+        int8_t ta_idx = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  bitvec_unhex(immediate_assignment, DUMMY_VEC);</span><br><span style="color: hsl(120, 100%, 40%);">+        plen = Encoding::write_immediate_assignment(tbf, immediate_assignment, dl,</span><br><span style="color: hsl(120, 100%, 40%);">+                                                ra, ref_fn, ta, arfcn, ts, tsc, usf,</span><br><span style="color: hsl(120, 100%, 40%);">+                                                  poll, fn, alpha, gamma, ta_idx, bt);</span><br><span style="color: hsl(120, 100%, 40%);">+      printf("[%u] %s Immediate Assignment <%s>:\n\t%s\n", plen, dl ? "DL" : "UL", kind,</span><br><span style="color: hsl(120, 100%, 40%);">+               osmo_hexdump(immediate_assignment->data, sz));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    memcpy(msgb_put(m, sz), immediate_assignment->data, sz);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!msgb_eq_data_print(m, exp, len))</span><br><span style="color: hsl(120, 100%, 40%);">+         printf("%s(%s, %s) failed!\n", __func__, dl ? "DL" : "UL", kind);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_free(m);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void test_immediate_assign_dl()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        BTS the_bts;</span><br><span style="color: hsl(120, 100%, 40%);">+  the_bts.bts_data()->alloc_algorithm = alloc_algorithm_a;</span><br><span style="color: hsl(120, 100%, 40%);">+   the_bts.bts_data()->trx[0].pdch[2].enable();</span><br><span style="color: hsl(120, 100%, 40%);">+       the_bts.bts_data()->trx[0].pdch[3].enable();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     struct gprs_rlcmac_tbf *tbf = tbf_alloc_dl_tbf(the_bts.bts_data(), NULL, 0, 1, 1, false);</span><br><span style="color: hsl(120, 100%, 40%);">+     static uint8_t res[] = { 0x06,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x3f, /* Immediate Assignment Message Type */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x30, /* §10.5.2.26 Page Mode and §10.5.2.25b Dedicated mode/TBF */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x0d, 0x23, 0x6d, /* §10.5.2.25a Packet Channel Description */</span><br><span style="color: hsl(120, 100%, 40%);">+                               /* ETSI TS 44.018 §10.5.2.30 Request Reference */</span><br><span style="color: hsl(120, 100%, 40%);">+                            0x7f, /* RA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x03, 0x18, /* T1'-T3 */</span><br><span style="color: hsl(120, 100%, 40%);">+                          0x23, /* TA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x00, /* 0-length §10.5.2.21 Mobile Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+                            /* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */</span><br><span style="color: hsl(120, 100%, 40%);">+                               0xd0, 0x00, 0x00, 0x00, 0x08, 0x17, 0x47, 0x08, 0x0b, 0x5b, 0x2b, 0x2b, };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ check_imm_ass(tbf, true, GSM_L1_BURST_TYPE_ACCESS_2, res, sizeof(res), "ia_rest_downlink");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void test_immediate_assign_ul0m()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      BTS the_bts;</span><br><span style="color: hsl(120, 100%, 40%);">+  the_bts.bts_data()->alloc_algorithm = alloc_algorithm_a;</span><br><span style="color: hsl(120, 100%, 40%);">+   the_bts.bts_data()->trx[0].pdch[4].enable();</span><br><span style="color: hsl(120, 100%, 40%);">+       the_bts.bts_data()->trx[0].pdch[5].enable();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     struct gprs_rlcmac_tbf *tbf = tbf_alloc_ul_tbf(the_bts.bts_data(), NULL, 0, 1, 1, false);</span><br><span style="color: hsl(120, 100%, 40%);">+     static uint8_t res[] = { 0x06,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x3f, /* Immediate Assignment Message Type */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x10, /* §10.5.2.26 Page Mode and §10.5.2.25b Dedicated mode/TBF */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x0d, 0x23, 0x6d, /* §10.5.2.25a Packet Channel Description */</span><br><span style="color: hsl(120, 100%, 40%);">+                               /* ETSI TS 44.018 §10.5.2.30 Request Reference */</span><br><span style="color: hsl(120, 100%, 40%);">+                            0x0d, /* RA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x03, 0x18, /* T1'-T3 */</span><br><span style="color: hsl(120, 100%, 40%);">+                          0x23, /* TA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x00, /* 0-length §10.5.2.21 Mobile Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+                            /* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */</span><br><span style="color: hsl(120, 100%, 40%);">+                               0xc8, 0x02, 0x7b, 0xa0, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ check_imm_ass(tbf, false, GSM_L1_BURST_TYPE_ACCESS_0, res, sizeof(res), "ia_rest_uplink(MBA)");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void test_immediate_assign_ul0s()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  static uint8_t res[] = { 0x06,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x3f, /* Immediate Assignment Message Type */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x10, /* §10.5.2.26 Page Mode and §10.5.2.25b Dedicated mode/TBF */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x0d, 0x23, 0x6d, /* §10.5.2.25a Packet Channel Description */</span><br><span style="color: hsl(120, 100%, 40%);">+                               /* ETSI TS 44.018 §10.5.2.30 Request Reference */</span><br><span style="color: hsl(120, 100%, 40%);">+                            0x0d, /* RA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x03, 0x18, /* T1'-T3 */</span><br><span style="color: hsl(120, 100%, 40%);">+                          0x23, /* TA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x00, /* 0-length §10.5.2.21 Mobile Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+                            /* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */</span><br><span style="color: hsl(120, 100%, 40%);">+                               0xc5, 0xd1, 0x08, 0x0b, 0x5b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ check_imm_ass(NULL, false, GSM_L1_BURST_TYPE_ACCESS_0, res, sizeof(res), "ia_rest_uplink(SBA)");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void test_immediate_assign_ul1s()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ BTS the_bts;</span><br><span style="color: hsl(120, 100%, 40%);">+  the_bts.bts_data()->alloc_algorithm = alloc_algorithm_a;</span><br><span style="color: hsl(120, 100%, 40%);">+   the_bts.bts_data()->trx[0].pdch[1].enable();</span><br><span style="color: hsl(120, 100%, 40%);">+       the_bts.bts_data()->trx[0].pdch[2].enable();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     struct gprs_rlcmac_tbf *tbf = tbf_alloc_ul_tbf(the_bts.bts_data(), NULL, 0, 1, 1, false);</span><br><span style="color: hsl(120, 100%, 40%);">+     static uint8_t res[] = { 0x06,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x3f, /* Immediate Assignment Message Type */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x10, /* §10.5.2.26 Page Mode and §10.5.2.25b Dedicated mode/TBF */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x0d, 0x23, 0x6d, /* §10.5.2.25a Packet Channel Description */</span><br><span style="color: hsl(120, 100%, 40%);">+                               /* ETSI TS 44.018 §10.5.2.30 Request Reference */</span><br><span style="color: hsl(120, 100%, 40%);">+                            0x7f, /* RA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x03, 0x18, /* T1'-T3 */</span><br><span style="color: hsl(120, 100%, 40%);">+                          0x23, /* TA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x00, /* 0-length §10.5.2.21 Mobile Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+                            /* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */</span><br><span style="color: hsl(120, 100%, 40%);">+                               0x46, 0xa0, 0x09, 0xe0, 0x17, 0x40, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ check_imm_ass(tbf, false, GSM_L1_BURST_TYPE_ACCESS_1, res, sizeof(res), "ia_rest_egprs_uplink(SBA)");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void test_immediate_assign_ul1m()</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    static uint8_t res[] = { 0x06,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x3f, /* Immediate Assignment Message Type */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x10, /* §10.5.2.26 Page Mode and §10.5.2.25b Dedicated mode/TBF */</span><br><span style="color: hsl(120, 100%, 40%);">+                                 0x0d, 0x23, 0x6d, /* §10.5.2.25a Packet Channel Description */</span><br><span style="color: hsl(120, 100%, 40%);">+                               /* ETSI TS 44.018 §10.5.2.30 Request Reference */</span><br><span style="color: hsl(120, 100%, 40%);">+                            0x7f, /* RA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x03, 0x18, /* T1'-T3 */</span><br><span style="color: hsl(120, 100%, 40%);">+                          0x23, /* TA */</span><br><span style="color: hsl(120, 100%, 40%);">+                                0x00, /* 0-length §10.5.2.21 Mobile Allocation */</span><br><span style="color: hsl(120, 100%, 40%);">+                            /* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */</span><br><span style="color: hsl(120, 100%, 40%);">+                               0x46, 0x97, 0x40, 0x0b, 0x58, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ check_imm_ass(NULL, false, GSM_L1_BURST_TYPE_ACCESS_1, res, sizeof(res), "ia_rest_egprs_uplink(MBA)");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void test_immediate_assign_rej()</span><br><span> {</span><br><span>       uint8_t plen;</span><br><span>@@ -496,6 +624,11 @@</span><br><span>         test_rlc_v_b();</span><br><span>      test_rlc_v_n();</span><br><span>      test_rlc_dl_ul_basic();</span><br><span style="color: hsl(120, 100%, 40%);">+       test_immediate_assign_dl();</span><br><span style="color: hsl(120, 100%, 40%);">+   test_immediate_assign_ul0m();</span><br><span style="color: hsl(120, 100%, 40%);">+ test_immediate_assign_ul0s();</span><br><span style="color: hsl(120, 100%, 40%);">+ test_immediate_assign_ul1m();</span><br><span style="color: hsl(120, 100%, 40%);">+ test_immediate_assign_ul1s();</span><br><span>        test_immediate_assign_rej();</span><br><span>         test_lsb();</span><br><span> </span><br><span>diff --git a/tests/types/TypesTest.err b/tests/types/TypesTest.err</span><br><span>index e69de29..3abc61c 100644</span><br><span>--- a/tests/types/TypesTest.err</span><br><span>+++ b/tests/types/TypesTest.err</span><br><span>@@ -0,0 +1,9 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Allocating DL TBF: MS_CLASS=1/1</span><br><span style="color: hsl(120, 100%, 40%);">+TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) Setting Control TS 2</span><br><span style="color: hsl(120, 100%, 40%);">+TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) Allocated: trx = 0, ul_slots = 04, dl_slots = 04</span><br><span style="color: hsl(120, 100%, 40%);">+Allocating UL TBF: MS_CLASS=1/1</span><br><span style="color: hsl(120, 100%, 40%);">+TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL) Setting Control TS 4</span><br><span style="color: hsl(120, 100%, 40%);">+TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL) Allocated: trx = 0, ul_slots = 10, dl_slots = 00</span><br><span style="color: hsl(120, 100%, 40%);">+Allocating UL TBF: MS_CLASS=1/1</span><br><span style="color: hsl(120, 100%, 40%);">+TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL) Setting Control TS 1</span><br><span style="color: hsl(120, 100%, 40%);">+TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL) Allocated: trx = 0, ul_slots = 02, dl_slots = 00</span><br><span>diff --git a/tests/types/TypesTest.ok b/tests/types/TypesTest.ok</span><br><span>index 4bdd917..d4cc255 100644</span><br><span>--- a/tests/types/TypesTest.ok</span><br><span>+++ b/tests/types/TypesTest.ok</span><br><span>@@ -6,6 +6,16 @@</span><br><span> rbb: 10 00 00 00 00 00 00 01 </span><br><span> show_rbb: RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR</span><br><span> show_rbb: IIRRIIIR</span><br><span style="color: hsl(120, 100%, 40%);">+[11] DL Immediate Assignment <ia_rest_downlink>:</span><br><span style="color: hsl(120, 100%, 40%);">+   06 3f 30 0d 23 6d 7f 03 18 23 00 d0 00 00 00 08 17 47 08 0b 5b 2b 2b </span><br><span style="color: hsl(120, 100%, 40%);">+[11] UL Immediate Assignment <ia_rest_uplink(MBA)>:</span><br><span style="color: hsl(120, 100%, 40%);">+      06 3f 10 0d 23 6d 0d 03 18 23 00 c8 02 7b a0 2b 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(120, 100%, 40%);">+[11] UL Immediate Assignment <ia_rest_uplink(SBA)>:</span><br><span style="color: hsl(120, 100%, 40%);">+      06 3f 10 0d 23 6d 0d 03 18 23 00 c5 d1 08 0b 5b 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(120, 100%, 40%);">+[11] UL Immediate Assignment <ia_rest_egprs_uplink(MBA)>:</span><br><span style="color: hsl(120, 100%, 40%);">+        06 3f 10 0d 23 6d 7f 03 18 23 00 46 97 40 0b 58 2b 2b 2b 2b 2b 2b 2b </span><br><span style="color: hsl(120, 100%, 40%);">+[11] UL Immediate Assignment <ia_rest_egprs_uplink(SBA)>:</span><br><span style="color: hsl(120, 100%, 40%);">+        06 3f 10 0d 23 6d 7f 03 18 23 00 46 a0 09 e0 17 40 2b 2b 2b 2b 2b 2b </span><br><span> assignment reject: 06 3a 10 7f 06 36 14 7f 06 36 14 7f 06 36 14 7f 06 36 14 c0 2b 2b </span><br><span> assignment reject: 06 3a 10 70 06 36 14 70 06 36 14 70 06 36 14 70 06 36 14 0b 2b 2b </span><br><span> Testing LBS utility...</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12947">change 12947</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12947"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I63f4654b23c7c4f063f6b3254d77157fac798586 </div>
<div style="display:none"> Gerrit-Change-Number: 12947 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>