diff --git a/unit-test-coverage/modules/CMakeLists.txt b/unit-test-coverage/modules/CMakeLists.txt index 5e712874..9e6eb640 100644 --- a/unit-test-coverage/modules/CMakeLists.txt +++ b/unit-test-coverage/modules/CMakeLists.txt @@ -66,3 +66,4 @@ endfunction(add_psp_covtest) # a list of modules for which there is a coverage test implemented add_subdirectory(timebase_vxworks) +add_subdirectory(vxworks_sysmon) diff --git a/unit-test-coverage/modules/vxworks_sysmon/CMakeLists.txt b/unit-test-coverage/modules/vxworks_sysmon/CMakeLists.txt new file mode 100644 index 00000000..1b9652f3 --- /dev/null +++ b/unit-test-coverage/modules/vxworks_sysmon/CMakeLists.txt @@ -0,0 +1,11 @@ +###################################################################### +# +# CMAKE build recipe for white-box coverage tests of VxWorks timebase module +# +add_definitions(-D_CFE_PSP_MODULE_) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/inc") +include_directories("${CFEPSP_SOURCE_DIR}/fsw/modules/iodriver/inc") + +add_psp_covtest(vxworks_sysmon src/coveragetest-vxworks_sysmon.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/vxworks_sysmon/vxworks_sysmon.c +) diff --git a/unit-test-coverage/modules/vxworks_sysmon/inc/coveragetest-vxworks_sysmon.h b/unit-test-coverage/modules/vxworks_sysmon/inc/coveragetest-vxworks_sysmon.h new file mode 100644 index 00000000..d68abc11 --- /dev/null +++ b/unit-test-coverage/modules/vxworks_sysmon/inc/coveragetest-vxworks_sysmon.h @@ -0,0 +1,56 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: + * Draco + * + * Copyright (c) 2023 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. + **********************************************************************/ + +/* + * + * Copyright (c) 2023, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + +/** + * \file + * \ingroup vxworks + * \author anh.d.van@nasa.gov + * + */ + +#ifndef COVERAGETEST_VXWORKS_SYSMON_H +#define COVERAGETEST_VXWORKS_SYSMON_H + +#include "utassert.h" +#include "uttest.h" +#include "utstubs.h" + +#include "iodriver_analog_io.h" +#include "iodriver_base.h" +#include "iodriver_impl.h" + +void Test_Entry_Nominal(void); +void Test_Aggregate_Nominal(void); +void Test_Aggregate_Error(void); +void Test_Dispatch_Nominal(void); +void Test_Dispatch_Error(void); + +#endif diff --git a/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c b/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c new file mode 100644 index 00000000..4816b4f2 --- /dev/null +++ b/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c @@ -0,0 +1,266 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: + * Draco + * + * Copyright (c) 2023 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. + **********************************************************************/ + +/* + * + * Copyright (c) 2023, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + +/** + * \file + * \ingroup modules + * + * Coverage test for VxWorks Sysmon + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +#include "PCS_spyLib.h" +#include "PCS_spyLibP.h" + +#include "coveragetest-vxworks_sysmon.h" + +/* + * Reference to the API entry point for the module + */ +extern CFE_PSP_ModuleApi_t CFE_PSP_vxworks_sysmon_API; +const CFE_PSP_ModuleApi_t *TgtAPI = &CFE_PSP_vxworks_sysmon_API; + +void ModuleTest_ResetState(void) +{ + TgtAPI->Init(0); /* Init Vxworks Sysmon */ +} + +void Test_Entry_Nominal(void) +{ + int32 StatusCode; + CFE_PSP_IODriver_API_t *EntryAPI = TgtAPI->ExtendedApi; + + /* Nominal Case: Aggregate Subsystem */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_NOOP, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Nominal Case: Aggregate Subsystem"); + + /* Nominal Case: Cpuload Subsystem */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_NOOP, 1, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Cpuload Subsystem"); + + /* Nominal Case: No Subsystem */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_NOOP, 2, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Nominal Case: No Subsystem"); +} + +void Test_Aggregate_Nominal(void) +{ + int32 StatusCode; + int32 IsRunningStatus;; + CFE_PSP_IODriver_AdcCode_t Sample; + CFE_PSP_IODriver_AnalogRdWr_t RdWr = {.NumChannels = 1, .Samples = &Sample};; + CFE_PSP_IODriver_Direction_t QueryDirArg; + CFE_PSP_IODriver_API_t *EntryAPI = TgtAPI->ExtendedApi; + + /* Nominal Case: Aggregate Dispatch Noop CMD (Not Impl) */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_NOOP, 0, 0, CFE_PSP_IODriver_U32ARG(0)); /* Entry Point */ + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Nominal Case: IO Driver NOOP"); + + /* Nominal Case: Aggregate Dispatch Noop CMD (Not Impl) */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_NOOP, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Nominal Case: ANALOG IO NOOP"); + + /* Nominal Case: Start Vxworks Sysmon */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_SET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + IsRunningStatus = EntryAPI->DeviceCommand(CFE_PSP_IODriver_GET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Start Vxworks Sysmon"); + UtAssert_True(IsRunningStatus == true, "Nominal Case: Vxworks Sysmon running status set"); + + /* Nominal Case: VxWorks Sysmon already running */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_SET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + IsRunningStatus = EntryAPI->DeviceCommand(CFE_PSP_IODriver_GET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Vxworks Sysmon Already Running"); + UtAssert_True(IsRunningStatus == true, "Nominal Case: Vxworks Sysmon running status already set"); + + /* Nominal Case: Stop Vxworks Sysmon */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_SET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + IsRunningStatus = EntryAPI->DeviceCommand(CFE_PSP_IODriver_GET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Stop Vxworks Sysmon"); + UtAssert_True(IsRunningStatus == false, "Nominal Case: Vxworks Sysmon running status disabled"); + + /* Nominal Case: Vxworks Sysmon already stop */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_SET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + IsRunningStatus = EntryAPI->DeviceCommand(CFE_PSP_IODriver_GET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Vxworks Sysmon already stopped"); + UtAssert_True(IsRunningStatus == false, "Nominal Case: Vxworks Sysmon running status already disabled"); + + /* Nominal Case: Set Configuration (Not Impl) */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_SET_CONFIGURATION, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Nominal Case: Set Configuration"); + + /* Nominal Case: Get Configuration (Not Impl) */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_GET_CONFIGURATION, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Nominal Case: Get Configuration"); + + /* Nominal Case: Look Up per-cpu Subsystem */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_LOOKUP_SUBSYSTEM, 0, 0, + CFE_PSP_IODriver_CONST_STR("per-cpu")); + UtAssert_True(StatusCode == 1, "Nominal Case: Look up per-cpu subsytem"); + + /* Nominal Case: Look Up aggregate Subsystem */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_LOOKUP_SUBSYSTEM, 0, 0, + CFE_PSP_IODriver_CONST_STR("aggregate")); + UtAssert_True(StatusCode == 0, "Nominal Case: Look up aggregate subsytem"); + + /* Nominal Case: Look Up cpu-load subchannel */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_LOOKUP_SUBCHANNEL, 0, 0, + CFE_PSP_IODriver_CONST_STR("cpu-load")); + UtAssert_True(StatusCode == 0, "Nominal Case: Look up cpu-load subchannel"); + + /* Nominal Case: Query Direction */ + QueryDirArg = CFE_PSP_IODriver_Direction_DISABLED; + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_QUERY_DIRECTION, 0, 0, CFE_PSP_IODriver_VPARG(&QueryDirArg)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: VxWorks Sysmon Driver Query Direction Status Code"); + UtAssert_True(QueryDirArg == CFE_PSP_IODriver_Direction_INPUT_ONLY, "Nominal Case: VxWorks Sysmon Direction (INPUT ONLY)"); + + /* Nominal Case: Analog IO Read Channel */ + Sample = -1; + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 0, 0, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: VxWorks Sysmon Aggregate CPU Load Status Code"); + UtAssert_True(Sample == 0, "Nominal Case: VxWorks Sysmon Aggregate CPU"); + +} + +void Test_Aggregate_Error(void) +{ + CFE_PSP_IODriver_API_t *EntryAPI = TgtAPI->ExtendedApi; + int32 StatusCode; + int32 IsRunningStatus; + CFE_PSP_IODriver_AdcCode_t Sample; + CFE_PSP_IODriver_AnalogRdWr_t RdWr = {.NumChannels = 1, .Samples = &Sample};; + + /* Error Case: Look Up Subsystem Not Found */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_LOOKUP_SUBSYSTEM, 0, 0, + CFE_PSP_IODriver_CONST_STR("Empty")); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: Subsystem Not Found"); + + /* Error Case: Look Up Subchannel Not Found */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_LOOKUP_SUBCHANNEL, 0, 0, + CFE_PSP_IODriver_CONST_STR("Empty")); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: Subchannel Not Found"); + + /* Error Case: NULL Query Direction */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_QUERY_DIRECTION, 0, 0, CFE_PSP_IODriver_VPARG(NULL)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: NULL Query Direction Status Code"); + + /* Error Case: Analog IO Read, Wrong Channel Number */ + Sample = -1; + RdWr.NumChannels = 0; + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 0, 0, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: Analog IO Read, Wrong Channel Number"); + + /* Error Case: Analog IO Read, Wrong Channel Subchannel */ + Sample = -1; + RdWr.NumChannels = 1; + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 0, 5, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: Analog IO Read, Wrong Subchannel"); + + /* Error Case: Command Code Not Found */ + StatusCode = EntryAPI->DeviceCommand(40, 0, 0, CFE_PSP_IODriver_U32ARG(0)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: Aggregated Substem, Bad Command Code"); + + /* Error Case: Unable To Start Child Process */ + UT_SetDeferredRetcode(UT_KEY(OS_TaskCreate), 1, OS_ERROR); + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_SET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + IsRunningStatus = EntryAPI->DeviceCommand(CFE_PSP_IODriver_GET_RUNNING, 0, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_ERROR, "Error Case: Creating Child Process, Status Code"); + UtAssert_True(IsRunningStatus == false, "Error Case: Creating Child Process, Running Status"); +} + +void Test_Dispatch_Nominal(void) +{ + CFE_PSP_IODriver_API_t *EntryAPI = TgtAPI->ExtendedApi; + CFE_PSP_IODriver_AdcCode_t Sample[2]; + CFE_PSP_IODriver_AnalogRdWr_t RdWr = {.NumChannels = 1, .Samples = Sample}; + int32 StatusCode; + + /* Nominal Case: Dispatch IO Driver NOOP */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_NOOP, 1, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Dispatch IO Driver NOOP "); + + /* Nominal Case: Dispatch Analog IO NOOP */ + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_NOOP, 1, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Dispatch Analog IO NOOP"); + + /* Nominal Case: Dispatch Analog Read Channels */ + Sample[0] = -1; + Sample[1] = -1; + EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 1, 0, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(Sample[0] == 0 && Sample[1] == -1, "Nominal Case: Dispatch cpuload"); +} + +void Test_Dispatch_Error(void) +{ + CFE_PSP_IODriver_API_t *EntryAPI = TgtAPI->ExtendedApi; + CFE_PSP_IODriver_AdcCode_t Sample[2]; + CFE_PSP_IODriver_AnalogRdWr_t RdWr = {.NumChannels = 1, .Samples = Sample}; + int StatusCode; + + /* Error Case: Dispatch Analog Read Channels, Subchannel >= Max Cpu */ + /* Default max cpu == 1 */ + Sample[0] = -1; + Sample[1] = -1; + EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 1, 2, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(Sample[0] == -1 && Sample[1] == -1, "Error Case: Dispatch cpuload, subchannel >= max cpu"); + + /* Error Case: Dispatch Analog Read Channels, NumChannels > max cpu */ + RdWr.NumChannels = 2; + EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 1, 0, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(Sample[0] == -1 && Sample[1] == -1, "Error Case: Dispatch cpuload, NumChannels > max cpu"); + + /* Error Case: Command Code Not Found */ + StatusCode = EntryAPI->DeviceCommand(10, 1, 0, CFE_PSP_IODriver_U32ARG(1)); + UtAssert_True(StatusCode == CFE_PSP_ERROR_NOT_IMPLEMENTED, "Error Case: Command Code Not Found"); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ModuleTest_ResetState, NULL, #test) + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_Entry_Nominal); + ADD_TEST(Test_Aggregate_Nominal); + ADD_TEST(Test_Aggregate_Error); + ADD_TEST(Test_Dispatch_Nominal); + ADD_TEST(Test_Dispatch_Error); +} diff --git a/unit-test-coverage/ut-stubs/CMakeLists.txt b/unit-test-coverage/ut-stubs/CMakeLists.txt index c9c1c91d..3f9aeb2e 100644 --- a/unit-test-coverage/ut-stubs/CMakeLists.txt +++ b/unit-test-coverage/ut-stubs/CMakeLists.txt @@ -49,6 +49,8 @@ add_library(ut_psp_libc_stubs STATIC EXCLUDE_FROM_ALL src/vxworks-rebootLib-stubs.c src/vxworks-sysLib-stubs.c src/vxworks-vxLib-stubs.c + src/vxworks-spyLib-stubs.c + src/vxworks-spyLibP-stubs.c ) target_include_directories(ut_libc_stubs PUBLIC diff --git a/unit-test-coverage/ut-stubs/inc/PCS_spyLib.h b/unit-test-coverage/ut-stubs/inc/PCS_spyLib.h new file mode 100644 index 00000000..088ec671 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_spyLib.h @@ -0,0 +1,39 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2023 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. + ************************************************************************/ + +/* PSP coverage stub replacement for spyLib.h */ +#ifndef PCS_SPYLIB_H +#define PCS_SPYLIB_H + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ----------------------------------------- */ +/* constants normally defined in spyLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in spyLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in spyLib.h */ +/* ----------------------------------------- */ +void PCS_spyLibInit(int maxTasks); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_spyLibP.h b/unit-test-coverage/ut-stubs/inc/PCS_spyLibP.h new file mode 100644 index 00000000..f7d5c71e --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_spyLibP.h @@ -0,0 +1,42 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2023 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. + ************************************************************************/ + +/* PSP coverage stub replacement for spyLibP.h */ +#ifndef PCS_SPYLIBP_H +#define PCS_SPYLIBP_H + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ----------------------------------------- */ +/* constants normally defined in spyLibP.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in spyLibP.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in spyLibP.h */ +/* ----------------------------------------- */ +void PCS_spyReportCommon(PCS_FUNCPTR print); +void PCS_spyClkStopCommon(void); +int PCS_spyClkStartCommon(int intsPerSec, PCS_FUNCPTR print); + + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_stdarg.h b/unit-test-coverage/ut-stubs/inc/PCS_stdarg.h index aa112293..69524342 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_stdarg.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_stdarg.h @@ -40,5 +40,6 @@ typedef struct #define PCS_va_start(ap, last) ap.p = &last #define PCS_va_end(ap) +#define PCS_va_arg(ap, type) (ap.p = (char *)ap.p + sizeof(type), (type) 0) /* FIXME */ #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_stdio.h b/unit-test-coverage/ut-stubs/inc/PCS_stdio.h index 9636800f..dd00db45 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_stdio.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_stdio.h @@ -46,6 +46,7 @@ extern int PCS_snprintf(char *s, size_t maxlen, const char *format, ...); extern int PCS_vsnprintf(char *s, size_t maxlen, const char *format, PCS_va_list arg); extern int PCS_printf(const char *format, ...); extern int PCS_putchar(int c); +extern void PCS_perror(const char *str); extern PCS_FILE *PCS_stdin; extern PCS_FILE *PCS_stdout; diff --git a/unit-test-coverage/ut-stubs/override_inc/private/spyLibP.h b/unit-test-coverage/ut-stubs/override_inc/private/spyLibP.h new file mode 100644 index 00000000..a900d71a --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/private/spyLibP.h @@ -0,0 +1,33 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2023 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. + ************************************************************************/ + +/* PSP coverage stub replacement for spyLibP.h */ +#ifndef OVERRIDE_SPYLIBP_H +#define OVERRIDE_SPYLIBP_H + +#include "PCS_spyLibP.h" +#include + +/* ----------------------------------------- */ +/* mappings for declarations in spyLibP.h */ +/* ----------------------------------------- */ +#define spyReportCommon PCS_spyReportCommon +#define spyClkStartCommon PCS_spyClkStartCommon +#define spyClkStopCommon PCS_spyClkStopCommon + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/spyLib.h b/unit-test-coverage/ut-stubs/override_inc/spyLib.h new file mode 100644 index 00000000..0819ad20 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/spyLib.h @@ -0,0 +1,34 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2023 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. + ************************************************************************/ + +/* PSP coverage stub replacement for spyLib.h */ +#ifndef OVERRIDE_SPYLIB_H +#define OVERRIDE_SPYLIB_H + +#include "PCS_spyLib.h" +#include + +/* ----------------------------------------- */ +/* mappings for declarations in spyLib.h */ +/* ----------------------------------------- */ + +#define spyLibInit PCS_spyLibInit + + + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/stdarg.h b/unit-test-coverage/ut-stubs/override_inc/stdarg.h index 0152b1f5..a2d72bf5 100644 --- a/unit-test-coverage/ut-stubs/override_inc/stdarg.h +++ b/unit-test-coverage/ut-stubs/override_inc/stdarg.h @@ -29,5 +29,6 @@ #define va_list PCS_va_list #define va_start(ap, last) PCS_va_start(ap, last) #define va_end(ap) PCS_va_end(ap) +#define va_arg(ap, type) PCS_va_arg(ap, type) #endif diff --git a/unit-test-coverage/ut-stubs/override_inc/stdio.h b/unit-test-coverage/ut-stubs/override_inc/stdio.h index 7bff6b00..a55da486 100644 --- a/unit-test-coverage/ut-stubs/override_inc/stdio.h +++ b/unit-test-coverage/ut-stubs/override_inc/stdio.h @@ -37,6 +37,7 @@ #define vsnprintf PCS_vsnprintf #define printf(...) PCS_printf(__VA_ARGS__) #define putchar PCS_putchar +#define perror PCS_perror #define stdin PCS_stdin #define stdout PCS_stdout diff --git a/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c b/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c index 702afe42..d5f43c3b 100644 --- a/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c +++ b/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c @@ -194,6 +194,11 @@ int PCS_printf(const char *format, ...) return UT_DEFAULT_IMPL(PCS_printf); } +void PCS_perror(const char * str) +{ + /* No implmentation */ +} + static PCS_FILE LOCAL_FP[3] = {{10}, {11}, {12}}; PCS_FILE *PCS_stdin = &LOCAL_FP[0]; diff --git a/unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c b/unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c new file mode 100644 index 00000000..ef22cbb2 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c @@ -0,0 +1,31 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2023 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. + ************************************************************************/ + +/* PSP coverage stub replacement for spyLib.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_spyLib.h" + + +void PCS_spyLibInit(int maxTasks) +{ + /* Not Implment */ +} + diff --git a/unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c b/unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c new file mode 100644 index 00000000..e70ea0fe --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c @@ -0,0 +1,40 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2023 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. + ************************************************************************/ + +/* PSP coverage stub replacement for spyLibP.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_spyLibP.h" + +void PCS_spyReportCommon(PCS_FUNCPTR print) +{ + /* Not Implement */ +} + +void PCS_spyClkStopCommon(void) +{ + /* Not Implement */ +} + +int PCS_spyClkStartCommon(int intsPerSec, PCS_FUNCPTR print) +{ + return PCS_OK; +} +