From 2ca3253e81f1b056705ab44397550fcc2cc69c3a Mon Sep 17 00:00:00 2001 From: andysun2015 Date: Mon, 6 Sep 2021 08:32:02 +0800 Subject: [PATCH] [Cellular Library] Fix build warning message. (#37) * [Cellular Library] Fix build warning message in unit test * [Cellular Library] Correct memory estimation. * [Cellular Library] Use stack memory instead of heap memory. * [Cellular Library] Fix spelling error. --- .github/workflows/ci.yml | 2 +- common/src/cellular_3gpp_api.c | 324 ++++++++---------- common/src/cellular_pkthandler.c | 2 +- common/src/cellular_pktio.c | 8 +- docs/doxygen/include/size_table.md | 8 +- docs/doxygen/pages.dox | 4 +- include/cellular_config_defaults.h | 4 +- .../cellular_3gpp_urc_handler_utest.c | 4 + test/unit-test/cellular_at_core_utest.c | 41 +-- test/unit-test/cellular_common_utest.c | 8 + test/unit-test/cellular_pkthandler_utest.c | 5 + test/unit-test/cellular_pktio_utest.c | 54 ++- test/unit-test/cellular_platform.h | 32 +- 13 files changed, 238 insertions(+), 258 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97325db6..35278a73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_CLONE_SUBMODULES=ON \ - -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG' + -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG' make -C build/ all - name: Test run: | diff --git a/common/src/cellular_3gpp_api.c b/common/src/cellular_3gpp_api.c index 43fe92d2..b0294cf9 100644 --- a/common/src/cellular_3gpp_api.c +++ b/common/src/cellular_3gpp_api.c @@ -789,18 +789,15 @@ static CellularError_t queryNetworkStatus( CellularContext_t * pContext, CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularNetworkRegType_t recvRegType = regType; + CellularAtReq_t atReqGetResult = { 0 }; configASSERT( pContext != NULL ); - - CellularAtReq_t atReqGetResult = - { - pCommand, - CELLULAR_AT_MULTI_WITH_PREFIX, - pPrefix, - _Cellular_RecvFuncGetNetworkReg, - &recvRegType, - ( uint16_t ) sizeof( CellularNetworkRegType_t ) - }; + atReqGetResult.pAtCmd = pCommand; + atReqGetResult.atCmdType = CELLULAR_AT_MULTI_WITH_PREFIX; + atReqGetResult.pAtRspPrefix = pPrefix; + atReqGetResult.respCallback = _Cellular_RecvFuncGetNetworkReg; + atReqGetResult.pData = &recvRegType; + atReqGetResult.dataLen = ( uint16_t ) sizeof( CellularNetworkRegType_t ); pktStatus = _Cellular_AtcmdRequestWithCallback( pContext, atReqGetResult ); cellularStatus = _Cellular_TranslatePktStatus( pktStatus ); @@ -1356,15 +1353,14 @@ static CellularError_t atcmdUpdateMccMnc( CellularContext_t * pContext, { CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus; - CellularAtReq_t atReqGetMccMnc = - { - "AT+COPS?", - CELLULAR_AT_WITH_PREFIX, - "+COPS", - _Cellular_RecvFuncUpdateMccMnc, - pOperatorInfo, - ( uint16_t ) sizeof( cellularOperatorInfo_t ), - }; + CellularAtReq_t atReqGetMccMnc = { 0 }; + + atReqGetMccMnc.pAtCmd = "AT+COPS?"; + atReqGetMccMnc.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetMccMnc.pAtRspPrefix = "+COPS"; + atReqGetMccMnc.respCallback = _Cellular_RecvFuncUpdateMccMnc; + atReqGetMccMnc.pData = pOperatorInfo; + atReqGetMccMnc.dataLen = ( uint16_t ) sizeof( cellularOperatorInfo_t ); pktStatus = _Cellular_AtcmdRequestWithCallback( pContext, atReqGetMccMnc ); cellularStatus = _Cellular_TranslatePktStatus( pktStatus ); @@ -1563,15 +1559,14 @@ CellularError_t Cellular_CommonGetEidrxSettings( CellularHandle_t cellularHandle CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; - CellularAtReq_t atReqGetEidrx = - { - "AT+CEDRXS?", - CELLULAR_AT_MULTI_WITH_PREFIX, - "+CEDRXS", - _Cellular_RecvFuncGetEidrxSettings, - pEidrxSettingsList, - CELLULAR_EDRX_LIST_MAX_SIZE, - }; + CellularAtReq_t atReqGetEidrx = { 0 }; + + atReqGetEidrx.pAtCmd = "AT+CEDRXS?"; + atReqGetEidrx.atCmdType = CELLULAR_AT_MULTI_WITH_PREFIX; + atReqGetEidrx.pAtRspPrefix = "+CEDRXS"; + atReqGetEidrx.respCallback = _Cellular_RecvFuncGetEidrxSettings; + atReqGetEidrx.pData = pEidrxSettingsList; + atReqGetEidrx.dataLen = CELLULAR_EDRX_LIST_MAX_SIZE; cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -1609,15 +1604,14 @@ CellularError_t Cellular_CommonSetEidrxSettings( CellularHandle_t cellularHandle CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; char cmdBuf[ CELLULAR_AT_CMD_MAX_SIZE ] = { '\0' }; - CellularAtReq_t atReqSetEidrx = - { - cmdBuf, - CELLULAR_AT_NO_RESULT, - NULL, - NULL, - NULL, - 0, - }; + CellularAtReq_t atReqSetEidrx = { 0 }; + + atReqSetEidrx.pAtCmd = cmdBuf; + atReqSetEidrx.atCmdType = CELLULAR_AT_NO_RESULT; + atReqSetEidrx.pAtRspPrefix = NULL; + atReqSetEidrx.respCallback = NULL; + atReqSetEidrx.pData = NULL; + atReqSetEidrx.dataLen = 0; cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -1663,15 +1657,14 @@ CellularError_t Cellular_CommonRfOn( CellularHandle_t cellularHandle ) CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus; CellularPktStatus_t pktStatus; - CellularAtReq_t atReq = - { - "AT+CFUN=1", - CELLULAR_AT_NO_RESULT, - NULL, - NULL, - NULL, - 0, - }; + CellularAtReq_t atReq = { 0 }; + + atReq.pAtCmd = "AT+CFUN=1"; + atReq.atCmdType = CELLULAR_AT_NO_RESULT; + atReq.pAtRspPrefix = NULL; + atReq.respCallback = NULL; + atReq.pData = NULL; + atReq.dataLen = 0; /* Make sure library is open. */ cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -1692,15 +1685,14 @@ CellularError_t Cellular_CommonRfOff( CellularHandle_t cellularHandle ) CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus; CellularPktStatus_t pktStatus; - CellularAtReq_t atReq = - { - "AT+CFUN=4", - CELLULAR_AT_NO_RESULT, - NULL, - NULL, - NULL, - 0, - }; + CellularAtReq_t atReq = { 0 }; + + atReq.pAtCmd = "AT+CFUN=4"; + atReq.atCmdType = CELLULAR_AT_NO_RESULT; + atReq.pAtRspPrefix = NULL; + atReq.respCallback = NULL; + atReq.pData = NULL; + atReq.dataLen = 0; /* Make sure library is open. */ cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -1820,15 +1812,14 @@ CellularError_t Cellular_CommonGetNetworkTime( CellularHandle_t cellularHandle, CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; - CellularAtReq_t atReqGetNetworkTime = - { - "AT+CCLK?", - CELLULAR_AT_WITH_PREFIX, - "+CCLK", - _Cellular_RecvFuncGetNetworkTime, - pNetworkTime, - ( uint16_t ) sizeof( CellularTime_t ) - }; + CellularAtReq_t atReqGetNetworkTime = { 0 }; + + atReqGetNetworkTime.pAtCmd = "AT+CCLK?"; + atReqGetNetworkTime.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetNetworkTime.pAtRspPrefix = "+CCLK"; + atReqGetNetworkTime.respCallback = _Cellular_RecvFuncGetNetworkTime; + atReqGetNetworkTime.pData = pNetworkTime; + atReqGetNetworkTime.dataLen = ( uint16_t ) sizeof( CellularTime_t ); cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -1863,42 +1854,38 @@ CellularError_t Cellular_CommonGetModemInfo( CellularHandle_t cellularHandle, CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; - CellularAtReq_t atReqGetFirmwareVersion = - { - "AT+CGMR", - CELLULAR_AT_WO_PREFIX, - NULL, - _Cellular_RecvFuncGetFirmwareVersion, - pModemInfo->firmwareVersion, - CELLULAR_FW_VERSION_MAX_SIZE + 1U, - }; - CellularAtReq_t atReqGetImei = - { - "AT+CGSN", - CELLULAR_AT_WO_PREFIX, - NULL, - _Cellular_RecvFuncGetImei, - pModemInfo->imei, - CELLULAR_IMEI_MAX_SIZE + 1U, - }; - CellularAtReq_t atReqGetModelId = - { - "AT+CGMM", - CELLULAR_AT_WO_PREFIX, - NULL, - _Cellular_RecvFuncGetModelId, - pModemInfo->modelId, - CELLULAR_MODEL_ID_MAX_SIZE + 1U, - }; - CellularAtReq_t atReqGetManufactureId = - { - "AT+CGMI", - CELLULAR_AT_WO_PREFIX, - NULL, - _Cellular_RecvFuncGetManufactureId, - pModemInfo->manufactureId, - CELLULAR_MANUFACTURE_ID_MAX_SIZE + 1U, - }; + CellularAtReq_t atReqGetFirmwareVersion = { 0 }; + CellularAtReq_t atReqGetImei = { 0 }; + CellularAtReq_t atReqGetModelId = { 0 }; + CellularAtReq_t atReqGetManufactureId = { 0 }; + + atReqGetFirmwareVersion.pAtCmd = "AT+CGMR"; + atReqGetFirmwareVersion.atCmdType = CELLULAR_AT_WO_PREFIX; + atReqGetFirmwareVersion.pAtRspPrefix = NULL; + atReqGetFirmwareVersion.respCallback = _Cellular_RecvFuncGetFirmwareVersion; + atReqGetFirmwareVersion.pData = pModemInfo->firmwareVersion; + atReqGetFirmwareVersion.dataLen = CELLULAR_FW_VERSION_MAX_SIZE + 1U; + + atReqGetImei.pAtCmd = "AT+CGSN"; + atReqGetImei.atCmdType = CELLULAR_AT_WO_PREFIX; + atReqGetImei.pAtRspPrefix = NULL; + atReqGetImei.respCallback = _Cellular_RecvFuncGetImei; + atReqGetImei.pData = pModemInfo->imei; + atReqGetImei.dataLen = CELLULAR_IMEI_MAX_SIZE + 1U; + + atReqGetModelId.pAtCmd = "AT+CGMM"; + atReqGetModelId.atCmdType = CELLULAR_AT_WO_PREFIX; + atReqGetModelId.pAtRspPrefix = NULL; + atReqGetModelId.respCallback = _Cellular_RecvFuncGetModelId; + atReqGetModelId.pData = pModemInfo->modelId; + atReqGetModelId.dataLen = CELLULAR_MODEL_ID_MAX_SIZE + 1U; + + atReqGetManufactureId.pAtCmd = "AT+CGMI"; + atReqGetManufactureId.atCmdType = CELLULAR_AT_WO_PREFIX; + atReqGetManufactureId.pAtRspPrefix = NULL; + atReqGetManufactureId.respCallback = _Cellular_RecvFuncGetManufactureId; + atReqGetManufactureId.pData = pModemInfo->manufactureId; + atReqGetManufactureId.dataLen = CELLULAR_MANUFACTURE_ID_MAX_SIZE + 1U; /* pContext is checked in _Cellular_CheckLibraryStatus function. */ cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -1958,15 +1945,14 @@ CellularError_t Cellular_CommonGetIPAddress( CellularHandle_t cellularHandle, CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; char cmdBuf[ CELLULAR_AT_CMD_TYPICAL_MAX_SIZE ] = { '\0' }; - CellularAtReq_t atReqGetIp = - { - cmdBuf, - CELLULAR_AT_WITH_PREFIX, - "+CGPADDR", - _Cellular_RecvFuncIpAddress, - pBuffer, - ( uint16_t ) bufferLength - }; + CellularAtReq_t atReqGetIp = { 0 }; + + atReqGetIp.pAtCmd = cmdBuf; + atReqGetIp.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetIp.pAtRspPrefix = "+CGPADDR"; + atReqGetIp.respCallback = _Cellular_RecvFuncIpAddress; + atReqGetIp.pData = pBuffer; + atReqGetIp.dataLen = ( uint16_t ) bufferLength; /* Make sure the library is open. */ cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -2082,15 +2068,14 @@ CellularError_t Cellular_CommonSetPdnConfig( CellularHandle_t cellularHandle, CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; char cmdBuf[ CELLULAR_AT_CMD_MAX_SIZE ] = { '\0' }; char pPdpTypeStr[ CELULAR_PDN_CONTEXT_TYPE_MAX_SIZE ] = { '\0' }; - CellularAtReq_t atReqSetPdn = - { - cmdBuf, - CELLULAR_AT_NO_RESULT, - NULL, - NULL, - NULL, - 0, - }; + CellularAtReq_t atReqSetPdn = { 0 }; + + atReqSetPdn.pAtCmd = cmdBuf; + atReqSetPdn.atCmdType = CELLULAR_AT_NO_RESULT; + atReqSetPdn.pAtRspPrefix = NULL; + atReqSetPdn.respCallback = NULL; + atReqSetPdn.pData = NULL; + atReqSetPdn.dataLen = 0; if( pPdnConfig == NULL ) { @@ -2597,15 +2582,14 @@ CellularError_t Cellular_CommonGetSimCardLockStatus( CellularHandle_t cellularHa CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; - CellularAtReq_t atReqGetSimLockStatus = - { - "AT+CPIN?", - CELLULAR_AT_WITH_PREFIX, - "+CPIN", - _Cellular_RecvFuncGetSimLockStatus, - NULL, - 0, - }; + CellularAtReq_t atReqGetSimLockStatus = { 0 }; + + atReqGetSimLockStatus.pAtCmd = "AT+CPIN?"; + atReqGetSimLockStatus.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetSimLockStatus.pAtRspPrefix = "+CPIN"; + atReqGetSimLockStatus.respCallback = _Cellular_RecvFuncGetSimLockStatus; + atReqGetSimLockStatus.pData = NULL; + atReqGetSimLockStatus.dataLen = 0; /* pContext is checked in _Cellular_CheckLibraryStatus function. */ cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -2645,34 +2629,30 @@ CellularError_t Cellular_CommonGetSimCardInfo( CellularHandle_t cellularHandle, CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; - - CellularAtReq_t atReqGetIccid = - { - "AT+CCID", - CELLULAR_AT_WITH_PREFIX, - "+CCID", - _Cellular_RecvFuncGetIccid, - pSimCardInfo->iccid, - CELLULAR_ICCID_MAX_SIZE + 1U, - }; - CellularAtReq_t atReqGetImsi = - { - "AT+CIMI", - CELLULAR_AT_WO_PREFIX, - NULL, - _Cellular_RecvFuncGetImsi, - pSimCardInfo->imsi, - CELLULAR_IMSI_MAX_SIZE + 1U, - }; - CellularAtReq_t atReqGetHplmn = - { - "AT+CRSM=176,28514,0,0,0", /* READ BINARY commmand. HPLMN Selector with Access Technology( 6F62 ). */ - CELLULAR_AT_WITH_PREFIX, - "+CRSM", - _Cellular_RecvFuncGetHplmn, - &pSimCardInfo->plmn, - ( uint16_t ) sizeof( CellularPlmnInfo_t ), - }; + CellularAtReq_t atReqGetIccid = { 0 }; + CellularAtReq_t atReqGetImsi = { 0 }; + CellularAtReq_t atReqGetHplmn = { 0 }; + + atReqGetIccid.pAtCmd = "AT+CCID"; + atReqGetIccid.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetIccid.pAtRspPrefix = "+CCID"; + atReqGetIccid.respCallback = _Cellular_RecvFuncGetIccid; + atReqGetIccid.pData = pSimCardInfo->iccid; + atReqGetIccid.dataLen = CELLULAR_ICCID_MAX_SIZE + 1U; + + atReqGetImsi.pAtCmd = "AT+CIMI"; + atReqGetImsi.atCmdType = CELLULAR_AT_WO_PREFIX; + atReqGetImsi.pAtRspPrefix = NULL; + atReqGetImsi.respCallback = _Cellular_RecvFuncGetImsi; + atReqGetImsi.pData = pSimCardInfo->imsi; + atReqGetImsi.dataLen = CELLULAR_IMSI_MAX_SIZE + 1U; + + atReqGetHplmn.pAtCmd = "AT+CRSM=176,28514,0,0,0"; /* READ BINARY commmand. HPLMN Selector with Access Technology( 6F62 ). */ + atReqGetHplmn.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetHplmn.pAtRspPrefix = "+CRSM"; + atReqGetHplmn.respCallback = _Cellular_RecvFuncGetHplmn; + atReqGetHplmn.pData = &pSimCardInfo->plmn; + atReqGetHplmn.dataLen = ( uint16_t ) sizeof( CellularPlmnInfo_t ); /* pContext is checked in _Cellular_CheckLibraryStatus function. */ cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -2756,15 +2736,14 @@ CellularError_t Cellular_CommonSetPsmSettings( CellularHandle_t cellularHandle, CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; char cmdBuf[ CELLULAR_AT_CMD_MAX_SIZE ] = { '\0' }; uint32_t cmdBufLen = 0; - CellularAtReq_t atReqSetPsm = - { - cmdBuf, - CELLULAR_AT_NO_RESULT, - NULL, - NULL, - NULL, - 0 - }; + CellularAtReq_t atReqSetPsm = { 0 }; + + atReqSetPsm.pAtCmd = cmdBuf; + atReqSetPsm.atCmdType = CELLULAR_AT_NO_RESULT; + atReqSetPsm.pAtRspPrefix = NULL; + atReqSetPsm.respCallback = NULL; + atReqSetPsm.pData = NULL; + atReqSetPsm.dataLen = 0; cellularStatus = _Cellular_CheckLibraryStatus( pContext ); @@ -2953,15 +2932,14 @@ CellularError_t Cellular_CommonGetPsmSettings( CellularHandle_t cellularHandle, CellularContext_t * pContext = ( CellularContext_t * ) cellularHandle; CellularError_t cellularStatus = CELLULAR_SUCCESS; CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; - CellularAtReq_t atReqGetPsm = - { - "AT+CPSMS?", - CELLULAR_AT_WITH_PREFIX, - "+CPSMS", - _Cellular_RecvFuncGetPsmSettings, - pPsmSettings, - ( uint16_t ) sizeof( CellularPsmSettings_t ), - }; + CellularAtReq_t atReqGetPsm = { 0 }; + + atReqGetPsm.pAtCmd = "AT+CPSMS?"; + atReqGetPsm.atCmdType = CELLULAR_AT_WITH_PREFIX; + atReqGetPsm.pAtRspPrefix = "+CPSMS"; + atReqGetPsm.respCallback = _Cellular_RecvFuncGetPsmSettings; + atReqGetPsm.pData = pPsmSettings; + atReqGetPsm.dataLen = ( uint16_t ) sizeof( CellularPsmSettings_t ); cellularStatus = _Cellular_CheckLibraryStatus( pContext ); diff --git a/common/src/cellular_pkthandler.c b/common/src/cellular_pkthandler.c index 3b5900b7..71bd241e 100644 --- a/common/src/cellular_pkthandler.c +++ b/common/src/cellular_pkthandler.c @@ -190,7 +190,7 @@ static CellularPktStatus_t _processUrcPacket( CellularContext_t * pContext, else { pktStatus = CELLULAR_PKT_STATUS_FAILURE; - LogWarn( ( "Couldn't allocate memory of %d for urc", strlen( pBuf ) ) ); + LogWarn( ( "Couldn't allocate memory of %lu for urc", strlen( pBuf ) ) ); } } else diff --git a/common/src/cellular_pktio.c b/common/src/cellular_pktio.c index 05307a04..11271972 100644 --- a/common/src/cellular_pktio.c +++ b/common/src/cellular_pktio.c @@ -136,7 +136,7 @@ static void _saveData( char * pLine, LogDebug( ( "_saveData : Save data %p with length %d", pLine, dataLen ) ); pNew = ( CellularATCommandLine_t * ) Platform_Malloc( sizeof( CellularATCommandLine_t ) ); - configASSERT( ( int32_t ) ( pNew != NULL ) ); + configASSERT( ( pNew != NULL ) ); /* Reuse the pktio buffer instead of allocate. */ pNew->pLine = pLine; @@ -174,7 +174,7 @@ static void _saveRawData( char * pLine, static void _saveATData( char * pLine, CellularATCommandResponse_t * pResp ) { - LogDebug( ( "Save [%s] %d AT data to pResp", pLine, strlen( pLine ) ) ); + LogDebug( ( "Save [%s] %lu AT data to pResp", pLine, strlen( pLine ) ) ); _saveData( pLine, pResp, ( uint32_t ) ( strlen( pLine ) + 1U ) ); } @@ -254,7 +254,7 @@ static CellularATCommandResponse_t * _Cellular_AtResponseNew( void ) CellularATCommandResponse_t * pNew = NULL; pNew = ( CellularATCommandResponse_t * ) Platform_Malloc( sizeof( CellularATCommandResponse_t ) ); - configASSERT( ( int32_t ) ( pNew != NULL ) ); + configASSERT( ( pNew != NULL ) ); ( void ) memset( ( void * ) pNew, 0, sizeof( CellularATCommandResponse_t ) ); @@ -676,7 +676,7 @@ static CellularPktStatus_t _handleMsgType( CellularContext_t * pContext, if( *ppAtResp == NULL ) { *ppAtResp = _Cellular_AtResponseNew(); - LogDebug( ( "Allocat at response %p", *ppAtResp ) ); + LogDebug( ( "Allocate at response %p", ( void * ) *ppAtResp ) ); } LogDebug( ( "AT solicited Resp[%s]", pLine ) ); diff --git a/docs/doxygen/include/size_table.md b/docs/doxygen/include/size_table.md index 8a9f0a0a..8114a9b9 100644 --- a/docs/doxygen/include/size_table.md +++ b/docs/doxygen/include/size_table.md @@ -10,7 +10,7 @@ cellular_3gpp_api.c
6.3K
-
5.7K
+
5.8K
cellular_3gpp_urc_handler.c @@ -30,12 +30,12 @@ cellular_common.c
1.6K
-
1.4K
+
1.5K
cellular_pkthandler.c
1.4K
-
1.2K
+
1.3K
cellular_pktio.c @@ -45,6 +45,6 @@ Total estimates
13.9K
-
12.4K
+
12.7K
diff --git a/docs/doxygen/pages.dox b/docs/doxygen/pages.dox index 5055e0bb..e8d59742 100644 --- a/docs/doxygen/pages.dox +++ b/docs/doxygen/pages.dox @@ -145,8 +145,8 @@ Some configuration settings are C pre-processor constants, and some are function @section CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT @copydoc CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT -@section CELLULAR_CONFIG_STATIC_ALLOCATION_COMM_CONTEXT -@copydoc CELLULAR_CONFIG_STATIC_ALLOCATION_COMM_CONTEXT +@section CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION +@copydoc CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION @section CELLULAR_CONFIG_DEFAULT_RAT @copydoc CELLULAR_CONFIG_DEFAULT_RAT diff --git a/include/cellular_config_defaults.h b/include/cellular_config_defaults.h index 1518f78a..039dc59c 100644 --- a/include/cellular_config_defaults.h +++ b/include/cellular_config_defaults.h @@ -331,8 +331,8 @@ * Possible values:`0 or 1`
* Default value (if undefined): 0 */ -#ifndef CELLULAR_CONFIG_STATIC_ALLOCATION_COMM_CONTEXT - #define CELLULAR_CONFIG_STATIC_ALLOCATION_COMM_CONTEXT ( 0U ) +#ifndef CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION + #define CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION ( 0U ) #endif /** diff --git a/test/unit-test/cellular_3gpp_urc_handler_utest.c b/test/unit-test/cellular_3gpp_urc_handler_utest.c index 1430b038..456535e3 100644 --- a/test/unit-test/cellular_3gpp_urc_handler_utest.c +++ b/test/unit-test/cellular_3gpp_urc_handler_utest.c @@ -82,6 +82,10 @@ int suiteTearDown( int numFailures ) } /* ========================================================================== */ +void dummyDelay( uint32_t milliseconds ) +{ + ( void ) milliseconds; +} void * mock_malloc( size_t size ) { diff --git a/test/unit-test/cellular_at_core_utest.c b/test/unit-test/cellular_at_core_utest.c index 79b2f7ff..5c59acb2 100644 --- a/test/unit-test/cellular_at_core_utest.c +++ b/test/unit-test/cellular_at_core_utest.c @@ -479,7 +479,7 @@ void test_Cellular_ATRemoveAllDoubleQuote_Invalid_Param( void ) void test_Cellular_ATRemoveAllDoubleQuote_Happy_Path( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; - char * pString = malloc( sizeof( char ) * ( strlen( CELLULAR_SAMPLE_STRING_TWO_DOUBLE_QUOTE ) + 1 ) ); + char pString[ sizeof( CELLULAR_SAMPLE_STRING_TWO_DOUBLE_QUOTE ) ] = { 0 }; strcpy( pString, CELLULAR_SAMPLE_STRING_TWO_DOUBLE_QUOTE ); @@ -487,7 +487,6 @@ void test_Cellular_ATRemoveAllDoubleQuote_Happy_Path( void ) TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL_STRING( CELLULAR_SAMPLE_STRING_NO_WHITE_SPACE, pString ); - free( pString ); } /** @@ -783,7 +782,7 @@ void test_Cellular_ATcheckErrorCode_Invalid_Param( void ) cellularStatus = Cellular_ATcheckErrorCode( pString, NULL, keyListLen, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus ); - cellularStatus = Cellular_ATcheckErrorCode( pString, ppKeyList, keyListLen, NULL ); + cellularStatus = Cellular_ATcheckErrorCode( pString, ( const char * const * ) ppKeyList, keyListLen, NULL ); TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus ); } @@ -799,16 +798,16 @@ void test_Cellular_ATcheckErrorCode_Happy_Path( void ) size_t keyListLen = 2; bool Result; - cellularStatus = Cellular_ATcheckErrorCode( pString, ppKeyList, keyListLen, &Result ); + cellularStatus = Cellular_ATcheckErrorCode( pString, ( const char * const * ) ppKeyList, keyListLen, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( true, Result ); - cellularStatus = Cellular_ATcheckErrorCode( pStringError, ppKeyList, keyListLen, &Result ); + cellularStatus = Cellular_ATcheckErrorCode( pStringError, ( const char * const * ) ppKeyList, keyListLen, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( true, Result ); ppKeyList[ 0 ] = CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT; - cellularStatus = Cellular_ATcheckErrorCode( pString, ppKeyList, keyListLen, &Result ); + cellularStatus = Cellular_ATcheckErrorCode( pString, ( const char * const * ) ppKeyList, keyListLen, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( false, Result ); } @@ -820,11 +819,11 @@ void test_Cellular_ATcheckErrorCode_Error_Path( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; char * pString = ""; - const char * const * const ppKeyList = { "TEST1:SUCCESS", "TEST2:ERROR" }; + char * ppKeyList[] = { "TEST1:SUCCESS", "TEST2:ERROR" }; size_t keyListLen = 2; bool Result; - cellularStatus = Cellular_ATcheckErrorCode( pString, ppKeyList, keyListLen, &Result ); + cellularStatus = Cellular_ATcheckErrorCode( pString, ( const char * const * ) ppKeyList, keyListLen, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus ); } @@ -902,16 +901,14 @@ void test_Cellular_ATStrtoi_Invalid_Param( void ) void test_Cellular_ATStrtoi_Happy_Path( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; - char * pStr = malloc( sizeof( char ) * ( strlen( CELLULAR_SAMPLE_STRTOL_HAPPY_CASE_STRING ) + 1 ) ); - - strcpy( pStr, CELLULAR_SAMPLE_STRTOL_HAPPY_CASE_STRING ); + char pStr[ sizeof( CELLULAR_SAMPLE_STRTOL_HAPPY_CASE_STRING ) ] = { 0 }; int32_t base = 10; int32_t Result; + strcpy( pStr, CELLULAR_SAMPLE_STRTOL_HAPPY_CASE_STRING ); cellularStatus = Cellular_ATStrtoi( pStr, base, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( CELLULAR_SAMPLE_STRTOL_HAPPY_CASE_NUMBER, Result ); - free( pStr ); } /** @@ -923,12 +920,11 @@ void test_Cellular_ATStrtoi_Error_Path( void ) int32_t base = 10; int32_t Result; - char * pStr = malloc( sizeof( char ) * ( strlen( CELLULAR_SAMPLE_PREFIX_STRING_STAR_FIRST_INPUT ) + 1 ) ); + char pStr[ sizeof( CELLULAR_SAMPLE_PREFIX_STRING_STAR_FIRST_INPUT ) ] = { 0 }; strcpy( pStr, CELLULAR_SAMPLE_PREFIX_STRING_STAR_FIRST_INPUT ); cellularStatus = Cellular_ATStrtoi( pStr, base, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_ERROR, cellularStatus ); - free( pStr ); } /** @@ -938,7 +934,7 @@ void test_Cellular_ATStrDup_Invalid_Param( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; char * pDst; - char * pSrc; + char pSrc[ sizeof( CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT ) ] = { 0 }; cellularStatus = Cellular_ATStrDup( NULL, NULL ); TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus ); @@ -946,11 +942,9 @@ void test_Cellular_ATStrDup_Invalid_Param( void ) cellularStatus = Cellular_ATStrDup( &pDst, NULL ); TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus ); - pSrc = malloc( strlen( CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT ) + 1 ); strcpy( pSrc, CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT ); cellularStatus = Cellular_ATStrDup( &pDst, pSrc ); TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus ); - free( pSrc ); } /** @@ -1004,15 +998,14 @@ void test_Cellular_ATIsPrefixPresent_Invalid_Param( void ) void test_Cellular_ATIsPrefixPresent_Happy_Path( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; - char * pStr = malloc( sizeof( char ) * ( strlen( CELLULAR_SAMPLE_PREFIX_STRING_INPUT ) + 1 ) ); + char pStr[ sizeof( CELLULAR_SAMPLE_PREFIX_STRING_INPUT ) ] = { 0 }; + bool Result; strcpy( pStr, CELLULAR_SAMPLE_PREFIX_STRING_INPUT ); - bool Result; cellularStatus = Cellular_ATIsPrefixPresent( pStr, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( true, Result ); - free( pStr ); } /** @@ -1034,15 +1027,13 @@ void test_Cellular_ATIsPrefixPresent_Empty_String( void ) void test_Cellular_ATIsPrefixPresent_No_Delimiter( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; - char * pString; + char pString[ sizeof( CELLULAR_SAMPLE_PREFIX_STRING_WRONG_INPUT ) ] = { 0 }; bool Result; - pString = malloc( sizeof( char ) * ( strlen( CELLULAR_SAMPLE_PREFIX_STRING_WRONG_INPUT ) + 1 ) ); strcpy( pString, CELLULAR_SAMPLE_PREFIX_STRING_WRONG_INPUT ); cellularStatus = Cellular_ATIsPrefixPresent( pString, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( false, Result ); - free( pString ); } /** @@ -1051,13 +1042,11 @@ void test_Cellular_ATIsPrefixPresent_No_Delimiter( void ) void test_Cellular_ATIsPrefixPresent_Wrong_Prefix( void ) { CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS; - char * pString; + char pString[ sizeof( CELLULAR_SAMPLE_PREFIX_STRING_STAR_FIRST_INPUT ) ] = { 0 }; bool Result; - pString = malloc( sizeof( char ) * ( strlen( CELLULAR_SAMPLE_PREFIX_STRING_STAR_FIRST_INPUT ) + 1 ) ); strcpy( pString, CELLULAR_SAMPLE_PREFIX_STRING_STAR_FIRST_INPUT ); cellularStatus = Cellular_ATIsPrefixPresent( pString, &Result ); TEST_ASSERT_EQUAL( CELLULAR_AT_SUCCESS, cellularStatus ); TEST_ASSERT_EQUAL( false, Result ); - free( pString ); } diff --git a/test/unit-test/cellular_common_utest.c b/test/unit-test/cellular_common_utest.c index 03f4d087..5100d4df 100644 --- a/test/unit-test/cellular_common_utest.c +++ b/test/unit-test/cellular_common_utest.c @@ -230,6 +230,14 @@ int suiteTearDown( int numFailures ) /* ========================================================================== */ +void dummyTaskENTER_CRITICAL( void ) +{ +} + +void dummyTaskEXIT_CRITICAL( void ) +{ +} + static CellularCommInterfaceError_t _prvCommIntfOpen( CellularCommInterfaceReceiveCallback_t receiveCallback, void * pUserData, CellularCommInterfaceHandle_t * pCommInterfaceHandle ) diff --git a/test/unit-test/cellular_pkthandler_utest.c b/test/unit-test/cellular_pkthandler_utest.c index fbb1ff8e..17859a6e 100644 --- a/test/unit-test/cellular_pkthandler_utest.c +++ b/test/unit-test/cellular_pkthandler_utest.c @@ -189,6 +189,11 @@ int suiteTearDown( int numFailures ) /* ========================================================================== */ +void dummyDelay( uint32_t milliseconds ) +{ + ( void ) milliseconds; +} + void * mock_malloc( size_t size ) { return ( void * ) malloc( size ); diff --git a/test/unit-test/cellular_pktio_utest.c b/test/unit-test/cellular_pktio_utest.c index 8a9e16c8..f6800356 100644 --- a/test/unit-test/cellular_pktio_utest.c +++ b/test/unit-test/cellular_pktio_utest.c @@ -212,6 +212,11 @@ int suiteTearDown( int numFailures ) /* ========================================================================== */ +void dummyDelay( uint32_t milliseconds ) +{ + ( void ) milliseconds; +} + void * mock_malloc( size_t size ) { return ( void * ) malloc( size ); @@ -545,22 +550,18 @@ static void _shutdownCallback( CellularContext_t * pContext ) } } -void PktioHandlePacketCallback_t( CellularContext_t * pContext, - _atRespType_t atRespType, - const void * pBuffer ) +CellularPktStatus_t PktioHandlePacketCallback_t( CellularContext_t * pContext, + _atRespType_t atRespType, + const void * pBuffer ) { - ( void ) pContext; - ( void ) atRespType; - ( void ) pBuffer; -} + CellularPktStatus_t status = CELLULAR_PKT_STATUS_OK; -void pktioHandlePacketCallback( CellularContext_t * pContext, - _atRespType_t atRespType, - const void * pBuffer ) -{ ( void ) pContext; ( void ) atRespType; ( void ) pBuffer; + ( void ) status; + + return status; } CellularPktStatus_t cellularATCommandDataPrefixCallback( void * pCallbackContext, @@ -1186,6 +1187,7 @@ void test__Cellular_PktioInit_Thread_Rx_Data_Event_CELLULAR_AT_MULTI_WO_PREFIX_W CellularCommInterface_t * pCommIntf = &CellularCommInterface; threadReturn = true; + ( void ) pktStatus; memset( &context, 0, sizeof( CellularContext_t ) ); /* Assign the comm interface to pContext. */ @@ -1487,7 +1489,6 @@ void test__Cellular_PktioInit_Thread_Rx_Data_Event_URC_TOKEN_STRING_RESP( void ) context.pktDataSendPrefixCB = sendDataPrefix; isSendDataPrefixCbkSuccess = 0; context.pRespPrefix = CELLULAR_URC_TOKEN_PREFIX_STRING; - context.pPktioHandlepktCB = pktioHandlePacketCallback; /* Check that CELLULAR_PKT_STATUS_OK is returned. */ pktStatus = _Cellular_PktioInit( &context, PktioHandlePacketCallback_t ); TEST_ASSERT_EQUAL( CELLULAR_PKT_STATUS_OK, pktStatus ); @@ -1500,7 +1501,6 @@ void test__Cellular_PktioInit_Event_Aborted( void ) { CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularContext_t context; - CellularCommInterface_t * pCommIntf = &CellularCommInterface; memset( &context, 0, sizeof( CellularContext_t ) ); @@ -1520,12 +1520,11 @@ void test__Cellular_PktioInit_Event_Group_Create_Null( void ) { CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularContext_t context; - CellularCommInterface_t * pCommIntf = &CellularCommInterface; memset( &context, 0, sizeof( CellularContext_t ) ); /* Test the pPktioCommEvent NULL case. */ - context.pPktioCommEvent = NULL; + context.pPktioCommEvent = ( PlatformEventGroupHandle_t ) 0U; evtGroupCreate = ( uintptr_t ) ( uintptr_t * ) NULL; /* Check that CELLULAR_PKT_STATUS_CREATION_FAIL is returned. */ pktStatus = _Cellular_PktioInit( &context, PktioHandlePacketCallback_t ); @@ -1539,8 +1538,6 @@ void test__Cellular_PktioInit_Create_Thread_Fail( void ) { CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularContext_t context; - CellularCommInterface_t * pCommIntf = &CellularCommInterface; - memset( &context, 0, sizeof( CellularContext_t ) ); @@ -1650,7 +1647,7 @@ void test__Cellular_PktioSendAtCmd_Null_AtCmd( void ) CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularContext_t context; CellularCommInterface_t * pCommIntf = &CellularCommInterface; - CellularCommInterfaceHandle_t commInterfaceHandle; + struct _cellularCommContext commInterfaceHandle = { 0 }; CellularAtReq_t atReqSetRatPriority = { "AT+QCFG=\"nwscanseq\"", @@ -1664,7 +1661,7 @@ void test__Cellular_PktioSendAtCmd_Null_AtCmd( void ) memset( &context, 0, sizeof( CellularContext_t ) ); context.pCommIntf = pCommIntf; - context.hPktioCommIntf = commInterfaceHandle; + context.hPktioCommIntf = ( CellularCommInterfaceHandle_t ) &commInterfaceHandle; pktStatus = _Cellular_PktioSendAtCmd( &context, NULL, atReqSetRatPriority.atCmdType, atReqSetRatPriority.pAtRspPrefix ); @@ -1679,7 +1676,7 @@ void test__Cellular_PktioSendAtCmd_Invalid_String( void ) CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularContext_t context; CellularCommInterface_t * pCommIntf = &CellularCommInterface; - CellularCommInterfaceHandle_t commInterfaceHandle; + struct _cellularCommContext commInterfaceHandle = { 0 }; CellularAtReq_t atReqSetRatPriority = { "AT+QCFG=\"Story for Littel Red Riding Hood: Once upon a time there was a dear little girl who was loved by every one who looked at her, but most of all by her grandmother, and there was nothing that she would not have given to the child. Once she gave her a little cap of red velvet, which suited her so well that she would never wear anything else. So she was always called Little Red Riding Hood.\"", @@ -1692,7 +1689,7 @@ void test__Cellular_PktioSendAtCmd_Invalid_String( void ) memset( &context, 0, sizeof( CellularContext_t ) ); context.pCommIntf = pCommIntf; - context.hPktioCommIntf = commInterfaceHandle; + context.hPktioCommIntf = ( CellularCommInterfaceHandle_t ) &commInterfaceHandle; pktStatus = _Cellular_PktioSendAtCmd( &context, atReqSetRatPriority.pAtCmd, atReqSetRatPriority.atCmdType, atReqSetRatPriority.pAtRspPrefix ); @@ -1707,7 +1704,7 @@ void test__Cellular_PktioSendAtCmd_Happy_Path( void ) CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK; CellularContext_t context; CellularCommInterface_t * pCommIntf = &CellularCommInterface; - CellularCommInterfaceHandle_t commInterfaceHandle; + struct _cellularCommContext commInterfaceHandle = { 0 }; CellularAtReq_t atReqSetRatPriority = { "AT+QCFG=\"nwscanseq\"", @@ -1720,7 +1717,7 @@ void test__Cellular_PktioSendAtCmd_Happy_Path( void ) memset( &context, 0, sizeof( CellularContext_t ) ); context.pCommIntf = pCommIntf; - context.hPktioCommIntf = commInterfaceHandle; + context.hPktioCommIntf = ( CellularCommInterfaceHandle_t ) &commInterfaceHandle; pktStatus = _Cellular_PktioSendAtCmd( &context, atReqSetRatPriority.pAtCmd, atReqSetRatPriority.atCmdType, atReqSetRatPriority.pAtRspPrefix ); @@ -1735,7 +1732,7 @@ void test__Cellular_PktioSendData_Invalid_Param( void ) uint32_t sentLen = 0; CellularContext_t context; CellularCommInterface_t * pCommIntf = &CellularCommInterface; - CellularCommInterfaceHandle_t commInterfaceHandle = ( CellularCommInterfaceHandle_t ) malloc( sizeof( CellularCommInterfaceHandle_t ) ); + struct _cellularCommContext commInterfaceHandle = { 0 }; char pString[] = CELLULAR_AT_CMD_MULTI_WO_PREFIX; memset( &context, 0, sizeof( CellularContext_t ) ); @@ -1755,13 +1752,11 @@ void test__Cellular_PktioSendData_Invalid_Param( void ) 0 ); TEST_ASSERT_EQUAL( 0, sentLen ); - context.hPktioCommIntf = commInterfaceHandle; + context.hPktioCommIntf = ( CellularCommInterfaceHandle_t ) &commInterfaceHandle; sentLen = _Cellular_PktioSendData( &context, NULL, 0 ); TEST_ASSERT_EQUAL( 0, sentLen ); - - free( commInterfaceHandle ); } /** @@ -1772,18 +1767,17 @@ void test__Cellular_PktioSendData_Happy_Path( void ) uint32_t sentLen = 0; CellularContext_t context; CellularCommInterface_t * pCommIntf = &CellularCommInterface; - CellularCommInterfaceHandle_t commInterfaceHandle = ( CellularCommInterfaceHandle_t ) malloc( sizeof( CellularCommInterfaceHandle_t ) ); + struct _cellularCommContext commInterfaceHandle = { 0 }; char pString[] = CELLULAR_AT_CMD_MULTI_WO_PREFIX; memset( &context, 0, sizeof( CellularContext_t ) ); context.pCommIntf = pCommIntf; - context.hPktioCommIntf = commInterfaceHandle; + context.hPktioCommIntf = ( CellularCommInterfaceHandle_t ) &commInterfaceHandle; sentLen = _Cellular_PktioSendData( &context, ( uint8_t * ) pString, strlen( pString ) + 1 ); TEST_ASSERT_EQUAL( strlen( pString ) + 1, sentLen ); - free( commInterfaceHandle ); } /** diff --git a/test/unit-test/cellular_platform.h b/test/unit-test/cellular_platform.h index 362f3a74..1ba227fd 100644 --- a/test/unit-test/cellular_platform.h +++ b/test/unit-test/cellular_platform.h @@ -38,21 +38,10 @@ /*-----------------------------------------------------------*/ -/* Users should define their platform dependent method if they need. - * Otherwise use our predefine method which has no effect but pass - * the coverity check. - */ -#ifdef DEBUG_METHOD - #define configASSERT - #define Platform_Delay - #define taskENTER_CRITICAL() - #define taskEXIT_CRITICAL() -#else - #define configASSERT( X ) ( { 1U; } ) - #define Platform_Delay( X ) ( { ( void ) X; 1U; } ) - #define taskENTER_CRITICAL() ( { 1U; } ) - #define taskEXIT_CRITICAL() ( { 1U; } ) -#endif /* ifdef DEBUG_METHOD */ +#define configASSERT assert +#define Platform_Delay dummyDelay +#define taskENTER_CRITICAL dummyTaskENTER_CRITICAL +#define taskEXIT_CRITICAL dummyTaskEXIT_CRITICAL #define PlatformEventGroupHandle_t uint16_t #define PlatformEventGroup_Delete MockPlatformEventGroup_Delete @@ -181,6 +170,13 @@ typedef struct PlatformMutex */ typedef TickType_t EventBits_t; +struct _cellularCommContext +{ + int test1; + int test2; + int test3; +}; + /*-----------------------------------------------------------*/ /** @@ -250,4 +246,10 @@ int32_t MockPlatformEventGroup_SetBitsFromISR( PlatformEventGroupHandle_t groupE EventBits_t event, BaseType_t * pHigherPriorityTaskWoken ); +void dummyDelay( uint32_t milliseconds ); + +void dummyTaskENTER_CRITICAL( void ); + +void dummyTaskEXIT_CRITICAL( void ); + #endif /* __CELLULAR_PLATFORM_H__ */