lib,pdcp_nr: fixed PDCP NR tx unit tests

master
Pedro Alvarez 3 years ago
parent b361ab0650
commit 904dbff471

@ -57,14 +57,14 @@ uint8_t sdu1[] = {0x18, 0xe2};
uint8_t sdu2[] = {0xde, 0xad}; uint8_t sdu2[] = {0xde, 0xad};
// Test PDUs for rx (generated from SDU1) // Test PDUs for rx (generated from SDU1)
uint8_t pdu1_count0_snlen12[] = {0x80, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92}; uint8_t pdu1_count0_snlen12[] = {0x80, 0x00, 0x8f, 0xe3, 0xc7, 0x1b, 0xad, 0x14};
uint8_t pdu1_count2048_snlen12[] = {0x88, 0x00, 0x8d, 0x2c, 0x47, 0x5e, 0xb1, 0x5b}; uint8_t pdu1_count2048_snlen12[] = {0x88, 0x00, 0x8d, 0x2c, 0xe5, 0x38, 0xc0, 0x42};
uint8_t pdu1_count4096_snlen12[] = {0x80, 0x00, 0x97, 0xbe, 0xa3, 0x32, 0xfa, 0x61}; uint8_t pdu1_count4096_snlen12[] = {0x80, 0x00, 0x97, 0xbe, 0xee, 0x62, 0xf5, 0xe0};
uint8_t pdu1_count4294967295_snlen12[] = {0x8f, 0xff, 0x1e, 0x47, 0xe6, 0x86, 0x28, 0x6c}; uint8_t pdu1_count4294967295_snlen12[] = {0x8f, 0xff, 0x1e, 0x47, 0xa9, 0x55, 0xa9, 0xd8};
uint8_t pdu1_count0_snlen18[] = {0x80, 0x00, 0x00, 0x8f, 0xe3, 0xe0, 0xdf, 0x82, 0x92}; uint8_t pdu1_count0_snlen18[] = {0x80, 0x00, 0x00, 0x8f, 0xe3, 0x37, 0x33, 0xd5, 0x64};
uint8_t pdu1_count131072_snlen18[] = {0x82, 0x00, 0x00, 0x15, 0x01, 0xf4, 0xb0, 0xfc, 0xc5}; uint8_t pdu1_count131072_snlen18[] = {0x82, 0x00, 0x00, 0x15, 0x01, 0x99, 0x97, 0xe0, 0x4e};
uint8_t pdu1_count262144_snlen18[] = {0x80, 0x00, 0x00, 0xc2, 0x47, 0xa8, 0xdd, 0xc0, 0x73}; uint8_t pdu1_count262144_snlen18[] = {0x80, 0x00, 0x00, 0xc2, 0x47, 0xc2, 0xee, 0x46, 0xd9};
uint8_t pdu1_count4294967295_snlen18[] = {0x83, 0xff, 0xff, 0x1e, 0x47, 0xe6, 0x86, 0x28, 0x6c}; uint8_t pdu1_count4294967295_snlen18[] = {0x83, 0xff, 0xff, 0x1e, 0x47, 0x78, 0xb8, 0x7a, 0x9f};
// Test PDUs for rx (generated from SDU2) // Test PDUs for rx (generated from SDU2)
uint8_t pdu2_count1_snlen12[] = {0x80, 0x01, 0x5e, 0x3d, 0x64, 0xaf, 0xac, 0x7c}; uint8_t pdu2_count1_snlen12[] = {0x80, 0x01, 0x5e, 0x3d, 0x64, 0xaf, 0xac, 0x7c};

@ -65,8 +65,11 @@ int test_tx_all(srslog::basic_logger& logger)
* TX Test 1: PDCP Entity with SN LEN = 12 * TX Test 1: PDCP Entity with SN LEN = 12
* TX_NEXT = 0. * TX_NEXT = 0.
* Input: {0x18, 0xE2} * Input: {0x18, 0xE2}
* Output: PDCP Header {0x80, 0x00}, Ciphered Text {0x8f, 0xe3}, MAC-I {0xe0, 0xdf, 0x82, 0x92} * Output: {0x80, 0x00, 0x8f, 0xe3, 0xc7, 0x1b, 0xad, 0x14}
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT 0, 12 bit SN");
n_packets = 1; n_packets = 1;
srsran::unique_byte_buffer_t pdu_exp_count0_len12 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count0_len12 = srsran::make_byte_buffer();
pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12)); pdu_exp_count0_len12->append_bytes(pdu1_count0_snlen12, sizeof(pdu1_count0_snlen12));
@ -74,13 +77,16 @@ int test_tx_all(srslog::basic_logger& logger)
test_tx( test_tx(
n_packets, normal_init_state, srsran::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), logger) == n_packets, normal_init_state, srsran::PDCP_SN_LEN_12, n_packets, std::move(pdu_exp_count0_len12), logger) ==
0); 0);
}
/* /*
* TX Test 2: PDCP Entity with SN LEN = 12 * TX Test 2: PDCP Entity with SN LEN = 12
* TX_NEXT = 2048. * TX_NEXT = 2048.
* Input: {0x18, 0xE2} * Input: {0x18, 0xE2}
* Output: PDCP Header {0x88, 0x00}, Ciphered Text {0x8d, 0x2c}, MAC-I {0x47, 0x5e, 0xb1, 0x5b} * Output: {0x88, 0x00, 0x8d, 0x2c, 0xe5, 0x38, 0xc0, 0x42}
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT 2048, 12 bit SN");
n_packets = 2049; n_packets = 2049;
srsran::unique_byte_buffer_t pdu_exp_count2048_len12 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count2048_len12 = srsran::make_byte_buffer();
pdu_exp_count2048_len12->append_bytes(pdu1_count2048_snlen12, sizeof(pdu1_count2048_snlen12)); pdu_exp_count2048_len12->append_bytes(pdu1_count2048_snlen12, sizeof(pdu1_count2048_snlen12));
@ -90,13 +96,16 @@ int test_tx_all(srslog::basic_logger& logger)
n_packets, n_packets,
std::move(pdu_exp_count2048_len12), std::move(pdu_exp_count2048_len12),
logger) == 0); logger) == 0);
}
/* /*
* TX Test 3: PDCP Entity with SN LEN = 12 * TX Test 3: PDCP Entity with SN LEN = 12
* TX_NEXT = 4096. * TX_NEXT = 4096.
* Input: {0x18, 0xE2} * Input: {0x18, 0xE2}
* Output: PDCP Header {0x80,0x00}, Ciphered Text {0x97, 0xbe}, MAC-I {0xa3, 0x32, 0xfa, 0x61} * Output: {0x80, 0x00, 0x97, 0xbe, 0xee, 0x62, 0xf5, 0xe0}
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT 4096, 12 bit SN");
n_packets = 4097; n_packets = 4097;
srsran::unique_byte_buffer_t pdu_exp_count4096_len12 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count4096_len12 = srsran::make_byte_buffer();
pdu_exp_count4096_len12->append_bytes(pdu1_count4096_snlen12, sizeof(pdu1_count4096_snlen12)); pdu_exp_count4096_len12->append_bytes(pdu1_count4096_snlen12, sizeof(pdu1_count4096_snlen12));
@ -106,13 +115,16 @@ int test_tx_all(srslog::basic_logger& logger)
n_packets, n_packets,
std::move(pdu_exp_count4096_len12), std::move(pdu_exp_count4096_len12),
logger) == 0); logger) == 0);
}
/* /*
* TX Test 4: PDCP Entity with SN LEN = 18 * TX Test 4: PDCP Entity with SN LEN = 18
* TX_NEXT = 0. * TX_NEXT = 0.
* Input: {0x18, 0xE2} * Input: {0x18, 0xE2}
* Output: PDCP Header {0x80, 0x80, 0x00}, Ciphered Text {0x8f, 0xe3}, MAC-I {0xe0, 0xdf, 0x82, 0x92} * Output: {0x80, 0x00, 0x00, 0x8f, 0xe3, 0x37, 0x33, 0xd5, 0x64}
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT 0, 18 bit SN");
n_packets = 1; n_packets = 1;
srsran::unique_byte_buffer_t pdu_exp_count0_len18 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count0_len18 = srsran::make_byte_buffer();
pdu_exp_count0_len18->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18)); pdu_exp_count0_len18->append_bytes(pdu1_count0_snlen18, sizeof(pdu1_count0_snlen18));
@ -120,27 +132,37 @@ int test_tx_all(srslog::basic_logger& logger)
test_tx( test_tx(
n_packets, normal_init_state, srsran::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), logger) == n_packets, normal_init_state, srsran::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_count0_len18), logger) ==
0); 0);
}
/* /*
* TX Test 5: PDCP Entity with SN LEN = 18 * TX Test 5: PDCP Entity with SN LEN = 18
* TX_NEXT = 131072. * TX_NEXT = 131072.
* Input: {0x18, 0xE2} * Input: {0x18, 0xE2}
* Output: PDCP Header {0x82, 0x00, 0x00}, Ciphered Text {0x15, 0x01}, MAC-I {0xf4, 0xb0, 0xfc, 0xc5} * Output: {0x82, 0x00, 0x00, 0x15, 0x01, 0x99, 0x97, 0xe0, 0x4e}
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT 131072, 18 bit SN");
n_packets = 131073; n_packets = 131073;
srsran::unique_byte_buffer_t pdu_exp_sn131072_len18 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_sn131072_len18 = srsran::make_byte_buffer();
pdu_exp_sn131072_len18->append_bytes(pdu1_count131072_snlen18, sizeof(pdu1_count131072_snlen18)); pdu_exp_sn131072_len18->append_bytes(pdu1_count131072_snlen18, sizeof(pdu1_count131072_snlen18));
TESTASSERT( TESTASSERT(test_tx(n_packets,
test_tx( normal_init_state,
n_packets, normal_init_state, srsran::PDCP_SN_LEN_18, n_packets, std::move(pdu_exp_sn131072_len18), logger) == srsran::PDCP_SN_LEN_18,
0); n_packets,
std::move(pdu_exp_sn131072_len18),
logger) == 0);
}
/* /*
* TX Test 6: PDCP Entity with SN LEN = 18 * TX Test 6: PDCP Entity with SN LEN = 18
* TX_NEXT = 262144. * TX_NEXT = 262144.
* Input: {0x18, 0xE2} * Input: {0x18, 0xE2}
* Output: PDCP Header {0x80, 0x00, 0x00}, Ciphered Text {0xc2, 0x47}, MAC-I {0xa8, 0xdd, 0xc0, 0x73} * Output: {0x80, 0x00, 0x00, 0xc2, 0x47, 0xc2, 0xee, 0x46, 0xd9}
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT 262144, 18 bit SN");
n_packets = 262145; n_packets = 262145;
srsran::unique_byte_buffer_t pdu_exp_count262144_len18 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count262144_len18 = srsran::make_byte_buffer();
pdu_exp_count262144_len18->append_bytes(pdu1_count262144_snlen18, sizeof(pdu1_count262144_snlen18)); pdu_exp_count262144_len18->append_bytes(pdu1_count262144_snlen18, sizeof(pdu1_count262144_snlen18));
@ -150,12 +172,15 @@ int test_tx_all(srslog::basic_logger& logger)
n_packets, n_packets,
std::move(pdu_exp_count262144_len18), std::move(pdu_exp_count262144_len18),
logger) == 0); logger) == 0);
}
/* /*
* TX Test 7: PDCP Entity with SN LEN = 12 * TX Test 7: PDCP Entity with SN LEN = 12
* Test TX at COUNT wraparound. * Test TX at COUNT wraparound.
* Should print a warning and drop all packets after wrap around. * Should print a warning and drop all packets after wrap around.
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT wrap arround, 12 bit SN");
n_packets = 5; n_packets = 5;
srsran::unique_byte_buffer_t pdu_exp_count4294967295_len12 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count4294967295_len12 = srsran::make_byte_buffer();
pdu_exp_count4294967295_len12->append_bytes(pdu1_count4294967295_snlen12, sizeof(pdu1_count4294967295_snlen12)); pdu_exp_count4294967295_len12->append_bytes(pdu1_count4294967295_snlen12, sizeof(pdu1_count4294967295_snlen12));
@ -165,12 +190,16 @@ int test_tx_all(srslog::basic_logger& logger)
1, 1,
std::move(pdu_exp_count4294967295_len12), std::move(pdu_exp_count4294967295_len12),
logger) == 0); logger) == 0);
}
/* /*
* TX Test 8: PDCP Entity with SN LEN = 18 * TX Test 8: PDCP Entity with SN LEN = 18
* Test TX at COUNT wraparound. * Test TX at COUNT wraparound.
* Should print a warning and drop all packets after wraparound. * Should print a warning and drop all packets after wraparound.
*/ */
{
auto& test_logger = srslog::fetch_basic_logger("TESTER ");
srsran::test_delimit_logger delimiter("TX COUNT wrap arround, 12 bit SN");
n_packets = 5; n_packets = 5;
srsran::unique_byte_buffer_t pdu_exp_count4294967295_len18 = srsran::make_byte_buffer(); srsran::unique_byte_buffer_t pdu_exp_count4294967295_len18 = srsran::make_byte_buffer();
pdu_exp_count4294967295_len18->append_bytes(pdu1_count4294967295_snlen18, sizeof(pdu1_count4294967295_snlen18)); pdu_exp_count4294967295_len18->append_bytes(pdu1_count4294967295_snlen18, sizeof(pdu1_count4294967295_snlen18));
@ -180,7 +209,8 @@ int test_tx_all(srslog::basic_logger& logger)
1, 1,
std::move(pdu_exp_count4294967295_len18), std::move(pdu_exp_count4294967295_len18),
logger) == 0); logger) == 0);
return 0; }
return SRSRAN_SUCCESS;
} }
// Setup all tests // Setup all tests

Loading…
Cancel
Save