rlc_am_{control}_test: extend status PDU test

This commit is contained in:
Andre Puschmann 2021-03-05 18:10:04 +01:00
parent 6a4bf65fd8
commit 9f627911df
2 changed files with 34 additions and 26 deletions

View File

@ -33,6 +33,7 @@ int simple_status_pdu_test1()
for (uint32_t i = 0; i < b2.N_bytes; i++) {
TESTASSERT(b2.msg[i] == b1.msg[i]);
}
TESTASSERT(rlc_am_is_valid_status_pdu(s1));
return SRSLTE_SUCCESS;
}
@ -59,6 +60,22 @@ int status_pdu_with_nacks_test1()
for (uint32_t i = 0; i < b2.N_bytes; i++) {
TESTASSERT(b2.msg[i] == b1.msg[i]);
}
TESTASSERT(rlc_am_is_valid_status_pdu(s2));
return SRSLTE_SUCCESS;
}
int malformed_status_pdu_test()
{
uint8_t pdu[] = {0x0b, 0x77, 0x6d, 0xd6, 0xe5, 0x6f, 0x56, 0xf8};
srslte::rlc_status_pdu_t s1;
srslte::byte_buffer_t b1, b2;
memcpy(b1.msg, pdu, sizeof(pdu));
b1.N_bytes = sizeof(pdu);
rlc_am_read_status_pdu(&b1, &s1);
TESTASSERT(rlc_am_is_valid_status_pdu(s1) == false);
return SRSLTE_SUCCESS;
}
@ -68,6 +85,7 @@ int main(int argc, char** argv)
TESTASSERT(simple_status_pdu_test1() == SRSLTE_SUCCESS);
TESTASSERT(status_pdu_with_nacks_test1() == SRSLTE_SUCCESS);
TESTASSERT(malformed_status_pdu_test() == SRSLTE_SUCCESS);
return SRSLTE_SUCCESS;
}

View File

@ -3215,28 +3215,28 @@ bool status_pdu_test()
}
// Push 5 SDUs into RLC1
unique_byte_buffer_t sdu_bufs[NBUFS];
for (int i = 0; i < NBUFS; i++) {
const uint32_t n_sdus = 10;
unique_byte_buffer_t sdu_bufs[n_sdus];
for (uint32_t i = 0; i < n_sdus; i++) {
sdu_bufs[i] = srslte::make_byte_buffer();
sdu_bufs[i]->N_bytes = 1; // Give each buffer a size of 1 byte
sdu_bufs[i]->msg[0] = i; // Write the index into the buffer
rlc1.write_sdu(std::move(sdu_bufs[i]));
}
TESTASSERT(13 == rlc1.get_buffer_state());
// Read 5 PDUs from RLC1 (1 byte each)
byte_buffer_t pdu_bufs[NBUFS];
for (int i = 0; i < NBUFS; i++) {
len = rlc1.read_pdu(pdu_bufs[i].msg, 4); // 2 byte header + 1 byte payload
const uint32_t n_pdus = n_sdus;
byte_buffer_t pdu_bufs[n_pdus];
for (uint32_t i = 0; i < n_pdus; i++) {
len = rlc1.read_pdu(pdu_bufs[i].msg, 3); // 2 byte header + 1 byte payload
pdu_bufs[i].N_bytes = len;
}
TESTASSERT(0 == rlc1.get_buffer_state());
// Only pass last PDUs to RLC2
for (int i = 0; i < NBUFS; i++) {
if (i == 4) {
// Only pass 2nd and last PDUs to RLC2
for (uint32_t i = 0; i < n_pdus; ++i) {
if (i == 0 || i == 2 || i == n_pdus - 1) {
rlc2.write_pdu(pdu_bufs[i].msg, pdu_bufs[i].N_bytes);
}
}
@ -3248,27 +3248,20 @@ bool status_pdu_test()
}
uint32_t buffer_state = rlc2.get_buffer_state();
TESTASSERT(8 == buffer_state);
// Read status PDU from RLC2
byte_buffer_t status_buf;
len = rlc2.read_pdu(status_buf.msg, 5); // provide only small grant
status_buf.N_bytes = len;
TESTASSERT(status_buf.N_bytes != 0);
// check status PDU doesn't contain ACK_SN in NACK list
rlc_status_pdu_t status_pdu = {};
rlc_am_read_status_pdu(status_buf.msg, status_buf.N_bytes, &status_pdu);
if (rlc_am_is_valid_status_pdu(status_pdu) == false) {
return -1;
}
TESTASSERT(rlc_am_is_valid_status_pdu(status_pdu));
// Write status PDU to RLC1
rlc1.write_pdu(status_buf.msg, status_buf.N_bytes);
TESTASSERT(3 == rlc1.get_buffer_state()); // 2 byte header + 1 byte payload
// Read the retx PDU from RLC1
byte_buffer_t retx;
len = rlc1.read_pdu(retx.msg, 10);
@ -3285,7 +3278,7 @@ bool status_pdu_test()
// get buffer state and status PDU again
status_buf.clear();
len = rlc2.read_pdu(status_buf.msg, 10); // big enough grant to fit full status PDU
len = rlc2.read_pdu(status_buf.msg, 20); // big enough grant to fit full status PDU
status_buf.N_bytes = len;
TESTASSERT(status_buf.N_bytes != 0);
@ -3293,7 +3286,7 @@ bool status_pdu_test()
rlc1.write_pdu(status_buf.msg, status_buf.N_bytes);
// retransmission of remaining PDUs
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 10; i++) {
retx.clear();
len = rlc1.read_pdu(retx.msg, 3);
retx.N_bytes = len;
@ -3302,15 +3295,12 @@ bool status_pdu_test()
rlc2.write_pdu(retx.msg, retx.N_bytes);
}
TESTASSERT(tester.sdus.size() == NBUFS);
TESTASSERT(tester.sdus.size() == n_sdus);
for (uint32_t i = 0; i < tester.sdus.size(); i++) {
if (tester.sdus[i]->N_bytes != 1)
return -1;
if (*(tester.sdus[i]->msg) != i)
return -1;
TESTASSERT(tester.sdus[i]->N_bytes == 1);
}
return 0;
return SRSLTE_SUCCESS;
}
// This test checks the correct functioning of RLC reestablishment