From 6b2961fceeabc0837812d32dd0eee8ef823140d9 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 2 Jul 2019 17:27:33 +0200 Subject: [PATCH] add MAC DL-SCH unpacking test --- lib/test/common/pdu_test.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/test/common/pdu_test.cc b/lib/test/common/pdu_test.cc index c65f49fe9..e09072e56 100644 --- a/lib/test/common/pdu_test.cc +++ b/lib/test/common/pdu_test.cc @@ -473,6 +473,30 @@ int mac_sch_pdu_pack_error_test() return SRSLTE_SUCCESS; } +// Parsing a corrupted MAC PDU and making sure the PDU is reset and not further processed +int mac_sch_pdu_unpack_test1() +{ + static uint8_t tv[] = {0x3f, 0x3f, 0x21, 0x3f, 0x03, 0x00, 0x04, 0x00, 0x04}; + + srslte::log_filter mac_log("MAC"); + mac_log.set_level(srslte::LOG_LEVEL_DEBUG); + mac_log.set_hex_limit(100000); + + srslte::sch_pdu pdu(10, &mac_log); + pdu.init_rx(sizeof(tv), false); + pdu.parse_packet(tv); + + // make sure this PDU is reset and will not be further processed + TESTASSERT(pdu.nof_subh() == 0); + TESTASSERT(pdu.next() == false); + +#if HAVE_PCAP + pcap_handle->write_ul_crnti(tv, sizeof(tv), 0x1001, true, 1); +#endif + + return SRSLTE_SUCCESS; +} + int main(int argc, char** argv) { #if HAVE_PCAP @@ -525,5 +549,10 @@ int main(int argc, char** argv) return SRSLTE_ERROR; } + if (mac_sch_pdu_unpack_test1()) { + fprintf(stderr, "mac_sch_pdu_unpack_test1 failed.\n"); + return SRSLTE_ERROR; + } + return SRSLTE_SUCCESS; }