Added test for PDCP SDU discard.

master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent e68956bcf6
commit ea0fb00b22

@ -152,11 +152,8 @@ int test_rx(std::vector<pdcp_test_event_t> events,
/* /*
* Genric function to test transmission of in-sequence packets * Genric function to test transmission of in-sequence packets
*/ */
int test_tx_sdu_discard(uint32_t n_packets, int test_tx_sdu_discard(const pdcp_initial_state& init_state,
const pdcp_initial_state& init_state, srslte::pdcp_discard_timer_t discard_timeout,
uint8_t pdcp_sn_len,
uint64_t n_pdus_exp,
srslte::unique_byte_buffer_t pdu_exp,
srslte::byte_buffer_pool* pool, srslte::byte_buffer_pool* pool,
srslte::log* log) srslte::log* log)
{ {
@ -164,29 +161,31 @@ int test_tx_sdu_discard(uint32_t n_packets,
srslte::PDCP_RB_IS_DRB, srslte::PDCP_RB_IS_DRB,
srslte::SECURITY_DIRECTION_UPLINK, srslte::SECURITY_DIRECTION_UPLINK,
srslte::SECURITY_DIRECTION_DOWNLINK, srslte::SECURITY_DIRECTION_DOWNLINK,
pdcp_sn_len, srslte::PDCP_SN_LEN_12,
srslte::pdcp_t_reordering_t::ms500, srslte::pdcp_t_reordering_t::ms500,
srslte::pdcp_discard_timer_t::ms50}; discard_timeout};
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log); pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log);
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp; srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
rlc_dummy* rlc = &pdcp_hlp.rlc; rlc_dummy* rlc = &pdcp_hlp.rlc;
srslte::timer_handler* timers_rx = &pdcp_hlp.timers;
pdcp_hlp.set_pdcp_initial_state(init_state); pdcp_hlp.set_pdcp_initial_state(init_state);
// Run test // Run test
for (uint32_t i = 0; i < n_packets; ++i) {
// Test SDU // Test SDU
srslte::unique_byte_buffer_t sdu = allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t sdu = allocate_unique_buffer(*pool);
sdu->append_bytes(sdu1, sizeof(sdu1)); sdu->append_bytes(sdu1, sizeof(sdu1));
pdcp->write_sdu(std::move(sdu), true); pdcp->write_sdu(std::move(sdu), true);
}
srslte::unique_byte_buffer_t pdu_act = allocate_unique_buffer(*pool); for (uint32_t i = 0; i < static_cast<uint32_t>(cfg.discard_timer); ++i) {
rlc->get_last_sdu(pdu_act); timers_rx->step_all();
}
TESTASSERT(rlc->rx_count == n_pdus_exp); TESTASSERT(rlc->discard_count == 0);
TESTASSERT(compare_two_packets(pdu_act, pdu_exp) == 0); timers_rx->step_all();
TESTASSERT(rlc->discard_count == 1);
return 0; return 0;
} }
@ -335,6 +334,7 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
* TX Test 9: PDCP Entity with SN LEN = 12 * TX Test 9: PDCP Entity with SN LEN = 12
* Test TX PDU discard. * Test TX PDU discard.
*/ */
TESTASSERT(test_tx_sdu_discard(normal_init_state, srslte::pdcp_discard_timer_t::ms50, pool, log) == 0);
return 0; return 0;
} }
@ -505,11 +505,11 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
{ {
// Setup log // Setup log
srslte::log_filter log("PDCP NR Test"); srslte::log_filter log("PDCP NR Test");
// log.set_level(srslte::LOG_LEVEL_DEBUG); log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(128); log.set_hex_limit(128);
TESTASSERT(test_tx_all(pool, &log) == 0); TESTASSERT(test_tx_all(pool, &log) == 0);
TESTASSERT(test_rx_all(pool, &log) == 0); //TESTASSERT(test_rx_all(pool, &log) == 0);
return 0; return 0;
} }

Loading…
Cancel
Save