blob: 792c9e731eed52a445c64fc41f53d364e18f267a [file] [log] [blame]
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2018
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* mcf_ut.c
*
* Project:
* --------
* UMOLYA
*
* Description:
* ------------
* MD Configuration Framework unit test implementation.
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#include "kal_public_api.h"
#include "sys_test.h"
#include "fs_general_api.h"
#include <direct.h>
#include "syscomp_config.h"
#include "em_msgid.h"
#include "em_l4_common_public_struct.h"
#include "em_mcf_public_struct.h"
#include "em_struct.h"
#include "nvram_interface.h"
#include "nvram_group_def.h"
#include "mcf_nvram_editor.h"
#include "mcf_if.h"
#include "mcf_util.h"
#include "mcf_defs.h"
#include "mcf_object.h"
#include "mcf_debug.h"
#include "mcf_utfwk.h"
/*------------------------------------------------------------------------------
* Constant definition.
*----------------------------------------------------------------------------*/
#define MCF_FS_DUMMY_AP_FILE_PATH "/nvdata/mdota"
#define MCF_TEST_OTA_LID_BASE_GID 5059
#define MCF_TEST_OTA_QUERY_LID_BASE_GID 5188
/*------------------------------------------------------------------------------
* Private Helper macros.
*----------------------------------------------------------------------------*/
#define MCF_UT_FAKE_PRINT 2
#if MCF_UT_FAKE_PRINT == 1
extern int fake_print(const char *fmt, ...);
#define _mcf_ut_printf fake_print
#elif MCF_UT_FAKE_PRINT == 2
#define _mcf_ut_printf printf
#else
#define _mcf_ut_printf(...)
#endif
#define mcf_ut_printf(_fmts, ...) \
_mcf_ut_printf("%s(): " _fmts, __FUNCTION__, ##__VA_ARGS__)
#define mcf_ut_format_err_str(_fmts, ...) \
kal_sprintf(p_ret_err_str, "%s():%d: " _fmts, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
mcf_ut_printf("[FAILED] %s():%d: " _fmts, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define MCF_UT_PASS() mcf_ut_printf("PASSED\n")
/*------------------------------------------------------------------------------
* Global variables.
*----------------------------------------------------------------------------*/
extern nvram_mcf_lid_info_struct mcf_last_mod_lid_g;
extern nvram_mcf_lid_info_struct mcf_curr_mod_lid_g;
extern nvram_mcf_lid_info_struct mcf_tlvota_last_mod_lid_g[MAX_SIM_NUM];
extern nvram_mcf_lid_info_struct mcf_tlvota_curr_mod_lid_g[MAX_SIM_NUM];
extern nvram_mcf_lid_info_struct mcf_general_tlvota_last_mod_lid_g[MAX_SIM_NUM];
extern nvram_mcf_lid_info_struct mcf_general_tlvota_curr_mod_lid_g[MAX_SIM_NUM];
extern kal_bool is_read_tlvota[MAX_SIM_NUM];
extern kal_bool is_read_general_tlvota[MAX_SIM_NUM];
extern nvram_ef_mcf_internal_info_struct nv_int_info;
#ifdef __MCF_COMBINE_FILE_SUPPORT__
extern kal_uint8 mcf_merge_buffer[MCF_MAX_TLVOTA_FILE_SIZE];
kal_uint8 mcf_file_buffer[MCF_MAX_TLVOTA_FILE_SIZE];
#endif
/*------------------------------------------------------------------------------
* Private variables.
*----------------------------------------------------------------------------*/
static nvram_ef_mcf_test_struct mcf_utfwk_lid_buffer;
/* OTA test LID value pattern */
static const nvram_ef_mcf_test_struct mcf_ut_test_lid_value_pattern = {
6, // val_byte_11
6, // val_byte_12
0x6, // val_bit_byte_11
0xf0, // val_bit_byte_12
6, // val_short_11
6, // val_short_12
6, // val_int_1
6, // val_float_1
6, // val_long_1
6.6, // val_double_1
"MCF Test 66", // val_buffer_1
{6, 6, 0x6, 0xf0, 6, 6, 6, 6, 6, 6.6, "MCF Test 66"}, // val_struct_1
6, // val_byte_21
6, // val_byte_22
0x6, // val_bit_byte_21
0xf0, // val_bit_byte_22
6, // val_short_21
6, // val_short_22
6, // val_int_2
6, // val_float_2
6, // val_long_2
6.6, // val_double_2
"MCF Test 66", // val_buffer_2
{6, 6, 0x6, 0xf0, 6, 6, 6, 6, 6, 6.6, "MCF Test 66"}, // val_struct_2
{{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}, // val_struct_3[0]
{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}, // val_struct_3[1]
{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}, // val_struct_3[2]
{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}} // val_struct_3[3]
};
/* OTA test LID value pattern */
static nvram_ef_mcf_test_struct mcf_ut_test_lid_value_new_pattern = {
0, // val_byte_11
0, // val_byte_12
0x0, // val_bit_byte_11
0x0, // val_bit_byte_12
0, // val_short_11
0, // val_short_12
0, // val_int_1
0, // val_float_1
0, // val_long_1
0, // val_double_1
"", // val_buffer_1
{0, 0, 0x0, 0x0, 0, 0, 0, 0, 0, 0, "", {"MCF"}, {1,2,3}}, // val_struct_1
0, // val_byte_21
0, // val_byte_22
0x0, // val_bit_byte_21
0x0, // val_bit_byte_22
0, // val_short_21
0, // val_short_22
0, // val_int_2
0, // val_float_2
0, // val_long_2
0, // val_double_2
"", // val_buffer_2
{0, 0, 0x0, 0x0, 0, 0, 0, 0, 0, 0, "", {"MCF"}, {1,2,3}}, // val_struct_2
{{0, 0, 0x0, 0x0, 0, 0, 0, 0, 0, 0, "", {"MCF"}, {1,2,3}}, // val_struct_3[0]
{0, 0, 0x0, 0x0, 0, 0, 0, 0, 0, 0, "", {"MCF"}, {1,2,3}}, // val_struct_3[1]
{0, 0, 0x0, 0x0, 0, 0, 0, 0, 0, 0, "", {"MCF"}, {1,2,3}}, // val_struct_3[2]
{0, 0, 0x0, 0x0, 0, 0, 0, 0, 0, 0, "", {"MCF"}, {1,2,3}}}, // val_struct_3[3]
0xFFFF,
0xFFFFFFFF,
0xFF,
0xFF,
0xFFFF,
0xFFFFFFFF
};
/*------------------------------------------------------------------------------
* Private fucntions.
*----------------------------------------------------------------------------*/
extern kal_char* release_verno(void);
extern kal_char* build_date_time(void);
extern sim_interface_enum l4c_gemini_get_actual_sim_id(sim_interface_enum simId);
extern kal_bool mcf_set_file_path(l4c_mcf_set_config_req_struct *req);
extern kal_bool mcf_get_applied_file_path(l4c_mcf_get_config_req_struct *req, l4c_mcf_get_config_cnf_struct *resp);
extern kal_bool mcf_em_update_req_hdlr(local_para_struct *local_para_ptr);
extern chmod(const char *_Filename,int _Mode);
void mcf_ut_init(void)
{
mcf_t *pMcf;
mcf_ota_file_t *ota_file;
mcf_tlvota_file_t *tlvota_file;
kal_uint8 *lid_buffer;
kal_uint32 i;
pMcf = mcf_get_instance();
ota_file = &(pMcf->ota_file);
kal_mem_set(pMcf, 0, sizeof(mcf_t));
/* Object init */
MCF_INIT_OBJECT_BEGIN(ota_file, mcf_enhmutex_g);
MCF_INIT_OBJECT_END(ota_file, mcf_enhmutex_g);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_INIT_OBJECT_BEGIN(tlvota_file, mcf_enhmutex_g);
MCF_INIT_OBJECT_END(tlvota_file, mcf_enhmutex_g);
}
tlvota_file = &(pMcf->general_tlvota_file);
MCF_INIT_OBJECT_BEGIN(tlvota_file, mcf_enhmutex_g);
MCF_INIT_OBJECT_END(tlvota_file, mcf_enhmutex_g);
/* Reset NVRAM_EF_MCF_OTA_FILE_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_TLVOTA_FILE_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_tlvota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_TLVOTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TLVOTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_TEST_OTA_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_TEST_OTA_QUERY_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_QUERY_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_QUERY_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_SW_INFO_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
for(i = 0; i < NVRAM_EF_MCF_SW_INFO_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_internal_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_internal_info_struct));
for(i = 0; i < NVRAM_EF_MCF_INTERNAL_INFO_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_INTERNAL_INFO_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
return;
}
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_open_test_data(kal_char *filename, kal_char *data_buff, kal_uint32 size)
{
kal_char test_data_path[512];
kal_char *pos;
FILE *file;
getcwd(test_data_path, sizeof(test_data_path));
pos = strstr(test_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s%c", MCF_UT_DB_FOLDER_PATH, filename, '\0');
file = fopen(test_data_path, "rb");
if(file != NULL)
{
kal_mem_set(data_buff, 0, size);
fread(data_buff, size, 1, file);
fclose(file);
} else {
return KAL_FALSE;
}
return KAL_TRUE;
}
kal_bool mcf_ut_write_test_data(kal_char *filename, kal_char *data_buff)
{
kal_char test_data_path[512];
kal_char *pos;
FILE *file;
getcwd(test_data_path, sizeof(test_data_path));
pos = strstr(test_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s%c", MCF_UT_DB_FOLDER_PATH, filename, '\0');
file = fopen(test_data_path, "w");
if(file != NULL)
{
fwrite(data_buff,1,strlen(data_buff),file);
fclose(file);
} else {
return KAL_FALSE;
}
return KAL_TRUE;
}
static kal_bool mcf_utfwk_dsbp_callback(sbp_reconfig_custom_param_struct *param_ptr)
{
mcf_ota_result_e mcf_ota_result = MCF_OTA_R_SUCCESS;
mcf_tlvota_sbp_tag_t ota_sbp_tag;
ota_sbp_tag.sbp_id = param_ptr->sbp_id;
memcpy(&(ota_sbp_tag.mcc), param_ptr->mcc, MAX_MCC_STR_LEN);
memcpy(&(ota_sbp_tag.mnc), param_ptr->mnc, MAX_MNC_STR_LEN);
mcf_ota_result = mcf_read_tlvota_buffer_sbp_tag(param_ptr->ps_id, ota_sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8*)&mcf_utfwk_lid_buffer, sizeof(mcf_utfwk_lid_buffer));
return KAL_TRUE;
}
#endif
kal_bool mcf_check_dsbp_mode(kal_bool is_ignore_dsbp, sim_interface_enum sim_id)
{
nvram_ef_mcf_internal_info_struct nv_int_info;
kal_bool ret = KAL_TRUE;
/* Read MCF SW information in NVRAM */
if ( !nvram_external_read_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, 1, (kal_uint8 *)&nv_int_info, sizeof(nvram_ef_mcf_internal_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_INTERNAL_INFO_LID);
ret = KAL_FALSE;
return ret;
}
if (nv_int_info.tlvota_is_ignore_dsbp[sim_id] != is_ignore_dsbp) {
ret = KAL_FALSE;
return ret;
}
return ret;
}
kal_bool mcf_ut_check_file_path(
l4c_mcf_set_config_req_struct *req,
kal_bool is_null_ota_path,
kal_bool is_null_tlvota_path,
kal_bool is_dsbp_active_mode)
{
mcf_t *pMcf = mcf_get_instance();
kal_bool ret = KAL_TRUE;
kal_uint8 sim_id = req->ps_id;
switch (req->op)
{
case L4C_MCF_CONFIG_SET_OTA_AND_OPOTA_FILE_PATH:
{
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
ret = mcf_check_dsbp_mode(KAL_FALSE, sim_id);
if ( (ret != KAL_TRUE) || (pMcf->is_ignore_dsbp[sim_id] != KAL_FALSE) ) {
printf("%s():%d: MCF DSBP mode is incorrect!! is_ignore_dsbp(%d)\n", __FUNCTION__, __LINE__, pMcf->is_ignore_dsbp[sim_id]);
ret = KAL_FALSE;
return ret;
}
/* OTA */
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_OTA_FILE_LID);
ret = KAL_FALSE;
return ret;
}
if (is_null_ota_path == KAL_FALSE) {
if ( (strncmp(nv_ota_file.path, MCF_FS_CUSTOM_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ){
ret = KAL_FALSE;
}
} else {
if ( (strcmp(nv_ota_file.path, "") != 0) || (strcmp(nv_ota_file.name, "") != 0) ) {
ret = KAL_FALSE;
}
}
/* TLV-OTA */
if ( !nvram_external_read_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, sim_id + 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_TLVOTA_FILE_LID);
ret = KAL_FALSE;
return ret;
}
if (is_null_tlvota_path == KAL_FALSE) {
if ( (strncmp(nv_tlvota_file.path, MCF_FS_CUSTOM_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ){
ret = KAL_FALSE;
}
} else {
if ( (strcmp(nv_tlvota_file.path, "") != 0) || (strcmp(nv_tlvota_file.name, "") != 0) ) {
ret = KAL_FALSE;
}
}
break;
}
case L4C_MCF_CONFIG_SET_OTA_FILE_PATH:
{
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
ret = mcf_check_dsbp_mode(KAL_FALSE, sim_id);
if ( (ret != KAL_TRUE) || (pMcf->is_ignore_dsbp[sim_id] != KAL_FALSE) ) {
printf("%s():%d: MCF DSBP mode is incorrect!! is_ignore_dsbp(%d)\n", __FUNCTION__, __LINE__, pMcf->is_ignore_dsbp[sim_id]);
ret = KAL_FALSE;
return ret;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_OTA_FILE_LID);
ret = KAL_FALSE;
return ret;
}
if (is_null_ota_path == KAL_FALSE) {
if ( (strncmp(nv_ota_file.path, MCF_FS_CUSTOM_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ){
ret = KAL_FALSE;
}
} else {
if ( (strcmp(nv_ota_file.path, "") != 0) || (strcmp(nv_ota_file.name, "") != 0) ) {
ret = KAL_FALSE;
}
}
break;
}
case L4C_MCF_CONFIG_SET_OPOTA_FILE_PATH:
{
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
ret = mcf_check_dsbp_mode(KAL_FALSE, sim_id);
if ( (ret != KAL_TRUE) || (pMcf->is_ignore_dsbp[sim_id] != KAL_FALSE) ) {
printf("%s():%d: MCF DSBP mode is incorrect!! is_ignore_dsbp(%d)\n", __FUNCTION__, __LINE__, pMcf->is_ignore_dsbp[sim_id]);
ret = KAL_FALSE;
return ret;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, sim_id + 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_TLVOTA_FILE_LID);
ret = KAL_FALSE;
return ret;
}
if (is_null_tlvota_path == KAL_FALSE) {
if ( (strncmp(nv_tlvota_file.path, MCF_FS_CUSTOM_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ){
ret = KAL_FALSE;
}
} else {
if ( (strcmp(nv_tlvota_file.path, "") != 0) || (strcmp(nv_tlvota_file.name, "") != 0) ) {
ret = KAL_FALSE;
}
}
break;
}
case L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE:
{
ret = mcf_check_dsbp_mode(KAL_TRUE, sim_id);
if ( (ret != KAL_TRUE) || (pMcf->is_ignore_dsbp[sim_id] != KAL_TRUE) ) {
printf("%s():%d: MCF DSBP mode is incorrect!! is_ignore_dsbp(%d)\n", __FUNCTION__, __LINE__, pMcf->is_ignore_dsbp[sim_id]);
ret = KAL_FALSE;
return ret;
}
switch (req->config_type)
{
case L4C_MCF_CONFIG_TYPE_DEFAULT_BIN:
{
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_OTA_FILE_LID);
ret = KAL_FALSE;
return ret;
}
if (is_null_ota_path == KAL_FALSE) {
if (req->path_type == L4C_MCF_PATH_TYPE_OTA) {
if ( (strncmp(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ) {
ret = KAL_FALSE;
}
} else if (req->path_type == L4C_MCF_PATH_TYPE_RUNTIME) {
if ( (strncmp(nv_ota_file.path, MCF_FS_CUSTOM_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ) {
ret = KAL_FALSE;
}
}
} else {
if ( (strncmp(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ){
ret = KAL_FALSE;
}
}
break;
}
case L4C_MCF_CONFIG_TYPE_CARRIER_BIN:
{
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
if ( !nvram_external_read_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, sim_id + 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct))) {
printf("%s():%d: Fail to read LID(%d)\n", __FUNCTION__, __LINE__, NVRAM_EF_MCF_TLVOTA_FILE_LID);
ret = KAL_FALSE;
return ret;
}
if (is_null_tlvota_path == KAL_FALSE) {
if (req->path_type == L4C_MCF_PATH_TYPE_OTA) {
if ( (strncmp(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ){
ret = KAL_FALSE;
}
} else if (req->path_type == L4C_MCF_PATH_TYPE_RUNTIME) {
if ( (strncmp(nv_tlvota_file.path, MCF_FS_CUSTOM_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN) != 0)
|| (strncmp(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN) != 0) ) {
ret = KAL_FALSE;
}
}
} else {
if ( (strcmp(nv_tlvota_file.path, "") != 0) || (strcmp(nv_tlvota_file.name, "") != 0) ) {
ret = KAL_FALSE;
}
}
break;
}
default:
printf("%s():%d: Invalid config type(%d)\n", __FUNCTION__, __LINE__, req->config_type);
ret = KAL_FALSE;
break;
}
break;
}
default:
ret = KAL_FALSE;
break;
}
return ret;
}
kal_bool mcf_check_test_lid_value(kal_uint8 *target_buff)
{
kal_bool ret = KAL_TRUE;
kal_uint8 *lid_buffer;
if (target_buff) {
if ( kal_mem_cmp(target_buff, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
}
} else {
/*
* NVRAM_EF_MCF_TEST_OTA_LID record 1
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if ( kal_mem_cmp(lid_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
if (ret == KAL_FALSE) {
return ret;
}
/*
* NVRAM_EF_MCF_TEST_OTA_LID record 2
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 2, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if ( kal_mem_cmp(lid_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
if (ret == KAL_FALSE) {
return ret;
}
}
return ret;
}
/*------------------------------------------------------------------------------
* Test case functions.
*----------------------------------------------------------------------------*/
kal_bool mcf_ut_mcf_set_file_path_dsbp_passive_mode(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
l4c_mcf_set_config_req_struct *req;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/*
* Set both OTA and TLV-OTA path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OTA_AND_OPOTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_OTA_FILE_NAME);
strcpy(req->config3, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config4, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set both OTA/TLV-OTA file paths positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_FALSE, KAL_FALSE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set both OTA/TLV-OTA file paths positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set both OTA and TLV-OTA path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OTA_AND_OPOTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_OTA_FILE_NAME);
strcpy(req->config3, "");
strcpy(req->config4, "");
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set one of OTA/TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_TRUE, KAL_FALSE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set one of OTA/TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set both OTA and TLV-OTA path negative test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OTA_AND_OPOTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_OTA_FILE_NAME);
strcpy(req->config3, "");
strcpy(req->config4, "");
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set one of OTA/TLV-OTA file path negative test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_FALSE, KAL_FALSE);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check set one of OTA/TLV-OTA file path negative test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set OTA path positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_OTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_TRUE, KAL_FALSE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Delete OTA path positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OTA_FILE_PATH;
strcpy(req->config1, "");
strcpy(req->config2, "");
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Delete OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_FALSE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check delete OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set OTA path negative test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path negative test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_TRUE, KAL_FALSE);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check set OTA file path negative test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set TLV-OTA path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OPOTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_FALSE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Delete TLV-OTA path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OPOTA_FILE_PATH;
strcpy(req->config1, "");
strcpy(req->config2, "");
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Delete TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_TRUE, KAL_FALSE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check delete TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path negative test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_OPOTA_FILE_PATH;
strcpy(req->config1, MCF_FS_DUMMY_AP_FILE_PATH);
strcpy(req->config2, MCF_FS_DEFAULT_OTA_FILE_NAME);
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path negative test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_FALSE, KAL_FALSE);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check set TLV-OTA file path negative test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_mcf_set_file_path_dsbp_active_mode(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file;
mcf_tlvota_file_t *tlvota_file;
mcf_tool_file_info_t *pFile;
l4c_mcf_set_config_req_struct *req;
sim_interface_enum sim_id;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
ota_file = &(pMcf->ota_file);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
pFile = (mcf_tool_file_info_t *)(ota_file->buff);
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("set file path FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
for(i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}else {
mcf_ut_format_err_str("set file path FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
/*
* Set OTA path in default path positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, MCF_FS_DEFAULT_OTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path in default path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set OTA file path in default path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set OTA path in default path with NULL file name positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, "");
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path in default path with NULL file name positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set OTA file path in default path with NULL file name positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set OTA path in runtime path positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(req->config1, MCF_FS_DEFAULT_OTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path in runtime path positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_FALSE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set OTA file path in runtime path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set OTA path in default path with NULL file name positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, "");
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path in default path with NULL file name positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set OTA file path in default path with NULL file name positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set OTA path in runtime path with NULL file name positive test
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(req->config1, "");
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set OTA file path in runtime path with NULL file name positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set OTA file path in runtime path with NULL file name positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set TLV-OTA path in default path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in default path with NULL file name (deactivate OTA by OP) positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, "");
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path with NULL file name (deactivate OTA by OP) positive test FAIL!!\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path with NULL file name (deactivate OTA by OP) positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in runtime path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in runtime path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in runtime path positive test FAIL\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in runtime path with NULL file name (deactivate OTA by OP) positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(req->config1, "");
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in runtime path with NULL file name (deactivate OTA by OP) positive test FAIL!!\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in runtime path with NULL file name (deactivate OTA by OP) positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in default path positive test - file is not changed
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
// First send file path
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
// Send same file path
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_FILE_NOT_CHANGE) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in runtime path positive test - file is not changed
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
// First send file path
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
// Send same file path
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_FILE_NOT_CHANGE) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in default path positive test - set file path after deactivated
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, "");
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
// First send file path
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
// Send same file path
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set TLV-OTA path in runtime path positive test - set file path after deactivated
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(req->config1, "");
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
// First send file path
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_TRUE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
// Send same file path
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile->file_version = 2;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Set TLV-OTA path fail! Fail to take write lock! \r\n");
return KAL_FALSE;
}
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
/* Assume DSBP success */
pMcf->is_dsbp_ongoing[sim_id] = KAL_FALSE;
kal_mem_cpy(&(tlvota_file->last_file), &(tlvota_file->temp_file), sizeof(mcf_file_info_t));
ret = mcf_ut_check_file_path(req, KAL_TRUE, KAL_FALSE, KAL_TRUE);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check set TLV-OTA file path in default path positive test FAIL\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
/*
* Set OTA path in default path negative test - invalid config type
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_MAX;
req->path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(req->config1, MCF_FS_DEFAULT_OTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Check set OTA path in default path negative test (invalid config type) FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set OTA path negative test - invalid path type
*/
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
req->path_type = L4C_MCF_PATH_TYPE_MAX;
strcpy(req->config1, MCF_FS_DEFAULT_OTA_FILE_NAME);
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Check set OTA path negative test (invalid path type) FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
/*
* Set TLV-OTA path negative test - invalid path type
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_SET_FILE_PATH_IN_MCF_DSBP_ACTIVE_MODE;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->path_type = L4C_MCF_PATH_TYPE_MAX;
strcpy(req->config1, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
req->ps_id = i;
mcf_ret = mcf_set_file_path(req);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Set TLV-OTA file path in runtime path with NULL file name (deactivate OTA by OP) positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_mcf_get_applied_file_path(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
l4c_mcf_get_config_req_struct *req;
l4c_mcf_get_config_cnf_struct *resp;
sim_interface_enum sim_id;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
mcf_ut_init();
pMcf->ota_file.path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(pMcf->ota_file.relative_path_name, MCF_FS_DEFAULT_OTA_FILE_NAME);
for(i = 0; i < MAX_SIM_NUM; i++) {
pMcf->tlvota_file[i].path_type = L4C_MCF_PATH_TYPE_OTA;
strcpy(pMcf->tlvota_file[i].relative_path_name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME);
}
/*
* Get applied OTA file path positive test
*/
req = (l4c_mcf_get_config_req_struct *)construct_local_para(sizeof(l4c_mcf_get_config_req_struct), TD_RESET);
resp = (l4c_mcf_get_config_cnf_struct *)construct_local_para(sizeof(l4c_mcf_get_config_cnf_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_GET_APPLIED_FILE_PATH;
req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
mcf_ret = mcf_get_applied_file_path(req, resp);
if ( (mcf_ret != MCF_OTA_R_SUCCESS) || (resp->config_type != req->config_type)
|| (resp->path_type != pMcf->ota_file.path_type)
|| (strcmp(resp->config1, pMcf->ota_file.relative_path_name) != 0) ) {
mcf_ut_format_err_str("Get applied OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)resp);
/*
* Get applied TLV-OTA file path positive test
*/
for(i = 0; i < MAX_SIM_NUM; i++) {
req = (l4c_mcf_get_config_req_struct *)construct_local_para(sizeof(l4c_mcf_get_config_req_struct), TD_RESET);
resp = (l4c_mcf_get_config_cnf_struct *)construct_local_para(sizeof(l4c_mcf_get_config_cnf_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_GET_APPLIED_FILE_PATH;
req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
req->ps_id = i;
sim_id = l4c_gemini_get_actual_sim_id(req->ps_id);
mcf_ret = mcf_get_applied_file_path(req, resp);
if ( (mcf_ret != MCF_OTA_R_SUCCESS) || (resp->config_type != req->config_type)
|| (resp->path_type != pMcf->tlvota_file[sim_id].path_type)
|| (strcmp(resp->config1, pMcf->tlvota_file[sim_id].relative_path_name) != 0) ) {
mcf_ut_format_err_str("Get applied TLV-OTA file path positive test FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)resp);
}
/*
* Get applied file path negative test - invalid config type
*/
req = (l4c_mcf_get_config_req_struct *)construct_local_para(sizeof(l4c_mcf_get_config_req_struct), TD_RESET);
resp = (l4c_mcf_get_config_cnf_struct *)construct_local_para(sizeof(l4c_mcf_get_config_cnf_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_GET_APPLIED_FILE_PATH;
req->config_type = L4C_MCF_CONFIG_TYPE_MAX;
mcf_ret = mcf_get_applied_file_path(req, resp);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Get applied OTA file path negative test (invalid config type) FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)resp);
MCF_UT_PASS();
return KAL_TRUE;
}
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_do_ota_full(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
kal_uint8 *lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_ota_result_e mcf_ret;
kal_bool ret;
kal_uint32 i;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - Both SW verno of file and MD mismatch
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - SW verno of file mismatch
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset updated file information in NVRAM */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno of file mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - SW verno of MD mismatch
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset updated MD SW version in NVRAM */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno of MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - SW verno match
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
mcf_ret = mcf_do_ota_full();
if ( (mcf_ret != MCF_OTA_R_SUCCESS) || ((com_Mcf.boot_trace_flag & MCF_BOOT_TRACE_F_NO_NEED) == 0) ) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if (kal_mem_cmp(lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno match) FAIL!!\r\n");
return KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
/*
* Do full OTA negative test - invlaid file type
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
strncpy(pFile->file_type, "MCF", 8);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if ( (mcf_ret != MCF_OTA_R_INVALID_FILE) || ((com_Mcf.boot_trace_flag & MCF_BOOT_TRACE_F_INVALID_FILE) == 0) ) {
mcf_ut_format_err_str("full OTA: invalid file type case FAIL!! ret(%d), boot_flag(%x) \r\n", mcf_ret, com_Mcf.boot_trace_flag);
return KAL_FALSE;
}
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if (kal_mem_cmp(lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno match) FAIL!!\r\n");
return KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
/*
* Do full OTA positive test - item with mismatched verno in file
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_mismatched_verno.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_mismatched_verno.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (item with mismatched verno in file) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - File with checksum
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_checksum_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_checksum_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (File with checksum) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - File with checksum and encryption
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_checksum_and_encryption_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_checksum_and_encryption_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (File with checksum) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_do_ota_by_lid(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_ota_file_item_t *pItem;
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
kal_uint8 *lid_buffer;
kal_uint32 i;
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
nvram_ltable_entry_struct lid_info;
nvram_errno_enum nvram_api_ret;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
pFile = (mcf_tool_file_info_t *)(ota_file->buff);
pItem = (mcf_tool_ota_file_item_t *)(ota_file->buff + sizeof(mcf_tool_file_info_t));
/*
* Do OTA by LID positive test
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
mcf_ut_format_err_str("Fail to get LID information!! lid(%d), nvram_ret(%d)\r\n", NVRAM_EF_MCF_TEST_OTA_LID, nvram_api_ret);
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do OTA by LID negative test - invalid OTA attribute
*/
lid_info.attr &= ~NVRAM_ATTR_MCF_OTA;
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_INVALID_ATTR) {
mcf_ut_format_err_str("OTA by LID: invalid OTA attribute case FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
/*
* Do OTA by LID negative test - invlaid file type
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
strncpy(pFile->file_type, "MCF", 8);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_INVALID_FILE) {
mcf_ut_format_err_str("OTA by LID: invlaid file type case FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
/*
* Do OTA by LID positive test - item with mismatched verno in file
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
mcf_ut_format_err_str("Fail to get LID information!! lid(%d), nvram_ret(%d)", NVRAM_EF_MCF_TEST_OTA_LID, nvram_api_ret);
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_mismatched_verno.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_mismatched_verno.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do OTA by LID positive test (item with mismatched verno in file) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_read_ota_buffer(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_ota_file_item_t *pItem;
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
nvram_ef_mcf_test_struct test_lid_buffer;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
pFile = (mcf_tool_file_info_t *)(ota_file->buff);
pItem = (mcf_tool_ota_file_item_t *)(ota_file->buff + sizeof(mcf_tool_file_info_t));
/*
* Read OTA LID positive test
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// Record index 1
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
// Record index 2
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 2, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read OTA by LID positive test - item with mismatched verno in file
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_mismatched_verno.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_mismatched_verno.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test (item with mismatched verno in file) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_read_tlvota_buffer(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
nvram_ef_mcf_test_struct test_lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_tlvota_tag_t tlvota_tag;
kal_char tag[16];
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - fully matched tag
*/
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_ICCID_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_ICCID_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, SBP_PARTIAL_TAG);
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (fully matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches tag (12_NA_NA_TEST)
*/
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, "12_NA_NA_TEST");
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches tag (12_NA)
*/
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, "12_NA");
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - item with mismatched verno in file
*/
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, SBP_PARTIAL_TAG);
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
tlvota_file = &(pMcf->general_tlvota_file);
pItem = (mcf_tool_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_ICCID_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_ICCID_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag negative test (item with mismatched verno in file) FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (fully matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_read_tlvota_buffer_sbp(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
nvram_ef_mcf_test_struct test_lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
/* Fill TLV-OTA file into buffer */
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (NA_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - fully matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_FULL_TAG (12_33_21), and user searches SBP_FULL_TAG (12_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (fully matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_FULL_TAG (12_33_21), and user searches SBP_FULL_TAG (12_33_NA)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "", MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG_NO_SBPID (NA_33_21), and user searches SBP_FULL_TAG (12_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_no_sbpid_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_no_sbpid_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_FULL_TAG (12_33_21), and user searches SBP_FULL_TAG (12_NA_NA)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, "", MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "", MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG_NO_SBPID (NA_33_21), and user searches SBP_PARTIAL_TAG_NO_SBPID (NA_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_no_sbpid_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_no_sbpid_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_ID_INVALID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MCC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - item with mismatched verno in file
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_mismatched_verno.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_mismatched_verno.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MCC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag negative test (item with mismatched verno in file) FAIL!!\r\n");
return KAL_FALSE;
}
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_reset_lid_full(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_ota_result_e mcf_ret;
kal_bool ret;
nvram_ef_mcf_test_struct test_lid_buffer;
kal_uint8 *lid_buffer;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Reset all LID positive
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if (kal_mem_cmp(lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Reset LID record 1 FAIL!!\r\n");
return KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID New OTA apply FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Reset all LID negative
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
pFile->operation_mask |= MCF_FILE_OP_NOT_RESET_LID;
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
pFile->operation_mask |= MCF_FILE_OP_NOT_RESET_LID;
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID New OTA apply FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID New OTA apply FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_gid_do_ota_full(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
kal_uint8 *lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_ota_result_e mcf_ret;
kal_bool ret;
kal_uint32 i;
nvram_ef_mcf_test_struct nv_lid_buffer;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - Both SW verno of file and MD mismatch
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - SW verno of file mismatch
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset updated file information in NVRAM */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno of file mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - SW verno of MD mismatch
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset updated MD SW version in NVRAM */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno of MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - SW verno match
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
mcf_ret = mcf_do_ota_full();
if ( (mcf_ret != MCF_OTA_R_SUCCESS) || ((com_Mcf.boot_trace_flag & MCF_BOOT_TRACE_F_NO_NEED) == 0) ) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if (kal_mem_cmp(lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno match) FAIL!!\r\n");
return KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
/*
* Do full OTA negative test - invlaid file type
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
strncpy(pFile->file_type, "MCF", 8);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if ( (mcf_ret != MCF_OTA_R_INVALID_FILE) || ((com_Mcf.boot_trace_flag & MCF_BOOT_TRACE_F_INVALID_FILE) == 0) ) {
mcf_ut_format_err_str("full OTA: invalid file type case FAIL!! ret(%d), boot_flag(%x) \r\n", mcf_ret, com_Mcf.boot_trace_flag);
return KAL_FALSE;
}
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if (kal_mem_cmp(lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Do full OTA positive test (SW verno match) FAIL!!\r\n");
return KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
/*
* Do full OTA positive test - 3-Dimension array
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_3d_array_and_bit_byte_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_3d_array_and_bit_byte_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, (kal_uint8 *)&nv_lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if ( kal_mem_cmp((kal_uint8 *)&nv_lid_buffer, &mcf_ut_test_lid_value_new_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
printf("Do full OTA positive test (SW verno match) FAIL!!\r\n");
}
if (ret == KAL_FALSE) {
return ret;
}
/*
* Do full OTA positive test - File with checksum
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_checksum_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_checksum_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (File with checksum) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do full OTA positive test - File with checksum and encryption
*/
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
}
free_ctrl_buffer_set_null(lid_buffer);
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
}
}
free_ctrl_buffer_set_null(lid_buffer);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_checksum_and_encryption_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_checksum_and_encryption_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (File with checksum) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_gid_do_ota_by_lid(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_ota_file_item_t *pItem;
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
nvram_ltable_entry_struct lid_info;
nvram_errno_enum nvram_api_ret;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
pFile = (mcf_tool_file_info_t *)(ota_file->buff);
pItem = (mcf_tool_gid_ota_file_item_t *)(ota_file->buff + sizeof(mcf_tool_file_info_t));
/*
* Do OTA by LID positive test
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
mcf_ut_format_err_str("Fail to get LID information!! lid(%d), nvram_ret(%d)\r\n", NVRAM_EF_MCF_TEST_OTA_LID, nvram_api_ret);
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Do OTA by LID negative test - invalid OTA attribute
*/
lid_info.attr &= ~NVRAM_ATTR_MCF_OTA;
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_INVALID_ATTR) {
mcf_ut_format_err_str("OTA by LID: invalid OTA attribute case FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
/*
* Do OTA by LID negative test - invlaid file type
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
strncpy(pFile->file_type, "MCF", 8);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_by_lid(NVRAM_EF_MCF_TEST_OTA_LID, 1, NVRAM_EF_MCF_TEST_OTA_TOTAL, &lid_info);
if (mcf_ret != MCF_OTA_R_INVALID_FILE) {
mcf_ut_format_err_str("OTA by LID: invlaid file type case FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_gid_read_ota_buffer(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_ota_file_item_t *pItem;
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
nvram_ef_mcf_test_struct test_lid_buffer;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
pFile = (mcf_tool_file_info_t *)(ota_file->buff);
pItem = (mcf_tool_gid_ota_file_item_t *)(ota_file->buff + sizeof(mcf_tool_file_info_t));
/*
* Read OTA LID positive test
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// Record index 1
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
// Record index 2
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 2, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_gid_read_tlvota_buffer(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
nvram_ef_mcf_test_struct test_lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_tlvota_tag_t tlvota_tag;
kal_char tag[16];
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - fully matched tag
*/
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_ICCID_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_ICCID_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, SBP_PARTIAL_TAG);
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (fully matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches tag (12_NA_NA_TEST)
*/
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, "12_NA_NA_TEST");
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches tag (12_NA)
*/
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, "12_NA");
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & tag positive test - item with mismatched verno in file
*/
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(&tlvota_tag, 0, sizeof(mcf_tlvota_tag_t));
tlvota_tag.tag_type = MCF_TLVOTA_TAG_ICCID;
strcpy(tag, SBP_PARTIAL_TAG);
tlvota_tag.tag_len = strlen(tag);
tlvota_tag.tag = tag;
tlvota_file = &(pMcf->general_tlvota_file);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_ICCID_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_ICCID_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_read_tlvota_buffer(0, tlvota_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag negative test (item with mismatched verno in file) FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & tag positive test (fully matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_gid_read_tlvota_buffer_sbp(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
nvram_ef_mcf_test_struct test_lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
/* Fill TLV-OTA file into buffer */
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (NA_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - fully matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_FULL_TAG (12_33_21), and user searches SBP_FULL_TAG (12_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (fully matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_FULL_TAG (12_33_21), and user searches SBP_FULL_TAG (12_33_NA)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "", MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG_NO_SBPID (NA_33_21), and user searches SBP_FULL_TAG (12_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_no_sbpid_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_no_sbpid_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - no matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_FULL_TAG (12_33_21), and user searches SBP_FULL_TAG (12_NA_NA)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, "", MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "", MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG_NO_SBPID (NA_33_21), and user searches SBP_PARTIAL_TAG_NO_SBPID (NA_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_no_sbpid_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_no_sbpid_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_ID_INVALID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), and user searches SBP_PARTIAL_TAG (12_NA_NA)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_OPOTA_ut_gid_3d_array_bit_byte_SBP_partial.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OPOTA_ut_gid_3d_array_bit_byte_SBP_partial.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, "NA", MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "NA", MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &mcf_ut_test_lid_value_new_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (no matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* General OPOTA INVALID_FILE / OPOTA SUCCESS
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), and user searches SBP_PARTIAL_TAG (12_NA_NA)
*/
tlvota_file = &(pMcf->general_tlvota_file);
kal_mem_set(tlvota_file->buff, 0, MCF_MAX_TLVOTA_FILE_SIZE);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, "NA", MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "NA", MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
/*
* General OPOTA SUCCESS / OPOTA INVALID_FILE
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG_NO_SBPID (NA_33_21), and user searches SBP_FULL_TAG (NA_33_21)
*/
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
kal_mem_set(tlvota_file->buff, 0, MCF_MAX_TLVOTA_FILE_SIZE);
}
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_no_sbpid_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_no_sbpid_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_ID_INVALID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(0, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_gid_reset_lid_full(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_ota_result_e mcf_ret;
kal_bool ret;
nvram_ef_mcf_test_struct test_lid_buffer;
kal_uint8 *lid_buffer;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Reset all LID positive
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if (kal_mem_cmp(lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Reset LID record 1 FAIL!!\r\n");
return KAL_FALSE;
}
free_ctrl_buffer_set_null(lid_buffer);
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID New OTA apply FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Reset all LID negative
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
pFile->operation_mask |= MCF_FILE_OP_NOT_RESET_LID;
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read OTA by LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
pFile->operation_mask |= MCF_FILE_OP_NOT_RESET_LID;
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID New OTA apply FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID New OTA apply FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
kal_bool mcf_ut_em_update_req_hdlr(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
l4cps_em_update_req_struct req;
kal_bool ret;
mcf_ut_init();
/*
* EM update request handler positive test - ON
*/
com_Mcf.is_em_on = KAL_FALSE;
req.em_src = EM_FROM_ELT;
req.info_request[MCF_EM_OTA_FILE_INFO] = EM_ON;
ret = mcf_em_update_req_hdlr((local_para_struct *)&req);
if ( (ret != KAL_TRUE) && (com_Mcf.is_em_on != KAL_TRUE) ) {
mcf_ut_format_err_str("EM update request handler positive test (ON) FAIL!! \r\n");
return KAL_FALSE;
}
/*
* EM update request handler positive test - OFF
*/
com_Mcf.is_em_on = KAL_TRUE;
req.em_src = EM_FROM_ELT;
req.info_request[MCF_EM_OTA_FILE_INFO] = EM_OFF;
ret = mcf_em_update_req_hdlr((local_para_struct *)&req);
if ( (ret != KAL_TRUE) && (com_Mcf.is_em_on != KAL_FALSE) ) {
mcf_ut_format_err_str("EM update request handler positive test (OFF) FAIL!! \r\n");
return KAL_FALSE;
}
/*
* EM update request handler positive test - No change
*/
com_Mcf.is_em_on = KAL_TRUE;
req.em_src = EM_FROM_ELT;
req.info_request[MCF_EM_OTA_FILE_INFO] = EM_NC;
ret = mcf_em_update_req_hdlr((local_para_struct *)&req);
if ( (ret != KAL_TRUE) && (com_Mcf.is_em_on != KAL_TRUE) ) {
mcf_ut_format_err_str("EM update request handler positive test (No change) FAIL!! \r\n");
return KAL_FALSE;
}
/*
* EM update request handler positive test - Invalid operation
*/
com_Mcf.is_em_on = KAL_TRUE;
req.em_src = EM_FROM_ELT;
req.info_request[MCF_EM_OTA_FILE_INFO] = 0xFF;
ret = mcf_em_update_req_hdlr((local_para_struct *)&req);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("EM update request handler positive test (Invalid operation) FAIL!! \r\n");
return KAL_FALSE;
}
/*
* EM update request handler positive test - Invalid EM source
*/
com_Mcf.is_em_on = KAL_TRUE;
req.em_src = EM_FROM_RMMI;
req.info_request[MCF_EM_OTA_FILE_INFO] = EM_OFF;
ret = mcf_em_update_req_hdlr((local_para_struct *)&req);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("EM update request handler positive test (Invalid EM source) FAIL!! \r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
#if defined(__MCF_FIND_TAG_SUPPORT__)
kal_bool mcf_ut_find_tag(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
kal_uint16 byte_offset, bit_offset;
kal_uint32 size;
mcf_tag_info_struct unuse;
MCF_DB_STRUCT_VARIABLE const *unuse_db_ptr = NULL;
kal_char tag[64];
// INT
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BYTE_11");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 0 || bit_offset != 0 || size != 1)
return KAL_FALSE;
// BIT
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BIT_BYTE_11.B1");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BIT_BYTE_11.B4");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2 || bit_offset != 3 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BIT_BYTE_12.F4B");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 3 || bit_offset != 0 || size != 4)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BIT_BYTE_12.L4B");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 3 || bit_offset != 4 || size != 4)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_DOUBLE_1");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 24 || bit_offset != 0 || size != 8)
return KAL_FALSE;
// array
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BUFFER_1");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 32 || bit_offset != 0 || size != 32)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BUFFER_1[0]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 32 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_BUFFER_1[10]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 42 || bit_offset != 0 || size != 1)
return KAL_FALSE;
// struct
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_1.VBYTE1");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 64 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_1.VDOUBLE");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 88 || bit_offset != 0 || size != 8)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_1.VBUFFER");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 96 || bit_offset != 0 || size != 32)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_1.VBUFFER[31]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 127 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[0].VBUFFER[0]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 896 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3.VBUFFER[0]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 896 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[0].VBUFFER");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 896 || bit_offset != 0 || size != 32)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[3].VBUFFER[0]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2000 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[3].VBUFFER[3]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2003 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[0].ARRAY_D[0][0][0]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 928 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[0].ARRAY_D[4][3][2]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 987 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[3].ARRAY_D[0][0][0]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2032 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[3].ARRAY_D[4][3][2]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2091 || bit_offset != 0 || size != 1)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[3].ARRAY_D4[0][0][2]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2100 || bit_offset != 0 || size != 4)
return KAL_FALSE;
kal_mem_set(tag, 0, 64);
strcpy(tag, "VAL_STRUCT_3[3].ARRAY_D4[4][3][2]");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_TRUE || byte_offset != 2328 || bit_offset != 0 || size != 4)
return KAL_FALSE;
// can not find tag
kal_mem_set(tag, 0, 64);
strcpy(tag, "XXX");
ret = mcf_find_tag_offset(4098, tag, &byte_offset, &bit_offset, &size, &unuse_db_ptr, &unuse);
if(ret != KAL_FALSE)
return KAL_FALSE;
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if defined(__MCF_FIND_GID_SUPPORT__)
kal_bool mcf_ut_find_gid(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret = KAL_FALSE;
kal_uint16 lid_num;
kal_uint16 byte_offset;
kal_int16 bit_offset;
kal_uint32 size;
kal_bool is_bit;
// val_byte_11
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 44, "", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 0 || bit_offset != -1 || size !=1 || is_bit != KAL_FALSE) return KAL_FALSE;
// val_bit_2byte_3.F2b
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 1, "", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 2336 || bit_offset != 8 || size != 2 || is_bit != KAL_TRUE) return KAL_FALSE;
// val_buffer_2[]
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 43, "0$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 464 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 43, "1$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 465 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 43, "31$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 495 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
//val_struct_3[x].array_d[x][x][x]
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 106, "0$0$0$0$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 928 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 106, "0$4$3$2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 987 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 106, "2$0$0$0$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 1664 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 106, "3$4$3$2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 2091 || bit_offset != -1 && size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
// val_struct_3[x].vbit_byte1.b8
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 116, "2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 1602 || bit_offset != 7 || size != 1 || is_bit != KAL_TRUE) return KAL_FALSE;
// val_struct_3[x].vbit_byte2.F4b
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 118, "2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 1603 || bit_offset != 0 || size != 4 || is_bit != KAL_TRUE) return KAL_FALSE;
// val_struct_3[x].vbit_byte2.L4b
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 119, "2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 1603 || bit_offset != 4 || size != 4 || is_bit != KAL_TRUE) return KAL_FALSE;
// val_struct_1.vbuffer[]
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 74, "0$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 96 || bit_offset != -1 || size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 74, "31$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 127 || bit_offset != -1 || size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
// val_struct_1.array_d4[][][]
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 61, "0$0$0$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 188 || bit_offset != -1 || size != 4 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 61, "4$3$2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 424 || bit_offset != -1 || size != 4 || is_bit != KAL_FALSE) return KAL_FALSE;
// val_struct_1.array_d[][][]
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 60, "0$0$0$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 128 || bit_offset != -1 || size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
ret = mcf_find_gid_offset(MCF_TEST_OTA_LID_BASE_GID + 60, "4$3$2$", &lid_num, &byte_offset, &bit_offset, &size, &is_bit);
if(ret!= KAL_TRUE || lid_num != 4098 || byte_offset != 187 || bit_offset != -1 || size != 1 || is_bit != KAL_FALSE) return KAL_FALSE;
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
kal_bool mcf_ut_mcf_encrypt_decrypt(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_char password[] = "MTKTEST";
kal_bool ret = KAL_FALSE;
kal_char content[192] = {0};
kal_uint32 content_length = 0;
kal_char test_data[] = "What does it take to change everything? Technology that¡¦s great, not expensive. Technology that helps people change the world on their own terms.";
strcpy(content, test_data);
content_length = (strlen(test_data) + 0xF & ~0xF); // 16B alignment
// CASE1 : AES128 test
ret = mcf_encrypt_128bit(password, content, content_length);
if(ret == KAL_FALSE) return KAL_FALSE;
ret = mcf_decrypt_128bit(password, content, content_length);
if(ret == KAL_FALSE) return KAL_FALSE;
if(strcmp(content, test_data) != 0) return KAL_FALSE;
// CASE2 : AES256 test
ret = mcf_encrypt_256bit(password, content, content_length);
if(ret == KAL_FALSE) return KAL_FALSE;
ret = mcf_decrypt_256bit(password, content, content_length);
if(ret == KAL_FALSE) return KAL_FALSE;
if(strcmp(content, test_data) != 0) return KAL_FALSE;
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_find_ini_item(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ini_file_t *ini_file;
kal_bool ret;
kal_char value[64];
kal_char tag[64];
mcf_ut_init();
ini_file = &(pMcf->ini_file);
//kal_mem_set(&ini_file, 0, sizeof(mcf_ini_file_t));
/*
* Read ini positive test
*/
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "AP_Monitor_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"120") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
//return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "TagName");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"108_466_97,1_460_NA,1_460_02") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "AP_Monitor_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"120") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Gen_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1025.120000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read ini positive test --- don't care uppercase
*/
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "GeN_TIme");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1025.120000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "GEN_TIME");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1025.120000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "gen_time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1025.120000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read ini positive test --- don't care space
*/
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "g e n_ tim e");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1025.120000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "gen _ time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1025.120000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "AP _Monitor_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"120") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Read ini negative test
*/
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Critical");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) == KAL_TRUE) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! \r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Config");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) == KAL_TRUE) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! \r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "GenTime");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) == KAL_TRUE) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! \r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Tag_Name");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) == KAL_TRUE) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! \r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "108");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) == KAL_TRUE) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! \r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "0000");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) == KAL_TRUE) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! \r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_find_ini_sbp_id(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_uint32 sbp_id[200];
kal_uint16 sbp_id_num = 0;
kal_uint16 i = 0;
kal_uint32 sbp_id_ans[5]={108,1};
kal_bool general = KAL_FALSE;
kal_char tag[64];
mcf_ut_init();
/*
* Read ini positive test
*/
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_466_97,1_460_NA,1_460_02");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
for (i = 0; i < sbp_id_num; i++){
if (sbp_id[i] != sbp_id_ans[i]){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! sbp id(%d) sbp id ans(%d) \r\n", sbp_id[i], sbp_id_ans[i]);
return KAL_FALSE;
}
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_466_97,1_460_NA,1_460_02,1_450_01,1_10_1");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
for (i = 0; i < sbp_id_num; i++){
if (sbp_id[i] != sbp_id_ans[i]){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! sbp id(%d) sbp id ans(%d) \r\n", sbp_id[i], sbp_id_ans[i]);
return KAL_FALSE;
}
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_470_97,108_466_97,1_460_NA,1_460_02");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
for (i = 0; i < sbp_id_num; i++){
if (sbp_id[i] != sbp_id_ans[i]){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! sbp id(%d) sbp id ans(%d) \r\n", sbp_id[i], sbp_id_ans[i]);
return KAL_FALSE;
}
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_470_97,108_466_97,1_460_NA,1_460_02,");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
for (i = 0; i < sbp_id_num; i++){
if (sbp_id[i] != sbp_id_ans[i]){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! sbp id(%d) sbp id ans(%d) \r\n", sbp_id[i], sbp_id_ans[i]);
return KAL_FALSE;
}
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_470_97,108_466_97,105_25_43,5_470_123,5_460_NA,1_460_NA,1_460_02");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
sbp_id_ans[0]=108; sbp_id_ans[1]=105; sbp_id_ans[2]=5; sbp_id_ans[3]=1;
for (i = 0; i < sbp_id_num; i++){
if (sbp_id[i] != sbp_id_ans[i]){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! sbp id(%d) sbp id ans(%d) \r\n", sbp_id[i], sbp_id_ans[i]);
return KAL_FALSE;
}
}
//NA case
kal_mem_set(tag, 0, 64);
strcpy(tag, "NA_123_45,NA_02_53,108_470_97,108_466_97,1_460_NA,1_460_02,");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if (general != KAL_TRUE){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! general(%d) \r\n", general);
return KAL_FALSE;
}
//ICCID case
kal_mem_set(tag, 0, 64);
strcpy(tag, "123456,NA_02_53,108_470_97,108_466_97,1_460_NA,1_460_02,");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if (general != KAL_TRUE){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! general(%d) \r\n", general);
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "123456");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if (general != KAL_TRUE){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! general(%d) \r\n", general);
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_460_32,123456");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if (general != KAL_TRUE){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! general(%d) \r\n", general);
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
strcpy(tag, "108_460_32");
if (mcf_find_ini_sbp_id(tag, sbp_id, &sbp_id_num, &general) != KAL_TRUE) {
mcf_ut_format_err_str("Find ini file sbp id FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
for (i = 0; i < sbp_id_num; i++){
if (sbp_id[i] != sbp_id_ans[i]){
mcf_ut_format_err_str("Find ini file sbp id FAIL!! sbp id(%d) sbp id ans(%d) \r\n", sbp_id[i], sbp_id_ans[i]);
return KAL_FALSE;
}
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_compose_ini_item(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
mcf_t *pMcf = mcf_get_instance();
mcf_ini_file_t *ini_file = &(pMcf->ini_file);
kal_char value[64];
kal_char test_data_path[512];
kal_char *pos;
kal_char tag[64];
kal_char new_value[64];
kal_char old_value[64];
mcf_ut_init();
/*
* Read ini positive test
*/
kal_mem_set(ini_file->buff, 0, MCF_MAX_INI_FILE_SIZE);
kal_mem_set(ini_file->tmp_buff, 0, MCF_MAX_INI_FILE_SIZE);
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG.ini", ini_file->buff, MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "AP_Monitor_Time");
strcpy(old_value, "120");
strcpy(new_value, "2");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
/* Change write permission of ini file */
getcwd(test_data_path, sizeof(test_data_path));
pos = strstr(test_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s%c", MCF_UT_DB_FOLDER_PATH, "MTK_MD_OTA_CONFIG_WRITE.ini", '\0');
chmod(test_data_path, 0666);
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "TagName");
strcpy(old_value, "108_466_97,1_460_NA,1_460_02");
strcpy(new_value, "108_466_97,1_460_02");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "AP_Monitor_Time");
strcpy(old_value, "2");
strcpy(new_value, "23000");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "Gen_Time");
strcpy(old_value, "2018.1025.120000");
strcpy(new_value, "2018.1104.182054");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
/* New item */
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "Reboot_Mode");
strcpy(old_value, "");
strcpy(new_value, "1");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "GenTime");
strcpy(old_value, "");
strcpy(new_value, "2018.1106.110355");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "BatteryLife");
strcpy(old_value, "");
strcpy(new_value, "87%");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "AP_Monitor_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"23000") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "GenTime");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1106.110355") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "TagName");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"108_466_97,1_460_02") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Gen_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"2018.1104.182054") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Reboot_Mode");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"1") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "BatteryLife");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"87%") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Battery Life");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"87%") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "BaTTery LIFE");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"87%") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
/* Read again */
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "Gen_Time");
strcpy(old_value, "2018.1104.182054");
strcpy(new_value, "");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Gen_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(tag, 0, 64);
kal_mem_set(new_value, 0, 64);
kal_mem_set(old_value, 0, 64);
strcpy(tag, "Gen_Time");
strcpy(old_value, "");
strcpy(new_value, "125_25_67");
if (mcf_compose_ini_item(ini_file->buff, ini_file->tmp_buff, tag, old_value, new_value) != KAL_TRUE) {
mcf_ut_format_err_str("Find compose_ini_item FAIL!! item(%s) value(%s) \r\n", tag, new_value);
return KAL_FALSE;
}
ret = mcf_ut_write_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", ini_file->tmp_buff);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG.ini");
return KAL_FALSE;
}
ret = mcf_ut_open_test_data("MTK_MD_OTA_CONFIG_WRITE.ini", (kal_char *)(ini_file->buff), MCF_MAX_INI_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_MD_OTA_CONFIG_WRITE.ini");
return KAL_FALSE;
}
kal_mem_set(value, 0, 64);
kal_mem_set(tag, 0, 64);
strcpy(tag, "Gen_Time");
if (mcf_find_ini_item((kal_char *)ini_file->buff, tag, value, pMcf) != KAL_TRUE) {
mcf_ut_format_err_str("Read ini file FAIL!! item(%s) \r\n", tag);
return KAL_FALSE;
}
if(strcmp(value,"125_25_67") != 0){
mcf_ut_format_err_str("Read ini file positive test FAIL!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_mcf_boot_trace(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_uint32 d1 = 100, d2 = 200;
char string[] = "MCF TEST";
char string2[] = "MCF TEST2";
kal_uint32 i = 0;
mcf_do_ota_full();
MCF_BOOT_TRACE(MCF_BOOT_TRACE_TEST2);
MCF_BOOT_TRACE(MCF_BOOT_TRACE_TEST1, d1);
MCF_BOOT_TRACE(MCF_BOOT_TRACE_TEST3, string);
MCF_BOOT_TRACE(MCF_BOOT_TRACE_TEST4, d1, string);
MCF_BOOT_TRACE(MCF_BOOT_TRACE_TEST5, string, string2, d1);
for(i = 0;i< 10000;i++)
{
MCF_BOOT_TRACE(MCF_BOOT_TRACE_TEST5, string, string2, d1);
}
mcf_dump_boot_trace();
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_config_LID(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
l4c_mcf_config_lid_variable_operation_req_struct *req = NULL;
l4c_mcf_config_lid_variable_operation_cnf_struct *cnf = NULL;
mcf_ota_result_e mcf_ret = MCF_OTA_R_SUCCESS;
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
kal_uint8 test_pattern[512];
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Apply default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Set OTA path in default path positive test
*/
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_BYTE_11");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable FAIL!!(%s)\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_BIT_BYTE_11");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable FAIL!!(%s)\r\n", "VAL_BIT_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_bit_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_BIT_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, VAL_BIT_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_BIT_BYTE_11.B3");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_BIT_BYTE_11.B3, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, VAL_BIT_BYTE_11.B3, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_byte_12");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_byte_12");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_bit_byte_12), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_byte_12, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_byte_12, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_byte_12.L4b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_byte_12.L4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_byte_12.F4b, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_byte_12.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_short_11");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_short_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_short_11), cnf->len*2, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*4) != 0){
mcf_ut_format_err_str("Config LID, val_short_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_short_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "val_double_1");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_double_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_double_1), cnf->len*8, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*16) != 0){
mcf_ut_format_err_str("Config LID, val_double_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_double_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "val_buffer_1");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_buffer_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("Config LID, val_buffer_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_buffer_1");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_buffer_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 32){
mcf_ut_format_err_str("Config LID, val_buffer_1, %d, %d\r\n", cnf->len, 32);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "val_buffer_1[0]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_buffer_1[0]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_buffer_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "val_struct_1.vfloat");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_struct_1.vfloat");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_1.vfloat), cnf->len*4, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, val_struct_1.vfloat, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_struct_1.vfloat, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "val_struct_3[0].vint");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_struct_3[0].vint");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_3[0].vint), cnf->len*4, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, val_struct_3[0].vint, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_struct_3[0].vint, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_struct_3[0]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_3[0]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, 510) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 255){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0], %d, %d\r\n", cnf->len, 255);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* negative test */
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[3].VBUFFER[2][4][5]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[3].VBUFFER[2][4][5]");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Test TLV OTA */
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OPOTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
req->ps_id = 0;
strcpy(req->tag_name, "VAL_BYTE_11");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Test 3-d array */
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Apply 3-d array default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_3d_array_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_3d_array_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[4][3][2]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "06", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][3][2], %s, %s\r\n", cnf->value, "06");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][3][2], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 4;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[4][3]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][3], %s, %s\r\n", cnf->value, "060606");
return KAL_FALSE;
}
if(cnf->len != 3){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][3], %d, %d\r\n", cnf->len, 3);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[4][3]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][3], %s, %s\r\n", cnf->value, "060606");
return KAL_FALSE;
}
if(cnf->len != 3){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][3], %d, %d\r\n", cnf->len, 3);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[4]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606060606060606060606", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4], %s, %s\r\n", cnf->value, "060606060606060606060606");
return KAL_FALSE;
}
if(cnf->len != 12){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4], %d, %d\r\n", cnf->len, 12);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D, %s, %s\r\n", cnf->value, "060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606");
return KAL_FALSE;
}
if(cnf->len != 60){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D, %d, %d\r\n", cnf->len, 60);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[4][2]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0606", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][2], %s, %s\r\n", cnf->value, "0606");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[4][2], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 10;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[3]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "06060606060606060606", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[3], %s, %s\r\n", cnf->value, "06060606060606060606");
return KAL_FALSE;
}
if(cnf->len != 10){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D[3], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Different variable size */
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D4[4][3][2]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][3][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "06000000", cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4][3][2], %s, %s\r\n", cnf->value, "06000000");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4][3][2], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D4[4][3]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060000000600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4][3], %s, %s\r\n", cnf->value, "060000000600000006000000");
return KAL_FALSE;
}
if(cnf->len != 3){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4][3], %d, %d\r\n", cnf->len, 3);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D4[4]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, "060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000");
return KAL_FALSE;
}
if(cnf->len != 12){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 12);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D4[4]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, "0600000006000000");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D4[4][2]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, "0600000006000000");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D4");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4");
return KAL_FALSE;
}
kal_mem_set(test_pattern, 0 , 512);
for (i = 0; i < cnf->len; i++){
kal_mem_cpy(test_pattern+(i*8),"06000000",8);
}
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*8) != 0){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 60){
mcf_ut_format_err_str("Config LID, VAL_STRUCT_3[0].ARRAY_D4, %d, %d\r\n", cnf->len, 60);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Nagative test case */
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[0].ARRAY_D[5]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[5]");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "VAL_STRUCT_3[4]");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "VAL_STRUCT_3[4]");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/*
* Apply 2bytes to bit default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_2_byte_4_byte_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_2byte_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_2byte_3");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_2byte_3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "F02F", cnf->len*4) != 0){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3, %s, %s\r\n", cnf->value, "F02F");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_2byte_3.F4b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_2byte_3.F4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "00", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.F4b, %s, %s\r\n", cnf->value, "00");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_2byte_3.L4b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_2byte_3.L4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.L4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.L4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_2byte_3.F2b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_2byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.F2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_2byte_3.L2b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_2byte_3.L2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.L2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.L2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_2byte_3.b2");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_2byte_3.b2");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.b2, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_2byte_3.b2, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_4byte_3");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_4byte_3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0001FE0F", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3, %s, %s\r\n", cnf->value, "0001FE0F");
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_4byte_3.F9b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_4byte_3.F9b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0001", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3.F9b, %s, %s\r\n", cnf->value, "0001");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3.F9b, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_4byte_3.F4b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_4byte_3.F4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3.F4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_config_lid_variable_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_LID_VARIABLE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->lid_num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->tag_name, "val_bit_4byte_3.F2b");
cnf = (l4c_mcf_config_lid_variable_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_config_lid_variable_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_config_LID_variable(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Config LID variable (%s) FAIL!!\r\n", "val_bit_4byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("Config LID, val_bit_4byte_3.F2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_query_variable_value(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
l4c_mcf_variable_value_operation_req_struct *req = NULL;
l4c_mcf_variable_value_operation_cnf_struct *cnf = NULL;
mcf_ota_result_e mcf_ret = MCF_OTA_R_SUCCESS;
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
kal_uint8 test_pattern[512];
kal_uint8 array_tag[16];
nvram_ef_mcf_test_struct nv_lid_buffer;
#ifdef __MCF_FIND_TAG_SUPPORT__
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Apply default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
//Byte operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_BYTE_11");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Bit operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_BIT_BYTE_11");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_bit_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_BIT_BYTE_11.B3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_byte_12");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_byte_12");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_bit_byte_12), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_12, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_byte_12.L4b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_byte_12.L4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_12.F4b, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//short operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_short_11");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_short_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_short_11), cnf->len*2, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*4) != 0){
mcf_ut_format_err_str("val_short_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_short_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//double operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "val_double_1");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_double_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_double_1), cnf->len*8, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*16) != 0){
mcf_ut_format_err_str("val_double_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_double_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer operation with len = 2
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "val_buffer_1");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_buffer_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_buffer_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer operation - read all buffer
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_buffer_1");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_buffer_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 32){
mcf_ut_format_err_str("val_buffer_1, %d, %d\r\n", cnf->len, 32);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "val_buffer_1[0]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_buffer_1[0]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_buffer_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//float operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "val_struct_1.vfloat");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_struct_1.vfloat");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_1.vfloat), cnf->len*4, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*8) != 0){
mcf_ut_format_err_str("val_struct_1.vfloat, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_struct_1.vfloat, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//int in struct operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "val_struct_3[0].vint");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_struct_3[0].vint");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_3[0].vint), cnf->len*4, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*8) != 0){
mcf_ut_format_err_str("val_struct_3[0].vint, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_struct_3[0].vint, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//struct operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_struct_3[0]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_3[0]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, 510) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 255){
mcf_ut_format_err_str("VAL_STRUCT_3[0], %d, %d\r\n", cnf->len, 255);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer in struct operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[3].VBUFFER[2][4][5]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[3].VBUFFER[2][4][5]");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Test TLV OTA */
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//byte operation
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
req->ps_id = 0;
strcpy(req->config, "VAL_BYTE_11");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Test 3-d array */
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Apply 3-d array default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_3d_array_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_3d_array_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[4][3][2]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "06", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3][2], %s, %s\r\n", cnf->value, "06");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3][2], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 4;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[4][3]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3], %s, %s\r\n", cnf->value, "060606");
return KAL_FALSE;
}
if(cnf->len != 3){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3], %d, %d\r\n", cnf->len, 3);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[4][3]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3], %s, %s\r\n", cnf->value, "060606");
return KAL_FALSE;
}
if(cnf->len != 3){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3], %d, %d\r\n", cnf->len, 3);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[4]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606060606060606060606", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4], %s, %s\r\n", cnf->value, "060606060606060606060606");
return KAL_FALSE;
}
if(cnf->len != 12){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4], %d, %d\r\n", cnf->len, 12);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D, %s, %s\r\n", cnf->value, "060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606060606");
return KAL_FALSE;
}
if(cnf->len != 60){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D, %d, %d\r\n", cnf->len, 60);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[4][2]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0606", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][2], %s, %s\r\n", cnf->value, "0606");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][2], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 10;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[3]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "06060606060606060606", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %s, %s\r\n", cnf->value, "06060606060606060606");
return KAL_FALSE;
}
if(cnf->len != 10){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Different variable size */
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D4[4][3][2]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][3][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "06000000", cnf->len*8) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3][2], %s, %s\r\n", cnf->value, "06000000");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3][2], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D4[4][3]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][3]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060000000600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3], %s, %s\r\n", cnf->value, "060000000600000006000000");
return KAL_FALSE;
}
if(cnf->len != 3){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3], %d, %d\r\n", cnf->len, 3);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D4[4]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, "060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000");
return KAL_FALSE;
}
if(cnf->len != 12){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 12);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D4[4]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, "0600000006000000");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D4[4][2]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][2]");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0600000006000000", cnf->len*8) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, "0600000006000000");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D4");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4");
return KAL_FALSE;
}
kal_mem_set(test_pattern, 0 , 512);
for (i = 0; i < cnf->len; i++){
kal_mem_cpy(test_pattern+(i*8),"06000000",8);
}
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*8) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 60){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4, %d, %d\r\n", cnf->len, 60);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Nagative test case */
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[0].ARRAY_D[5]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[5]");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "VAL_STRUCT_3[4]");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[4]");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/*
* Apply 2bytes to bit default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_2_byte_4_byte_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_2byte_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_2byte_3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "F02F", cnf->len*4) != 0){
mcf_ut_format_err_str("val_bit_2byte_3, %s, %s\r\n", cnf->value, "F02F");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_bit_2byte_3, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_2byte_3.F4b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.F4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "00", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.F4b, %s, %s\r\n", cnf->value, "00");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_2byte_3.L4b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.L4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.L4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.L4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_2byte_3.F2b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.F2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_2byte_3.L2b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.L2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.L2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.L2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_2byte_3.b2");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.b2");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.b2, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.b2, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_4byte_3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0001FE0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3, %s, %s\r\n", cnf->value, "0001FE0F");
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_bit_4byte_3, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_4byte_3.F9b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F9b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0001", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F9b, %s, %s\r\n", cnf->value, "0001");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_bit_4byte_3.F9b, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_4byte_3.F4b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_4byte_3.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_PATH;
req->num = 4098;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "val_bit_4byte_3.F2b");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_4byte_3.F2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
#else
#endif
/*Query variable with gid format*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Apply default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+44;
req->rec_id = 1;
req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Bit operation - VAL_BIT_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+18;
req->rec_id = 1;
req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_bit_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Bit operation - VAL_BIT_BYTE_11.B3
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+21;
req->rec_id = 1;
req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Bit operation - val_bit_byte_12
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+27;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_byte_12");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_bit_byte_12), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_12, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Bit operation - val_bit_byte_12.L4b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+29;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_byte_12.L4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_12.F4b, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//short operation - val_short_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+56;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_short_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_short_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_short_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_short_11, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//double operation - val_double_1
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+48;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_double_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_double_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_double_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 8){
mcf_ut_format_err_str("val_double_1, %d, %d\r\n", cnf->len, 8);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer operation with len = 2 - val_buffer_1
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+42;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_buffer_1");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_buffer_1, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer operation - read all buffer - val_buffer_1[0]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+42;
req->rec_id = 1;
req->len = 32;
strcpy(req->config, "0");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_buffer_1[0]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1[0], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 32){
mcf_ut_format_err_str("val_buffer_1[0], %d, %d\r\n", cnf->len, 32);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer operation - val_buffer_1[0]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+42;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "0");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_buffer_1[0]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1[0], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_buffer_1[0], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//float operation - val_struct_1.vfloat
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+78;
req->rec_id = 1;
req->len = 4;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_struct_1.vfloat");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_1.vfloat), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_struct_1.vfloat, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_struct_1.vfloat, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//int in struct operation - val_struct_3[0].vint
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+125;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_struct_3[0].vint");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_3[0].vint), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_struct_3[0].vint, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_struct_3[0].vint, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//buffer in struct operation - VAL_STRUCT_3[3].VBUFFER[2][4][5]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+120;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "3,2,4,5");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[3].VBUFFER[2][4][5]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_struct_3[3].vbuffer[2]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[3].VBUFFER[2][4][5], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[3].VBUFFER[2][4][5], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Test TLV OTA */
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+44;
req->rec_id = 1;
req->len = 0;
req->ps_id = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_pattern.val_byte_11), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BYTE_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Test 3-d array */
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
/*
* Apply 3-d array and bit byte operation default OTA
*/
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_3d_array_and_bit_byte_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_3d_array_and_bit_byte_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Reset LID FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, (kal_uint8 *)&nv_lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
mcf_ut_format_err_str("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
if ( kal_mem_cmp((kal_uint8 *)&nv_lid_buffer, &mcf_ut_test_lid_value_new_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
mcf_ut_format_err_str("Do full OTA positive test (SW verno match) FAIL!!\r\n");
}
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[4][3][2]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,4,3,2");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3][2]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[4][3][2]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3][2], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3][2], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[4][3]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,4,3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][3]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[4][3]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][3], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[4]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,4");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[4]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[4][2]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "0,4,2");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[4][2]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[4][2]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][2], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[4][2], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[3]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 10;
strcpy(req->config, "0,3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[3]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[3]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 10){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %d, %d\r\n", cnf->len, 10);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Different variable size */
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D4[4][3][2]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+107;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,4,3,2");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][3][2]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d4[4][3][2]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3][2], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3][2], %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D4[4][3]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+107;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,4,3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][3]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d4[4][3]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][3], %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D4[4]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+107;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,4");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d4[4]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D4[4]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+107;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "0,4");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d4[4]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D4[4][2]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+107;
req->rec_id = 1;
req->len = 2;
strcpy(req->config, "0,4,2");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4[4][2]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d4[4]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][2], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4[4][2], %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D4
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+107;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D4");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d4), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D4, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Nagative test case */
//over array size - VAL_STRUCT_3[0].ARRAY_D[5]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0,5");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("over array size! VAL_STRUCT_3[0].ARRAY_D[5] is not FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//over array size - VAL_STRUCT_3[4].ARRAY_D
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "4");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_INVALID_PARAMETER) {
mcf_ut_format_err_str("over array size! VAL_STRUCT_3[4].ARRAY_D is not FAIL!!\r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation- val_bit_2byte_3
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "FFFF", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3, %s, %s\r\n", cnf->value, "FFFF");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_bit_2byte_3, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation- val_bit_2byte_3.F4b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+2;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.F4b");
return KAL_FALSE;
}
if(strncmp((cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.F4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_2byte_3.L4b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+4;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.L4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.L4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.L4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_2byte_3.F2b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+1;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.F2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_2byte_3.L2b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+3;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.L2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.L2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.L2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_2byte_3.b2
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+6;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_2byte_3.b2");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_2byte_3.b2, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_2byte_3.b2, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_4byte_3
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+9;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "FFFFFFFF", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3, %s, %s\r\n", cnf->value, "FFFFFFFF");
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_bit_4byte_3, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_4byte_3.F9b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+12;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F9b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "FF01", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F9b, %s, %s\r\n", cnf->value, "FF01");
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_bit_4byte_3.F9b, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_4byte_3.F4b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+11;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F4b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_4byte_3.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//2 byte bit operation - val_bit_4byte_3
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+10;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "03", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_4byte_3.F2b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Negative test */
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[3] - not end '$'
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 10;
strcpy(req->config, "0,3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[3]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[3]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 10){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %d, %d\r\n", cnf->len, 10);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//3-D array operation - VAL_STRUCT_3[0].ARRAY_D[3] - not use '$' to separate - result = VAL_STRUCT_3[0].ARRAY_D[0]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+106;
req->rec_id = 1;
req->len = 1;
strcpy(req->config, "0,3");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_STRUCT_3[0].ARRAY_D[3]");
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(mcf_ut_test_lid_value_new_pattern.val_struct_3[0].array_d[3]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
if(strncmp((kal_char *)(cnf->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[0].ARRAY_D[3], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Read len is too large - val_bit_4byte_3(4 byte)
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+9;
req->rec_id = 1;
req->len = 4;
strcpy(req->config, "");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "val_bit_4byte_3.F2b");
return KAL_FALSE;
}
if(strncmp((kal_char *)(cnf->value), "FFFFFFFF", cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_4byte_3.F2b, %s, %s\r\n", cnf->value, "03");
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_bit_4byte_3.F2b, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
MCF_UT_PASS();
return KAL_TRUE;
}
#if !defined(__MTK_TARGET__)
kal_bool mcf_ut_mcf_check_lid_need_reset(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/*
* Check LID need reset positive test - Modify 3 LIDs
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("OTA_3_LIDs.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "OTA_3_LIDs.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Modify 2 LIDs
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("OTA_2_LIDs.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "OTA_2_LIDs.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - OTA file does not update
*/
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Max last LID list count
*/
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_last_mod_lid_g.lid_cnt = NVRAM_MCF_SAVE_LAST_LID_CNT;
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max last LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max last LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max last LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Max current LID list count
*/
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_curr_mod_lid_g.lid_cnt = NVRAM_MCF_SAVE_LAST_LID_CNT;
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max current LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max current LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max current LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_gid_mcf_check_lid_need_reset(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_ut_init();
/*
* Check LID need reset positive test - Modify 3 LIDs
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("OTA_3_LIDs_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "OTA_3_LIDs_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Modify 2 LIDs
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("OTA_2_LIDs_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "OTA_2_LIDs_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - OTA file does not update
*/
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Max last LID list count
*/
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_last_mod_lid_g.lid_cnt = NVRAM_MCF_SAVE_LAST_LID_CNT;
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max last LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max last LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max last LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Max current LID list count
*/
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
mcf_curr_mod_lid_g.lid_cnt = NVRAM_MCF_SAVE_LAST_LID_CNT;
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max current LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_IMS_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max current LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_XCAP_PROFILE_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Max current LID list count) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_gid_mcf_check_lid_need_reset_by_psid(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
mcf_ota_result_e mcf_ret;
kal_bool ret;
kal_uint8 i;
sbp_reconfig_custom_param_struct param_ptr;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_ut_init();
if ( !nvram_external_read_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct))) {
mcf_ut_format_err_str("Read NVRAM_EF_MCF_SW_INFO_LID FAIL!");
return KAL_FALSE;
}
strncpy(nv_sw_info.version, release_verno(), MCF_SW_VERNO_LEN);
strncpy(nv_sw_info.build_time, build_date_time(), MCF_SW_BUILD_TIME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct))) {
mcf_ut_format_err_str("Write NVRAM_EF_MCF_SW_INFO_LID FAIL!");
return KAL_FALSE;
}
/*
* Check LID need reset positive test - Modify 3 LIDs with SBP_PARTIAL_TAG
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_TRUE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Modify 2 LIDs
*/
/* Read MCF TLV-OTA file into cache buffer */
if ( !nvram_external_read_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct))) {
mcf_ut_format_err_str("Fail to read MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/* Write MCF TLV-OTA file version to NVRAM */
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_2LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_2LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_TRUE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - TLV-OTA file does not update
*/
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (TLV-OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (TLV-OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (TLV-OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Max last LID list count
*/
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
mcf_tlvota_last_mod_lid_g[i].lid_cnt = NVRAM_MCF_SAVE_LAST_LID_CNT;
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
}
/*
* Check LID need reset positive test - Max current LID list count
*/
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
mcf_tlvota_curr_mod_lid_g[i].lid_cnt = NVRAM_MCF_SAVE_LAST_LID_CNT;
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
}
/*
* Check LID need reset positive test - Modify 3 LIDs with SBP_PARTIAL_TAG_WITH_MCC
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_tag_with_mcc_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_tag_with_mcc_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG_WITH_MCC
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_TRUE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_partial_tag_with_mcc) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_partial_tag_with_mcc) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_partial_tag_with_mcc) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Modify 3 LIDs with SBP_FULL_TAG
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_tag_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_tag_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_FULL_TAG
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_TRUE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Modify 3 LIDs by auto select apply
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_12.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_12.mcfopota");
return KAL_FALSE;
}
tlvota_file->last_mod_time = MCF_UT_GEN_TIME;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++) {
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_FALSE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++){
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*General TLV-OTA*/
/*
* Check LID need reset positive test - Modify 3 LIDs
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_GENERAL_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF General TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_general_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_general_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(is_read_general_tlvota, 0, MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_tlvota[i] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
is_read_general_tlvota[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Modify 2 LIDs
*/
/* Read MCF TLV-OTA file into cache buffer */
if ( !nvram_external_read_data(NVRAM_EF_MCF_GENERAL_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct))) {
mcf_ut_format_err_str("Fail to read MCF General TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/* Write MCF TLV-OTA file version to NVRAM */
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_GENERAL_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF General TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_general_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_general_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_2LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_2LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(is_read_general_tlvota, 0, MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_tlvota[i] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
is_read_general_tlvota[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - General TLV-OTA file does not update
*/
kal_mem_set(&mcf_general_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_general_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (TLV-OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (TLV-OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (TLV-OTA file does not update) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Modify 3 LIDs with ICCID tag by auto select apply
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_GENERAL_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF General TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_general_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_general_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_ICCID_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_ICCID_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
tlvota_file->last_mod_time = MCF_UT_GEN_TIME;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(is_read_general_tlvota, 0, MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
strcpy(param_ptr.iccid, SBP_PARTIAL_TAG);
is_read_tlvota[i] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_FALSE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with NA tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++){
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Apply SIM1 and SIM2 and General OP-OTA separately
*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_12.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_12.mcfopota");
return KAL_FALSE;
}
tlvota_file->last_mod_time = MCF_UT_GEN_TIME;
kal_mem_set(&(tlvota_file->last_file), 0, sizeof(mcf_file_info_t));
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(0);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[0] = KAL_FALSE;
is_read_tlvota[0] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_FALSE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(0));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Apply SIM1 and SIM2 and General OP-OTA separately FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(0));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Apply SIM1 and SIM2 and General OP-OTA separately FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(0));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Apply SIM1 and SIM2 and General OP-OTA separately FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(0));
tlvota_file = &(pMcf->tlvota_file[1]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_12.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_12.mcfopota");
return KAL_FALSE;
}
tlvota_file->last_mod_time = MCF_UT_GEN_TIME;
kal_mem_set(&(tlvota_file->last_file), 0, sizeof(mcf_file_info_t));
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(1);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[1] = KAL_FALSE;
is_read_tlvota[1] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_FALSE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(1));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Apply SIM1 and SIM2 and General OP-OTA separately FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(1));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Apply SIM1 and SIM2 and General OP-OTA separately FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(1));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Apply SIM1 and SIM2 and General OP-OTA separately FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(1));
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_NA_ut_2LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_NA_ut_2LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
tlvota_file->last_mod_time = MCF_UT_GEN_TIME;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(is_read_general_tlvota, 0, MAX_SIM_NUM);
for(i = 0; i < MAX_SIM_NUM; i++){
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_tlvota[i] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_FALSE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_full_tag) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
}
for(i = 0; i < MAX_SIM_NUM; i++){
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
/*
* Check LID need reset positive test - Change SIM1, SIM2 card
*/
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_tlvota_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
kal_mem_set(&mcf_tlvota_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct)*MAX_SIM_NUM);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_TRUE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
//Change SIM1/SIM2
for (i = 0; i < MAX_SIM_NUM; i++) {
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
param_ptr.sbp_id = 108;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
is_read_general_tlvota[i] = KAL_FALSE;
is_read_tlvota[i] = KAL_FALSE;
pMcf->is_ignore_dsbp[i] = KAL_TRUE;
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, l4c_gemini_get_switched_sim_id(i));
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs with SBP_PARTIAL_TAG) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(i));
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_mcf_check_ota_need_update(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
mcf_tlvota_sbp_tag_t sbp_tag;
kal_char iccid_tag[16];
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
sbp_reconfig_custom_param_struct param_ptr;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_ut_init();
if ( !nvram_external_read_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct))) {
mcf_ut_format_err_str("Read NVRAM_EF_MCF_SW_INFO_LID FAIL!");
return KAL_FALSE;
}
strncpy(nv_sw_info.version, release_verno(), MCF_SW_VERNO_LEN);
strncpy(nv_sw_info.build_time, build_date_time(), MCF_SW_BUILD_TIME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct))) {
mcf_ut_format_err_str("Write NVRAM_EF_MCF_SW_INFO_LID FAIL!");
return KAL_FALSE;
}
/*
* TLV-OTA file test
*/
/* First time, need to update TLV-OTA*/
/* Fill TLV-OTA file into buffer */
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_12.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_12.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(0);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
/* Second time, do not change TLV-OTA, no need to update */
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
/* When chang sim card, need to update */
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = 1;
strncpy(sbp_tag.mcc, "460", MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "01", MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = 1;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(0);
kal_mem_cpy(param_ptr.mcc, "460", MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, "01", MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Fill TLV-OTA file into buffer */
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_1.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_1.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
/*
* General TLV-OTA file test
*/
/* First time, need to update TLV-OTA*/
/* Fill TLV-OTA file into buffer */
tlvota_file = &(pMcf->general_tlvota_file);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_GENERAL.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_GENERAL.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(0);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
/* Second time, do not change General TLV-OTA, no need to update */
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_mcf_get_tlvota_file_result(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
mcf_tlvota_sbp_tag_t sbp_tag;
kal_char iccid_tag[16];
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
sbp_reconfig_custom_param_struct param_ptr;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_ota_result_e mcf_ret = MCF_OTA_R_SUCCESS;
kal_uint8 i;
mcf_ut_init();
if ( !nvram_external_read_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct))) {
mcf_ut_format_err_str("Read NVRAM_EF_MCF_SW_INFO_LID FAIL!");
return KAL_FALSE;
}
strncpy(nv_sw_info.version, release_verno(), MCF_SW_VERNO_LEN);
strncpy(nv_sw_info.build_time, build_date_time(), MCF_SW_BUILD_TIME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct))) {
mcf_ut_format_err_str("Write NVRAM_EF_MCF_SW_INFO_LID FAIL!");
return KAL_FALSE;
}
/*
* TLV-OTA file test
*/
/* First time, need to update TLV-OTA*/
/* Fill TLV-OTA file into buffer */
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_12.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_12.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(0);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
/* Second time, do not change TLV-OTA, no need to update */
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
/* When chang sim card, need to update */
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = 1;
strncpy(sbp_tag.mcc, "460", MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, "01", MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = 1;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(0);
kal_mem_cpy(param_ptr.mcc, "460", MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, "01", MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Fill TLV-OTA file into buffer */
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MTK_OPOTA_SBPID_1.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MTK_OPOTA_SBPID_1.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
/*
*
* False positive test - Invalid TLVOTA file
*
*/
for(i = 0; i < MAX_SIM_NUM; i++){
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Use OTA file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_INVALID_FILE){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
}
/*
*
* False positive test - decyption FAIL
*
*/
for(i = 0; i < MAX_SIM_NUM; i++){
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Use error AES-128 file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_encyption_wrong_key.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_encyption_wrong_key.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_CHECKSUM_ERROR){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
}
/*
*
* False positive test - digest FAIL
*
*/
for(i = 0; i < MAX_SIM_NUM; i++){
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Use error AES-128 file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_wrong_RSA2048.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_wrong_RSA2048.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_DIGEST_FAIL){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
}
/*
*
* False positive test - Invalid TLVOTA file - mcf_check_ota_need_update
*
*/
for(i = 0; i < MAX_SIM_NUM; i++){
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Use OTA file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_INVALID_FILE){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
}
/*
*
* False positive test - decyption FAIL - mcf_check_ota_need_update
*
*/
for(i = 0; i < MAX_SIM_NUM; i++){
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Use error AES-128 file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_encyption_wrong_key.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_encyption_wrong_key.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
/* Use error AES-128 file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_encyption_wrong_key.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_encyption_wrong_key.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_CHECKSUM_ERROR){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
}
/*
*
* False positive test - digest FAIL - mcf_check_ota_need_update
*
*/
for(i = 0; i < MAX_SIM_NUM; i++){
// fill in SBP TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&iccid_tag, 0, sizeof(kal_char));
strcpy(iccid_tag, SBP_PARTIAL_TAG);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = l4c_gemini_get_switched_sim_id(i);
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
/* Use error RSA2048 file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_wrong_RSA2048.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_wrong_RSA2048.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
// Check TLV-OTA need update
ret = mcf_check_ota_need_update(param_ptr.ps_id, sbp_tag, iccid_tag);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf_check_ota_need_update FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
/* Use error RSA2048 file */
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_wrong_RSA2048.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_wrong_RSA2048.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
//DSBP flow
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("mcf_auto_select_tlvota_file FAIL! ret(%d) \r\n", ret);
return KAL_FALSE;
}
mcf_set_config_after_dsbp(l4c_gemini_get_switched_sim_id(param_ptr.ps_id));
mcf_ret = mcf_get_tlvota_file_result(param_ptr.ps_id);
if (mcf_ret != MCF_OTA_R_DIGEST_FAIL){
mcf_ut_format_err_str("mcf_get_tlvota_file_result FAIL! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if defined(__MCF_UT_FRAMEWORK_SUPPORT__)
extern kal_bool mcf_utfwk_sample_code_start_ut();
kal_bool mcf_utfwk_sample_code_ut(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret = KAL_TRUE;
ret = mcf_utfwk_sample_code_start_ut();
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("mcf utfwk sample code failed \r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_utfwk_ut_test_flow (void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret = KAL_TRUE;
static mcf_utfwk_ota_input_struct ota_input;
kal_char ota_data_path[512];
kal_char *pos;
kal_uint8 *dump_buffer;
nvram_errno_enum nvram_api_ret;
nvram_ltable_entry_struct lid_info = {0};
static kal_uint32 value;
kal_uint64 sh_value;
kal_uint8 oring_value[20];
kal_uint8 hex_value[20];
kal_uint32 sim_id = 0;
static mcf_utfwk_config_variable_struct var;
static mcf_utfwk_config_variable_struct var_arr[5];
static kal_uint32 value1;
static kal_uint32 bit_value;
nvram_ef_mcf_test_struct test_lid_buffer;
/* Normal Case */
kal_mem_set(&ota_input, 0, sizeof(mcf_utfwk_ota_input_struct));
ota_input.lid[0] = NVRAM_EF_MCF_TEST_OTA_LID;
ota_input.lid_cnt = 1;
ota_input.ota_type = MCF_UTFWK_ATTR_OTA;
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s%c", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_ut_gid_normal.mcfota", '\0');
ota_input.input_op = MCF_UTFWK_OTA_FILE_PATH;
strcpy(ota_input.input_mode.file_path_name, ota_data_path);
ret = mcf_utfwk_initial_env(ota_input);
if (ret == KAL_FALSE){
return ret;
}
mcf_utfwk_execute();
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
ret = KAL_FALSE;
return ret;
}
dump_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_LID, dump_buffer, lid_info.size, 0, "") != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
if ( kal_mem_cmp(dump_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
free_ctrl_buffer_set_null(dump_buffer);
mcf_utfwk_reset();
/* OTA for Query Case */
kal_mem_set(&ota_input, 0, sizeof(mcf_utfwk_ota_input_struct));
ota_input.lid[0] = NVRAM_EF_MCF_TEST_OTA_QUERY_LID;
ota_input.lid_cnt = 1;
ota_input.ota_type = MCF_UTFWK_ATTR_OTA;
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s%c", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_QUERY_ut_gid_normal.mcfota", '\0');
ota_input.input_op = MCF_UTFWK_OTA_FILE_PATH;
strcpy(ota_input.input_mode.file_path_name, ota_data_path);
ret = mcf_utfwk_initial_env(ota_input);
if (ret == KAL_FALSE){
return ret;
}
mcf_utfwk_execute();
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
ret = KAL_FALSE;
return ret;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if((lid_info.attr & NVRAM_ATTR_MCF_OTA_FOR_QUERY) != 0) {
if(mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct)) != MCF_OTA_R_SUCCESS){
ret = KAL_FALSE;
return ret;
}
}else {
ret = KAL_FALSE;
return ret;
}
if ( kal_mem_cmp(&test_lid_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
return ret;
}
dump_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, MCF_UTFWK_DUMP_LID, dump_buffer, lid_info.size, 0, "") != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
if ( kal_mem_cmp(dump_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
free_ctrl_buffer_set_null(dump_buffer);
mcf_utfwk_reset();
/* Generate OTA Case */
kal_mem_set(&ota_input, 0, sizeof(mcf_utfwk_ota_input_struct));
kal_mem_set(&var, 0, sizeof(mcf_utfwk_config_variable_struct));
ota_input.lid[0] = NVRAM_EF_MCF_TEST_OTA_LID;
ota_input.lid_cnt = 1;
ota_input.ota_type = MCF_UTFWK_ATTR_OTA;
ota_input.input_op = MCF_UTFWK_OTA_VARIABLE_CONFIG;
//VAL_STRUCT_3[0].ARRAY_D[4][3][2]
var.gid = MCF_TEST_OTA_LID_BASE_GID+106;
strcpy(var.array_index, "0$4$3$2$");
value = 12;
var.value = &value;
var.value_len = 1;
var.rec_id = 1;
ota_input.input_mode.var_info.var = &var;
ota_input.input_mode.var_info.var_cnt = 1;
ret = mcf_utfwk_initial_env(ota_input);
if (ret == KAL_FALSE){
return ret;
}
mcf_utfwk_execute();
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
ret = KAL_FALSE;
return ret;
}
dump_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 1, var.gid, var.array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&value, 1, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 1, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 2) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
free_ctrl_buffer_set_null(dump_buffer);
mcf_utfwk_reset();
/* Generate OTA Case - 2 variables */
kal_mem_set(&ota_input, 0, sizeof(mcf_utfwk_ota_input_struct));
kal_mem_set(&var_arr, 0, sizeof(mcf_utfwk_config_variable_struct)*5);
ota_input.lid[0] = NVRAM_EF_MCF_TEST_OTA_LID;
ota_input.lid_cnt = 1;
ota_input.ota_type = MCF_UTFWK_ATTR_OTA;
ota_input.input_op = MCF_UTFWK_OTA_VARIABLE_CONFIG;
//VAL_STRUCT_3[0].ARRAY_D[4][3][2]
var_arr[0].gid = MCF_TEST_OTA_LID_BASE_GID+106;
strcpy(var_arr[0].array_index, "0$4$3$2$");
value = 12;
var_arr[0].value = &value;
var_arr[0].value_len = 1;
var_arr[0].rec_id = 1;
//val_byte_11
var_arr[1].gid = MCF_TEST_OTA_LID_BASE_GID+44;
value1 = 32;
var_arr[1].value = &value1;
var_arr[1].value_len = 1;
var_arr[1].rec_id = 1;
ota_input.input_mode.var_info.var = var_arr;
ota_input.input_mode.var_info.var_cnt = 2;
ret = mcf_utfwk_initial_env(ota_input);
if (ret == KAL_FALSE){
return ret;
}
mcf_utfwk_execute();
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
ret = KAL_FALSE;
return ret;
}
dump_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 1, var_arr[0].gid, var_arr[0].array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&value, 1, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 1, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 2) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 1, var_arr[1].gid, var_arr[1].array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&value1, 1, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 1, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 2) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
free_ctrl_buffer_set_null(dump_buffer);
mcf_utfwk_reset();
/* OP OTA Case */
kal_mem_set(&ota_input, 0, sizeof(mcf_utfwk_ota_input_struct));
kal_mem_set(&mcf_utfwk_lid_buffer,0, sizeof(nvram_ef_mcf_test_struct));
ota_input.lid[0] = NVRAM_EF_MCF_TEST_OTA_LID;
ota_input.lid_cnt = 1;
ota_input.ota_type = MCF_UTFWK_ATTR_OTA_BY_OP;
ota_input.sim_id = 0;
ota_input.sbp_id = SBP_TAG_SBPID;
strncpy(ota_input.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(ota_input.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s%c", MCF_UT_DB_FOLDER_PATH, "MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota", '\0');
ota_input.input_op = MCF_UTFWK_OTA_FILE_PATH;
strcpy(ota_input.input_mode.file_path_name, ota_data_path);
ret = mcf_utfwk_initial_env(ota_input);
if (ret == KAL_FALSE){
return ret;
}
mcf_utfwk_initial_dsbp_callback(mcf_utfwk_dsbp_callback);
mcf_utfwk_execute();
if ( kal_mem_cmp(&mcf_utfwk_lid_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
return ret;
}
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
ret = KAL_FALSE;
return ret;
}
dump_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_LID, dump_buffer, lid_info.size, 0, "") != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
if ( kal_mem_cmp(dump_buffer, &mcf_ut_test_lid_value_pattern, sizeof(nvram_ef_mcf_test_struct)) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
free_ctrl_buffer_set_null(dump_buffer);
mcf_utfwk_reset();
/* OP OTA Generate Case */
kal_mem_set(&ota_input, 0, sizeof(mcf_utfwk_ota_input_struct));
kal_mem_set(&var_arr, 0, sizeof(mcf_utfwk_config_variable_struct)*5);
kal_mem_set(&mcf_utfwk_lid_buffer,0, sizeof(nvram_ef_mcf_test_struct));
ota_input.lid[0] = NVRAM_EF_MCF_TEST_OTA_LID;
ota_input.lid_cnt = 1;
ota_input.ota_type = MCF_UTFWK_ATTR_OTA_BY_OP;
ota_input.sim_id = 0;
ota_input.sbp_id = SBP_TAG_SBPID;
strncpy(ota_input.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(ota_input.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
ota_input.input_mode.var_info.tag_type = 1;
ota_input.input_op = MCF_UTFWK_OTA_VARIABLE_CONFIG;
//VAL_BYTE_11
var_arr[0].gid = MCF_TEST_OTA_LID_BASE_GID+44;
value = 32;
var_arr[0].value = &value;
var_arr[0].value_len = 1;
var_arr[0].rec_id = 1;
//VAL_STRUCT_3[0].ARRAY_D[4][3][2]
var_arr[1].gid = MCF_TEST_OTA_LID_BASE_GID+106;
strcpy(var_arr[1].array_index, "0$4$3$2$");
value1 = 64;
var_arr[1].value = &value1;
var_arr[1].value_len = 1;
var_arr[1].rec_id = 1;
//VAL_SHORT_11
var_arr[2].gid = MCF_TEST_OTA_LID_BASE_GID+56;
sh_value = 5566;
var_arr[2].value = &sh_value;
var_arr[2].value_len = 2;
var_arr[2].rec_id = 1;
//VAL_BIT_BYTE_11.B3
var_arr[3].gid = MCF_TEST_OTA_LID_BASE_GID+21;
bit_value = 1;
var_arr[3].value = &bit_value;
var_arr[3].value_len = 1;
var_arr[3].rec_id = 1;
ota_input.input_mode.var_info.var = var_arr;
ota_input.input_mode.var_info.var_cnt = 4;
ret = mcf_utfwk_initial_env(ota_input);
if (ret == KAL_FALSE){
return ret;
}
mcf_utfwk_initial_dsbp_callback(mcf_utfwk_dsbp_callback);
mcf_utfwk_execute();
nvram_api_ret = nvram_external_get_lid_info(NVRAM_EF_MCF_TEST_OTA_LID, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
ret = KAL_FALSE;
return ret;
}
dump_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 1, var_arr[0].gid, var_arr[0].array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&value, 1, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 1, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 2) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 1, var_arr[1].gid, var_arr[1].array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&value1, 1, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 1, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 2) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 2, var_arr[2].gid, var_arr[2].array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&sh_value, 2, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 2, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 4) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
kal_mem_set(dump_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
if(mcf_utfwk_dump_result(NVRAM_EF_MCF_TEST_OTA_LID, 1, MCF_UTFWK_DUMP_ONE_VARIABLE, dump_buffer, 1, var_arr[3].gid, var_arr[3].array_index) != KAL_TRUE){
ret = KAL_FALSE;
return KAL_FALSE;
}
mcf_bytes_to_hex(&bit_value, 1, KAL_FALSE, &oring_value);
mcf_bytes_to_hex(dump_buffer, 1, KAL_FALSE, &hex_value);
if (strncmp(hex_value, oring_value, 2) != 0 ) {
ret = KAL_FALSE;
return KAL_FALSE;
}
free_ctrl_buffer_set_null(dump_buffer);
mcf_utfwk_reset();
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
#if defined(__MCF_COMBINE_FILE_SUPPORT__)
kal_uint8 test_file1[MCF_MAX_OTA_FILE_SIZE];
kal_uint8 test_file2[MCF_MAX_OTA_FILE_SIZE];
kal_uint8 output_file[MCF_MAX_OTA_FILE_SIZE];
kal_bool mcf_merge_ota_file_ut(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_char ota_data_path[512];
kal_bool ret = KAL_FALSE;
FILE *file1, *file2;
kal_char *pos;
kal_bool mcf_ret;
// ========== BASIC TEST ========== //
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "OTA_2_LIDs_ut_gid_normal.mcfota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "OTA_3_LIDs_ut_gid_normal.mcfota");
file2 = fopen(ota_data_path, "rb");
if(file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
} else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE){
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
// checksum comparasion
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
if (mcf_check_check_sum((kal_uint32 *)output_file, output_header->file_size) != 0) {
mcf_ut_format_err_str("Merge OTA buffer checksim failed!!\r\n");
return KAL_FALSE;
}
}
// ========== VALUE TEST : no encypted file========== //
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_test_struct test_lid_buffer;
mcf_tool_file_info_t *file_header;
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_ut_gid_normal.mcfota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_QUERY_ut_gid_normal.mcfota");
file2 = fopen(ota_data_path, "rb");
if (file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
}
else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
file_header = (mcf_tool_file_info_t *)test_file2;
file_header->operation_mask |= MCF_FILE_OP_AES_128;
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_GID_MERGE.mcfota");
file1 = fopen(ota_data_path, "wb");
if (file1 != NULL)
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
fwrite(output_file, 1, output_header->file_size, file1);
fclose(file1);
}
else {
return KAL_FALSE;
}
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_GID_MERGE.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_GID_MERGE.mcfota");
return KAL_FALSE;
}
}
else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test FAIL!!\r\n");
return KAL_FALSE;
}
// Record index 1
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
// Record index 2
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 2, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
}
// ========== VALUE TEST : encypted file========== //
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_test_struct test_lid_buffer;
mcf_tool_file_info_t *file_header;
kal_char password[32] = {0};
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_ut_gid_normal_AES256_RSA3072.mcfota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_QUERY_ut_gid_normal_AES256_RSA3072.mcfota");
file2 = fopen(ota_data_path, "rb");
if (file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
}
else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
// decrypt input file
file_header = (mcf_tool_file_info_t *)test_file1;
mcf_get_custom_aes_password(password);
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
file_header = (mcf_tool_file_info_t *)test_file2;
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_GID_MERGE_AES256.mcfota");
file1 = fopen(ota_data_path, "wb");
if (file1 != NULL)
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
fwrite(output_file, 1, output_header->file_size, file1);
fclose(file1);
}
else {
return KAL_FALSE;
}
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_GID_MERGE_AES256.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_GID_MERGE_AES256.mcfota");
return KAL_FALSE;
}
}
else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test FAIL!!\r\n");
return KAL_FALSE;
}
// Record index 1
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
// Record index 2
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 2, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
}
// ========== BIG FILE TEST ========== //
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_ut_big_size.mcfota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_ut_big_size.mcfota");
file2 = fopen(ota_data_path, "rb");
if(file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
} else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE){
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_merge_ota_by_op_file_ut(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_char ota_data_path[512];
kal_bool ret = KAL_FALSE;
FILE *file1, *file2;
kal_char *pos;
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MTK_OPOTA_SBPID_1.mcfopota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MTK_OPOTA_SBPID_2.mcfopota");
file2 = fopen(ota_data_path, "rb");
if (file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
}
else {
mcf_ut_format_err_str("Merge OTA by OP open file failed!!\r\n");
return KAL_FALSE;
}
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Merge OTA by OP buffer failed!!\r\n");
return KAL_FALSE;
}
// checksum comparasion
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
if (mcf_check_check_sum((kal_uint32 *)output_file, output_header->file_size) != 0) {
mcf_ut_format_err_str("Merge OTA by OP buffer checksim failed!!\r\n");
return KAL_FALSE;
}
}
// ========== VALUE TEST : no encrypted file========== //
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
nvram_ef_mcf_test_struct test_lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = { 0 };
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_tool_file_info_t *file_header;
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_TLVOTA_SBP_full_ut_gid_normal.mcfopota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
file2 = fopen(ota_data_path, "rb");
if (file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
}
else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
file_header = (mcf_tool_file_info_t *)test_file2;
//file_header->operation_mask |= MCF_FILE_OP_AES_128;
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_BY_OP_GID_MERGE.mcfota");
file1 = fopen(ota_data_path, "wb");
if (file1 != NULL)
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
fwrite(output_file, 1, output_header->file_size, file1);
fclose(file1);
}
else {
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
/* Fill TLV-OTA file into buffer */
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_OTA_BY_OP_GID_MERGE.mcfota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_BY_OP_GID_MERGE.mcfota");
return KAL_FALSE;
}
}
else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
}
// ========== VALUE TEST : encrypted file========== //
{
mcf_t *pMcf = mcf_get_instance();
mcf_tool_file_info_t *pFile;
mcf_tool_gid_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
nvram_ef_mcf_test_struct test_lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = { 0 };
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
mcf_ota_result_e mcf_ret;
kal_bool ret;
mcf_tool_file_info_t *file_header;
kal_char password[32] = {0};
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_TLVOTA_SBP_full_ut_gid_normal_AES256_RSA3072.mcfopota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_TLVOTA_SBP_partial_ut_gid_normal_AES256_RSA3072.mcfopota");
file2 = fopen(ota_data_path, "rb");
if (file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
}
else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
// decrypt input file
file_header = (mcf_tool_file_info_t *)test_file1;
mcf_get_custom_aes_password(password);
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
file_header = (mcf_tool_file_info_t *)test_file2;
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MCF_OTA_BY_OP_GID_MERGE_AES256.mcfota");
file1 = fopen(ota_data_path, "wb");
if (file1 != NULL)
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
fwrite(output_file, 1, output_header->file_size, file1);
fclose(file1);
}
else {
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
/* Fill TLV-OTA file into buffer */
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
if (tlvota_file) {
l4c_mcf_path_type_enum *apply_path_type;
kal_char apply_filename[256],
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_OTA_BY_OP_GID_MERGE_AES256.mcfota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
mcf_read_tlvota_file(KAL_FALSE, i, "", "", &apply_path_type, apply_filename, pMcf);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_BY_OP_GID_MERGE_AES256.mcfota");
return KAL_FALSE;
}
}
else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
}
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_uint8 gid_buffer[256];
kal_bool mcf_merge_one_gid_ut(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret = KAL_FALSE;
mcf_tool_gid_ota_file_item_t *ota_gid;
mcf_tool_gid_tlvota_file_item_t *ota_by_op_gid;
kal_uint32 *value;
kal_mem_set(gid_buffer, 0, sizeof(gid_buffer));
ota_gid = gid_buffer;
ota_gid->global_id = 5103;
ota_gid->record_idx = 1;
ota_gid->value_len = 4;
value = &ota_gid->buff_start;
*value = 6;
ota_gid->total_len = (kal_uint32)&ota_gid->buff_start + ota_gid->value_len - (kal_uint32)gid_buffer;
mcf_merge_one_gid(ota_gid, MCF_TYPE_OTA, output_file, sizeof(output_file), MCF_FILE_OP_CHECKSUM);
// check result
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
kal_uint8 *current_pos = NULL;
if (output_header->item_num != 1) {
mcf_ut_format_err_str("Merge one gid item_num FAIL!!\r\n");
return KAL_FALSE;
}
if (output_header->operation_mask != MCF_FILE_OP_CHECKSUM) {
mcf_ut_format_err_str("Merge one gid mask FAIL!!\r\n");
return KAL_FALSE;
}
if (mcf_check_check_sum((kal_uint32 *)output_file, output_header->file_size) != 0) {
mcf_ut_format_err_str("Merge one gid checksum failed!!\r\n");
return KAL_FALSE;
}
current_pos = (kal_uint8 *)output_header + output_header->total_len;
if (kal_mem_cmp(ota_gid, current_pos, ota_gid->total_len)) {
mcf_ut_format_err_str("Merge one gid value failed!!\r\n");
return KAL_FALSE;
}
}
kal_mem_set(gid_buffer, 0, sizeof(gid_buffer));
ota_by_op_gid = gid_buffer;
ota_by_op_gid->global_id = 5103;
ota_by_op_gid->value_len = 4;
ota_by_op_gid->tag_type = MCF_TLVOTA_TAG_SBPID;
ota_by_op_gid->tag_len = strlen(SBP_FULL_TAG);
strcpy((kal_uint32)&ota_by_op_gid->buff_start, SBP_FULL_TAG);
value = &ota_by_op_gid->buff_start + ota_by_op_gid->tag_len;
*value = 6;
ota_by_op_gid->total_len = (kal_uint32)&ota_by_op_gid->buff_start + ota_by_op_gid->value_len + ota_by_op_gid->tag_len - (kal_uint32)gid_buffer;
mcf_merge_one_gid(ota_by_op_gid, MCF_TYPE_OTA_BY_OP, output_file, sizeof(output_file), MCF_FILE_OP_CHECKSUM);
// check result
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
kal_uint8 *current_pos = NULL;
if (output_header->item_num != 1) {
mcf_ut_format_err_str("Merge one gid item_num FAIL!!\r\n");
return KAL_FALSE;
}
if (output_header->operation_mask != MCF_FILE_OP_CHECKSUM) {
mcf_ut_format_err_str("Merge one gid mask FAIL!!\r\n");
return KAL_FALSE;
}
if (mcf_check_check_sum((kal_uint32 *)output_file, output_header->file_size) != 0) {
mcf_ut_format_err_str("Merge one gid checksum failed!!\r\n");
return KAL_FALSE;
}
current_pos = (kal_uint8 *)output_header + output_header->total_len;
if (kal_mem_cmp(ota_by_op_gid, current_pos, ota_by_op_gid->total_len)) {
mcf_ut_format_err_str("Merge one gid value failed!!\r\n");
return KAL_FALSE;
}
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_merge_ota_by_op_merge_one_gid_ut(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_char ota_data_path[512];
kal_bool ret = KAL_FALSE;
FILE *file1, *file2;
kal_char *pos;
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "MTK_OPOTA_SBPID_1.mcfopota");
file1 = fopen(ota_data_path, "rb");
if (file1 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
}
else {
mcf_ut_format_err_str("Merge OTA by OP open file failed!!\r\n");
return KAL_FALSE;
}
mcf_tool_gid_tlvota_file_item_t *ota_by_op_gid;
kal_uint32 *value;
kal_mem_set(gid_buffer, 0, sizeof(gid_buffer));
ota_by_op_gid = gid_buffer;
ota_by_op_gid->global_id = 5103;
ota_by_op_gid->value_len = 4;
ota_by_op_gid->tag_type = MCF_TLVOTA_TAG_SBPID;
ota_by_op_gid->tag_len = strlen(SBP_FULL_TAG);
strcpy((kal_uint32)&ota_by_op_gid->buff_start, SBP_FULL_TAG);
value = &ota_by_op_gid->buff_start + ota_by_op_gid->tag_len;
*value = 6;
ota_by_op_gid->total_len = (kal_uint32)&ota_by_op_gid->buff_start + ota_by_op_gid->value_len + ota_by_op_gid->tag_len - (kal_uint32)gid_buffer;
mcf_merge_one_gid(ota_by_op_gid, MCF_TYPE_OTA_BY_OP, test_file2, sizeof(test_file2), MCF_FILE_OP_CHECKSUM);
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Merge OTA by OP buffer failed!!\r\n");
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_merge_encrypted_ota_file_ut(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_char ota_data_path[512];
kal_bool ret = KAL_FALSE;
FILE *file1, *file2;
kal_char *pos;
kal_bool mcf_ret;
kal_char password[32] = {0};
mcf_tool_file_info_t *file_header;
// ========== BASIC TEST ========== //
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "AES256_SHA256_RSA2048.mcfota");
file1 = fopen(ota_data_path, "rb");
getcwd(ota_data_path, sizeof(ota_data_path));
pos = strstr(ota_data_path, "mcu");
kal_sprintf(pos + strlen("mcu"), "\\%s\\%s", MCF_UT_DB_FOLDER_PATH, "AES256_SHA384_RSA3072.mcfota");
file2 = fopen(ota_data_path, "rb");
if(file1 != NULL && file2 != NULL)
{
kal_mem_set(test_file1, 0, sizeof(test_file1));
fread(test_file1, sizeof(test_file1), 1, file1);
fclose(file1);
kal_mem_set(test_file2, 0, sizeof(test_file2));
fread(test_file2, sizeof(test_file2), 1, file2);
fclose(file2);
} else {
mcf_ut_format_err_str("Merge OTA open file failed!!\r\n");
return KAL_FALSE;
}
// decrypt input file
file_header = (mcf_tool_file_info_t *)test_file1;
mcf_get_custom_aes_password(password);
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
file_header = (mcf_tool_file_info_t *)test_file2;
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
ret = mcf_merge_ota_buffer(test_file1, test_file2, output_file, sizeof(output_file));
if (ret == KAL_FALSE){
mcf_ut_format_err_str("Merge OTA buffer failed!!\r\n");
return KAL_FALSE;
}
// decrypt merge file
file_header = (mcf_tool_file_info_t *)output_file;
if (mcf_decrypt_256bit(password, (kal_char *)file_header + file_header->total_len, (file_header->file_size - file_header->total_len)) != KAL_TRUE)
return KAL_FALSE;
// checksum comparasion
{
mcf_tool_file_info_t *output_header = (mcf_tool_file_info_t *)output_file;
if (mcf_check_check_sum((kal_uint32 *)output_file, output_header->file_size) != 0) {
mcf_ut_format_err_str("Merge OTA buffer checksim failed!!\r\n");
return KAL_FALSE;
}
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_combined_ota_file(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
kal_uint8 *lid_buffer;
nvram_ef_mcf_test_struct empty_buffer = {0};
mcf_ota_result_e mcf_ret;
kal_bool ret;
kal_uint32 i;
nvram_ef_mcf_test_struct nv_lid_buffer;
nvram_ef_mcf_test_struct test_lid_buffer;
l4c_mcf_set_config_req_struct *assigned_file_req;
l4c_mcf_set_config_req_struct *combined_file_req;
mcf_tool_gid_tlvota_file_item_t *pItem;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
mcf_tlvota_sbp_tag_t sbp_tag;
sbp_reconfig_custom_param_struct param_ptr;
mcf_ut_init();
/*
* Merge two file positive test - Same path
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
assigned_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
assigned_file_req->op = L4C_MCF_CONFIG_ASSIGN_COMBINED_PATH;
assigned_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
assigned_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(assigned_file_req->config1,"MCF_OTA_ut_merge.mcfota");
if(mcf_assign_combined_file_path(assigned_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Assign combined OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)assigned_file_req);
/* First apply MCF_OTA_ut_gid_normal - reset */
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_ut_normal.mcfota");
combined_file_req->reset = KAL_TRUE;
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
/* Second. apply MCF_OTA_QUERY_ut_gid_normal.mcfota - append */
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_QUERY_ut_gid_normal.mcfota");
combined_file_req->reset = KAL_FALSE;
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(mcf_file_buffer, ota_file->buff, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
if(mcf_merge_ota_buffer(mcf_file_buffer, ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE) != KAL_TRUE){
mcf_ut_format_err_str("Merge OTA file FAIL!!\r\n");
ret = KAL_FALSE;
MCF_R_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
return ret;
}
MCF_R_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.path,MCF_FS_CUSTOM_FOLDER_PATH) != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.name,"MCF_OTA_ut_merge.mcfota") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy((kal_char *)(ota_file->buff), mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
//first reset NVRAM_EF_MCF_TEST_OTA_LID
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_QUERY_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Merge two file positive test - different path
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
kal_mem_set(&nv_int_info, 0, sizeof(nvram_ef_mcf_internal_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, 1, (kal_uint8 *)&nv_int_info, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
mcf_ut_format_err_str("Fail to write NVRAM_EF_MCF_INTERNAL_INFO_LID to NVRAM!!\r\n");
return KAL_FALSE;
}
assigned_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
assigned_file_req->op = L4C_MCF_CONFIG_ASSIGN_COMBINED_PATH;
assigned_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
assigned_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(assigned_file_req->config1,"MCF_OTA_ut_merge.mcfota");
if(mcf_assign_combined_file_path(assigned_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Assign combined OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)assigned_file_req);
/* First apply MCF_OTA_ut_gid_normal - reset */
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_ut_normal.mcfota");
combined_file_req->reset = KAL_TRUE;
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
/* Second. apply MCF_OTA_QUERY_ut_gid_normal.mcfota - append */
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_QUERY_ut_gid_normal.mcfota");
combined_file_req->reset = KAL_FALSE;
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(mcf_file_buffer, ota_file->buff, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
if(mcf_merge_ota_buffer(mcf_file_buffer, ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE) != KAL_TRUE){
mcf_ut_format_err_str("Merge OTA file FAIL!!\r\n");
ret = KAL_FALSE;
MCF_R_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
return ret;
}
MCF_R_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.path,MCF_FS_CUSTOM_FOLDER_PATH) != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.name,"MCF_OTA_ut_merge.mcfota") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy((kal_char *)(ota_file->buff), mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
//first reset, second append
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_QUERY_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Merge two file positive test - Same path - both of reset
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
kal_mem_set(&nv_int_info, 0, sizeof(nvram_ef_mcf_internal_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, 1, (kal_uint8 *)&nv_int_info, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
mcf_ut_format_err_str("Fail to write NVRAM_EF_MCF_INTERNAL_INFO_LID to NVRAM!!\r\n");
return KAL_FALSE;
}
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
kal_mem_set(&nv_int_info, 0, sizeof(nvram_ef_mcf_internal_info_struct));
assigned_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
assigned_file_req->op = L4C_MCF_CONFIG_ASSIGN_COMBINED_PATH;
assigned_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
assigned_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(assigned_file_req->config1,"MCF_OTA_ut_merge.mcfota");
if(mcf_assign_combined_file_path(assigned_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Assign combined OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)assigned_file_req);
/* First. apply MCF_OTA_QUERY_ut_gid_normal.mcfota - reset */
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_QUERY_ut_gid_normal.mcfota");
combined_file_req->reset = KAL_TRUE;
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
/* Second apply MCF_OTA_ut_gid_normal - reset */
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_ut_gid_normal.mcfota");
combined_file_req->reset = KAL_TRUE;
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.path,MCF_FS_CUSTOM_FOLDER_PATH) != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.name,"MCF_OTA_ut_gid_normal.mcfota") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
//Due to reset, need to reset
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if (kal_mem_cmp(&test_lid_buffer, &empty_buffer, sizeof(nvram_ef_mcf_test_struct)) != 0) {
mcf_ut_format_err_str("Reset LID FAIL!!\r\n");
return KAL_FALSE;
}
/*
* Merge two file positive test - Same path - both of append
*/
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&mcf_last_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
kal_mem_set(&mcf_curr_mod_lid_g, 0, sizeof(nvram_mcf_lid_info_struct));
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
kal_mem_set(&nv_int_info, 0, sizeof(nvram_ef_mcf_internal_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, 1, (kal_uint8 *)&nv_int_info, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
mcf_ut_format_err_str("Fail to write NVRAM_EF_MCF_INTERNAL_INFO_LID to NVRAM!!\r\n");
return KAL_FALSE;
}
assigned_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
assigned_file_req->op = L4C_MCF_CONFIG_ASSIGN_COMBINED_PATH;
assigned_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
assigned_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(assigned_file_req->config1,"MCF_OTA_ut_merge.mcfota");
if(mcf_assign_combined_file_path(assigned_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Assign combined OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)assigned_file_req);
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_set(ota_file->buff, 0, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
/* First. apply MCF_OTA_QUERY_ut_gid_normal.mcfota - append */
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_QUERY_ut_gid_normal.mcfota");
combined_file_req->reset = KAL_FALSE;
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_QUERY_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_QUERY_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
/* Second apply MCF_OTA_ut_gid_normal - append */
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_OTA_ut_normal.mcfota");
combined_file_req->reset = KAL_FALSE;
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(mcf_file_buffer, ota_file->buff, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
if(mcf_merge_ota_buffer(mcf_file_buffer, ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE) != KAL_TRUE){
mcf_ut_format_err_str("Merge OTA file FAIL!!\r\n");
ret = KAL_FALSE;
MCF_R_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
return ret;
}
MCF_R_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.path,MCF_FS_CUSTOM_FOLDER_PATH) != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.name,"MCF_OTA_ut_merge.mcfota") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy((kal_char *)(ota_file->buff), mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
//Due to append, no need to reset
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_QUERY_LID);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_ota_buffer(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 1, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read OTA by LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read OTA by LID positive test FAIL!!\r\n");
return KAL_FALSE;
}
//Deactive combine OTA
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_DEFAULT_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"");
combined_file_req->reset = KAL_FALSE;
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
ret = mcf_ut_open_test_data("MCF_OTA_ut_gid_normal.mcfota", (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_OTA_ut_gid_normal.mcfota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.path,"") != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_ota_file.name,"") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Do full OTA FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value(NULL);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Do full OTA positive test (Both SW verno of file and MD mismatch) FAIL!!\r\n");
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset(NVRAM_EF_MCF_TEST_OTA_LID);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
/*
* Read TLV-OTA by LID & sbp_tag positive test - partially matched tag
* NVRAM_EF_MCF_TEST_OTA_LID with tag SBP_PARTIAL_TAG (12_NA_NA), but user searches SBP_FULL_TAG (12_33_21)
*/
/* Fill TLV-OTA file into buffer */
/*Merge two OP-OTA file positive test - Same path */
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
kal_mem_set(&nv_int_info, 0, sizeof(nvram_ef_mcf_internal_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, 1, (kal_uint8 *)&nv_int_info, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
mcf_ut_format_err_str("Fail to write NVRAM_EF_MCF_INTERNAL_INFO_LID to NVRAM!!\r\n");
return KAL_FALSE;
}
/*Assign merged file name*/
assigned_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
assigned_file_req->op = L4C_MCF_CONFIG_ASSIGN_COMBINED_PATH;
assigned_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
assigned_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(assigned_file_req->config1,"MCF_OPOTA_ut_merge.mcfopota");
if(mcf_assign_combined_file_path(assigned_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Assign combined OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)assigned_file_req);
/* First. apply MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota - reset */
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
combined_file_req->reset = KAL_TRUE;
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
/* Second. apply MCF_TLVOTA_SBP_full_ut_gid_query_normal.mcfopota - append */
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_TLVOTA_SBP_full_ut_gid_query_normal.mcfopota");
combined_file_req->reset = KAL_FALSE;
tlvota_file = &(pMcf->tlvota_file[0]);
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
//Due to append, no need to reset
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, 0);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, 0);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 3 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(mcf_file_buffer, (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_full_ut_gid_query_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_full_ut_gid_query_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
if(mcf_merge_ota_buffer(mcf_file_buffer, tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE) != KAL_TRUE){
//XXX
ret = MCF_OTA_R_INVALID_PARAMETER;
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
return ret;
}
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLVOTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_tlvota_file.path,MCF_FS_CUSTOM_FOLDER_PATH) != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_tlvota_file.name,"MCF_OPOTA_ut_merge.mcfopota") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}
// NVRAM_EF_MCF_TEST_OTA_LID with SBP_PARTIAL_TAG
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(0, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", 0, mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&test_lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(0, sbp_tag, NVRAM_EF_MCF_TEST_OTA_QUERY_LID, (kal_uint8 *)&test_lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", 0, mcf_ret);
return KAL_FALSE;
}
ret = mcf_check_test_lid_value((kal_uint8 *)&test_lid_buffer);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag positive test (partially matched tag) FAIL!!\r\n");
return KAL_FALSE;
}
/* Test By OP merged reset */
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
kal_mem_set(&nv_int_info, 0, sizeof(nvram_ef_mcf_internal_info_struct));
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, 1, (kal_uint8 *)&nv_int_info, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
mcf_ut_format_err_str("Fail to write NVRAM_EF_MCF_INTERNAL_INFO_LID to NVRAM!!\r\n");
return KAL_FALSE;
}
/*Assign merged file name*/
assigned_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
assigned_file_req->op = L4C_MCF_CONFIG_ASSIGN_COMBINED_PATH;
assigned_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
assigned_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(assigned_file_req->config1,"MCF_OPOTA_ut_merge.mcfopota");
if(mcf_assign_combined_file_path(assigned_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Assign combined OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)assigned_file_req);
/* First. apply MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota - reset */
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota");
combined_file_req->reset = KAL_TRUE;
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_3LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
/* Second. apply MCF_TLVOTA_SBP_partial_ut_2LIDs_gid_normal.mcfopota - append */
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_TLVOTA_SBP_partial_ut_2LIDs_gid_normal.mcfopota");
combined_file_req->reset = KAL_FALSE;
combined_file_req->trigger_dsbp = KAL_TRUE;
tlvota_file = &(pMcf->tlvota_file[0]);
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(mcf_file_buffer, (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_2LIDs_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_2LIDs_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
if(mcf_merge_ota_buffer(mcf_file_buffer, tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE) != KAL_TRUE){
//XXX
ret = MCF_OTA_R_INVALID_PARAMETER;
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
return ret;
}
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}
free_local_para((local_para_struct *)combined_file_req);
if ( !nvram_external_read_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLVOTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_tlvota_file.path,MCF_FS_CUSTOM_FOLDER_PATH) != 0){
mcf_ut_format_err_str("Fail to store file path!!\r\n");
return KAL_FALSE;
}
if(strcmp(nv_tlvota_file.name,"MCF_OPOTA_ut_merge.mcfopota") != 0){
mcf_ut_format_err_str("Fail to store file name!!\r\n");
return KAL_FALSE;
}
MCF_R_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = 0;
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//Due to append, no need to reset
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, 0);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, 0);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, 0);
if (ret != KAL_FALSE) {
mcf_ut_format_err_str("Check LID need reset positive test (Modify 2 LIDs) FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_set_config_after_dsbp(0);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("can not set config. ret(%d) \r\n", ret);
return KAL_FALSE;
}
//Apply MCF_TLVOTA_SBP_partial_ut_gid_normal with reset
combined_file_req = (l4c_mcf_set_config_req_struct *)construct_local_para(sizeof(l4c_mcf_set_config_req_struct), TD_RESET);
combined_file_req->op = L4C_MCF_CONFIG_SET_FILE_PATH_AND_AUTO_SELECT_BIN;
combined_file_req->config_type = L4C_MCF_CONFIG_TYPE_CARRIER_BIN;
combined_file_req->path_type = L4C_MCF_PATH_TYPE_RUNTIME;
strcpy(combined_file_req->config1,"MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
combined_file_req->reset = KAL_TRUE;
combined_file_req->trigger_dsbp = KAL_TRUE;
tlvota_file = &(pMcf->tlvota_file[0]);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + sizeof(mcf_tool_file_info_t));
ret = mcf_ut_open_test_data("MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota", (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE);
if (ret == KAL_FALSE) {
mcf_ut_format_err_str("Open test data(%s) FAIL!! \r\n", "MCF_TLVOTA_SBP_partial_ut_gid_normal.mcfopota");
return KAL_FALSE;
}
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
if(mcf_combined_ota_file(combined_file_req) != MCF_OTA_R_SUCCESS){
mcf_ut_format_err_str("Combine OTA fail!! \r\n");
return KAL_FALSE;
}
free_local_para((local_para_struct *)combined_file_req);
param_ptr.sbp_id = SBP_TAG_SBPID;
param_ptr.ps_id = 0;
kal_mem_cpy(param_ptr.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
kal_mem_cpy(param_ptr.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
kal_mem_set(param_ptr.iccid, 0, 21);
ret = mcf_auto_select_tlvota_file(&param_ptr);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("auto select tlvota file FAIL!! ret(%d) \r\n", ret);
return KAL_FALSE;
}
//Due to reset, need to reset
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_MCF_TEST_OTA_LID, 0);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset reset test FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_MCF_TEST_OTA_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_IMS_PROFILE_LID, 0);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset reset test FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_IMS_PROFILE_LID);
return KAL_FALSE;
}
ret = mcf_check_lid_need_reset_by_psid(NVRAM_EF_XCAP_PROFILE_LID, 0);
if (ret != KAL_TRUE) {
mcf_ut_format_err_str("Check LID need reset reset test FAIL!! ret(%d), LID(%d) \r\n", ret, NVRAM_EF_XCAP_PROFILE_LID);
return KAL_FALSE;
}
MCF_UT_PASS();
return KAL_TRUE;
}
kal_bool mcf_ut_write_variable_value(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_bool ret;
l4c_mcf_variable_value_operation_req_struct *req = NULL;
l4c_mcf_variable_value_operation_cnf_struct *cnf = NULL;
mcf_ota_result_e mcf_ret = MCF_OTA_R_SUCCESS;
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tool_file_info_t *pFile = (mcf_tool_file_info_t *)(ota_file->buff);
nvram_ef_mcf_ota_file_info_struct nv_ota_file;
nvram_ef_mcf_sw_info_struct nv_sw_info;
mcf_tlvota_file_t *tlvota_file;
nvram_ef_mcf_tlvota_file_info_struct nv_tlvota_file;
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint8 i;
kal_uint8 test_pattern[512];
kal_uint8 array_tag[16];
nvram_ef_mcf_test_struct nv_lid_buffer;
kal_uint32 int_value;
kal_char value[256];
kal_uint16 sh_value;
nvram_ef_mcf_test_struct lid_buffer;
l4c_mcf_variable_value_operation_req_struct *query_req = NULL;
l4c_mcf_variable_value_operation_cnf_struct *query_cnf = NULL;
double db_value;
float fl_value;
kal_uint8 ch_value;
mcf_ut_init();
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+44;
req->rec_id = 1;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 64;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_byte_11), 1, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BYTE_11, %s, %s\r\n", req->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//Bit operation - VAL_BIT_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+18;
req->rec_id = 1;
req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 255;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_bit_byte_11), 1, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_11, %s, %s\r\n", req->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//Bit operation - VAL_BIT_BYTE_11.B3
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+21;
req->rec_id = 1;
req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 255;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
query_req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
query_req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
query_req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
query_req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
query_req->num = MCF_TEST_OTA_LID_BASE_GID+21;
query_req->rec_id = 1;
query_req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(query_req->config, array_tag);
query_cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(query_req, query_cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp((query_cnf->value), "01", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
free_local_para((local_para_struct *)query_req);
free_local_para((local_para_struct *)query_cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//Bit operation - val_bit_byte_12
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+27;
req->rec_id = 1;
req->len = 1;
strcpy(req->config, "");
int_value = 16;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_bit_byte_12), 1, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_12, %s, %s\r\n", req->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//Bit operation - val_bit_byte_12.L4b
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+29;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
int_value = 15;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
query_req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
query_req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
query_req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OTA;
query_req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
query_req->num = MCF_TEST_OTA_LID_BASE_GID+29;
query_req->rec_id = 1;
query_req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(query_req->config, array_tag);
query_cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(query_req, query_cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp(query_cnf->value, "0F", cnf->len*2+2) != 0){
mcf_ut_format_err_str("val_bit_byte_12.F4b, %s, %s\r\n", cnf->value, "0F");
return KAL_FALSE;
}
if(query_cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12.F4b, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
free_local_para((local_para_struct *)query_req);
free_local_para((local_para_struct *)query_cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//short operation - val_short_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+56;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
sh_value = 256;
mcf_bytes_to_hex(&sh_value, 2, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_short_11), 2, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_short_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_short_11, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//double operation - val_double_1
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+48;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "");
db_value = 6.6;
mcf_bytes_to_hex(&db_value, 8, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_double_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_double_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 8){
mcf_ut_format_err_str("val_double_1, %d, %d\r\n", cnf->len, 8);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//buffer operation - val_buffer_1[0]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+42;
req->rec_id = 1;
req->len = 1;
strcpy(req->config, "0");
ch_value = 'M';
mcf_bytes_to_hex(&ch_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1[0], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_buffer_1[0], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//float operation - val_struct_1.vfloat
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+78;
req->rec_id = 1;
req->len = 4;
strcpy(req->config, "");
fl_value = 0.4;
mcf_bytes_to_hex(&fl_value, 4, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_struct_1.vfloat), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_struct_1.vfloat, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_struct_1.vfloat, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//int in struct operation - val_struct_3[0].vint
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+125;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "0");
int_value = 66;
mcf_bytes_to_hex(&int_value, 4, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_struct_3[0].vint), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_struct_3[0].vint, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_struct_3[0].vint, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//buffer in struct operation - VAL_STRUCT_3[3].VBUFFER[2][4][5]
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+120;
req->rec_id = 1;
req->len = 0;
strcpy(req->config, "3,2,4,5");
ch_value = 'C';
mcf_bytes_to_hex(&ch_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_struct_3[3].vbuffer[2]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[3].VBUFFER[2][4][5], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[3].VBUFFER[2][4][5], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
//Test value byte is not equal to variable size
/* Write MCF OTA file version to NVRAM */
kal_mem_set(&nv_ota_file, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
strncpy(nv_ota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_ota_file.name, MCF_FS_DEFAULT_OTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, 1, (kal_uint8 *)&nv_ota_file, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&nv_sw_info, 0, sizeof(nvram_ef_mcf_sw_info_struct));
strncpy(nv_sw_info.last_update_file.sw_version, MCF_UT_SW_VERNO, MCF_FILE_MAX_SW_VERSION_LEN);
strncpy(nv_sw_info.last_update_file.gen_time, MCF_UT_GEN_TIME, MCF_FILE_MAX_GEN_TIME_LEN);
strcpy(nv_sw_info.last_update_file.path, "");
strcpy(nv_sw_info.last_update_file.name, "");
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, 1, (kal_uint8 *)&nv_sw_info, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF sw info to NVRAM!!\r\n");
return KAL_FALSE;
}
//buffer operation - val_long_1
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = 5113;
req->rec_id = 1;
req->len = 1;
strcpy((kal_char *)(req->value), "be15");
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_cpy(ota_file->buff, mcf_merge_buffer, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Do full OTA FAIL!! Fail to take write lock! \r\n");
return KAL_FALSE;
}
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Reset LID FAIL!! ret(%d) \r\n", mcf_ret);
return KAL_FALSE;
}
if ( !nvram_external_read_data(NVRAM_EF_MCF_TEST_OTA_LID, 1, &lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
printf("Fail to read NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
ret = KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_long_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp(test_pattern, "BE15000000000000", cnf->len*2) != 0){
mcf_ut_format_err_str("val_long_1, %s, %s\r\n", "BE15000000000000", test_pattern);
return KAL_FALSE;
}
if(cnf->len != 8){
mcf_ut_format_err_str("val_long_1, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
/*Test TLVOTA file*/
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+44;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 64;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_byte_11), 1, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BYTE_11, %s, %s\r\n", req->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BYTE_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//Bit operation - VAL_BIT_BYTE_11
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+18;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 255;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_bit_byte_11), 1, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_11, %s, %s\r\n", req->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_11, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//Bit operation - VAL_BIT_BYTE_11.B3
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BIT_BYTE_11.B3
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+21;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 255;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
query_req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
query_req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
query_req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OPOTA;
query_req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
query_req->num = MCF_TEST_OTA_LID_BASE_GID+21;
query_req->ps_id = i;
query_req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(query_req->config, array_tag);
query_cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(query_req, query_cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp(query_cnf->value, "01", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_11.B3, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
free_local_para((local_para_struct *)query_req);
free_local_para((local_para_struct *)query_cnf);
}
//Bit operation - val_bit_byte_12
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+27;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 16;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_bit_byte_12), 1, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_bit_byte_12, %s, %s\r\n", req->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_bit_byte_12, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//Bit operation - val_bit_byte_12.L4b
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+29;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
int_value = 15;
mcf_bytes_to_hex(&int_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
query_req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
query_req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
query_req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_READ_OPOTA;
query_req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
query_req->num = MCF_TEST_OTA_LID_BASE_GID+29;
query_req->ps_id = i;
query_req->len = 0;
kal_mem_set(array_tag, 0, 16);
strcpy(query_req->config, array_tag);
query_cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_query_variable_value(query_req, query_cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BIT_BYTE_11.B3");
return KAL_FALSE;
}
if(strncmp(query_cnf->value, "0F", cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_BIT_BYTE_12.L4B, %s, %s\r\n", cnf->value, "01");
return KAL_FALSE;
}
if(query_cnf->len != 1){
mcf_ut_format_err_str("VAL_BIT_BYTE_12.L4B, %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
free_local_para((local_para_struct *)query_req);
free_local_para((local_para_struct *)query_cnf);
}
//short operation - val_short_11
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+56;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
sh_value = 256;
mcf_bytes_to_hex(&sh_value, 2, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_short_11), 2, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_short_11, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 2){
mcf_ut_format_err_str("val_short_11, %d, %d\r\n", cnf->len, 2);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//double operation - val_double_1
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+48;
req->ps_id = i;
req->len = 1;
kal_mem_set(array_tag, 0, 16);
strcpy(req->config, array_tag);
db_value = 6.6;
mcf_bytes_to_hex(&db_value, 8, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_double_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_double_1, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 8){
mcf_ut_format_err_str("val_double_1, %d, %d\r\n", cnf->len, 8);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//buffer operation - val_buffer_1[0]
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+42;
req->ps_id = i;
req->len = 1;
strcpy(req->config, "0");
ch_value = 'M';
mcf_bytes_to_hex(&ch_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_buffer_1), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_buffer_1[0], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("val_buffer_1[0], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//float operation - val_struct_1.vfloat
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+78;
req->ps_id = i;
req->len = 4;
strcpy(req->config, "");
fl_value = 0.4;
mcf_bytes_to_hex(&fl_value, 4, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_struct_1.vfloat), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_struct_1.vfloat, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_struct_1.vfloat, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//int in struct operation - val_struct_3[0].vint
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+125;
req->ps_id = i;
req->len = 0;
strcpy(req->config, "0");
int_value = 66;
mcf_bytes_to_hex(&int_value, 4, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_struct_3[0].vint), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("val_struct_3[0].vint, %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 4){
mcf_ut_format_err_str("val_struct_3[0].vint, %d, %d\r\n", cnf->len, 4);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
//buffer in struct operation - VAL_STRUCT_3[3].VBUFFER[2][4][5]
/* Write MCF TLV-OTA file version to NVRAM */
kal_mem_set(&nv_tlvota_file, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
strncpy(nv_tlvota_file.path, MCF_FS_DEFAULT_FOLDER_PATH, MCF_FILE_MAX_MD_PATH_LEN);
strncpy(nv_tlvota_file.name, MCF_FS_DEFAULT_TLVOTA_FILE_NAME, MCF_FILE_MAX_NAME_LEN);
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, 1, (kal_uint8 *)&nv_tlvota_file, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_ut_format_err_str("Fail to write MCF TLV-OTA file info to NVRAM!!\r\n");
return KAL_FALSE;
}
kal_mem_set(&sbp_tag, 0, sizeof(mcf_tlvota_sbp_tag_t));
sbp_tag.sbp_id = SBP_TAG_SBPID;
strncpy(sbp_tag.mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_TAG_SBPID;
strncpy(tlvota_file->mcc, SBP_TAG_MCC, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, SBP_TAG_MNC, MAX_MNC_STR_LEN);
//Byte operation - VAL_BYTE_11
req = (l4c_mcf_variable_value_operation_req_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_req_struct), TD_RESET);
req->op = L4C_MCF_CONFIG_VARIABLE_VALUE_OPERATION;
req->action = L4C_MCF_CONFIG_LID_VARIABLE_ACT_WRITE_OPOTA;
req->format = L4C_MCF_QUERY_VARIABLE_FORM_GID;
req->num = MCF_TEST_OTA_LID_BASE_GID+120;
req->ps_id = i;
req->len = 0;
strcpy(req->config, "3,2,4,5");
ch_value = 'C';
mcf_bytes_to_hex(&ch_value, 1, KAL_FALSE, &value);
strcpy((kal_char *)(req->value), value);
cnf = (l4c_mcf_variable_value_operation_cnf_struct *)construct_local_para(sizeof(l4c_mcf_variable_value_operation_cnf_struct), TD_RESET);
mcf_ret = mcf_set_variable_value(req, cnf);
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("GID Query Variable Value (%s) FAIL!!\r\n", "VAL_BYTE_11");
return KAL_FALSE;
}
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
kal_mem_cpy(tlvota_file->buff, mcf_merge_buffer, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
} else {
mcf_ut_format_err_str("Fail to take write lock! \r\n");
return KAL_FALSE;
}
kal_mem_set(&lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
mcf_ret = mcf_read_tlvota_buffer_sbp_tag(i, sbp_tag, NVRAM_EF_MCF_TEST_OTA_LID, (kal_uint8 *)&lid_buffer, sizeof(nvram_ef_mcf_test_struct));
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_ut_format_err_str("Read TLV-OTA by LID & sbp_tag FAIL!! i(%d), ret(%d) \r\n", i, mcf_ret);
return KAL_FALSE;
}
kal_mem_set(test_pattern,0,512);
mcf_bytes_to_hex(&(lid_buffer.val_struct_3[3].vbuffer[2]), cnf->len, KAL_FALSE, &test_pattern);
mcf_toupper((char *)test_pattern);
mcf_toupper((char *)req->value);
if(strncmp((kal_char *)(req->value), test_pattern, cnf->len*2) != 0){
mcf_ut_format_err_str("VAL_STRUCT_3[3].VBUFFER[2][4][5], %s, %s\r\n", cnf->value, test_pattern);
return KAL_FALSE;
}
if(cnf->len != 1){
mcf_ut_format_err_str("VAL_STRUCT_3[3].VBUFFER[2][4][5], %d, %d\r\n", cnf->len, 1);
return KAL_FALSE;
}
free_local_para((local_para_struct *)req);
free_local_para((local_para_struct *)cnf);
}
MCF_UT_PASS();
return KAL_TRUE;
}
#endif
kal_char mcf_ut_digest_file[MCF_MAX_OTA_FILE_SIZE];
kal_bool mcf_ut_mcf_verify_digest(void *p_param, kal_char *p_ret_err_str, kal_uint32 *p_ret_err_str_sz)
{
kal_uint32 ret = KAL_TRUE;
kal_uint32 checksum = KAL_TRUE;
mcf_tool_file_info_t *ota_file;
mcf_digest *sign;
// CASE1 : verify pure digest by SHA256+RSA2048
ret = mcf_ut_open_test_data("SHA256_RSA2048.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA256_RSA2048, ota_file, sign);
if(ret == KAL_FALSE) return KAL_FALSE;
// CASE2 : verify AES128 & digest by SHA256+RSA2048
ret = mcf_ut_open_test_data("AES128_SHA256_RSA2048.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA256_RSA2048, ota_file, sign);
if(ret == KAL_FALSE) return KAL_FALSE;
{
kal_char password[32] = { '\0' };
mcf_get_custom_aes_password(password);
mcf_decrypt_128bit((kal_char *)password, ((kal_char *)ota_file + ota_file->total_len), (ota_file->file_size - ota_file->total_len));
checksum = mcf_check_check_sum((kal_uint32 *)(ota_file), ota_file->file_size);
if(checksum != 0) return KAL_FALSE;
}
// CASE3 : verify AES256 & digest by SHA256+RSA2048
ret = mcf_ut_open_test_data("AES256_SHA256_RSA2048.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA256_RSA2048, ota_file, sign);
if(ret == KAL_FALSE) return KAL_FALSE;
{
kal_char password[32] = { '\0' };
mcf_get_custom_aes_password(password);
mcf_decrypt_256bit((kal_char *)password, ((kal_char *)ota_file + ota_file->total_len), (ota_file->file_size - ota_file->total_len));
checksum = mcf_check_check_sum((kal_uint32 *)(ota_file), ota_file->file_size);
if(checksum != 0) return KAL_FALSE;
}
// CASE4 : verify pure digest by SHA384+RSA3072
ret = mcf_ut_open_test_data("SHA384_RSA3072.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA384_RSA3072, ota_file, sign);
if(ret == KAL_FALSE) return KAL_FALSE;
// CASE5 : verify AES128 & pure digest by SHA384+RSA3072
ret = mcf_ut_open_test_data("AES128_SHA384_RSA3072.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA384_RSA3072, ota_file, sign);
if(ret == KAL_FALSE) return KAL_FALSE;
{
kal_char password[32] = { '\0' };
mcf_get_custom_aes_password(password);
mcf_decrypt_128bit((kal_char *)password, ((kal_char *)ota_file + ota_file->total_len), (ota_file->file_size - ota_file->total_len));
checksum = mcf_check_check_sum((kal_uint32 *)(ota_file), ota_file->file_size);
if(checksum != 0) return KAL_FALSE;
}
// CASE6 : verify AES256 & pure digest by SHA384+RSA3072
ret = mcf_ut_open_test_data("AES256_SHA384_RSA3072.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA384_RSA3072, ota_file, sign);
if(ret == KAL_FALSE) return KAL_FALSE;
{
kal_char password[32] = { '\0' };
mcf_get_custom_aes_password(password);
mcf_decrypt_256bit((kal_char *)password, ((kal_char *)ota_file + ota_file->total_len), (ota_file->file_size - ota_file->total_len));
checksum = mcf_check_check_sum((kal_uint32 *)(ota_file), ota_file->file_size);
if(checksum != 0) return KAL_FALSE;
}
// CASE7 : Test wrong digest for SHA256 RSA2048
ret = mcf_ut_open_test_data("wrong_SHA256_RSA2048.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA256_RSA2048, ota_file, sign);
if(ret == KAL_TRUE) return KAL_FALSE;
// CASE8 : Test wrong digest for SHA384 RSA3072
ret = mcf_ut_open_test_data("wrong_SHA384_RSA3072.mcfota", mcf_ut_digest_file, MCF_MAX_OTA_FILE_SIZE);
if(ret == KAL_FALSE) return KAL_FALSE;
ota_file = (mcf_tool_file_info_t *) mcf_ut_digest_file;
sign = (kal_char *)ota_file + ota_file->file_size;
ret = mcf_verify_digest(MCF_FILE_OP_SHA384_RSA3072, ota_file, sign);
if(ret == KAL_TRUE) return KAL_FALSE;
MCF_UT_PASS();
return KAL_TRUE;
}
/*------------------------------------------------------------------------------
* Public fucntions.
*----------------------------------------------------------------------------*/
#define MCF_UT_CASE(_func, _param) { #_func, _func, _param }
kal_bool mcf_ut_st_create(void)
{
static ST_TCASE_T mcf_ut_cases_s[] = {
MCF_UT_CASE(mcf_ut_mcf_set_file_path_dsbp_passive_mode, NULL),
MCF_UT_CASE(mcf_ut_mcf_set_file_path_dsbp_active_mode, NULL),
MCF_UT_CASE(mcf_ut_mcf_get_applied_file_path, NULL),
#if !defined(__MTK_TARGET__)
MCF_UT_CASE(mcf_ut_find_ini_item, NULL),
MCF_UT_CASE(mcf_ut_find_ini_sbp_id, NULL),
MCF_UT_CASE(mcf_ut_compose_ini_item, NULL),
MCF_UT_CASE(mcf_ut_gid_do_ota_full, NULL),
MCF_UT_CASE(mcf_ut_gid_do_ota_by_lid, NULL),
MCF_UT_CASE(mcf_ut_gid_read_ota_buffer, NULL),
MCF_UT_CASE(mcf_ut_gid_read_tlvota_buffer, NULL),
MCF_UT_CASE(mcf_ut_gid_read_tlvota_buffer_sbp, NULL),
MCF_UT_CASE(mcf_ut_gid_reset_lid_full, NULL),
MCF_UT_CASE(mcf_ut_gid_mcf_check_lid_need_reset, NULL),
MCF_UT_CASE(mcf_ut_mcf_check_ota_need_update, NULL),
MCF_UT_CASE(mcf_ut_mcf_get_tlvota_file_result, NULL),
#if defined(__MCF_COMBINE_FILE_SUPPORT__)
MCF_UT_CASE(mcf_ut_combined_ota_file, NULL),
MCF_UT_CASE(mcf_ut_write_variable_value, NULL),
#endif
#endif
#if defined(__MCF_UT_FRAMEWORK_SUPPORT__)
MCF_UT_CASE(mcf_utfwk_ut_test_flow, NULL),
MCF_UT_CASE(mcf_utfwk_sample_code_ut, NULL),
#endif
MCF_UT_CASE(mcf_ut_em_update_req_hdlr, NULL),
#if defined(__MCF_FIND_TAG_SUPPORT__)
MCF_UT_CASE(mcf_ut_find_tag, NULL),
MCF_UT_CASE(mcf_ut_config_LID, NULL),
#if !defined(__MTK_TARGET__)
MCF_UT_CASE(mcf_ut_do_ota_full, NULL),
MCF_UT_CASE(mcf_ut_do_ota_by_lid, NULL),
MCF_UT_CASE(mcf_ut_read_ota_buffer, NULL),
MCF_UT_CASE(mcf_ut_read_tlvota_buffer, NULL),
MCF_UT_CASE(mcf_ut_read_tlvota_buffer_sbp, NULL),
MCF_UT_CASE(mcf_ut_reset_lid_full, NULL),
MCF_UT_CASE(mcf_ut_mcf_check_lid_need_reset, NULL),
#endif
#endif
#if defined(__MCF_FIND_GID_SUPPORT__)
MCF_UT_CASE(mcf_ut_find_gid, NULL),
MCF_UT_CASE(mcf_ut_query_variable_value, NULL),
#endif
MCF_UT_CASE(mcf_ut_gid_mcf_check_lid_need_reset_by_psid, NULL),
MCF_UT_CASE(mcf_ut_mcf_encrypt_decrypt, NULL),
MCF_UT_CASE(mcf_ut_mcf_verify_digest, NULL),
#if defined(__MCF_COMBINE_FILE_SUPPORT__)
MCF_UT_CASE(mcf_merge_ota_file_ut, NULL),
MCF_UT_CASE(mcf_merge_ota_by_op_file_ut, NULL),
MCF_UT_CASE(mcf_merge_one_gid_ut, NULL),
MCF_UT_CASE(mcf_merge_ota_by_op_merge_one_gid_ut, NULL),
MCF_UT_CASE(mcf_merge_encrypted_ota_file_ut, NULL),
#endif
//MCF_UT_CASE(mcf_ut_mcf_boot_trace, NULL),
};
#if defined(TEST_MCF_TEST_TASK)
{
kal_uint32 i = 0;
kal_bool ret = KAL_FALSE;
kal_char p_ret_err_str[100];
kal_uint32 p_ret_err_str_sz;
for (i = 0 ; i < (sizeof(mcf_ut_cases_s)/sizeof(ST_TCASE_T)) ; i++)
{
ret = mcf_ut_cases_s[i].test_func(mcf_ut_cases_s[i].test_param, p_ret_err_str, &p_ret_err_str_sz);
if (ret == KAL_FALSE)
ASSERT(0);
}
}
#elif defined(TEST_SYS_TEST_TASK)
return st_reg_test("MCF", &(mcf_ut_cases_s[0]), (sizeof(mcf_ut_cases_s)/sizeof(ST_TCASE_T)));
#endif
}
#if defined(TEST_MCF_TEST_TASK)
kal_bool mcf_test_task_init(void)
{
return KAL_TRUE;
}
void mcf_test_task_main(task_entry_struct *task_entry_ptr)
{
ilm_struct current_ilm;
kal_set_active_module_id(MOD_MCF_TEST);
mcf_ut_st_create();
// external queue, this may suspend.*/
while(1)
{
if (KAL_TRUE == msg_receive_extq(&current_ilm)) {
// handle ILM
destroy_ilm(&current_ilm);
}
}
}
kal_bool mcf_test_create(comptask_handler_struct **handle)
{
static const comptask_handler_struct mcf_test_task_info =
{
mcf_test_task_main, /* task entry function */
mcf_test_task_init, /* task initialization function */
NULL /* task reset handler */
};
*handle = (comptask_handler_struct *)&mcf_test_task_info;
return KAL_TRUE;
}
#endif