diff --git a/lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc b/lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc index 99c1804bb..c2a45b2cc 100644 --- a/lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_dl_ccch_test.cc @@ -47,8 +47,8 @@ int rrc_conn_setup_test1() log1.set_level(srslte::LOG_LEVEL_DEBUG); log1.set_hex_limit(128); - uint8_t rrc_msg[] = {0x60, 0x12, 0x98, 0x0b, 0xfd, 0xd2, 0x04, 0xfa, 0x18, 0x3e, 0xd5, 0xe6, 0xc2, - 0x59, 0x90, 0xc1, 0xa6, 0x00, 0x01, 0x31, 0x40, 0x42, 0x50, 0x80, 0x00, 0xf8}; + uint8_t rrc_msg[] = {0x60, 0x12, 0x98, 0x0b, 0xfd, 0xd2, 0x04, 0xfa, 0x18, 0x3e, 0xd5, 0xe6, 0xc2, + 0x59, 0x90, 0xc1, 0xa6, 0x00, 0x01, 0x31, 0x40, 0x42, 0x50, 0x80, 0x00, 0xf8}; uint32_t rrc_msg_len = sizeof(rrc_msg); // 6012980bfdd204fa183ed5e6c25990c1a60001314042508000f8 @@ -83,6 +83,7 @@ int rrc_conn_setup_test1() // test repacking uint8_t rrc_msg2[rrc_msg_len]; + bzero(rrc_msg2, sizeof(rrc_msg2)); bit_ref bref2(&rrc_msg2[0], sizeof(rrc_msg2)); if (dl_ccch_msg.pack(bref2) != SRSASN_SUCCESS) { return -1; @@ -110,6 +111,7 @@ int rrc_reestablishment_reject_test() // test repacking uint8_t rrc_msg[32]; + bzero(rrc_msg, sizeof(rrc_msg)); bit_ref bref(rrc_msg, sizeof(rrc_msg)); if (dl_ccch_msg.pack(bref) != SRSASN_SUCCESS) { return -1; diff --git a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc b/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc index 6c35386c8..8af37b184 100644 --- a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc @@ -123,6 +123,7 @@ int basic_test() //log1.info_hex(byte_buf.msg, byte_buf.N_bytes, "MCCH packed message:"); uint8_t rrc_msg2[known_reference_len]; + bzero(rrc_msg2, sizeof(rrc_msg2)); asn1::bit_ref bref2(&rrc_msg2[0], sizeof(rrc_msg2)); mcch_msg.pack(bref2); TESTASSERT(bref.distance(bref0) == bref2.distance(&rrc_msg2[0])); diff --git a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc b/lib/test/asn1/srslte_asn1_rrc_meas_test.cc index f91a1d68e..018a4af02 100644 --- a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_meas_test.cc @@ -93,6 +93,7 @@ int basic_test() TESTASSERT(meas_list[0].meas_result.rsrq_result == 18); uint8_t rrc_msg2[rrc_msg_len]; + bzero(rrc_msg2, rrc_msg_len); bit_ref bref2(&rrc_msg2[0], sizeof(rrc_msg2)); ul_dcch_msg.pack(bref2); TESTASSERT(bref.distance(bref0) == bref2.distance(&rrc_msg2[0])); diff --git a/lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc b/lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc index 1c46a981b..4742cad2c 100644 --- a/lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_ul_dcch_test.cc @@ -33,6 +33,8 @@ using namespace asn1::rrc; +#define PCAP 0 + #define TESTASSERT(cond) \ { \ if (!(cond)) { \ @@ -41,7 +43,7 @@ using namespace asn1::rrc; } \ } -int rrc_ue_cap_info_test(srslte::mac_pcap& pcap) +int rrc_ue_cap_info_test(srslte::mac_pcap* pcap) { srslte::log_filter log1("RRC"); log1.set_level(srslte::LOG_LEVEL_DEBUG); @@ -85,17 +87,19 @@ int rrc_ue_cap_info_test(srslte::mac_pcap& pcap) cap.feature_group_inds.from_number(args.feature_group); uint8_t buf[64]; + bzero(buf, sizeof(buf)); asn1::bit_ref bref(buf, sizeof(buf)); cap.pack(bref); bref.align_bytes_zero(); uint32_t cap_len = (uint32_t)bref.distance_bytes(buf); + info->ue_cap_rat_container_list[0].ue_cap_rat_container.resize(cap_len); memcpy(info->ue_cap_rat_container_list[0].ue_cap_rat_container.data(), buf, cap_len); log1.debug_hex(buf, cap_len, "UE-Cap (%d/%zd B)\n", cap_len, sizeof(buf)); // pack the message - uint8_t byte_buf[16]; - ZERO_OBJECT(byte_buf); + uint8_t byte_buf[32]; + bzero(byte_buf, sizeof(byte_buf)); asn1::bit_ref bref3(byte_buf, sizeof(byte_buf)); ul_dcch_msg.pack(bref3); bref3.align_bytes_zero(); @@ -103,7 +107,9 @@ int rrc_ue_cap_info_test(srslte::mac_pcap& pcap) uint32_t len = (uint32_t)bref3.distance_bytes(byte_buf); log1.debug_hex(byte_buf, len, "UL-DCCH (%d/%zd B)\n", len, sizeof(byte_buf)); - pcap.write_ul_rrc_pdu(byte_buf, len); + if (pcap != NULL) { + pcap->write_ul_rrc_pdu(byte_buf, len); + } return 0; } @@ -163,12 +169,17 @@ int pack_fail_test() int main(int argc, char** argv) { +#if PCAP srslte::mac_pcap pcap; pcap.open("ul_dcch.pcap"); - - TESTASSERT(rrc_ue_cap_info_test(pcap) == 0); + TESTASSERT(rrc_ue_cap_info_test(&pcap) == 0); +#else + TESTASSERT(rrc_ue_cap_info_test(NULL) == 0); +#endif TESTASSERT(pack_fail_test() == -1); +#if PCAP pcap.close(); +#endif return 0; } \ No newline at end of file diff --git a/srsue/test/upper/rrc_reconfig_test.cc b/srsue/test/upper/rrc_reconfig_test.cc index ffb3f56da..a89a33030 100644 --- a/srsue/test/upper/rrc_reconfig_test.cc +++ b/srsue/test/upper/rrc_reconfig_test.cc @@ -144,6 +144,7 @@ int basic_test() TESTASSERT(reconf_r8->rr_cfg_ded.phys_cfg_ded.pusch_cfg_ded_present); uint8_t rrc_msg2[rrc_msg_len]; + bzero(rrc_msg2, sizeof(rrc_msg2)); bit_ref bref2(&rrc_msg2[0], rrc_msg_len); dl_dcch_msg.pack(bref2);