rlc_um: add dedicated unit test for the PDU packing bug

Here is the test output with the fix disabled:

13:47:42.679774 [RLC_UM_1] [D] MAC opportunity - 14 bytes
13:47:42.679784 [RLC_UM_1] [D] pdu_space=14, head_len=2
13:47:42.679790 [RLC_UM_1] [D]  adding new SDU segment - 10 bytes of 10 remaining
13:47:42.679834 [RLC_UM_1] [D]  Complete SDU scheduled for tx. Stack latency: 0 us
13:47:42.679909 [RLC_UM_1] [D] pdu_space=4, head_len=2
13:47:42.679922 [RLC_UM_1] [D]  adding new SDU segment - 0 bytes of 10 remaining
13:47:42.679928 [RLC_UM_1] [I]  Tx PDU SN=0 (14 B)
13:47:42.679974 [RLC_UM_1] [D]  vt_us = 1

The test checks the correct packing and of the two PDUs at the end.
master
Andre Puschmann 4 years ago
parent df50dd7d3c
commit a3d7d4517c

@ -389,6 +389,56 @@ int reassmble_test2()
return 0;
}
/* PDU pack test where 2nd SDU segment is added but no
* space is left in PDU to add data bytes of the newly added SDU.
* The test makes sure that a SDU header is removed again and that
* the SDU is in fact transmitted in the next PDU.
*/
int pdu_pack_no_space_test()
{
rlc_um_lte_test_context1 ctxt;
const int32_t num_sdus = 2;
// Push 2 SDUs into RLC1
byte_buffer_pool* pool = byte_buffer_pool::get_instance();
unique_byte_buffer_t sdu_bufs[num_sdus];
for (int i = 0; i < num_sdus; i++) {
sdu_bufs[i] = srslte::allocate_unique_buffer(*pool, true);
*sdu_bufs[i]->msg = i; // Write the index into the buffer
sdu_bufs[i]->N_bytes = 10; // Give each buffer a size of 1 byte
ctxt.rlc1.write_sdu(std::move(sdu_bufs[i]));
}
// Read 1 PDU from RLC1
byte_buffer_t pdu_bufs[num_sdus];
int grant_size = 14; // Provide grant slightly bigger than the SDU
int len = ctxt.rlc1.read_pdu(pdu_bufs[0].msg, grant_size);
pdu_bufs[0].N_bytes = len;
// the generated PDU is shorter than the MAC opportunity
TESTASSERT(len < grant_size);
// this PDU contains a full SDU
{
srslte::rlc_umd_pdu_header_t h;
rlc_um_read_data_pdu_header(&pdu_bufs[0], srslte::rlc_umd_sn_size_t::size10bits, &h);
TESTASSERT(h.fi == RLC_FI_FIELD_START_AND_END_ALIGNED);
}
// get the 2nd SDU
len = ctxt.rlc1.read_pdu(pdu_bufs[1].msg, grant_size);
pdu_bufs[1].N_bytes = len;
{
srslte::rlc_umd_pdu_header_t h;
rlc_um_read_data_pdu_header(&pdu_bufs[1], srslte::rlc_umd_sn_size_t::size10bits, &h);
TESTASSERT(h.fi == RLC_FI_FIELD_START_AND_END_ALIGNED);
}
return SRSLTE_SUCCESS;
}
int main(int argc, char** argv)
{
if (meas_obj_test()) {
@ -415,4 +465,7 @@ int main(int argc, char** argv)
return -1;
}
byte_buffer_pool::get_instance()->cleanup();
TESTASSERT(pdu_pack_no_space_test() == 0);
byte_buffer_pool::get_instance()->cleanup();
}

Loading…
Cancel
Save