From 94fe9d4a4710dc09a41bcb0e4844f59923d4fb35 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 20 Feb 2018 12:27:02 +0100 Subject: [PATCH] rlc: add basic RLC AM reset test --- lib/test/upper/rlc_am_test.cc | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index 184de3a00..67305c093 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -1056,6 +1056,60 @@ void resegment_test_6() } } +void reset_test() +{ + srslte::log_filter log1("RLC_AM_1"); + srslte::log_filter log2("RLC_AM_2"); + log1.set_level(srslte::LOG_LEVEL_DEBUG); + log2.set_level(srslte::LOG_LEVEL_DEBUG); + log1.set_hex_limit(-1); + log2.set_hex_limit(-1); + rlc_am_tester tester; + mac_dummy_timers timers; + + rlc_am rlc1; + int len; + + log1.set_level(srslte::LOG_LEVEL_DEBUG); + + rlc1.init(&log1, 1, &tester, &tester, &timers); + + LIBLTE_RRC_RLC_CONFIG_STRUCT cnfg; + cnfg.rlc_mode = LIBLTE_RRC_RLC_MODE_AM; + cnfg.dl_am_rlc.t_reordering = LIBLTE_RRC_T_REORDERING_MS5; + cnfg.dl_am_rlc.t_status_prohibit = LIBLTE_RRC_T_STATUS_PROHIBIT_MS5; + cnfg.ul_am_rlc.max_retx_thresh = LIBLTE_RRC_MAX_RETX_THRESHOLD_T4; + cnfg.ul_am_rlc.poll_byte = LIBLTE_RRC_POLL_BYTE_KB25; + cnfg.ul_am_rlc.poll_pdu = LIBLTE_RRC_POLL_PDU_P4; + cnfg.ul_am_rlc.t_poll_retx = LIBLTE_RRC_T_POLL_RETRANSMIT_MS5; + + rlc1.configure(&cnfg); + + // Push 1 SDU of size 10 into RLC1 + byte_buffer_t sdu_buf; + *sdu_buf.msg = 1; // Write the index into the buffer + sdu_buf.N_bytes = 100; + rlc1.write_sdu(&sdu_buf); + + // read 1 PDU from RLC1 and force segmentation + byte_buffer_t pdu_bufs; + len = rlc1.read_pdu(pdu_bufs.msg, 4); + pdu_bufs.N_bytes = len; + + // reset RLC1 + rlc1.reset(); + + // read another PDU segment from RLC1 + len = rlc1.read_pdu(pdu_bufs.msg, 4); + pdu_bufs.N_bytes = len; + + // now empty RLC buffer + len = rlc1.read_pdu(pdu_bufs.msg, 100); + pdu_bufs.N_bytes = len; + + assert(0 == rlc1.get_buffer_state()); +} + int main(int argc, char **argv) { basic_test(); byte_buffer_pool::get_instance()->cleanup(); @@ -1086,4 +1140,7 @@ int main(int argc, char **argv) { resegment_test_6(); byte_buffer_pool::get_instance()->cleanup(); + + reset_test(); + byte_buffer_pool::get_instance()->cleanup(); }