-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #413, Add coverage tests for pc-rtems
- Loading branch information
1 parent
71ee927
commit 5f24032
Showing
28 changed files
with
946 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
###################################################################### | ||
# | ||
# CMake build recipe for pc-rtems PSP white-box coverage tests | ||
# | ||
###################################################################### | ||
|
||
include_directories(${CFEPSP_SOURCE_DIR}/fsw/pc-rtems/inc) | ||
include_directories(${PSPCOVERAGE_SOURCE_DIR}/shared/inc) | ||
|
||
# Target names use a "ut" prefix to avoid confusion with the FSW targets | ||
set(CFE_PSP_TARGETNAME "ut-${SETNAME}") | ||
add_subdirectory(${CFEPSP_SOURCE_DIR}/fsw/${SETNAME} ${CFE_PSP_TARGETNAME}-impl) | ||
add_subdirectory(${CFEPSP_SOURCE_DIR}/fsw/shared ${CFE_PSP_TARGETNAME}-shared) | ||
|
||
# The UT assert library defines OS_Application_Startup, so this redefines ours with a "UT_" prefix | ||
target_compile_definitions(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE | ||
OS_Application_Startup=UT_OS_Application_Startup | ||
) | ||
|
||
foreach(TGT psp-${CFE_PSP_TARGETNAME}-impl psp-${CFE_PSP_TARGETNAME}-shared) | ||
target_compile_options(${TGT} PRIVATE ${UT_COVERAGE_COMPILE_FLAGS}) | ||
target_include_directories(${TGT} BEFORE PRIVATE ${PSPCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc) | ||
endforeach() | ||
|
||
add_executable(coverage-${CFE_PSP_TARGETNAME}-testrunner | ||
src/coveragetest-cfe-psp-exception.c | ||
src/coveragetest-cfe-psp-memory.c | ||
src/coveragetest-cfe-psp-ssr.c | ||
src/coveragetest-cfe-psp-start.c | ||
src/coveragetest-cfe-psp-support.c | ||
src/coveragetest-cfe-psp-watchdog.c | ||
src/coveragetest-psp-pc-rtems.c | ||
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-shared> | ||
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-impl> | ||
) | ||
|
||
target_link_libraries(coverage-${CFE_PSP_TARGETNAME}-testrunner PUBLIC | ||
${UT_COVERAGE_LINK_FLAGS} | ||
psp_module_api | ||
ut_psp_cfe_stubs | ||
ut_psp_libc_stubs | ||
ut_osapi_stubs | ||
ut_assert | ||
) | ||
|
||
add_test(coverage-${CFE_PSP_TARGETNAME} coverage-${CFE_PSP_TARGETNAME}-testrunner) | ||
|
||
foreach(TGT ${INSTALL_TARGET_LIST}) | ||
install(TARGETS coverage-${CFE_PSP_TARGETNAME}-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}) | ||
endforeach() |
52 changes: 52 additions & 0 deletions
52
unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-exception.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/************************************************************************ | ||
* 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://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. | ||
************************************************************************/ | ||
|
||
#include "coveragetest-psp-pc-rtems.h" | ||
|
||
#include "cfe_psp.h" | ||
#include "PCS_stdlib.h" | ||
|
||
extern int32 CFE_PSP_ExceptionGetSummary_Impl(void *, char *, uint32); | ||
extern void CFE_PSP_SetupReservedMemoryMap(void); | ||
|
||
uint32 UT_AttachExceptionsBuffer[1024]; | ||
|
||
void Test_CFE_PSP_AttachExceptions(void) | ||
{ | ||
/* Need to call CFE_PSP_SetupReservedMemoryMap here for initialization of CFE_PSP_ReservedMemoryMap */ | ||
UT_SetDataBuffer(UT_KEY(PCS_malloc), UT_AttachExceptionsBuffer, sizeof(UT_AttachExceptionsBuffer), false); | ||
CFE_PSP_SetupReservedMemoryMap(); | ||
UT_ResetState(UT_KEY(OS_printf)); /* Reset so calls to OS_printf in the setup above don't affect the actual test */ | ||
|
||
/* Nominal path */ | ||
CFE_PSP_AttachExceptions(); | ||
UtAssert_STUB_COUNT(OS_printf, 1); | ||
UT_ResetState(UT_KEY(PCS_malloc)); /* Reset so cleared for next test */ | ||
} | ||
|
||
void Test_CFE_PSP_ExceptionGetSummary_Impl(void) | ||
{ | ||
/* Placeholder test to exercise function - amend tests if/when function is fully implemented */ | ||
UtAssert_INT32_EQ(CFE_PSP_ExceptionGetSummary_Impl(NULL, NULL, 4), CFE_PSP_ERROR_NOT_IMPLEMENTED); | ||
} | ||
|
||
void Test_CFE_PSP_SetDefaultExceptionEnvironment(void) | ||
{ | ||
/* Placeholder test to exercise function - amend tests if/when function is fully implemented */ | ||
CFE_PSP_SetDefaultExceptionEnvironment(); | ||
} |
144 changes: 144 additions & 0 deletions
144
unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-memory.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/************************************************************************ | ||
* 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://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. | ||
************************************************************************/ | ||
|
||
#include "coveragetest-psp-pc-rtems.h" | ||
|
||
#include "cfe_psp.h" | ||
#include "PCS_stdlib.h" | ||
|
||
extern int32 CFE_PSP_InitProcessorReservedMemory(uint32 ResetType); | ||
extern void CFE_PSP_SetupReservedMemoryMap(void); | ||
|
||
/* Blocks of 'heap' memory for emulated calls to malloc (via PCS_malloc) in the tests */ | ||
uint32 UT_MemoryMapBuffer[1024]; | ||
uint32 UT_TooSmallMemoryMapBuffer[1]; | ||
|
||
void Test_CFE_PSP_GetCDSSize(void) | ||
{ | ||
uint32 SizeOfCDS; | ||
|
||
/* Test NULL pointer guard */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetCDSSize(NULL), OS_ERROR); | ||
|
||
/* Nominal/success path */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetCDSSize(&SizeOfCDS), OS_SUCCESS); | ||
} | ||
|
||
void Test_CFE_PSP_WriteToCDS(void) | ||
{ | ||
uint32 CDSOffset = 8; | ||
uint32 NumBytes = 8; | ||
|
||
/* Test NULL pointer guard */ | ||
UtAssert_INT32_EQ(CFE_PSP_WriteToCDS(NULL, CDSOffset, NumBytes), OS_ERROR); | ||
} | ||
|
||
void Test_CFE_PSP_ReadFromCDS(void) | ||
{ | ||
uint32 CDSOffset = 8; | ||
uint32 NumBytes = 8; | ||
|
||
/* Test NULL pointer guard */ | ||
UtAssert_INT32_EQ(CFE_PSP_ReadFromCDS(NULL, CDSOffset, NumBytes), OS_ERROR); | ||
} | ||
|
||
void Test_CFE_PSP_GetResetArea(void) | ||
{ | ||
cpuaddr PtrToResetArea; | ||
uint32 SizeOfResetArea; | ||
|
||
/* Test both NULL pointer guards */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetResetArea(NULL, &SizeOfResetArea), OS_ERROR); | ||
UtAssert_INT32_EQ(CFE_PSP_GetResetArea(&PtrToResetArea, NULL), OS_ERROR); | ||
|
||
/* Nominal/success path */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetResetArea(&PtrToResetArea, &SizeOfResetArea), OS_SUCCESS); | ||
} | ||
|
||
void Test_CFE_PSP_GetUserReservedArea(void) | ||
{ | ||
cpuaddr PtrToUserArea; | ||
uint32 SizeOfUserArea; | ||
|
||
/* Test both NULL pointer guards */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetUserReservedArea(NULL, &SizeOfUserArea), OS_ERROR); | ||
UtAssert_INT32_EQ(CFE_PSP_GetUserReservedArea(&PtrToUserArea, NULL), OS_ERROR); | ||
|
||
/* Nominal/success path */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetUserReservedArea(&PtrToUserArea, &SizeOfUserArea), OS_SUCCESS); | ||
} | ||
|
||
void Test_CFE_PSP_GetVolatileDiskMem(void) | ||
{ | ||
cpuaddr PtrToVolDisk; | ||
uint32 SizeOfVolDisk; | ||
|
||
/* Test both NULL pointer guards */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetVolatileDiskMem(NULL, &SizeOfVolDisk), OS_ERROR); | ||
UtAssert_INT32_EQ(CFE_PSP_GetVolatileDiskMem(&PtrToVolDisk, NULL), OS_ERROR); | ||
|
||
/* Nominal/success path */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetVolatileDiskMem(&PtrToVolDisk, &SizeOfVolDisk), OS_SUCCESS); | ||
} | ||
|
||
void Test_CFE_PSP_SetupReservedMemoryMap(void) | ||
{ | ||
/* Test NULL ReservedMemBlock.BlockPtr path and early abort due to failure of malloc with a too-small heap */ | ||
UT_SetDataBuffer(UT_KEY(PCS_malloc), UT_TooSmallMemoryMapBuffer, sizeof(UT_TooSmallMemoryMapBuffer), false); | ||
CFE_PSP_SetupReservedMemoryMap(); | ||
UtAssert_STUB_COUNT(PCS_abort, 1); | ||
UT_ResetState(UT_KEY(PCS_malloc)); /* Reset so cleared for next test */ | ||
UT_ResetState(UT_KEY(OS_printf)); /* Reset so cleared for next test */ | ||
|
||
/* Nominal/success path with sufficiently sized 'heap' for emulated call to malloc */ | ||
UT_SetDataBuffer(UT_KEY(PCS_malloc), UT_MemoryMapBuffer, sizeof(UT_MemoryMapBuffer), false); | ||
CFE_PSP_SetupReservedMemoryMap(); | ||
UtAssert_STUB_COUNT(OS_printf, 3); /* 3 calls to OS_printf along nominal path in CFE_PSP_SetupReservedMemoryMap */ | ||
UT_ResetState(UT_KEY(PCS_malloc)); /* Reset so cleared for future tests that invoke malloc */ | ||
} | ||
|
||
void Test_CFE_PSP_InitProcessorReservedMemory(void) | ||
{ | ||
/* Always returns CFE_PSP_SUCCESS */ | ||
UtAssert_INT32_EQ(CFE_PSP_InitProcessorReservedMemory(CFE_PSP_RST_TYPE_POWERON), CFE_PSP_SUCCESS); | ||
} | ||
|
||
void Test_CFE_PSP_GetKernelTextSegmentInfo(void) | ||
{ | ||
cpuaddr PtrToKernelSegment; | ||
uint32 SizeOfKernelSegment; | ||
|
||
/* Test both NULL pointer guards */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetKernelTextSegmentInfo(NULL, &SizeOfKernelSegment), OS_ERROR); | ||
UtAssert_INT32_EQ(CFE_PSP_GetKernelTextSegmentInfo(&PtrToKernelSegment, NULL), OS_ERROR); | ||
|
||
/* Nominal/success path */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetKernelTextSegmentInfo(&PtrToKernelSegment, &SizeOfKernelSegment), OS_SUCCESS); | ||
} | ||
|
||
void Test_CFE_PSP_GetCFETextSegmentInfo(void) | ||
{ | ||
cpuaddr PtrToCFESegment; | ||
uint32 SizeOfCFESegment; | ||
|
||
/* Test NULL pointer guard */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetCFETextSegmentInfo(&PtrToCFESegment, NULL), OS_ERROR); | ||
|
||
/* Nominal/success path */ | ||
UtAssert_INT32_EQ(CFE_PSP_GetCFETextSegmentInfo(&PtrToCFESegment, &SizeOfCFESegment), OS_SUCCESS); | ||
} |
31 changes: 31 additions & 0 deletions
31
unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-ssr.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/************************************************************************ | ||
* 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://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. | ||
************************************************************************/ | ||
|
||
#include "coveragetest-psp-pc-rtems.h" | ||
|
||
#include "cfe_psp.h" | ||
|
||
void Test_CFE_PSP_InitSSR(void) | ||
{ | ||
uint32 bus = 1; | ||
uint32 device = 1; | ||
char DeviceName[] = "TestDevice"; | ||
|
||
/* Placeholder test to exercise function - amend tests if/when function is fully implemented */ | ||
UtAssert_INT32_EQ(CFE_PSP_InitSSR(bus, device, DeviceName), CFE_PSP_SUCCESS); | ||
} |
Oops, something went wrong.