Skip to content

Commit

Permalink
Fix #1930, add coverage for null pointer check
Browse files Browse the repository at this point in the history
Add code coverage for null pointer check
  • Loading branch information
Van committed Jun 16, 2023
1 parent 112bc51 commit 33e92af
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,16 @@ void TestGenericPool(void)
/* Reset the structure so it will rebuild */
Pool1.TailPosition = 0;
CFE_UtAssert_SUCCESS(CFE_ES_GenPoolRebuild(&Pool1));

/* Branch coverage for no buffer in pool */
ES_ResetUnitTest();
UtAssert_INT32_EQ(CFE_ES_GenPoolCreatePoolBlock(&Pool1, 0, Pool1.Buckets[0].BlockSize, &Offset1),
CFE_ES_BUFFER_NOT_IN_POOL);

ES_ResetUnitTest();
UtAssert_INT32_EQ(CFE_ES_GenPoolRecyclePoolBlock(&Pool1, 0, Pool1.Buckets[0].BlockSize, &Offset1),
CFE_ES_BUFFER_NOT_IN_POOL);

}

void TestTask(void)
Expand Down
1 change: 1 addition & 0 deletions modules/es/ut-coverage/es_UT.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "cfe_version.h"
#include "ut_support.h"
#include "ut_osprintf_stubs.h"
#include "es_internal_UT.h"

/* ES unit test functions */
/*****************************************************************************/
Expand Down
45 changes: 45 additions & 0 deletions modules/es/ut-coverage/es_internal_UT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* @file
*
* Purpose:
* Expose internal function for es unit test
*
* References:
* 1. cFE Application Developers Guide
* 2. unit test standard 092503
* 3. C Coding Standard 102904
*
* Notes:
* 1. This is unit test code only, not for use in flight
*
*/

#ifndef ES_INTERNAL_UT_H
#define ES_INTERNAL_UT_H

/* Internal ES Function */
int32 CFE_ES_GenPoolCreatePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, size_t NewSize,
size_t *BlockOffsetPtr);

int32 CFE_ES_GenPoolRecyclePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, size_t NewSize,
size_t *BlockOffsetPtr);

#endif /* ES_INTERNAL_UT_H */

0 comments on commit 33e92af

Please sign in to comment.