diff --git a/lib/test/upper/pdcp_lte_test_rx.cc b/lib/test/upper/pdcp_lte_test_rx.cc index f003bce6f..e61e2e484 100644 --- a/lib/test/upper/pdcp_lte_test_rx.cc +++ b/lib/test/upper/pdcp_lte_test_rx.cc @@ -62,14 +62,19 @@ int test_rx(std::vector events, // Test if the number of RX packets if (rb_type == srslte::PDCP_RB_IS_DRB) { TESTASSERT(gw_rx->rx_count == n_sdus_exp); - srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool); - gw_rx->get_last_pdu(sdu_act); - TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); + if (n_sdus_exp > 0) { + srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool); + gw_rx->get_last_pdu(sdu_act); + TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); + } + } else { TESTASSERT(rrc_rx->rx_count == n_sdus_exp); - srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool); - rrc_rx->get_last_pdu(sdu_act); - TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); + if (n_sdus_exp > 0) { + srslte::unique_byte_buffer_t sdu_act = allocate_unique_buffer(*pool); + rrc_rx->get_last_pdu(sdu_act); + TESTASSERT(compare_two_packets(sdu_exp, sdu_act) == 0); + } } return 0; } @@ -154,6 +159,36 @@ int test_rx_all(srslte::byte_buffer_pool* pool, srslte::log_ref log) return SRSLTE_SUCCESS; } +// Basic test to verify the correct handling of PDCP status PDUs on DRBs +// As long as we don't implement status reporting, the PDU shall be dropped +int test_rx_control_pdu(srslte::byte_buffer_pool* pool, srslte::log_ref log) +{ + const uint8_t pdcp_status_report_long[] = {0x0a, 0xc9, 0x3c}; + + std::vector pdu_vec; + + pdcp_test_event_t event; + event.pkt = allocate_unique_buffer(*pool); + memcpy(event.pkt->msg, pdcp_status_report_long, sizeof(pdcp_status_report_long)); + event.pkt->N_bytes = sizeof(pdcp_status_report_long); + pdu_vec.push_back(std::move(event)); + + srslte::unique_byte_buffer_t tst_sdu1 = allocate_unique_buffer(*pool); + + srslte::pdcp_lte_state_t test_init_state = { + .next_pdcp_tx_sn = 0, .tx_hfn = 0, .rx_hfn = 0, .next_pdcp_rx_sn = 32, .last_submitted_pdcp_rx_sn = 31}; + TESTASSERT(test_rx(std::move(pdu_vec), + test_init_state, + srslte::PDCP_SN_LEN_12, + srslte::PDCP_RB_IS_DRB, + 0, + tst_sdu1, + pool, + log) == 0); + + return SRSLTE_SUCCESS; +} + // Setup all tests int run_all_tests(srslte::byte_buffer_pool* pool) { @@ -163,6 +198,8 @@ int run_all_tests(srslte::byte_buffer_pool* pool) log->set_hex_limit(128); TESTASSERT(test_rx_all(pool, log) == 0); + TESTASSERT(test_rx_control_pdu(pool, log) == 0); + return 0; }