Merge remote-tracking branch 'origin/nr-ue-ra-testcase' into integration_2024_w46 (!3059)
Test for init_RA A testcase for init_RA function. The testcase redefines the following functions as stubs: - nr_mac_rrc_ra_ind - nr_write_ce_ulsch_pdu - mac_rlc_data_req - lockGet_ul_config - release_ul_config - remove_ul_config_last_item - nr_ue_configure_pucch These stubs can be used to check init_RA behavior
This commit is contained in:
+2
-3
@@ -1374,7 +1374,6 @@ set (MAC_NR_SRC_UE
|
||||
${NR_UE_MAC_DIR}/nr_ue_scheduler.c
|
||||
${NR_UE_MAC_DIR}/nr_ue_scheduler_sl.c
|
||||
${NR_UE_MAC_DIR}/nr_ue_dci_configuration.c
|
||||
${NR_UE_MAC_DIR}/nr_ra_procedures.c
|
||||
)
|
||||
|
||||
set (ENB_APP_SRC
|
||||
@@ -1423,7 +1422,7 @@ endif()
|
||||
|
||||
|
||||
add_library(MAC_UE_NR ${MAC_NR_SRC_UE})
|
||||
target_link_libraries(MAC_UE_NR PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs PUBLIC nr_ue_power_procedures)
|
||||
target_link_libraries(MAC_UE_NR PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs PUBLIC nr_ue_power_procedures nr_ue_ra_procedures)
|
||||
|
||||
add_library(L2_LTE ${L2_LTE_SRC})
|
||||
target_link_libraries(L2_LTE PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
|
||||
@@ -1478,7 +1477,7 @@ target_link_libraries(L2_UE PRIVATE asn1_lte_rrc_hdrs)
|
||||
|
||||
add_library( NR_L2_UE ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} )
|
||||
target_link_libraries(NR_L2_UE PRIVATE f1ap nr_rlc)
|
||||
target_link_libraries(NR_L2_UE PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs nr_common nr_ue_power_procedures)
|
||||
target_link_libraries(NR_L2_UE PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs nr_common nr_ue_power_procedures nr_ue_ra_procedures)
|
||||
|
||||
add_library(MAC_NR_COMMON
|
||||
${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
add_library(nr_ue_power_procedures nr_ue_power_procedures.c)
|
||||
target_link_libraries(nr_ue_power_procedures PUBLIC asn1_nr_rrc ${T_LIB} MAC_NR_COMMON nr_common)
|
||||
add_library(nr_ue_ra_procedures nr_ra_procedures.c)
|
||||
target_link_libraries(nr_ue_ra_procedures PUBLIC asn1_nr_rrc asn1_lte_rrc_hdrs ${T_LIB} MAC_NR_COMMON nr_common)
|
||||
if (ENABLE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
@@ -325,27 +325,3 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac, NR_UE_MAC_reset_cause_t ca
|
||||
for (int i = mac->TAG_list.count; i > 0 ; i--)
|
||||
asn_sequence_del(&mac->TAG_list, i - 1, 1);
|
||||
}
|
||||
|
||||
void free_rach_structures(NR_UE_MAC_INST_t *nr_mac, int bwp_id)
|
||||
{
|
||||
for (int j = 0; j < MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD; j++)
|
||||
for (int k = 0; k < MAX_NB_FRAME_IN_PRACH_CONF_PERIOD; k++)
|
||||
for (int l = 0; l < MAX_NB_SLOT_IN_FRAME; l++)
|
||||
free(nr_mac->prach_assoc_pattern[bwp_id].prach_conf_period_list[j].prach_occasion_slot_map[k][l].prach_occasion);
|
||||
|
||||
free(nr_mac->ssb_list[bwp_id].tx_ssb);
|
||||
}
|
||||
|
||||
void reset_ra(NR_UE_MAC_INST_t *nr_mac, bool free_prach)
|
||||
{
|
||||
RA_config_t *ra = &nr_mac->ra;
|
||||
if(ra->rach_ConfigDedicated)
|
||||
asn1cFreeStruc(asn_DEF_NR_RACH_ConfigDedicated, ra->rach_ConfigDedicated);
|
||||
memset(ra, 0, sizeof(RA_config_t));
|
||||
|
||||
if (!free_prach)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < MAX_NUM_BWP_UE; i++)
|
||||
free_rach_structures(nr_mac, i);
|
||||
}
|
||||
|
||||
@@ -1076,3 +1076,27 @@ void prepare_msg4_msgb_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack)
|
||||
remove_ul_config_last_item(pdu);
|
||||
release_ul_config(pdu, false);
|
||||
}
|
||||
|
||||
void free_rach_structures(NR_UE_MAC_INST_t *nr_mac, int bwp_id)
|
||||
{
|
||||
for (int j = 0; j < MAX_NB_PRACH_CONF_PERIOD_IN_ASSOCIATION_PATTERN_PERIOD; j++)
|
||||
for (int k = 0; k < MAX_NB_FRAME_IN_PRACH_CONF_PERIOD; k++)
|
||||
for (int l = 0; l < MAX_NB_SLOT_IN_FRAME; l++)
|
||||
free(nr_mac->prach_assoc_pattern[bwp_id].prach_conf_period_list[j].prach_occasion_slot_map[k][l].prach_occasion);
|
||||
|
||||
free(nr_mac->ssb_list[bwp_id].tx_ssb);
|
||||
}
|
||||
|
||||
void reset_ra(NR_UE_MAC_INST_t *nr_mac, bool free_prach)
|
||||
{
|
||||
RA_config_t *ra = &nr_mac->ra;
|
||||
if (ra->rach_ConfigDedicated)
|
||||
asn1cFreeStruc(asn_DEF_NR_RACH_ConfigDedicated, ra->rach_ConfigDedicated);
|
||||
memset(ra, 0, sizeof(RA_config_t));
|
||||
|
||||
if (!free_prach)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < MAX_NUM_BWP_UE; i++)
|
||||
free_rach_structures(nr_mac, i);
|
||||
}
|
||||
|
||||
@@ -4,3 +4,9 @@ target_link_libraries(test_nr_ue_power_procedures PRIVATE nr_ue_power_procedures
|
||||
add_dependencies(tests test_nr_ue_power_procedures)
|
||||
add_test(NAME test_nr_ue_power_procedures
|
||||
COMMAND ./test_nr_ue_power_procedures)
|
||||
|
||||
add_executable(test_nr_ue_ra_procedures test_nr_ue_ra_procedures.cpp)
|
||||
target_link_libraries(test_nr_ue_ra_procedures PRIVATE nr_ue_ra_procedures nr_ue_power_procedures GTest::gtest minimal_lib)
|
||||
add_dependencies(tests test_nr_ue_ra_procedures)
|
||||
add_test(NAME test_nr_ue_ra_procedures
|
||||
COMMAND ./test_nr_ue_ra_procedures)
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
extern "C" {
|
||||
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
|
||||
#include "executables/softmodem-common.h"
|
||||
uint64_t get_softmodem_optmask(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static softmodem_params_t softmodem_params;
|
||||
softmodem_params_t *get_softmodem_params(void)
|
||||
{
|
||||
return &softmodem_params;
|
||||
}
|
||||
void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success)
|
||||
{
|
||||
}
|
||||
int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
|
||||
NR_UE_MAC_INST_t *mac,
|
||||
NR_SINGLE_ENTRY_PHR_MAC_CE *power_headroom,
|
||||
const type_bsr_t *bsr,
|
||||
uint8_t *mac_ce_end)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int nr_write_ce_msg3_pdu(uint8_t *mac_ce, NR_UE_MAC_INST_t *mac, rnti_t crnti, uint8_t *mac_ce_end)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
tbs_size_t mac_rlc_data_req(const module_id_t module_idP,
|
||||
const rnti_t rntiP,
|
||||
const eNB_index_t eNB_index,
|
||||
const frame_t frameP,
|
||||
const eNB_flag_t enb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP,
|
||||
const logical_chan_id_t channel_idP,
|
||||
const tb_size_t tb_sizeP,
|
||||
char *buffer_pP,
|
||||
const uint32_t sourceL2Id,
|
||||
const uint32_t destinationL2Id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
void release_ul_config(fapi_nr_ul_config_request_pdu_t *configPerSlot, bool clearIt)
|
||||
{
|
||||
}
|
||||
void remove_ul_config_last_item(fapi_nr_ul_config_request_pdu_t *pdu)
|
||||
{
|
||||
}
|
||||
int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
|
||||
int slot,
|
||||
frame_t frame,
|
||||
uint16_t rnti,
|
||||
PUCCH_sched_t *pucch,
|
||||
fapi_nr_ul_config_pucch_pdu *pucch_pdu)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#include <cstdio>
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
TEST(test_init_ra, four_step_cbra)
|
||||
{
|
||||
NR_UE_MAC_INST_t mac = {0};
|
||||
NR_PRACH_RESOURCES_t prach_resources = {0};
|
||||
NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0};
|
||||
NR_RACH_ConfigGeneric_t rach_ConfigGeneric = {0};
|
||||
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = nullptr;
|
||||
NR_UE_UL_BWP_t current_bwp;
|
||||
mac.current_UL_BWP = ¤t_bwp;
|
||||
long scs = 1;
|
||||
current_bwp.scs = scs;
|
||||
current_bwp.channel_bandwidth = 40;
|
||||
nr_rach_ConfigCommon.msg1_SubcarrierSpacing = &scs;
|
||||
mac.p_Max = 23;
|
||||
mac.nr_band = 78;
|
||||
mac.frame_type = TDD;
|
||||
mac.frequency_range = FR1;
|
||||
|
||||
init_RA(&mac, &prach_resources, &nr_rach_ConfigCommon, &rach_ConfigGeneric, rach_ConfigDedicated);
|
||||
|
||||
EXPECT_EQ(mac.ra.ra_type, RA_4_STEP);
|
||||
EXPECT_EQ(mac.state, UE_PERFORMING_RA);
|
||||
EXPECT_EQ(mac.ra.RA_active, true);
|
||||
EXPECT_EQ(mac.ra.cfra, 0);
|
||||
}
|
||||
|
||||
TEST(test_init_ra, four_step_cfra)
|
||||
{
|
||||
NR_UE_MAC_INST_t mac = {0};
|
||||
NR_PRACH_RESOURCES_t prach_resources = {0};
|
||||
NR_RACH_ConfigCommon_t nr_rach_ConfigCommon = {0};
|
||||
NR_RACH_ConfigGeneric_t rach_ConfigGeneric = {0};
|
||||
NR_UE_UL_BWP_t current_bwp;
|
||||
mac.current_UL_BWP = ¤t_bwp;
|
||||
long scs = 1;
|
||||
current_bwp.scs = scs;
|
||||
current_bwp.channel_bandwidth = 40;
|
||||
nr_rach_ConfigCommon.msg1_SubcarrierSpacing = &scs;
|
||||
mac.p_Max = 23;
|
||||
mac.nr_band = 78;
|
||||
mac.frame_type = TDD;
|
||||
mac.frequency_range = FR1;
|
||||
|
||||
NR_RACH_ConfigDedicated_t rach_ConfigDedicated = {0};
|
||||
struct NR_CFRA cfra;
|
||||
rach_ConfigDedicated.cfra = &cfra;
|
||||
|
||||
init_RA(&mac, &prach_resources, &nr_rach_ConfigCommon, &rach_ConfigGeneric, &rach_ConfigDedicated);
|
||||
|
||||
EXPECT_EQ(mac.ra.ra_type, RA_4_STEP);
|
||||
EXPECT_EQ(mac.state, UE_PERFORMING_RA);
|
||||
EXPECT_EQ(mac.ra.RA_active, true);
|
||||
EXPECT_EQ(mac.ra.cfra, 1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
logInit();
|
||||
uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY);
|
||||
g_log->log_component[MAC].level = OAILOG_DEBUG;
|
||||
g_log->log_component[NR_MAC].level = OAILOG_DEBUG;
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user