Starting to change the expected pdus name.

master
Pedro Alvarez 5 years ago committed by Andre Puschmann
parent 49e0e3a24a
commit cb0466bce7

@ -42,7 +42,7 @@ uint8_t sdu1[] = {0x18, 0xE2};
uint8_t sdu2[] = {0xde, 0xad};
// Test PDUs for rx (generated from SDU1)
uint8_t pdu1[] = {0x80, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92};
uint8_t pdu1_count0_snlen12[] = {0x80, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92};
uint8_t pdu2[] = {0x88, 0x00, 0x8d, 0x2c, 0x47, 0x5e, 0xb1, 0x5b};
uint8_t pdu3[] = {0x80, 0x00, 0x97, 0xbe, 0xa3, 0x32, 0xfa, 0x61};
uint8_t pdu4[] = {0x80, 0x00, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92};
@ -172,7 +172,7 @@ int test_rx_out_of_order(uint8_t pdcp_sn_len, srslte::byte_buffer_pool* pool, sr
// Get encripted and integrity protected PDUs used for testing
srslte::unique_byte_buffer_t rx_pdu1 = allocate_unique_buffer(*pool);
srslte::unique_byte_buffer_t rx_pdu7 = allocate_unique_buffer(*pool);
rx_pdu1->append_bytes(pdu1, sizeof(pdu1));
rx_pdu1->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
rx_pdu7->append_bytes(pdu7, sizeof(pdu7));
// decript and check matching SDUs (out of order)
@ -252,7 +252,7 @@ int test_rx_out_of_order_wraparound(uint8_t pdcp_sn_len, srslte::byte_buffer_poo
// Generate encripted and integrity protected PDUs
srslte::unique_byte_buffer_t rx_pdu1 = allocate_unique_buffer(*pool);
srslte::unique_byte_buffer_t rx_pdu7 = allocate_unique_buffer(*pool);
rx_pdu1->append_bytes(pdu1, sizeof(pdu1));
rx_pdu1->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
rx_pdu7->append_bytes(pdu7, sizeof(pdu7));
@ -372,7 +372,7 @@ int test_rx_with_initial_state(uint8_t pdcp_sn_len, srslte::byte_buffer_pool* po
rx_pdus[0] = srslte::allocate_unique_buffer(*pool);
rx_pdus[1] = srslte::allocate_unique_buffer(*pool);
rx_pdus[0]->append_bytes(pdu1, sizeof(pdu1));
rx_pdus[0]->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
rx_pdus[1]->append_bytes(pdu7, sizeof(pdu7));
// set sdu exp
@ -405,9 +405,9 @@ int test_tx_all(srslte::byte_buffer_pool* pool, srslte::log* log)
* Input: {0x18, 0xE2}
* Output: PDCP Header {0x80, 0x00}, Ciphered Text {0x8f, 0xe3}, MAC-I {0xe0, 0xdf, 0x82, 0x92}
*/
srslte::unique_byte_buffer_t pdu_exp_sn0_len12 = allocate_unique_buffer(*pool);
pdu_exp_sn0_len12->append_bytes(pdu1, sizeof(pdu1));
TESTASSERT(test_tx(1, srslte::PDCP_SN_LEN_12, std::move(pdu_exp_sn0_len12), pool, log) == 0);
srslte::unique_byte_buffer_t pdu_exp_count0_len12 = allocate_unique_buffer(*pool);
pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
TESTASSERT(test_tx(1, srslte::PDCP_SN_LEN_12, std::move(pdu_exp_count0_len12), pool, log) == 0);
/*
* TX Test 2: PDCP Entity with SN LEN = 12
@ -516,6 +516,17 @@ int run_all_tests(srslte::byte_buffer_pool* pool)
log.set_level(srslte::LOG_LEVEL_DEBUG);
log.set_hex_limit(128);
// Helpers for generating expected PDUs
srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
sdu->append_bytes(sdu1, sizeof(sdu1));
srslte::pdcp_config_t cfg_tx = {1,
srslte::PDCP_RB_IS_DRB,
srslte::SECURITY_DIRECTION_UPLINK,
srslte::SECURITY_DIRECTION_DOWNLINK,
srslte::PDCP_SN_LEN_12,
srslte::pdcp_t_reordering_t::ms500};
gen_expected_pdu(std::move(sdu), 0, cfg_tx, sec_cfg, &log, pool);
//gen_expected_pdu(std::move(sdu), 4096, cfg_tx, sec_cfg, &log, pool);
//TESTASSERT(test_tx_all(pool, &log) == 0);
//TESTASSERT(test_rx_all(pool, &log) == 0);
return 0;

@ -45,6 +45,14 @@ int compare_two_packets(const srslte::unique_byte_buffer_t& msg1, const srslte::
return 0;
}
void print_packet_array(const srslte::unique_byte_buffer_t &msg){
printf("uint8_t msg[] = {\n");
for (uint64_t i = 0; i < msg->N_bytes; ++i){
printf("0x%02x, ",msg->msg[i]);
}
printf("\n};\n");
}
struct pdcp_security_cfg {
uint8_t *k_int_rrc;
uint8_t *k_enc_rrc;
@ -149,7 +157,7 @@ public:
};
void gen_expected_pdu(srslte::unique_byte_buffer_t in_sdu,
uint32_t n_packets,
uint32_t count,
srslte::pdcp_config_t cfg,
pdcp_security_cfg sec_cfg,
srslte::log* log,
@ -157,16 +165,16 @@ void gen_expected_pdu(srslte::unique_byte_buffer_t in_sdu,
{
pdcp_nr_test_helper pdcp_hlp(cfg, sec_cfg, log);
srslte::pdcp_entity_nr* pdcp = &pdcp_hlp.pdcp;
gw_dummy* gw = &pdcp_hlp.gw;
rlc_dummy* rlc = &pdcp_hlp.rlc;
for (uint32_t i = 0; i < n_packets; ++i) {
for (uint32_t i = 0; i <= count; ++i) {
srslte::unique_byte_buffer_t sdu = srslte::allocate_unique_buffer(*pool);
*sdu = *in_sdu;
pdcp->write_sdu(std::move(sdu), true);
}
srslte::unique_byte_buffer_t out_pdu = srslte::allocate_unique_buffer(*pool);
gw->get_last_pdu(out_pdu);
log->info_hex(out_pdu->msg, out_pdu->N_bytes, "Output PDU");
rlc->get_last_sdu(out_pdu);
print_packet_array(out_pdu);
}
#endif // SRSLTE_PDCP_NR_TEST_H

Loading…
Cancel
Save