Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
run: |
make -C build/ coverage
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*3rdparty\*")
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
lcov --rc lcov_branch_coverage=1 --list build/coverage.info
echo ${EXCLUDE[@]} | xargs lcov --rc branch_coverage=1 -r build/coverage.info -o build/coverage.info
lcov --rc branch_coverage=1 --list build/coverage.info
- name: Check Coverage
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
with:
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
path: ./

formatting:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check formatting
Expand Down
43 changes: 24 additions & 19 deletions source/core_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static HTTPStatus_t addRangeHeader( HTTPRequestHeaders_t * pRequestHeaders,
* @param[in] parsingState State of the parsing on the HTTP response.
* @param[in] totalReceived The amount of network data received in the response
* buffer.
* @param[in] responseBufferLen The length of the response buffer.
* @param[in] pResponse The response information.
*
* @return Returns #HTTPSuccess if the parsing state is complete. If
* the parsing state denotes it never started, then return #HTTPNoResponse. If
Expand All @@ -147,7 +147,7 @@ static HTTPStatus_t addRangeHeader( HTTPRequestHeaders_t * pRequestHeaders,
*/
static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
size_t totalReceived,
size_t responseBufferLen );
const HTTPResponse_t * pResponse );

/**
* @brief Send the HTTP request over the network.
Expand Down Expand Up @@ -1984,13 +1984,13 @@ static HTTPStatus_t sendHttpBody( const TransportInterface_t * pTransport,

static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
size_t totalReceived,
size_t responseBufferLen )
const HTTPResponse_t * pResponse )
{
HTTPStatus_t returnStatus = HTTPSuccess;

assert( parsingState >= HTTP_PARSING_NONE &&
parsingState <= HTTP_PARSING_COMPLETE );
assert( totalReceived <= responseBufferLen );
assert( totalReceived <= pResponse->bufferLen );

/* If no parsing occurred, that means network data was never received. */
if( parsingState == HTTP_PARSING_NONE )
Expand All @@ -2002,21 +2002,26 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
}
else if( parsingState == HTTP_PARSING_INCOMPLETE )
{
if( totalReceived == responseBufferLen )
/* HTTP_PARSING_INCOMPLETE is okay when HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG is set
* as the body data may yet to be read from the transport. */
if( ( pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG ) == 0 )
{
LogError( ( "Cannot receive complete response from transport"
" interface: Response buffer has insufficient "
"space: responseBufferLen=%lu",
( unsigned long ) responseBufferLen ) );
returnStatus = HTTPInsufficientMemory;
}
else
{
LogError( ( "Received partial response from transport "
"receive(): ResponseSize=%lu, TotalBufferSize=%lu",
( unsigned long ) totalReceived,
( unsigned long ) ( responseBufferLen - totalReceived ) ) );
returnStatus = HTTPPartialResponse;
if( totalReceived == pResponse->bufferLen )
{
LogError( ( "Cannot receive complete response from transport"
" interface: Response buffer has insufficient "
"space: responseBufferLen=%lu",
( unsigned long ) pResponse->bufferLen ) );
returnStatus = HTTPInsufficientMemory;
}
else
{
LogError( ( "Received partial response from transport "
"receive(): ResponseSize=%lu, TotalBufferSize=%lu",
( unsigned long ) totalReceived,
( unsigned long ) ( pResponse->bufferLen - totalReceived ) ) );
returnStatus = HTTPPartialResponse;
}
}
}
else
Expand Down Expand Up @@ -2155,7 +2160,7 @@ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t
* the parsing and how much data is in the buffer. */
returnStatus = getFinalResponseStatus( parsingContext.state,
totalReceived,
pResponse->bufferLen );
pResponse );
}

return returnStatus;
Expand Down
9 changes: 4 additions & 5 deletions tools/cmock/coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ execute_process( COMMAND lcov --directory ${CMAKE_BINARY_DIR}
--base-directory ${CMAKE_BINARY_DIR}
--initial
--capture
--rc lcov_branch_coverage=1
--rc branch_coverage=1
--rc genhtml_branch_coverage=1
--output-file=${CMAKE_BINARY_DIR}/base_coverage.info
)
Expand Down Expand Up @@ -45,7 +45,7 @@ execute_process(COMMAND ruby
# capture data after running the tests
execute_process(
COMMAND lcov --capture
--rc lcov_branch_coverage=1
--rc branch_coverage=1
--rc genhtml_branch_coverage=1
--base-directory ${CMAKE_BINARY_DIR}
--directory ${CMAKE_BINARY_DIR}
Expand All @@ -59,11 +59,10 @@ execute_process(
--add-tracefile ${CMAKE_BINARY_DIR}/base_coverage.info
--add-tracefile ${CMAKE_BINARY_DIR}/second_coverage.info
--output-file ${CMAKE_BINARY_DIR}/coverage.info
--no-external
--rc lcov_branch_coverage=1
--rc branch_coverage=1
)
execute_process(
COMMAND genhtml --rc lcov_branch_coverage=1
COMMAND genhtml --rc branch_coverage=1
--branch-coverage
--output-directory ${CMAKE_BINARY_DIR}/coverage
${CMAKE_BINARY_DIR}/coverage.info
Expand Down
Loading