From bbfdab8aa78969fb5211a9e18545e52da0678ca1 Mon Sep 17 00:00:00 2001 From: Van Date: Fri, 25 Aug 2023 10:43:19 -0400 Subject: [PATCH 1/3] Fix #405, update rtems_sysmon banner --- fsw/modules/rtems_sysmon/rtems_sysmon.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fsw/modules/rtems_sysmon/rtems_sysmon.c b/fsw/modules/rtems_sysmon/rtems_sysmon.c index ff3bec79..8b9b355a 100644 --- a/fsw/modules/rtems_sysmon/rtems_sysmon.c +++ b/fsw/modules/rtems_sysmon/rtems_sysmon.c @@ -1,13 +1,21 @@ -/*********************************************************************** - * Copyright (c) 2017, United States government as represented by the - * administrator of the National Aeronautics and Space Administration. - * All rights reserved. This software was created at NASA Glenn - * Research Center pursuant to government contracts. +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: + * Draco * - * \file rtems_sysmon.c + * 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. + ************************************************************************/ /* * Based on RTEMS5 cpuusagereport.c */ From b41c89f15c6235eb9f1c1836f7f63ce4c2ae953f Mon Sep 17 00:00:00 2001 From: Van Date: Wed, 30 Aug 2023 10:33:25 -0400 Subject: [PATCH 2/3] Fix #407, unit test for vxworks sysmon Fix #407, unit test for vxworks sysmon gateway --- fsw/modules/vxworks_sysmon/vxworks_sysmon.c | 88 +---- fsw/modules/vxworks_sysmon/vxworks_sysmon.h | 110 ++++++ unit-test-coverage/modules/CMakeLists.txt | 1 + .../modules/vxworks_sysmon/CMakeLists.txt | 12 + .../inc/coveragetest-vxworks_sysmon.h | 63 ++++ .../src/coveragetest-vxworks_sysmon.c | 355 ++++++++++++++++++ unit-test-coverage/ut-stubs/CMakeLists.txt | 2 + unit-test-coverage/ut-stubs/inc/PCS_spyLib.h | 39 ++ unit-test-coverage/ut-stubs/inc/PCS_spyLibP.h | 42 +++ unit-test-coverage/ut-stubs/inc/PCS_stdarg.h | 1 + unit-test-coverage/ut-stubs/inc/PCS_stdio.h | 1 + .../ut-stubs/override_inc/private/spyLibP.h | 33 ++ .../override_inc/{stdarg.h => spyLib.h} | 18 +- .../ut-stubs/override_inc/stdio.h | 1 + .../ut-stubs/src/libc-stdio-stubs.c | 5 + .../ut-stubs/src/vxworks-spyLib-stubs.c | 31 ++ .../ut-stubs/src/vxworks-spyLibP-stubs.c | 49 +++ 17 files changed, 762 insertions(+), 89 deletions(-) create mode 100644 fsw/modules/vxworks_sysmon/vxworks_sysmon.h create mode 100644 unit-test-coverage/modules/vxworks_sysmon/CMakeLists.txt create mode 100644 unit-test-coverage/modules/vxworks_sysmon/inc/coveragetest-vxworks_sysmon.h create mode 100644 unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_spyLib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_spyLibP.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/private/spyLibP.h rename unit-test-coverage/ut-stubs/override_inc/{stdarg.h => spyLib.h} (73%) create mode 100644 unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c diff --git a/fsw/modules/vxworks_sysmon/vxworks_sysmon.c b/fsw/modules/vxworks_sysmon/vxworks_sysmon.c index 36067d1d..d1d6c65f 100644 --- a/fsw/modules/vxworks_sysmon/vxworks_sysmon.c +++ b/fsw/modules/vxworks_sysmon/vxworks_sysmon.c @@ -20,7 +20,6 @@ /************************************************************************ * Includes ************************************************************************/ - #include "cfe_psp.h" #include "iodriver_impl.h" @@ -28,86 +27,12 @@ #include #include #include - -/******************************************************************** - * Local Defines - ********************************************************************/ -#ifdef OS_MAXIMUM_PROCESSORS - #define VXWORKS_SYSMON_MAX_CPUS OS_MAXIMUM_PROCESSORS -#else - #define VXWORKS_SYSMON_MAX_CPUS 1 -#endif - -#define VXWORKS_SYSMON_AGGREGATE_SUBSYS 0 -#define VXWORKS_SYSMON_CPULOAD_SUBSYS 1 -#define VXWORKS_SYSMON_AGGR_CPULOAD_SUBCH 0 -#define VXWORKS_SYSMON_SAMPLE_DELAY 1000 -#define VXWORKS_SYSMON_TASK_PRIORITY 100 -#define VXWORKS_SYSMON_STACK_SIZE 4096 -#define VXWORKS_AUX_CLOCK_INTERRUPT_FREQ 100 /* Frequency to collect data (interrupts per second) */ -#define VXWORKS_SYSMON_MAX_SCALE 100 -#define VXWORKS_SYSMON_TASK_NAME "VXWORKS SYSMON" -#define VXWORKS_SYSMON_MAX_SPY_TASKS 100 /* Max number of tasks to spy on */ - -#ifdef DEBUG_BUILD -#define VXWORKS_SYSMON_DEBUG(...) OS_printf(__VA_ARGS__) -#else -#define VXWORKS_SYSMON_DEBUG(...) -#endif - -/******************************************************************** - * Local Type Definitions - ********************************************************************/ -typedef struct vxworks_sysmon_va_arg -{ - char *name; - char *placeholder; /* empty */ - int total_idle_percent; - int total_idle_ticks; - int idle_percent_since_last_report; - int idle_ticks_since_last_report; - -} vxworks_sysmon_va_arg_t; - -typedef struct vxworks_sysmon_cpuload_core -{ - CFE_PSP_IODriver_AdcCode_t avg_load; - - vxworks_sysmon_va_arg_t idle_state; -} vxworks_sysmon_cpuload_core_t; - -typedef struct vxworks_sysmon_cpuload_state -{ - volatile bool is_running; - volatile bool should_run; - - osal_id_t task_id; - - uint8_t num_cpus; - - vxworks_sysmon_cpuload_core_t per_core[VXWORKS_SYSMON_MAX_CPUS]; - -} vxworks_sysmon_cpuload_state_t; - -typedef struct vxworks_sysmon_state -{ - uint32_t local_module_id; - vxworks_sysmon_cpuload_state_t cpu_load; -} vxworks_sysmon_state_t; +#include "vxworks_sysmon.h" /******************************************************************** * Local Function Prototypes ********************************************************************/ -static void vxworks_sysmon_Init(uint32_t local_module_id); -static int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state); -static int32_t vxworks_sysmon_Stop(vxworks_sysmon_cpuload_state_t *state); - -int32_t vxworks_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg); -int32_t vxworks_sysmon_calc_aggregate_cpu(vxworks_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val); - -/* Function that starts up vxworks_sysmon driver. */ -static int32_t vxworks_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId, - CFE_PSP_IODriver_Arg_t Arg); +static void vxworks_sysmon_Init(uint32_t local_module_id); /******************************************************************** * Global Data @@ -117,7 +42,7 @@ CFE_PSP_IODriver_API_t vxworks_sysmon_DevApi = {.DeviceCommand = vxworks_sysmon_ CFE_PSP_MODULE_DECLARE_IODEVICEDRIVER(vxworks_sysmon); -static vxworks_sysmon_state_t vxworks_sysmon_global; +vxworks_sysmon_state_t vxworks_sysmon_global; static const char *vxworks_sysmon_subsystem_names[] = {"aggregate", "per-cpu", NULL}; static const char *vxworks_sysmon_subchannel_names[] = {"cpu-load", NULL}; @@ -240,7 +165,7 @@ void vxworks_sysmon_Task(void) * Starts the cpu load watcher function * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -static int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state) +int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state) { uint32_t StatusCode; @@ -440,6 +365,11 @@ int32_t vxworks_sysmon_cpu_load_dispatch(uint32_t CommandCode, uint16_t Subchann { RdWr->Samples[ch] = state->per_core[ch].avg_load; } + StatusCode = CFE_PSP_SUCCESS; + } + else + { + StatusCode = CFE_PSP_ERROR; } break; diff --git a/fsw/modules/vxworks_sysmon/vxworks_sysmon.h b/fsw/modules/vxworks_sysmon/vxworks_sysmon.h new file mode 100644 index 00000000..8a5acf4c --- /dev/null +++ b/fsw/modules/vxworks_sysmon/vxworks_sysmon.h @@ -0,0 +1,110 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * \file + * + * Internal header for vxworks_sysmon.c + */ + +#ifndef VXWORKS_SYSMON_H_ +#define VXWORKS_SYSMON_H_ + +/******************************************************************** + * Local Defines + ********************************************************************/ +#ifdef OS_MAXIMUM_PROCESSORS + #define VXWORKS_SYSMON_MAX_CPUS OS_MAXIMUM_PROCESSORS +#else + #define VXWORKS_SYSMON_MAX_CPUS 1 +#endif + +#define VXWORKS_SYSMON_AGGREGATE_SUBSYS 0 +#define VXWORKS_SYSMON_CPULOAD_SUBSYS 1 +#define VXWORKS_SYSMON_AGGR_CPULOAD_SUBCH 0 +#define VXWORKS_SYSMON_SAMPLE_DELAY 1000 +#define VXWORKS_SYSMON_TASK_PRIORITY 100 +#define VXWORKS_SYSMON_STACK_SIZE 4096 +#define VXWORKS_AUX_CLOCK_INTERRUPT_FREQ 100 /* Frequency to collect data (interrupts per second) */ +#define VXWORKS_SYSMON_MAX_SCALE 100 +#define VXWORKS_SYSMON_TASK_NAME "VXWORKS SYSMON" +#define VXWORKS_SYSMON_MAX_SPY_TASKS 100 /* Max number of tasks to spy on */ + +#ifdef DEBUG_BUILD +#define VXWORKS_SYSMON_DEBUG(...) OS_printf(__VA_ARGS__) +#else +#define VXWORKS_SYSMON_DEBUG(...) +#endif + +/******************************************************************** + * Local Type Definitions + ********************************************************************/ +typedef struct vxworks_sysmon_va_arg +{ + char *name; + char *placeholder; /* empty */ + int total_idle_percent; + int total_idle_ticks; + int idle_percent_since_last_report; + int idle_ticks_since_last_report; + +} vxworks_sysmon_va_arg_t; + +typedef struct vxworks_sysmon_cpuload_core +{ + CFE_PSP_IODriver_AdcCode_t avg_load; + + vxworks_sysmon_va_arg_t idle_state; +} vxworks_sysmon_cpuload_core_t; + +typedef struct vxworks_sysmon_cpuload_state +{ + volatile bool is_running; + volatile bool should_run; + + osal_id_t task_id; + + uint8_t num_cpus; + + vxworks_sysmon_cpuload_core_t per_core[VXWORKS_SYSMON_MAX_CPUS]; + +} vxworks_sysmon_cpuload_state_t; + +typedef struct vxworks_sysmon_state +{ + uint32_t local_module_id; + vxworks_sysmon_cpuload_state_t cpu_load; +} vxworks_sysmon_state_t; + +/******************************************************************** + * Local Function Prototypes + ********************************************************************/ +int vxworks_sysmon_update_stat(const char *fmt, ...); +void vxworks_sysmon_Task(void); + +int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state); +int32_t vxworks_sysmon_Stop(vxworks_sysmon_cpuload_state_t *state); + +int32_t vxworks_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg); +int32_t vxworks_sysmon_calc_aggregate_cpu(vxworks_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val); + +/* Function that starts up vxworks_sysmon driver. */ +int32_t vxworks_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId, + CFE_PSP_IODriver_Arg_t Arg); + +#endif /* VXWORKS_SYSMON_H_ */ 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..8fd5655a --- /dev/null +++ b/unit-test-coverage/modules/vxworks_sysmon/CMakeLists.txt @@ -0,0 +1,12 @@ +###################################################################### +# +# 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") +include_directories("${CFEPSP_SOURCE_DIR}/fsw/modules/vxworks_sysmon") + +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..21db0bb2 --- /dev/null +++ b/unit-test-coverage/modules/vxworks_sysmon/inc/coveragetest-vxworks_sysmon.h @@ -0,0 +1,63 @@ +/************************************************************************ + * 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" +#include "vxworks_sysmon.h" + +void UT_TaskDelay_Hook(void *UserObj); + +void Test_Init_Nominal(void); +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); +void Test_UpdateStat_Nominal(void); +void Test_Task_Nominal(void); +void Test_Task_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..d66fd62a --- /dev/null +++ b/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c @@ -0,0 +1,355 @@ +/************************************************************************ + * 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; +extern vxworks_sysmon_state_t vxworks_sysmon_global; +const CFE_PSP_ModuleApi_t *TgtAPI = &CFE_PSP_vxworks_sysmon_API; + +/* Hook */ +void UT_TaskDelay_Hook(void *UserObj) +{ + int *DelayCounter = UserObj; + vxworks_sysmon_global.cpu_load.should_run = false; + + (*DelayCounter)++; + +} + +void ModuleTest_ResetState(void) +{ + memset(&vxworks_sysmon_global, 0, sizeof(vxworks_sysmon_global)); +} + +void Test_Init_Nominal(void) +{ + TgtAPI->Init(1); /* Init Vxworks Sysmon */ + UtAssert_True(vxworks_sysmon_global.local_module_id == 1, "Nominal Case: 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; + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 1, 0, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(StatusCode == CFE_PSP_SUCCESS && 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; + StatusCode = EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 1, 2, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(Sample[0] == -1 && Sample[1] == -1 && StatusCode == CFE_PSP_ERROR, "Error Case: Dispatch cpuload, subchannel >= max cpu"); + + /* Error Case: Dispatch Analog Read Channels, NumChannels > max cpu */ + RdWr.NumChannels = 2; + StatusCode =EntryAPI->DeviceCommand(CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS, 1, 0, CFE_PSP_IODriver_VPARG(&RdWr)); + UtAssert_True(StatusCode == CFE_PSP_ERROR && 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"); +} + +void Test_UpdateStat_Nominal(void) +{ + const char * fmt = "%s %s %s %s %d ( %d) %d ( %d)"; + uint32 AvgLoad; + uint32 IdleTaskLoad; + + /* Nominal Case: Idle String 3 percents load */ + IdleTaskLoad = 97; + vxworks_sysmon_update_stat(fmt, "IDLE", "", "", "", 95, 7990, IdleTaskLoad, 1998); /* Function under test */ + + AvgLoad = ( (0x1000 * (100 - IdleTaskLoad) ) / 100 ); + AvgLoad |= (AvgLoad << 12); + UtAssert_True(vxworks_sysmon_global.cpu_load.per_core[0].avg_load == AvgLoad, "Nominal Case: 3 percents cpuload"); + + /* Nominal Case: Idle String 0 percents load */ + memset(&vxworks_sysmon_global, 0, sizeof(vxworks_sysmon_global)); + IdleTaskLoad = 100; + vxworks_sysmon_update_stat(fmt, "IDLE", "", "", "", 95, 7990, IdleTaskLoad, 1998); /* Function under test */ + + AvgLoad = 0; + UtAssert_True(vxworks_sysmon_global.cpu_load.per_core[0].avg_load == AvgLoad, "Nominal Case: 0 percents cpuload"); + + /* Nominal Case: Idle String 100 percents load */ + memset(&vxworks_sysmon_global, 0, sizeof(vxworks_sysmon_global)); + IdleTaskLoad = 0; + vxworks_sysmon_update_stat(fmt, "IDLE", "", "", "", 95, 7990, IdleTaskLoad, 1998); /* Function under test */ + + AvgLoad = 0xFFFFFF; + UtAssert_True(vxworks_sysmon_global.cpu_load.per_core[0].avg_load == AvgLoad, "Nominal Case: 100 percents cpuload"); + + /* Nominal Case: Max Cpu Num */ + IdleTaskLoad = 0; + vxworks_sysmon_global.cpu_load.num_cpus = 1; + vxworks_sysmon_update_stat(fmt, "IDLE", "", "", "", 95, 7990, IdleTaskLoad, 1998); /* Function under test */ + UtAssert_True(vxworks_sysmon_global.cpu_load.num_cpus == 1, "Nominal Case: Max Cpu Nums"); + + /* Nominal Case: Not Idle String */ + memset(&vxworks_sysmon_global, 0, sizeof(vxworks_sysmon_global)); + vxworks_sysmon_update_stat(fmt, "KERNEL", "", "", "", 95, 7990, 95, 1998); /* Function under test */ + UtAssert_True(vxworks_sysmon_global.cpu_load.per_core[0].avg_load == 0 && vxworks_sysmon_global.cpu_load.num_cpus == 0, + "Nominal Case: Not Idle String"); + +} + +void Test_Task_Nominal(void) +{ + int DelayCounter = 0; + + /* Nominal Case: vxworks sysmon task */ + vxworks_sysmon_global.cpu_load.should_run = true; + UT_SetHookFunction(UT_KEY(OS_TaskDelay), (UT_HookFunc_t)UT_TaskDelay_Hook, &DelayCounter); + vxworks_sysmon_Task(); + + UtAssert_True(DelayCounter == 1, "Nominal Case: Vxworks Sysmon Task"); +} + +void Test_Task_Error(void) +{ + vxworks_sysmon_global.cpu_load.should_run = true; + UT_SetDeferredRetcode(UT_KEY(PCS_spyClkStartCommon), 1, OS_ERROR); + + vxworks_sysmon_Task(); + UtAssert_True(vxworks_sysmon_global.cpu_load.should_run == false, "Error Case: Cannot Start Auxillary Clock"); + +} + +/* + * 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_Init_Nominal); + 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); + ADD_TEST(Test_UpdateStat_Nominal); + ADD_TEST(Test_Task_Nominal); + ADD_TEST(Test_Task_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/stdarg.h b/unit-test-coverage/ut-stubs/override_inc/spyLib.h similarity index 73% rename from unit-test-coverage/ut-stubs/override_inc/stdarg.h rename to unit-test-coverage/ut-stubs/override_inc/spyLib.h index 0152b1f5..87dbf623 100644 --- a/unit-test-coverage/ut-stubs/override_inc/stdarg.h +++ b/unit-test-coverage/ut-stubs/override_inc/spyLib.h @@ -1,7 +1,7 @@ /************************************************************************ * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” * - * Copyright (c) 2020 United States Government as represented by the + * Copyright (c) 2023 United States Government as represented by the * Administrator of the National Aeronautics and Space Administration. * All Rights Reserved. * @@ -16,18 +16,16 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for stdarg.h */ -#ifndef OVERRIDE_STDARG_H -#define OVERRIDE_STDARG_H +/* PSP coverage stub replacement for spyLib.h */ +#ifndef OVERRIDE_SPYLIB_H +#define OVERRIDE_SPYLIB_H -#include "PCS_stdarg.h" +#include "PCS_spyLib.h" +#include /* ----------------------------------------- */ -/* mappings for declarations in stdarg.h */ +/* mappings for declarations in spyLib.h */ /* ----------------------------------------- */ - -#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 spyLibInit PCS_spyLibInit #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..ed226f47 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c @@ -0,0 +1,49 @@ +/************************************************************************ + * 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 "utgenstub.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) +{ + + UT_GenStub_SetupReturnBuffer(PCS_spyClkStartCommon, int32); + + UT_GenStub_AddParam(PCS_spyClkStartCommon, int, intsPerSec); + UT_GenStub_AddParam(PCS_spyClkStartCommon, PCS_FUNCPTR, print); + + UT_GenStub_Execute(PCS_spyClkStartCommon, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_spyClkStartCommon, int32);; +} + From be6150bf2b39c969e0cb1fff4d2b033312fdcdc7 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 18 Oct 2023 07:15:17 -0400 Subject: [PATCH 3/3] Updating documentation and version numbers for v1.6.0-rc4+dev96 --- CHANGELOG.md | 5 +++++ fsw/mcp750-vxworks/inc/psp_version.h | 2 +- fsw/pc-linux/inc/psp_version.h | 2 +- fsw/pc-rtems/inc/psp_version.h | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d151eb4..aba500a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Development Build: v1.6.0-rc4+dev96 +- update rtems_sysmon banner +- unit test for vxworks sysmon +- See and + ## Development Build: v1.6.0-rc4+dev90 - RTEMS.cmake: add quotes around ${RTEMS_BSP_C_FLAGS}. - Fixes errors in IC Bundle workflow file diff --git a/fsw/mcp750-vxworks/inc/psp_version.h b/fsw/mcp750-vxworks/inc/psp_version.h index 3566bb6e..d863371f 100644 --- a/fsw/mcp750-vxworks/inc/psp_version.h +++ b/fsw/mcp750-vxworks/inc/psp_version.h @@ -27,7 +27,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 90 +#define CFE_PSP_IMPL_BUILD_NUMBER 96 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4" /* diff --git a/fsw/pc-linux/inc/psp_version.h b/fsw/pc-linux/inc/psp_version.h index 3566bb6e..d863371f 100644 --- a/fsw/pc-linux/inc/psp_version.h +++ b/fsw/pc-linux/inc/psp_version.h @@ -27,7 +27,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 90 +#define CFE_PSP_IMPL_BUILD_NUMBER 96 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4" /* diff --git a/fsw/pc-rtems/inc/psp_version.h b/fsw/pc-rtems/inc/psp_version.h index 3566bb6e..d863371f 100644 --- a/fsw/pc-rtems/inc/psp_version.h +++ b/fsw/pc-rtems/inc/psp_version.h @@ -27,7 +27,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 90 +#define CFE_PSP_IMPL_BUILD_NUMBER 96 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4" /*