From fb6c855a85b6822b5b34240c3242442d152d9172 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 12 Aug 2024 09:53:23 -0400 Subject: [PATCH 1/6] Fix #435, add coverage tests for PSP modules Adds a coverage test implementation for all existing PSP modules. This should get 100% coverage on all lines and branches. --- fsw/inc/cfe_psp.h | 927 +----------------- fsw/inc/cfe_psp_cache_api.h | 62 ++ fsw/inc/cfe_psp_cds_api.h | 82 ++ fsw/inc/cfe_psp_eepromaccess_api.h | 130 +++ fsw/inc/cfe_psp_error.h | 1 + fsw/inc/cfe_psp_exception_api.h | 103 ++ fsw/inc/cfe_psp_id_api.h | 72 ++ fsw/inc/cfe_psp_memaccess_api.h | 159 +++ fsw/inc/cfe_psp_memrange_api.h | 214 ++++ fsw/inc/cfe_psp_port_api.h | 127 +++ fsw/inc/cfe_psp_ssr_api.h | 63 ++ fsw/inc/cfe_psp_timertick_api.h | 137 +++ fsw/inc/cfe_psp_version_api.h | 106 ++ fsw/inc/cfe_psp_watchdog_api.h | 190 ++++ fsw/modules/eeprom_direct/CMakeLists.txt | 5 + .../eeprom_direct/cfe_psp_eeprom_direct.c | 24 +- fsw/modules/eeprom_mmap_file/CMakeLists.txt | 5 + fsw/modules/eeprom_notimpl/CMakeLists.txt | 5 + fsw/modules/port_direct/CMakeLists.txt | 5 + fsw/modules/port_direct/cfe_psp_port_direct.c | 118 ++- fsw/modules/port_notimpl/CMakeLists.txt | 5 + fsw/modules/ram_direct/CMakeLists.txt | 5 + fsw/modules/ram_notimpl/CMakeLists.txt | 5 + fsw/modules/soft_timebase/CMakeLists.txt | 5 + .../timebase_posix_clock/CMakeLists.txt | 5 + fsw/modules/timebase_vxworks/CMakeLists.txt | 5 + .../cfe_psp_timebase_vxworks.c | 65 +- fsw/shared/inc/cfe_psp_exceptionstorage_api.h | 12 +- .../inc/cfe_psp_exceptionstorage_types.h | 5 +- fsw/shared/inc/cfe_psp_memory.h | 17 +- fsw/shared/inc/cfe_psp_module.h | 70 +- fsw/shared/src/cfe_psp_exceptionstorage.c | 36 +- fsw/shared/src/cfe_psp_memrange.c | 18 +- fsw/shared/src/cfe_psp_memutils.c | 34 +- fsw/shared/src/cfe_psp_module.c | 195 ++-- .../mcp750-vxworks/CMakeLists.txt | 6 +- .../mcp750-vxworks/adaptors/CMakeLists.txt | 1 + .../adaptors/inc/ut-adaptor-bootrec.h | 6 +- .../adaptors/src/ut-adaptor-bootrec.c | 6 +- .../src/coveragetest-cfe-psp-start.c | 6 +- .../src/coveragetest-cfe-psp-support.c | 23 +- .../src/coveragetest-psp-mcp750-vxworks.c | 21 + .../src/coveragetest-psp-mcp750-vxworks.h | 1 + unit-test-coverage/modules/CMakeLists.txt | 16 +- .../modules/eeprom_direct/CMakeLists.txt | 12 + .../coveragetest-eeprom_direct.c | 236 +++++ .../modules/eeprom_mmap_file/CMakeLists.txt | 12 + .../coveragetest-eeprom_mmap_file.c | 209 ++++ .../modules/eeprom_notimpl/CMakeLists.txt | 12 + .../coveragetest-eeprom_notimpl.c | 131 +++ .../modules/iodriver/CMakeLists.txt | 11 + .../modules/iodriver/coveragetest-iodriver.c | 280 ++++++ .../modules/linux_sysmon/CMakeLists.txt | 12 + .../linux_sysmon/coveragetest-linux_sysmon.c | 842 ++++++++++++++++ unit-test-coverage/modules/modlist.txt | 12 + .../modules/port_direct/CMakeLists.txt | 12 + .../port_direct/coveragetest-port_direct.c | 237 +++++ .../modules/port_notimpl/CMakeLists.txt | 12 + .../port_notimpl/coveragetest-port_notimpl.c | 132 +++ .../modules/ram_direct/CMakeLists.txt | 12 + .../ram_direct/coveragetest-ram_direct.c | 220 +++++ .../modules/ram_notimpl/CMakeLists.txt | 12 + .../ram_notimpl/coveragetest-ram_notimpl.c | 132 +++ .../modules/rtems_sysmon/CMakeLists.txt | 12 + .../rtems_sysmon/coveragetest-rtems_sysmon.c | 758 ++++++++++++++ .../modules/soft_timebase/CMakeLists.txt | 10 + .../coveragetest-soft_timebase.c | 84 ++ .../soft_timebase/inc/cfe_psp_config.h | 50 + .../timebase_posix_clock/CMakeLists.txt | 12 + .../coveragetest-timebase_posix_clock.c | 389 ++++++++ .../src/coveragetest-timebase_vxworks.c | 27 + .../src/coveragetest-vxworks_sysmon.c | 147 ++- .../shared/adaptors/inc/ut-adaptor-bootrec.h | 50 + .../shared/adaptors/inc/ut-adaptor-cdsmem.h | 49 + .../adaptors/inc/ut-adaptor-exceptions.h | 4 + .../shared/adaptors/inc/ut-adaptor-memrange.h | 45 + .../shared/adaptors/inc/ut-adaptor-resetmem.h | 48 + .../shared/adaptors/inc/ut-adaptor-usermem.h | 49 + .../shared/adaptors/inc/ut-adaptor-voldisk.h | 49 + .../shared/adaptors/src/ut-adaptor-bootrec.c | 70 ++ .../shared/adaptors/src/ut-adaptor-cdsmem.c | 66 ++ .../adaptors/src/ut-adaptor-exceptions.c | 16 + .../shared/adaptors/src/ut-adaptor-memrange.c | 61 ++ .../shared/adaptors/src/ut-adaptor-resetmem.c | 61 ++ .../shared/adaptors/src/ut-adaptor-usermem.c | 66 ++ .../shared/adaptors/src/ut-adaptor-voldisk.c | 66 ++ .../shared/inc/coveragetest-psp-shared.h | 21 + .../shared/src/coveragetest-cfe-psp-error.c | 54 + .../coveragetest-cfe-psp-exceptionstorage.c | 11 +- .../src/coveragetest-cfe-psp-memrange.c | 118 +++ .../src/coveragetest-cfe-psp-memutils.c | 65 ++ .../shared/src/coveragetest-cfe-psp-module.c | 150 +++ .../shared/src/coveragetest-cfe-psp-version.c | 79 ++ unit-test-coverage/ut-stubs/CMakeLists.txt | 89 +- .../ut-stubs/inc/PCS_arch_ppc_vxPpcLib.h | 4 +- .../ut-stubs/inc/PCS_arpa_inet.h | 68 ++ unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h | 4 +- .../ut-stubs/inc/PCS_cfe_configdata.h | 2 +- .../ut-stubs/inc/PCS_drv_hdisk_ataDrv.h | 2 +- .../ut-stubs/inc/PCS_drv_pci_pciConfigLib.h | 40 + unit-test-coverage/ut-stubs/inc/PCS_errno.h | 80 ++ unit-test-coverage/ut-stubs/inc/PCS_excLib.h | 3 +- unit-test-coverage/ut-stubs/inc/PCS_fcntl.h | 114 +++ unit-test-coverage/ut-stubs/inc/PCS_intLib.h | 39 + unit-test-coverage/ut-stubs/inc/PCS_ioLib.h | 37 + unit-test-coverage/ut-stubs/inc/PCS_net_if.h | 65 ++ .../ut-stubs/inc/PCS_netinet_in.h | 77 ++ .../ut-stubs/inc/PCS_rebootLib.h | 2 +- unit-test-coverage/ut-stubs/inc/PCS_speLib.h | 70 ++ unit-test-coverage/ut-stubs/inc/PCS_stdlib.h | 1 + unit-test-coverage/ut-stubs/inc/PCS_string.h | 2 + .../ut-stubs/inc/PCS_sys950Lib.h | 63 ++ unit-test-coverage/ut-stubs/inc/PCS_sysApi.h | 81 ++ unit-test-coverage/ut-stubs/inc/PCS_sysLib.h | 5 + .../ut-stubs/inc/PCS_sys_mman.h | 48 + .../ut-stubs/inc/PCS_sys_select.h | 78 ++ .../ut-stubs/inc/PCS_sys_socket.h | 108 ++ .../ut-stubs/inc/PCS_sys_stat.h | 50 + .../ut-stubs/inc/PCS_sys_time.h | 71 ++ .../ut-stubs/inc/PCS_sys_types.h | 2 +- unit-test-coverage/ut-stubs/inc/PCS_taskLib.h | 1 + .../ut-stubs/inc/PCS_taskLibCommon.h | 40 + unit-test-coverage/ut-stubs/inc/PCS_tickLib.h | 38 + unit-test-coverage/ut-stubs/inc/PCS_time.h | 12 + unit-test-coverage/ut-stubs/inc/PCS_timers.h | 37 + unit-test-coverage/ut-stubs/inc/PCS_unistd.h | 2 +- unit-test-coverage/ut-stubs/inc/PCS_vxWorks.h | 3 + .../ut-stubs/override_inc/arpa/inet.h | 31 + .../override_inc/drv/pci/pciConfigLib.h | 32 + .../ut-stubs/override_inc/errno.h | 71 ++ .../ut-stubs/override_inc/fcntl.h | 61 ++ .../intLib.h} | 21 +- .../ioLib.h} | 18 +- .../ut-stubs/override_inc/net/if.h | 57 ++ .../ut-stubs/override_inc/netinet/in.h | 63 ++ .../ut-stubs/override_inc/netinet/ip.h | 58 ++ .../ut-stubs/override_inc/speLib.h | 55 ++ .../ut-stubs/override_inc/stdlib.h | 1 + .../ut-stubs/override_inc/string.h | 2 + .../ut-stubs/override_inc/sys/mman.h | 40 + .../ut-stubs/override_inc/sys/select.h | 72 ++ .../ut-stubs/override_inc/sys/socket.h | 76 ++ .../sys/stat.h} | 20 +- .../ut-stubs/override_inc/sys/time.h | 58 ++ .../ut-stubs/override_inc/sys950Lib.h | 56 ++ .../ut-stubs/override_inc/sysApi.h | 59 ++ .../ut-stubs/override_inc/sysLib.h | 9 +- .../ut-stubs/override_inc/taskLib.h | 2 + .../ut-stubs/override_inc/taskLibCommon.h | 34 + .../tickLib.h} | 19 +- .../src/PCS_arch_ppc_vxPpcLib_handlers.c | 38 + .../src/PCS_arch_ppc_vxPpcLib_stubs.c | 107 ++ .../ut-stubs/src/PCS_arpa_inet_handlers.c | 54 + .../ut-stubs/src/PCS_arpa_inet_stubs.c | 61 ++ ...s-bsdnet-stubs.c => PCS_bsdnet_handlers.c} | 28 +- .../ut-stubs/src/PCS_bsdnet_stubs.c | 86 ++ .../ut-stubs/src/PCS_cacheLib_stubs.c | 43 + .../ut-stubs/src/PCS_cfe_configdata_stubs.c | 63 ++ .../ut-stubs/src/PCS_dosFsLib_stubs.c | 44 + .../ut-stubs/src/PCS_drv_hdisk_ataDrv_stubs.c | 46 + .../src/PCS_drv_pci_pciConfigLib_handlers.c | 39 + .../src/PCS_drv_pci_pciConfigLib_stubs.c | 69 ++ .../ut-stubs/src/PCS_errnoLib_stubs.c | 40 + .../PCS_errno_globals.c} | 10 +- .../ut-stubs/src/PCS_excLib_stubs.c | 38 + .../ut-stubs/src/PCS_fcntl_stubs.c | 103 ++ .../ut-stubs/src/PCS_fppLib_stubs.c | 38 + .../ut-stubs/src/PCS_intLib_stubs.c | 52 + ...leLib-stubs.c => PCS_moduleLib_handlers.c} | 31 +- .../ut-stubs/src/PCS_moduleLib_stubs.c | 62 ++ .../ut-stubs/src/PCS_netinet_in_stubs.c | 90 ++ .../ut-stubs/src/PCS_ramDrv_stubs.c | 46 + ...ebootLib-stubs.c => PCS_rebootLib_stubs.c} | 21 +- .../ut-stubs/src/PCS_speLib_stubs.c | 38 + ...ks-spyLibP-stubs.c => PCS_spyLibP_stubs.c} | 53 +- ...orks-spyLib-stubs.c => PCS_spyLib_stubs.c} | 21 +- .../ut-stubs/src/PCS_stdio_handlers.c | 151 +++ .../ut-stubs/src/PCS_stdio_stubs.c | 223 +++++ ...c-stdlib-stubs.c => PCS_stdlib_handlers.c} | 113 +-- .../ut-stubs/src/PCS_stdlib_stubs.c | 131 +++ .../ut-stubs/src/PCS_string_handlers.c | 263 +++++ .../ut-stubs/src/PCS_string_stubs.c | 284 ++++++ .../ut-stubs/src/PCS_sys950Lib_stubs.c | 68 ++ .../ut-stubs/src/PCS_sysApi_stubs.c | 113 +++ ...s-sysLib-stubs.c => PCS_sysLib_handlers.c} | 58 +- .../ut-stubs/src/PCS_sysLib_stubs.c | 208 ++++ .../ut-stubs/src/PCS_sys_mman_stubs.c | 47 + .../ut-stubs/src/PCS_sys_select_stubs.c | 101 ++ .../ut-stubs/src/PCS_sys_socket_handlers.c | 45 + .../ut-stubs/src/PCS_sys_socket_stubs.c | 217 ++++ .../ut-stubs/src/PCS_sys_stat_handlers.c | 52 + .../ut-stubs/src/PCS_sys_stat_stubs.c | 63 ++ .../ut-stubs/src/PCS_taskLib_handlers.c | 137 +++ .../ut-stubs/src/PCS_taskLib_stubs.c | 367 +++++++ .../ut-stubs/src/PCS_time_handlers.c | 38 + .../ut-stubs/src/PCS_time_stubs.c | 62 ++ .../ut-stubs/src/PCS_unistd_handlers.c | 158 +++ .../ut-stubs/src/PCS_unistd_stubs.c | 205 ++++ .../ut-stubs/src/PCS_xbdBlkDev_stubs.c | 60 ++ .../src/cfe_psp_exceptionstorage_api_stubs.c | 97 ++ .../ut-stubs/src/cfe_psp_memory_stubs.c | 64 ++ .../ut-stubs/src/cfe_psp_module_stubs.c | 102 ++ .../ut-stubs/src/libc-stdio-stubs.c | 206 ---- .../ut-stubs/src/libc-string-stubs.c | 205 ---- .../ut-stubs/src/vxworks-taskLib-stubs.c | 159 --- ut-stubs/CMakeLists.txt | 40 +- ut-stubs/src/cfe_psp_cache_api_stubs.c | 40 + ut-stubs/src/cfe_psp_cds_api_handlers.c | 152 +++ ut-stubs/src/cfe_psp_cds_api_stubs.c | 82 ++ ut-stubs/src/cfe_psp_eepromaccess_api_stubs.c | 141 +++ ut-stubs/{ => src}/cfe_psp_error_stubs.c | 1 - ut-stubs/src/cfe_psp_exception_api_handlers.c | 93 ++ ut-stubs/src/cfe_psp_exception_api_stubs.c | 102 ++ .../src/cfe_psp_exceptionstorage_api_stubs.c | 97 ++ ut-stubs/src/cfe_psp_globaldata_stubs.c | 55 ++ .../src/cfe_psp_id_api_handlers.c | 64 +- ut-stubs/src/cfe_psp_id_api_stubs.c | 70 ++ ut-stubs/src/cfe_psp_memaccess_api_handlers.c | 140 +++ ut-stubs/src/cfe_psp_memaccess_api_stubs.c | 170 ++++ ut-stubs/src/cfe_psp_memory_stubs.c | 64 ++ ut-stubs/src/cfe_psp_memrange_api_handlers.c | 144 +++ ut-stubs/src/cfe_psp_memrange_api_stubs.c | 192 ++++ ut-stubs/src/cfe_psp_module_stubs.c | 71 ++ ut-stubs/src/cfe_psp_port_api_stubs.c | 128 +++ ut-stubs/src/cfe_psp_ssr_api_stubs.c | 44 + ut-stubs/src/cfe_psp_stubs.c | 37 + ut-stubs/src/cfe_psp_timertick_api_handlers.c | 82 ++ ut-stubs/src/cfe_psp_timertick_api_stubs.c | 83 ++ ut-stubs/src/cfe_psp_version_api_handlers.c | 80 ++ ut-stubs/src/cfe_psp_version_api_stubs.c | 82 ++ ut-stubs/src/cfe_psp_watchdog_api_handlers.c | 56 ++ ut-stubs/src/cfe_psp_watchdog_api_stubs.c | 139 +++ ut-stubs/ut_psp_stubs.c | 831 ---------------- 233 files changed, 16301 insertions(+), 2878 deletions(-) create mode 100644 fsw/inc/cfe_psp_cache_api.h create mode 100644 fsw/inc/cfe_psp_cds_api.h create mode 100644 fsw/inc/cfe_psp_eepromaccess_api.h create mode 100644 fsw/inc/cfe_psp_exception_api.h create mode 100644 fsw/inc/cfe_psp_id_api.h create mode 100644 fsw/inc/cfe_psp_memaccess_api.h create mode 100644 fsw/inc/cfe_psp_memrange_api.h create mode 100644 fsw/inc/cfe_psp_port_api.h create mode 100644 fsw/inc/cfe_psp_ssr_api.h create mode 100644 fsw/inc/cfe_psp_timertick_api.h create mode 100644 fsw/inc/cfe_psp_version_api.h create mode 100644 fsw/inc/cfe_psp_watchdog_api.h create mode 100644 unit-test-coverage/modules/eeprom_direct/CMakeLists.txt create mode 100644 unit-test-coverage/modules/eeprom_direct/coveragetest-eeprom_direct.c create mode 100644 unit-test-coverage/modules/eeprom_mmap_file/CMakeLists.txt create mode 100644 unit-test-coverage/modules/eeprom_mmap_file/coveragetest-eeprom_mmap_file.c create mode 100644 unit-test-coverage/modules/eeprom_notimpl/CMakeLists.txt create mode 100644 unit-test-coverage/modules/eeprom_notimpl/coveragetest-eeprom_notimpl.c create mode 100644 unit-test-coverage/modules/iodriver/CMakeLists.txt create mode 100644 unit-test-coverage/modules/iodriver/coveragetest-iodriver.c create mode 100644 unit-test-coverage/modules/linux_sysmon/CMakeLists.txt create mode 100644 unit-test-coverage/modules/linux_sysmon/coveragetest-linux_sysmon.c create mode 100644 unit-test-coverage/modules/modlist.txt create mode 100644 unit-test-coverage/modules/port_direct/CMakeLists.txt create mode 100644 unit-test-coverage/modules/port_direct/coveragetest-port_direct.c create mode 100644 unit-test-coverage/modules/port_notimpl/CMakeLists.txt create mode 100644 unit-test-coverage/modules/port_notimpl/coveragetest-port_notimpl.c create mode 100644 unit-test-coverage/modules/ram_direct/CMakeLists.txt create mode 100644 unit-test-coverage/modules/ram_direct/coveragetest-ram_direct.c create mode 100644 unit-test-coverage/modules/ram_notimpl/CMakeLists.txt create mode 100644 unit-test-coverage/modules/ram_notimpl/coveragetest-ram_notimpl.c create mode 100644 unit-test-coverage/modules/rtems_sysmon/CMakeLists.txt create mode 100644 unit-test-coverage/modules/rtems_sysmon/coveragetest-rtems_sysmon.c create mode 100644 unit-test-coverage/modules/soft_timebase/CMakeLists.txt create mode 100644 unit-test-coverage/modules/soft_timebase/coveragetest-soft_timebase.c create mode 100644 unit-test-coverage/modules/soft_timebase/inc/cfe_psp_config.h create mode 100644 unit-test-coverage/modules/timebase_posix_clock/CMakeLists.txt create mode 100644 unit-test-coverage/modules/timebase_posix_clock/coveragetest-timebase_posix_clock.c create mode 100644 unit-test-coverage/shared/adaptors/inc/ut-adaptor-bootrec.h create mode 100644 unit-test-coverage/shared/adaptors/inc/ut-adaptor-cdsmem.h create mode 100644 unit-test-coverage/shared/adaptors/inc/ut-adaptor-memrange.h create mode 100644 unit-test-coverage/shared/adaptors/inc/ut-adaptor-resetmem.h create mode 100644 unit-test-coverage/shared/adaptors/inc/ut-adaptor-usermem.h create mode 100644 unit-test-coverage/shared/adaptors/inc/ut-adaptor-voldisk.h create mode 100644 unit-test-coverage/shared/adaptors/src/ut-adaptor-bootrec.c create mode 100644 unit-test-coverage/shared/adaptors/src/ut-adaptor-cdsmem.c create mode 100644 unit-test-coverage/shared/adaptors/src/ut-adaptor-memrange.c create mode 100644 unit-test-coverage/shared/adaptors/src/ut-adaptor-resetmem.c create mode 100644 unit-test-coverage/shared/adaptors/src/ut-adaptor-usermem.c create mode 100644 unit-test-coverage/shared/adaptors/src/ut-adaptor-voldisk.c create mode 100644 unit-test-coverage/shared/src/coveragetest-cfe-psp-error.c create mode 100644 unit-test-coverage/shared/src/coveragetest-cfe-psp-memrange.c create mode 100644 unit-test-coverage/shared/src/coveragetest-cfe-psp-memutils.c create mode 100644 unit-test-coverage/shared/src/coveragetest-cfe-psp-module.c create mode 100644 unit-test-coverage/shared/src/coveragetest-cfe-psp-version.c create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_arpa_inet.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_drv_pci_pciConfigLib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_errno.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_fcntl.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_intLib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_ioLib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_net_if.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_netinet_in.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_speLib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sys950Lib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sysApi.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sys_mman.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sys_select.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sys_socket.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sys_stat.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_sys_time.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_taskLibCommon.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_tickLib.h create mode 100644 unit-test-coverage/ut-stubs/inc/PCS_timers.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/arpa/inet.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/drv/pci/pciConfigLib.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/errno.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/fcntl.h rename unit-test-coverage/ut-stubs/{src/vxworks-cacheLib-stubs.c => override_inc/intLib.h} (73%) rename unit-test-coverage/ut-stubs/{src/vxworks-excLib-stubs.c => override_inc/ioLib.h} (78%) create mode 100644 unit-test-coverage/ut-stubs/override_inc/net/if.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/netinet/in.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/netinet/ip.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/speLib.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/sys/mman.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/sys/select.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/sys/socket.h rename unit-test-coverage/ut-stubs/{src/vxworks-ataDrv-stubs.c => override_inc/sys/stat.h} (74%) create mode 100644 unit-test-coverage/ut-stubs/override_inc/sys/time.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/sys950Lib.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/sysApi.h create mode 100644 unit-test-coverage/ut-stubs/override_inc/taskLibCommon.h rename unit-test-coverage/ut-stubs/{src/vxworks-fppLib-stubs.c => override_inc/tickLib.h} (75%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_arpa_inet_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_arpa_inet_stubs.c rename unit-test-coverage/ut-stubs/src/{rtems-bsdnet-stubs.c => PCS_bsdnet_handlers.c} (69%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_cacheLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_cfe_configdata_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_dosFsLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_drv_hdisk_ataDrv_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_errnoLib_stubs.c rename unit-test-coverage/ut-stubs/{inc/PCS_dhcs_failsafe.h => src/PCS_errno_globals.c} (84%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_excLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_fcntl_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_fppLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_intLib_stubs.c rename unit-test-coverage/ut-stubs/src/{vxworks-moduleLib-stubs.c => PCS_moduleLib_handlers.c} (59%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_moduleLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_netinet_in_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_ramDrv_stubs.c rename unit-test-coverage/ut-stubs/src/{vxworks-rebootLib-stubs.c => PCS_rebootLib_stubs.c} (70%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_speLib_stubs.c rename unit-test-coverage/ut-stubs/src/{vxworks-spyLibP-stubs.c => PCS_spyLibP_stubs.c} (56%) rename unit-test-coverage/ut-stubs/src/{vxworks-spyLib-stubs.c => PCS_spyLib_stubs.c} (71%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_stdio_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_stdio_stubs.c rename unit-test-coverage/ut-stubs/src/{libc-stdlib-stubs.c => PCS_stdlib_handlers.c} (64%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_stdlib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_string_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_string_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys950Lib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sysApi_stubs.c rename unit-test-coverage/ut-stubs/src/{vxworks-sysLib-stubs.c => PCS_sysLib_handlers.c} (55%) create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sysLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys_mman_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys_select_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys_socket_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys_socket_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys_stat_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_sys_stat_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_taskLib_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_taskLib_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_time_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_time_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_unistd_handlers.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_unistd_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/PCS_xbdBlkDev_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/cfe_psp_memory_stubs.c create mode 100644 unit-test-coverage/ut-stubs/src/cfe_psp_module_stubs.c delete mode 100644 unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c delete mode 100644 unit-test-coverage/ut-stubs/src/libc-string-stubs.c delete mode 100644 unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c create mode 100644 ut-stubs/src/cfe_psp_cache_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_cds_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_cds_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_eepromaccess_api_stubs.c rename ut-stubs/{ => src}/cfe_psp_error_stubs.c (98%) create mode 100644 ut-stubs/src/cfe_psp_exception_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_exception_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_globaldata_stubs.c rename unit-test-coverage/ut-stubs/src/vxworks-vxLib-stubs.c => ut-stubs/src/cfe_psp_id_api_handlers.c (57%) create mode 100644 ut-stubs/src/cfe_psp_id_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_memaccess_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_memaccess_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_memory_stubs.c create mode 100644 ut-stubs/src/cfe_psp_memrange_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_memrange_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_module_stubs.c create mode 100644 ut-stubs/src/cfe_psp_port_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_ssr_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_stubs.c create mode 100644 ut-stubs/src/cfe_psp_timertick_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_timertick_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_version_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_version_api_stubs.c create mode 100644 ut-stubs/src/cfe_psp_watchdog_api_handlers.c create mode 100644 ut-stubs/src/cfe_psp_watchdog_api_stubs.c delete mode 100644 ut-stubs/ut_psp_stubs.c diff --git a/fsw/inc/cfe_psp.h b/fsw/inc/cfe_psp.h index 478c9dcc..789d2c53 100644 --- a/fsw/inc/cfe_psp.h +++ b/fsw/inc/cfe_psp.h @@ -39,104 +39,34 @@ #include "common_types.h" #include "osapi.h" -#include "cfe_psp_error.h" - -/****************************************************************************** - MACRO DEFINITIONS - ******************************************************************************/ - -/* -** Definitions for PSP PANIC types -*/ -#define CFE_PSP_PANIC_STARTUP 1 -#define CFE_PSP_PANIC_VOLATILE_DISK 2 -#define CFE_PSP_PANIC_MEMORY_ALLOC 3 -#define CFE_PSP_PANIC_NONVOL_DISK 4 -#define CFE_PSP_PANIC_STARTUP_SEM 5 -#define CFE_PSP_PANIC_CORE_APP 6 -#define CFE_PSP_PANIC_GENERAL_FAILURE 7 - -/* -** Macros for the file loader -*/ -#define BUFF_SIZE 256 -#define SIZE_BYTE 1 -#define SIZE_HALF 2 -#define SIZE_WORD 3 - -/* -** Define memory types -*/ -#define CFE_PSP_MEM_RAM 1 -#define CFE_PSP_MEM_EEPROM 2 -#define CFE_PSP_MEM_ANY 3 -#define CFE_PSP_MEM_INVALID 4 - -/* -** Define Memory Read/Write Attributes -*/ -#define CFE_PSP_MEM_ATTR_WRITE 0x01 -#define CFE_PSP_MEM_ATTR_READ 0x02 -#define CFE_PSP_MEM_ATTR_READWRITE 0x03 - -/* -** Define the Memory Word Sizes -*/ -#define CFE_PSP_MEM_SIZE_BYTE 0x01 -#define CFE_PSP_MEM_SIZE_WORD 0x02 -#define CFE_PSP_MEM_SIZE_DWORD 0x04 - /* - * Common definition for reset types at the PSP layer - */ -/** @name Reset Types */ -/** \{ */ -#define CFE_PSP_RST_TYPE_PROCESSOR 1 /**< Volatile disk, CDS and User Reserved memory may be valid */ -#define CFE_PSP_RST_TYPE_POWERON 2 /**< All memory has been cleared */ -#define CFE_PSP_RST_TYPE_MAX 3 /**< Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ -/** \} */ - -/* -** Reset Sub-Types -*/ -/** @name Reset Sub-Types */ -/** \{ */ - -/** @brief Reset caused by power having been removed and restored */ -#define CFE_PSP_RST_SUBTYPE_POWER_CYCLE 1 -/** @brief Reset caused by reset button on the board */ -#define CFE_PSP_RST_SUBTYPE_PUSH_BUTTON 2 -/** @brief Reset was caused by a reset line having been stimulated by a hardware special command */ -#define CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND 3 -/** @brief Reset was caused by a watchdog timer expiring */ -#define CFE_PSP_RST_SUBTYPE_HW_WATCHDOG 4 -/** @brief Reset was caused by cFE ES processing a @link #CFE_ES_RESTART_CC Reset Command @endlink */ -#define CFE_PSP_RST_SUBTYPE_RESET_COMMAND 5 -/** @brief Reset was caused by a Processor Exception */ -#define CFE_PSP_RST_SUBTYPE_EXCEPTION 6 -/** @brief Reset was caused in an unknown manner */ -#define CFE_PSP_RST_SUBTYPE_UNDEFINED_RESET 7 -/** @brief Reset was caused by a JTAG or BDM connection */ -#define CFE_PSP_RST_SUBTYPE_HWDEBUG_RESET 8 -/** @brief Reset reverted to a cFE POWERON due to a boot bank switch */ -#define CFE_PSP_RST_SUBTYPE_BANKSWITCH_RESET 9 -/** @brief Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ -#define CFE_PSP_RST_SUBTYPE_MAX 10 -/** \} */ - -/** - * @brief The name of the software/RTOS timebase for general system timers. + * All PSP API sub-components * - * This name may be referred to by CFE TIME and/or SCH when setting up its own timers. + * Historically these were all declared as part of a monolithic cfe_psp.h header file + * Breaking them up aids in unit testability, allowing each sub-component to be tested + * individually - particulary important for items where the implementation was moved to + * a module. The whole API is included here for backward compatibilty. */ -#define CFE_PSP_SOFT_TIMEBASE_NAME "cFS-Master" +#include "cfe_psp_cache_api.h" +#include "cfe_psp_cds_api.h" +#include "cfe_psp_eepromaccess_api.h" +#include "cfe_psp_error.h" +#include "cfe_psp_exception_api.h" +#include "cfe_psp_id_api.h" +#include "cfe_psp_memaccess_api.h" +#include "cfe_psp_memrange_api.h" +#include "cfe_psp_port_api.h" +#include "cfe_psp_ssr_api.h" +#include "cfe_psp_timertick_api.h" +#include "cfe_psp_version_api.h" +#include "cfe_psp_watchdog_api.h" /****************************************************************************** FUNCTION PROTOTYPES ******************************************************************************/ /* -** PSP entry point and reset routines +** PSP entry point */ /*--------------------------------------------------------------------------------------*/ /** @@ -148,823 +78,6 @@ * * @note The flight software (i.e. cFE) should not call this routine. */ -extern void CFE_PSP_Main(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Sample/Read a monotonic platform clock with normalization - * - * Outputs an OS_time_t value indicating the time elapsed since an epoch. The - * epoch is not defined, but typically represents the system boot time. The - * value increases continuously over time and cannot be reset by software. - * - * This is similar to the CFE_PSP_Get_Timebase(), but additionally it normalizes - * the output value to an OS_time_t, thereby providing consistent units to the - * calling application. Any OSAL-provided routine that accepts OS_time_t inputs - * may be used to convert this value into other standardized time units. - * - * @note This should refer to the same time domain as CFE_PSP_Get_Timebase(), - * the primary difference being the format and units of the output value. - * - * @sa CFE_PSP_Get_Timebase() - * - * @param[out] LocalTime Value of PSP tick counter as OS_time_t - */ -extern void CFE_PSP_GetTime(OS_time_t *LocalTime); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Entry point back to the BSP to restart the processor. - * - * The flight software calls this routine to restart the processor. - * - * @param[in] resetType Type of reset - */ -extern void CFE_PSP_Restart(uint32 resetType); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the last reset type - * - * @note If a pointer to a valid memory space is passed in, it returns the reset - * sub-type in that memory. Right now the reset types are application-specific. - * For the cFE they are defined in the cfe_es.h file. - * - * @param restartSubType - */ -extern uint32 CFE_PSP_GetRestartType(uint32 *restartSubType); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief This is a BSP-specific cache flush routine - * - * Provides a common interface to flush the processor caches. This routine is in - * the BSP because it is sometimes implemented in hardware and sometimes taken - * care of by the RTOS. - * - * @param[in] type - * @param[in] address - * @param[in] size - */ -extern void CFE_PSP_FlushCaches(uint32 type, void *address, uint32 size); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the CPU ID as defined by the specific board and BSP. - * - * @return The processor ID - */ -extern uint32 CFE_PSP_GetProcessorId(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the Spacecraft ID (if any) - * - * @return The Spacecraft ID - */ -extern uint32 CFE_PSP_GetSpacecraftId(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the processor name - * - * @return The processor name - */ -extern const char *CFE_PSP_GetProcessorName(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the underlying OS timer tick value - * - * It is used for the performance monitoring software - */ -extern uint32 CFE_PSP_Get_Timer_Tick(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * Provides the resolution of the least significant 32 bits of the 64-bit time - * stamp returned by CFE_PSP_Get_Timebase in timer ticks per second. The timer - * resolution for accuracy should not be any slower than 1000000 ticks per - * second or 1 us (microsecond) per tick - * - * @return The number of timer ticks per second of the time stamp returned by - * CFE_PSP_Get_Timebase - */ -extern uint32 CFE_PSP_GetTimerTicksPerSecond(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * Provides the number that the least significant 32 bits of the 64-bit time - * stamp returned by CFE_PSP_Get_Timebase rolls over. If the lower 32 bits rolls - * at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER will be 1000000. If the - * lower 32 bits rolls at its maximum value (2^32) then - * CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. - * - * @return The number that the least significant 32 bits of the 64-bit time - * stamp returned by CFE_PSP_Get_Timebase rolls over. - */ -extern uint32 CFE_PSP_GetTimerLow32Rollover(void); - -/** - * @brief Sample/Read a monotonic platform clock without normalization - * - * Provides a common interface to system timebase. This routine is in the BSP - * because it is sometimes implemented in hardware and sometimes taken care of - * by the RTOS. - * - * This is defined as a free-running, monotonically-increasing tick counter. The - * epoch is not defined, but typically is the system boot time, and the value - * increases indefinitely as the system runs. The tick period/rate is also not - * defined. - * - * Rollover events - where the range of representable values is exceeded - are - * theoretically possible, but would take many years of continuous uptime to - * occur (typically hundreds of years, if not thousands). System designers - * should ensure that the actual tick rate and resulting timebase range is - * sufficiently large to ensure that rollover is not a concern. - * - * @note This is a "raw" value from the underlying platform with minimal/no - * conversions or normalization applied. Neither the epoch nor the resolution of - * this tick counter is specified, and it may vary from platform to platform. - * Use the CFE_PSP_GetTime() function to sample the timebase and also convert - * the units into a normalized/more consistent form. - * - * @sa CFE_PSP_GetTime() - * - * @param[out] Tbu Buffer to hold the upper 32 bits of a 64-bit tick counter - * @param[out] Tbl Buffer to hold the lower 32 bits of a 64-bit tick counter - */ -extern void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief CFE_PSP_Get_Dec - */ -extern uint32 CFE_PSP_Get_Dec(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Fetches the size of the OS Critical Data Store area. - * - * @param[out] SizeOfCDS Pointer to the variable that will store the size of the CDS - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Writes to the CDS Block. - * - * @param[in] PtrToDataToWrite Pointer to the data that will be written to the CDS - * @param[in] CDSOffset CDS offset - * @param[in] NumBytes Number of bytes to write - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Reads from the CDS Block - * - * @param[out] PtrToDataToRead Pointer to the location that will store the data to be read from the CDS - * @param[in] CDSOffset CDS offset - * @param[in] NumBytes Number of bytes to read - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the location and size of the ES Reset information area. - * - * This area is preserved during a processor reset and is used to store the ER - * Log, System Log and reset-related variables - * - * @param[out] PtrToResetArea Pointer to the variable that will store the location of the reset area - * @param[out] SizeOfResetArea Pointer to the variable that will store the reset area size - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the location and size of the memory used for the cFE user-reserved area. - * - * @param[out] PtrToUserArea Pointer to the variable that will store the location of the user-reserved area - * @param[out] SizeOfUserArea Pointer to the variable that will store the size of the user-reserved area - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the location and size of the memory used for the cFE volatile disk. - * - * @param[out] PtrToVolDisk Pointer to the variable that will store the location of the cFE volatile disk - * @param[out] SizeOfVolDisk Pointer to the variable that will store the size of the cFE volatile disk - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the location and size of the kernel memory. - * - * This function returns the start and end address of the kernel text segment. - * It may not be implemented on all architectures. - * - * @param[out] PtrToKernelSegment Pointer to the variable that will store the location of the kernel text segment - * @param[out] SizeOfKernelSegment Pointer to the variable that will store the size of the kernel text segment - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - * or CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -extern int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the location and size of the kernel memory. - * - * This function returns the start and end address of the CFE text segment. It - * may not be implemented on all architectures. - * - * @param[out] PtrToCFESegment Pointer to the variable that will store the location of the cFE text segment - * @param[out] SizeOfCFESegment Pointer to the variable that will store the size of the cFE text segment - * - * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error - */ -extern int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Configures the watchdog timer. - * - * To set up the timer resolution and/or other settings custom to this platform. - */ -extern void CFE_PSP_WatchdogInit(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Enables the watchdog timer. - */ -extern void CFE_PSP_WatchdogEnable(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Disables the watchdog timer. - */ -extern void CFE_PSP_WatchdogDisable(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Services the watchdog timer according to the value set in WatchDogSet. - * - * Load the watchdog timer with a count that corresponds to the millisecond - * time given in the parameter. - * - * @note Currently an ExpireTime value of zero will result in the minimum reset - * time of 4.5 seconds. All other ExpireTime values will result in a reset time - * of 5.5 seconds. - */ -extern void CFE_PSP_WatchdogService(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Gets the watchdog time in milliseconds - * - * @return The current watchdog value - */ -extern uint32 CFE_PSP_WatchdogGet(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Sets the watchdog time in milliseconds - * - * @param[in] WatchdogValue New watchdog value to set - */ -extern void CFE_PSP_WatchdogSet(uint32 WatchdogValue); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Aborts the cFE startup - * - * Provides a common interface to abort the cFE startup process and return back - * to the OS. - * - * @note This is called by the cFE Core startup code when it needs to abort the - * cFE startup. This should not be called by applications. - * - * @param[in] ErrorCode Reason for exiting - */ -extern void CFE_PSP_Panic(int32 ErrorCode); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Initializes the Solid State recorder memory for a particular platform - * - * @note For the MCP750, this simply initializes the Hard Disk device. - * - * @param[in] bus - * @param[in] device - * @param[in] DeviceName - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR on error - */ -extern int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Uncompresses the source file to the file specified in the destination file name. - * - * @note The Decompress uses the "gzip" algorithm. Files can be compressed - * using the "gzip" program available on almost all host platforms. - * - * @param srcFileName Source file to decompress - * @param dstFileName Destination file name - */ -extern int32 CFE_PSP_Decompress(char *srcFileName, char *dstFileName); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Sets up the exception environment for the chosen platform - * - * On a board, this can be configured to look at a debug flag or switch in order - * to keep the standard OS exception handlers, rather than restarting the system. - */ -extern void CFE_PSP_AttachExceptions(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Defines the CPU and FPU exceptions that are enabled for each cFE Task/App - * - * This function sets a default exception environment that can be used - * - * @note The exception environment is local to each task. Therefore, this must - * be Called for each task that wants to do floating point and catch exceptions. - */ -extern void CFE_PSP_SetDefaultExceptionEnvironment(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the unread exception count - * - * @return The unread exception count - */ -extern uint32 CFE_PSP_Exception_GetCount(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Retrieves a summary of an exception log entry - * - * @note This function returns CFE_PSP_SUCCESS to indicate that an entry was - * popped from the queue. This doesn't necessarily mean that the output fields - * have valid data, but it does mean they are initialized to something. - * - * @param[in] ContextLogId ID of the exception log entry to get a summary for - * @param[in, out] TaskId Pointer to the TaskID buffer - * @param[out] ReasonBuf Pointer to the buffer that will store the exception summary string - * @param[in] ReasonSize Maximum size of the summary string to retrieve - * - * @retval CFE_PSP_SUCCESS on success (see note above) - * @retval CFE_PSP_NO_EXCEPTION_DATA if no context available for reading - */ -extern int32 CFE_PSP_Exception_GetSummary(uint32 *ContextLogId, osal_id_t *TaskId, char *ReasonBuf, uint32 ReasonSize); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Retrieves exception log entry context information - * - * @param[in] ContextLogId ID of the exception log entry to copy - * @param[out] ContextBuf Pointer to the buffer where the context information is to be copied to - * @param[in] ContextSize Maximum size of context information data to copy - * - * @return Size of the copied data - * @retval CFE_PSP_NO_EXCEPTION_DATA if data has expired from the memory log - */ -extern int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint32 ContextSize); - -/* -** I/O Port API -*/ -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Read one byte of memory. - * - * @param[in] PortAddress Address to be read - * @param[out] ByteValue The address content will be copied to the location pointed to by this argument - * - * @return Always returns CFE_PSP_SUCCESS (if implemented) - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write one byte of memory. - * - * @param[out] PortAddress Address to be written to - * @param[in] ByteValue The content pointed to by this argument will be copied to the address - * - * @return Always returns CFE_PSP_SUCCESS (if implemented) - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Read 2 bytes of memory. - * - * @param[in] PortAddress Address to be read - * @param[out] uint16Value The address content will be copied to the location pointed to by this argument - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write 2 bytes of memory. - * - * @param[out] PortAddress Address to be written to - * @param[in] uint16Value the content pointed to by this argument will be copied to the address - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Read 4 bytes of memory. - * - * @param[in] PortAddress Address to be read - * @param[out] uint32Value The address content will be copied to the location pointed to by this argument - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write 4 bytes of memory. - * - * @param[out] PortAddress Address to be written to - * @param[in] uint32Value The content pointed to by this argument will be copied to the address - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value); - -/* -** Memory API -*/ -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Read one byte of memory. - * - * @param[in] MemoryAddress Address to be read - * @param[out] ByteValue The address content will be copied to the location pointed to by this argument - * - * @return Always returns CFE_PSP_SUCCESS (if implemented) - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write one byte of memory. - * - * @param[out] MemoryAddress Address to be written to - * @param[in] ByteValue The content pointed to by this argument will be copied to the address - * - * @return Always returns CFE_PSP_SUCCESS (if implemented) - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Read 2 bytes of memory. - * - * @param[in] MemoryAddress Address to be read - * @param[out] uint16Value The address content will be copied to the location pointed to by this argument - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write 2 bytes of memory. - * - * @param[out] MemoryAddress Address to be written to - * @param[in] uint16Value The content pointed to by this argument will be copied to the address - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Read 4 bytes of memory. - * - * @param[in] MemoryAddress Address to be read - * @param[out] uint32Value The address content will be copied to the location pointed to by this argument - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write 4 bytes of memory. - * - * @param[out] MemoryAddress Address to be written to - * @param[in] uint32Value The content pointed to by this argument will be copied to the address - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Copy 'n' bytes from 'src' to 'dest' - * - * Copies 'n' bytes from memory address pointed to by 'src' to memory - * address pointed to by 'dest'. - * - * @note For now we are using the standard C library call 'memcpy' but if we - * find we need to make it more efficient then we'll implement it in assembly. - * - * @param[out] dest Pointer to the destination address to copy to - * @param[in] src Pointer to the address to copy from - * @param[in] n Number of bytes to copy - * - * @return Always returns CFE_PSP_SUCCESS - */ -int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Copy 'n' bytes of value 'value' to 'dest' - * - * Copies 'n' number of bytes of value 'value' to memory address pointed - * to by 'dest'. - * - * @note For now we are using the standard C library call 'memset' but if we - * find we need to make it more efficient then we'll implement it in assembly. - * - * @param[out] dest Pointer to the destination address to copy to - * @param[in] value Value to set - * @param[in] n Number of bytes to copy - * - * @return Always returns CFE_PSP_SUCCESS - */ -int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Validates the memory range and type using the global CFE_PSP_MemoryTable - * - * @param[in] Address A 32-bit starting address of the memory range - * @param[in] Size A 32-bit size of the memory range (Address + Size = End Address) - * @param[in] MemoryType The memory type to validate, including but not limited to: - * CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY - * Any defined CFE_PSP_MEM_* enumeration can be specified - * - * @retval CFE_PSP_SUCCESS Memory range and type information is valid and can be used. - * @retval CFE_PSP_INVALID_MEM_ADDR Starting address is not valid - * @retval CFE_PSP_INVALID_MEM_TYPE Memory type associated with the range does not match the passed-in type. - * @retval CFE_PSP_INVALID_MEM_RANGE The Memory range associated with the address is not large enough to contain - * Address + Size. - */ -int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Returns the number of memory ranges in the CFE_PSP_MemoryTable - * - * @return Positive integer number of entries in the memory range table - */ -uint32 CFE_PSP_MemRanges(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Populates one of the records in the CFE_PSP_MemoryTable. - * - * @note Because the table is fixed size, the entries are set by using the - * integer index. No validation is done with the address or size. - * - * @param[in] RangeNum A 32-bit integer (starting with 0) specifying the MemoryTable entry. - * @param[in] MemoryType The memory type to validate, including but not limited to: - * CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY - * Any defined CFE_PSP_MEM_* enumeration can be specified - * @param[in] StartAddr A 32-bit starting address of the memory range - * @param[in] Size A 32-bit size of the memory range (Address + Size = End Address) - * @param[in] WordSize The minimum addressable size of the range: - * (CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD) - * @param[in] Attributes The attributes of the Memory Range: - * (CFE_PSP_MEM_ATTR_WRITE, CFE_PSP_MEM_ATTR_READ, CFE_PSP_MEM_ATTR_READWRITE) - * - * @retval CFE_PSP_SUCCESS Memory range set successfully. - * @retval CFE_PSP_INVALID_MEM_RANGE The index into the table is invalid - * @retval FE_PSP_INVALID_MEM_ADDR Starting address is not valid - * @retval CFE_PSP_INVALID_MEM_TYPE Memory type associated with the range does not match the passed-in type. - * @retval CFE_PSP_INVALID_MEM_WORDSIZE The WordSize parameter is not one of the predefined types. - * @retval CFE_PSP_INVALID_MEM_ATTR The Attributes parameter is not one of the predefined types. - * @retval OP_INVALID_MEM_SIZE The Memory range associated with the address is not large enough to contain - * Address + Size. - */ -int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, size_t Size, size_t WordSize, - uint32 Attributes); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Retrieves one of the records in the CFE_PSP_MemoryTable. - * - * @note Because the table is fixed size, the entries are accessed by using the integer index. - * - * @param[in] RangeNum A 32-bit integer (starting with 0) specifying the MemoryTable entry. - * @param[out] MemoryType A pointer to the 32-bit integer where the Memory Type is stored. - * Any defined CFE_PSP_MEM_* enumeration can be specified - * @param[out] StartAddr Pointer to the 32-bit integer where the 32-bit starting address of the memory range is stored. - * @param[out] Size A pointer to the 32-bit integer where the 32-bit size of the memory range is stored. - * @param[out] WordSize A pointer to the 32-bit integer where the minimum addressable size of the range: - * (CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD) - * @param[out] Attributes The attributes of the Memory Range: - * (CFE_PSP_MEM_ATTR_WRITE, CFE_PSP_MEM_ATTR_READ, CFE_PSP_MEM_ATTR_READWRITE) - * - * @retval CFE_PSP_SUCCESS Memory range returned successfully. - * @retval CFE_PSP_INVALID_POINTER Parameter error - * @retval CFE_PSP_INVALID_MEM_RANGE The index into the table is invalid - */ -int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, size_t *Size, size_t *WordSize, - uint32 *Attributes); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write one byte (ByteValue) to EEPROM address MemoryAddress - * - * @param[out] MemoryAddress Memory address to write to - * @param[in] ByteValue Value to write to memory - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific timeout. - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write two bytes (uint16Value) to EEPROM address MemoryAddress - * - * @param[out] MemoryAddress Memory address to write to - * @param[in] uint16Value Value to write to memory - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific timeout. - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Write four bytes (uint32Value) to EEPROM address MemoryAddress - * - * @param[out] MemoryAddress Memory address to write to - * @param[in] uint32Value Value to write to memory - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific timeout. - * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Enable the EEPROM for write operation - * - * @param[in] Bank The bank of EEPROM to enable - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromWriteEnable(uint32 Bank); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Disable the EEPROM from write operation - * - * @param[in] Bank The bank of EEPROM to disable - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromWriteDisable(uint32 Bank); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Power up the EEPROM - * - * @param[in] Bank The bank of EEPROM to power up - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromPowerUp(uint32 Bank); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Power down the EEPROM - * - * @param[in] Bank The bank of EEPROM to power down - * - * @retval CFE_PSP_SUCCESS on success - * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented - */ -int32 CFE_PSP_EepromPowerDown(uint32 Bank); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Obtain the PSP version/baseline identifier string - * - * This retrieves the PSP version identifier string without extra info - * - * @return Version string. This is a fixed string and cannot be NULL. - */ -const char *CFE_PSP_GetVersionString(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Obtain the version code name - * - * This retrieves the PSP code name. This is a compatibility indicator for the - * overall NASA cFS ecosystem. All modular components which are intended to - * interoperate should report the same code name. - * - * @return Code name. This is a fixed string and cannot be NULL. - */ -const char *CFE_PSP_GetVersionCodeName(void); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Retrieves the numeric PSP version identifier as an array of uint8 values - * - * The array of numeric values is in order of precedence: - * [0] = Major Number - * [1] = Minor Number - * [2] = Revision Number - * [3] = Mission Revision - * - * The "Mission Revision" (last output) also indicates whether this is an - * official release, a patched release, or a development version. - * 0 indicates an official release - * 1-254 local patch level (reserved for mission use) - * 255 indicates a development build - * - * @param[out] VersionNumbers A fixed-size array to be filled with the version numbers - */ -void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]); - -/*--------------------------------------------------------------------------------------*/ -/** - * @brief Obtain the PSP library numeric build number - * - * The build number is a monotonically increasing number that (coarsely) - * reflects the number of commits/changes that have been merged since the epoch - * release. During development cycles this number should increase after each - * subsequent merge/modification. - * - * Like other version information, this is a fixed number assigned at compile - * time. - * - * @return The OSAL library build number - */ -uint32 CFE_PSP_GetBuildNumber(void); +void CFE_PSP_Main(void); #endif diff --git a/fsw/inc/cfe_psp_cache_api.h b/fsw/inc/cfe_psp_cache_api.h new file mode 100644 index 00000000..43a97b12 --- /dev/null +++ b/fsw/inc/cfe_psp_cache_api.h @@ -0,0 +1,62 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_CACHE_API_H +#define CFE_PSP_CACHE_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief This is a BSP-specific cache flush routine + * + * Provides a common interface to flush the processor caches. This routine is in + * the BSP because it is sometimes implemented in hardware and sometimes taken + * care of by the RTOS. + * + * @param[in] type + * @param[in] address + * @param[in] size + */ +void CFE_PSP_FlushCaches(uint32 type, void *address, uint32 size); + +#endif diff --git a/fsw/inc/cfe_psp_cds_api.h b/fsw/inc/cfe_psp_cds_api.h new file mode 100644 index 00000000..995c7bce --- /dev/null +++ b/fsw/inc/cfe_psp_cds_api.h @@ -0,0 +1,82 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_CDS_API_H +#define CFE_PSP_CDS_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Fetches the size of the OS Critical Data Store area. + * + * @param[out] SizeOfCDS Pointer to the variable that will store the size of the CDS + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Writes to the CDS Block. + * + * @param[in] PtrToDataToWrite Pointer to the data that will be written to the CDS + * @param[in] CDSOffset CDS offset + * @param[in] NumBytes Number of bytes to write + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Reads from the CDS Block + * + * @param[out] PtrToDataFromRead Pointer to the location that will store the data to be read from the CDS + * @param[in] CDSOffset CDS offset + * @param[in] NumBytes Number of bytes to read + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_ReadFromCDS(void *PtrToDataFromRead, uint32 CDSOffset, uint32 NumBytes); + +#endif diff --git a/fsw/inc/cfe_psp_eepromaccess_api.h b/fsw/inc/cfe_psp_eepromaccess_api.h new file mode 100644 index 00000000..492f4333 --- /dev/null +++ b/fsw/inc/cfe_psp_eepromaccess_api.h @@ -0,0 +1,130 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_EEPROMACCESS_API_H +#define CFE_PSP_EEPROMACCESS_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write one byte (ByteValue) to EEPROM address MemoryAddress + * + * @param[out] MemoryAddress Memory address to write to + * @param[in] ByteValue Value to write to memory + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific timeout. + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write two bytes (uint16Value) to EEPROM address MemoryAddress + * + * @param[out] MemoryAddress Memory address to write to + * @param[in] uint16Value Value to write to memory + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific timeout. + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write four bytes (uint32Value) to EEPROM address MemoryAddress + * + * @param[out] MemoryAddress Memory address to write to + * @param[in] uint32Value Value to write to memory + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_TIMEOUT write operation did not go through after a specific timeout. + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Enable the EEPROM for write operation + * + * @param[in] Bank The bank of EEPROM to enable + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromWriteEnable(uint32 Bank); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Disable the EEPROM from write operation + * + * @param[in] Bank The bank of EEPROM to disable + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromWriteDisable(uint32 Bank); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Power up the EEPROM + * + * @param[in] Bank The bank of EEPROM to power up + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromPowerUp(uint32 Bank); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Power down the EEPROM + * + * @param[in] Bank The bank of EEPROM to power down + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_EepromPowerDown(uint32 Bank); + +#endif diff --git a/fsw/inc/cfe_psp_error.h b/fsw/inc/cfe_psp_error.h index ded4bec1..8fd31596 100644 --- a/fsw/inc/cfe_psp_error.h +++ b/fsw/inc/cfe_psp_error.h @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ************************************************************************/ + #ifndef CFE_PSP_ERROR_H #define CFE_PSP_ERROR_H diff --git a/fsw/inc/cfe_psp_exception_api.h b/fsw/inc/cfe_psp_exception_api.h new file mode 100644 index 00000000..9bff3dcd --- /dev/null +++ b/fsw/inc/cfe_psp_exception_api.h @@ -0,0 +1,103 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_EXCEPTION_API_H +#define CFE_PSP_EXCEPTION_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Sets up the exception environment for the chosen platform + * + * On a board, this can be configured to look at a debug flag or switch in order + * to keep the standard OS exception handlers, rather than restarting the system. + */ +void CFE_PSP_AttachExceptions(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Defines the CPU and FPU exceptions that are enabled for each cFE Task/App + * + * This function sets a default exception environment that can be used + * + * @note The exception environment is local to each task. Therefore, this must + * be Called for each task that wants to do floating point and catch exceptions. + */ +void CFE_PSP_SetDefaultExceptionEnvironment(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the unread exception count + * + * @return The unread exception count + */ +uint32 CFE_PSP_Exception_GetCount(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Retrieves a summary of an exception log entry + * + * @note This function returns CFE_PSP_SUCCESS to indicate that an entry was + * popped from the queue. This doesn't necessarily mean that the output fields + * have valid data, but it does mean they are initialized to something. + * + * @param[in] ContextLogId ID of the exception log entry to get a summary for + * @param[in, out] TaskId Pointer to the TaskID buffer + * @param[out] ReasonBuf Pointer to the buffer that will store the exception summary string + * @param[in] ReasonSize Maximum size of the summary string to retrieve + * + * @retval CFE_PSP_SUCCESS on success (see note above) + * @retval CFE_PSP_NO_EXCEPTION_DATA if no context available for reading + */ +int32 CFE_PSP_Exception_GetSummary(uint32 *ContextLogId, osal_id_t *TaskId, char *ReasonBuf, uint32 ReasonSize); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Retrieves exception log entry context information + * + * @param[in] ContextLogId ID of the exception log entry to copy + * @param[out] ContextBuf Pointer to the buffer where the context information is to be copied to + * @param[in] ContextSize Maximum size of context information data to copy + * + * @return Size of the copied data + * @retval CFE_PSP_NO_EXCEPTION_DATA if data has expired from the memory log + */ +int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint32 ContextSize); + +#endif diff --git a/fsw/inc/cfe_psp_id_api.h b/fsw/inc/cfe_psp_id_api.h new file mode 100644 index 00000000..4c2a9cdf --- /dev/null +++ b/fsw/inc/cfe_psp_id_api.h @@ -0,0 +1,72 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_ID_API_H +#define CFE_PSP_ID_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the CPU ID as defined by the specific board and BSP. + * + * @return The processor ID + */ +uint32 CFE_PSP_GetProcessorId(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the Spacecraft ID (if any) + * + * @return The Spacecraft ID + */ +uint32 CFE_PSP_GetSpacecraftId(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the processor name + * + * @return The processor name + */ +const char *CFE_PSP_GetProcessorName(void); + +#endif diff --git a/fsw/inc/cfe_psp_memaccess_api.h b/fsw/inc/cfe_psp_memaccess_api.h new file mode 100644 index 00000000..0dc0ceaa --- /dev/null +++ b/fsw/inc/cfe_psp_memaccess_api.h @@ -0,0 +1,159 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_MEMACCESS_API_H +#define CFE_PSP_MEMACCESS_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/* +** Memory API +*/ +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Read one byte of memory. + * + * @param[in] MemoryAddress Address to be read + * @param[out] ByteValue The address content will be copied to the location pointed to by this argument + * + * @return Always returns CFE_PSP_SUCCESS (if implemented) + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write one byte of memory. + * + * @param[out] MemoryAddress Address to be written to + * @param[in] ByteValue The content pointed to by this argument will be copied to the address + * + * @return Always returns CFE_PSP_SUCCESS (if implemented) + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Read 2 bytes of memory. + * + * @param[in] MemoryAddress Address to be read + * @param[out] uint16Value The address content will be copied to the location pointed to by this argument + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write 2 bytes of memory. + * + * @param[out] MemoryAddress Address to be written to + * @param[in] uint16Value The content pointed to by this argument will be copied to the address + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Read 4 bytes of memory. + * + * @param[in] MemoryAddress Address to be read + * @param[out] uint32Value The address content will be copied to the location pointed to by this argument + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write 4 bytes of memory. + * + * @param[out] MemoryAddress Address to be written to + * @param[in] uint32Value The content pointed to by this argument will be copied to the address + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Copy 'n' bytes from 'src' to 'dest' + * + * Copies 'n' bytes from memory address pointed to by 'src' to memory + * address pointed to by 'dest'. + * + * @note For now we are using the standard C library call 'memcpy' but if we + * find we need to make it more efficient then we'll implement it in assembly. + * + * @param[out] dest Pointer to the destination address to copy to + * @param[in] src Pointer to the address to copy from + * @param[in] n Number of bytes to copy + * + * @return Always returns CFE_PSP_SUCCESS + */ +int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Copy 'n' bytes of value 'value' to 'dest' + * + * Copies 'n' number of bytes of value 'value' to memory address pointed + * to by 'dest'. + * + * @note For now we are using the standard C library call 'memset' but if we + * find we need to make it more efficient then we'll implement it in assembly. + * + * @param[out] dest Pointer to the destination address to copy to + * @param[in] value Value to set + * @param[in] n Number of bytes to copy + * + * @return Always returns CFE_PSP_SUCCESS + */ +int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n); + +#endif diff --git a/fsw/inc/cfe_psp_memrange_api.h b/fsw/inc/cfe_psp_memrange_api.h new file mode 100644 index 00000000..82482750 --- /dev/null +++ b/fsw/inc/cfe_psp_memrange_api.h @@ -0,0 +1,214 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_MEMRANGE_API_H +#define CFE_PSP_MEMRANGE_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + MACRO DEFINITIONS + ******************************************************************************/ + +/* +** Define memory types +*/ +#define CFE_PSP_MEM_RAM 1 +#define CFE_PSP_MEM_EEPROM 2 +#define CFE_PSP_MEM_ANY 3 +#define CFE_PSP_MEM_INVALID 4 + +/* +** Define Memory Read/Write Attributes +*/ +#define CFE_PSP_MEM_ATTR_WRITE 0x01 +#define CFE_PSP_MEM_ATTR_READ 0x02 +#define CFE_PSP_MEM_ATTR_READWRITE 0x03 + +/* +** Define the Memory Word Sizes +*/ +#define CFE_PSP_MEM_SIZE_BYTE 0x01 +#define CFE_PSP_MEM_SIZE_WORD 0x02 +#define CFE_PSP_MEM_SIZE_DWORD 0x04 + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the location and size of the ES Reset information area. + * + * This area is preserved during a processor reset and is used to store the ER + * Log, System Log and reset-related variables + * + * @param[out] PtrToResetArea Pointer to the variable that will store the location of the reset area + * @param[out] SizeOfResetArea Pointer to the variable that will store the reset area size + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the location and size of the memory used for the cFE user-reserved area. + * + * @param[out] PtrToUserArea Pointer to the variable that will store the location of the user-reserved area + * @param[out] SizeOfUserArea Pointer to the variable that will store the size of the user-reserved area + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the location and size of the memory used for the cFE volatile disk. + * + * @param[out] PtrToVolDisk Pointer to the variable that will store the location of the cFE volatile disk + * @param[out] SizeOfVolDisk Pointer to the variable that will store the size of the cFE volatile disk + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the location and size of the kernel memory. + * + * This function returns the start and end address of the kernel text segment. + * It may not be implemented on all architectures. + * + * @param[out] PtrToKernelSegment Pointer to the variable that will store the location of the kernel text segment + * @param[out] SizeOfKernelSegment Pointer to the variable that will store the size of the kernel text segment + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + * or CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the location and size of the kernel memory. + * + * This function returns the start and end address of the CFE text segment. It + * may not be implemented on all architectures. + * + * @param[out] PtrToCFESegment Pointer to the variable that will store the location of the cFE text segment + * @param[out] SizeOfCFESegment Pointer to the variable that will store the size of the cFE text segment + * + * @return 0 (OS_SUCCESS or CFE_PSP_SUCCESS) on success, -1 (OS_ERROR or CFE_PSP_ERROR) on error + */ +int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Validates the memory range and type using the global CFE_PSP_MemoryTable + * + * @param[in] Address A 32-bit starting address of the memory range + * @param[in] Size A 32-bit size of the memory range (Address + Size = End Address) + * @param[in] MemoryType The memory type to validate, including but not limited to: + * CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY + * Any defined CFE_PSP_MEM_* enumeration can be specified + * + * @retval CFE_PSP_SUCCESS Memory range and type information is valid and can be used. + * @retval CFE_PSP_INVALID_MEM_ADDR Starting address is not valid + * @retval CFE_PSP_INVALID_MEM_TYPE Memory type associated with the range does not match the passed-in type. + * @retval CFE_PSP_INVALID_MEM_RANGE The Memory range associated with the address is not large enough to contain + * Address + Size. + */ +int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the number of memory ranges in the CFE_PSP_MemoryTable + * + * @return Positive integer number of entries in the memory range table + */ +uint32 CFE_PSP_MemRanges(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Populates one of the records in the CFE_PSP_MemoryTable. + * + * @note Because the table is fixed size, the entries are set by using the + * integer index. No validation is done with the address or size. + * + * @param[in] RangeNum A 32-bit integer (starting with 0) specifying the MemoryTable entry. + * @param[in] MemoryType The memory type to validate, including but not limited to: + * CFE_PSP_MEM_RAM, CFE_PSP_MEM_EEPROM, or CFE_PSP_MEM_ANY + * Any defined CFE_PSP_MEM_* enumeration can be specified + * @param[in] StartAddr A 32-bit starting address of the memory range + * @param[in] Size A 32-bit size of the memory range (Address + Size = End Address) + * @param[in] WordSize The minimum addressable size of the range: + * (CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD) + * @param[in] Attributes The attributes of the Memory Range: + * (CFE_PSP_MEM_ATTR_WRITE, CFE_PSP_MEM_ATTR_READ, CFE_PSP_MEM_ATTR_READWRITE) + * + * @retval CFE_PSP_SUCCESS Memory range set successfully. + * @retval CFE_PSP_INVALID_MEM_RANGE The index into the table is invalid + * @retval FE_PSP_INVALID_MEM_ADDR Starting address is not valid + * @retval CFE_PSP_INVALID_MEM_TYPE Memory type associated with the range does not match the passed-in type. + * @retval CFE_PSP_INVALID_MEM_WORDSIZE The WordSize parameter is not one of the predefined types. + * @retval CFE_PSP_INVALID_MEM_ATTR The Attributes parameter is not one of the predefined types. + * @retval OP_INVALID_MEM_SIZE The Memory range associated with the address is not large enough to contain + * Address + Size. + */ +int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, size_t Size, size_t WordSize, + uint32 Attributes); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Retrieves one of the records in the CFE_PSP_MemoryTable. + * + * @note Because the table is fixed size, the entries are accessed by using the integer index. + * + * @param[in] RangeNum A 32-bit integer (starting with 0) specifying the MemoryTable entry. + * @param[out] MemoryType A pointer to the 32-bit integer where the Memory Type is stored. + * Any defined CFE_PSP_MEM_* enumeration can be specified + * @param[out] StartAddr Pointer to the 32-bit integer where the 32-bit starting address of the memory range is stored. + * @param[out] Size A pointer to the 32-bit integer where the 32-bit size of the memory range is stored. + * @param[out] WordSize A pointer to the 32-bit integer where the minimum addressable size of the range: + * (CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_SIZE_WORD, CFE_PSP_MEM_SIZE_DWORD) + * @param[out] Attributes The attributes of the Memory Range: + * (CFE_PSP_MEM_ATTR_WRITE, CFE_PSP_MEM_ATTR_READ, CFE_PSP_MEM_ATTR_READWRITE) + * + * @retval CFE_PSP_SUCCESS Memory range returned successfully. + * @retval CFE_PSP_INVALID_POINTER Parameter error + * @retval CFE_PSP_INVALID_MEM_RANGE The index into the table is invalid + */ +int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, size_t *Size, size_t *WordSize, + uint32 *Attributes); + +#endif diff --git a/fsw/inc/cfe_psp_port_api.h b/fsw/inc/cfe_psp_port_api.h new file mode 100644 index 00000000..cee6ab39 --- /dev/null +++ b/fsw/inc/cfe_psp_port_api.h @@ -0,0 +1,127 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_PORT_API_H +#define CFE_PSP_PORT_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/* +** I/O Port API +*/ +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Read one byte of memory. + * + * @param[in] PortAddress Address to be read + * @param[out] ByteValue The address content will be copied to the location pointed to by this argument + * + * @return Always returns CFE_PSP_SUCCESS (if implemented) + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write one byte of memory. + * + * @param[out] PortAddress Address to be written to + * @param[in] ByteValue The content pointed to by this argument will be copied to the address + * + * @return Always returns CFE_PSP_SUCCESS (if implemented) + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Read 2 bytes of memory. + * + * @param[in] PortAddress Address to be read + * @param[out] uint16Value The address content will be copied to the location pointed to by this argument + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write 2 bytes of memory. + * + * @param[out] PortAddress Address to be written to + * @param[in] uint16Value the content pointed to by this argument will be copied to the address + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Read 4 bytes of memory. + * + * @param[in] PortAddress Address to be read + * @param[out] uint32Value The address content will be copied to the location pointed to by this argument + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Write 4 bytes of memory. + * + * @param[out] PortAddress Address to be written to + * @param[in] uint32Value The content pointed to by this argument will be copied to the address + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR_ADDRESS_MISALIGNED if the address is not aligned to a 16-bit addressing scheme. + * @retval CFE_PSP_ERROR_NOT_IMPLEMENTED if not implemented + */ +int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value); + +#endif diff --git a/fsw/inc/cfe_psp_ssr_api.h b/fsw/inc/cfe_psp_ssr_api.h new file mode 100644 index 00000000..116f9430 --- /dev/null +++ b/fsw/inc/cfe_psp_ssr_api.h @@ -0,0 +1,63 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_SSR_H +#define CFE_PSP_SSR_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Initializes the Solid State recorder memory for a particular platform + * + * @note For the MCP750, this simply initializes the Hard Disk device. + * + * @param[in] bus + * @param[in] device + * @param[in] DeviceName + * + * @retval CFE_PSP_SUCCESS on success + * @retval CFE_PSP_ERROR on error + */ +int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName); + +#endif diff --git a/fsw/inc/cfe_psp_timertick_api.h b/fsw/inc/cfe_psp_timertick_api.h new file mode 100644 index 00000000..efeb1149 --- /dev/null +++ b/fsw/inc/cfe_psp_timertick_api.h @@ -0,0 +1,137 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_TIMERTICK_API_H +#define CFE_PSP_TIMERTICK_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + MACRO DEFINITIONS + ******************************************************************************/ + +/** + * @brief The name of the software/RTOS timebase for general system timers. + * + * This name may be referred to by CFE TIME and/or SCH when setting up its own timers. + */ +#define CFE_PSP_SOFT_TIMEBASE_NAME "cFS-Master" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Sample/Read a monotonic platform clock with normalization + * + * Outputs an OS_time_t value indicating the time elapsed since an epoch. The + * epoch is not defined, but typically represents the system boot time. The + * value increases continuously over time and cannot be reset by software. + * + * This is similar to the CFE_PSP_Get_Timebase(), but additionally it normalizes + * the output value to an OS_time_t, thereby providing consistent units to the + * calling application. Any OSAL-provided routine that accepts OS_time_t inputs + * may be used to convert this value into other standardized time units. + * + * @note This should refer to the same time domain as CFE_PSP_Get_Timebase(), + * the primary difference being the format and units of the output value. + * + * @sa CFE_PSP_Get_Timebase() + * + * @param[out] LocalTime Value of PSP tick counter as OS_time_t + */ +void CFE_PSP_GetTime(OS_time_t *LocalTime); + +/*--------------------------------------------------------------------------------------*/ +/** + * Provides the resolution of the least significant 32 bits of the 64-bit time + * stamp returned by CFE_PSP_Get_Timebase in timer ticks per second. The timer + * resolution for accuracy should not be any slower than 1000000 ticks per + * second or 1 us (microsecond) per tick + * + * @return The number of timer ticks per second of the time stamp returned by + * CFE_PSP_Get_Timebase + */ +uint32 CFE_PSP_GetTimerTicksPerSecond(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * Provides the number that the least significant 32 bits of the 64-bit time + * stamp returned by CFE_PSP_Get_Timebase rolls over. If the lower 32 bits rolls + * at 1 second, then the CFE_PSP_TIMER_LOW32_ROLLOVER will be 1000000. If the + * lower 32 bits rolls at its maximum value (2^32) then + * CFE_PSP_TIMER_LOW32_ROLLOVER will be 0. + * + * @return The number that the least significant 32 bits of the 64-bit time + * stamp returned by CFE_PSP_Get_Timebase rolls over. + */ +uint32 CFE_PSP_GetTimerLow32Rollover(void); + +/** + * @brief Sample/Read a monotonic platform clock without normalization + * + * Provides a common interface to system timebase. This routine is in the BSP + * because it is sometimes implemented in hardware and sometimes taken care of + * by the RTOS. + * + * This is defined as a free-running, monotonically-increasing tick counter. The + * epoch is not defined, but typically is the system boot time, and the value + * increases indefinitely as the system runs. The tick period/rate is also not + * defined. + * + * Rollover events - where the range of representable values is exceeded - are + * theoretically possible, but would take many years of continuous uptime to + * occur (typically hundreds of years, if not thousands). System designers + * should ensure that the actual tick rate and resulting timebase range is + * sufficiently large to ensure that rollover is not a concern. + * + * @note This is a "raw" value from the underlying platform with minimal/no + * conversions or normalization applied. Neither the epoch nor the resolution of + * this tick counter is specified, and it may vary from platform to platform. + * Use the CFE_PSP_GetTime() function to sample the timebase and also convert + * the units into a normalized/more consistent form. + * + * @sa CFE_PSP_GetTime() + * + * @param[out] Tbu Buffer to hold the upper 32 bits of a 64-bit tick counter + * @param[out] Tbl Buffer to hold the lower 32 bits of a 64-bit tick counter + */ +void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl); + +#endif diff --git a/fsw/inc/cfe_psp_version_api.h b/fsw/inc/cfe_psp_version_api.h new file mode 100644 index 00000000..e49ee8bb --- /dev/null +++ b/fsw/inc/cfe_psp_version_api.h @@ -0,0 +1,106 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_VERSION_API_H +#define CFE_PSP_VERSION_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Obtain the PSP version/baseline identifier string + * + * This retrieves the PSP version identifier string without extra info + * + * @return Version string. This is a fixed string and cannot be NULL. + */ +const char *CFE_PSP_GetVersionString(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Obtain the version code name + * + * This retrieves the PSP code name. This is a compatibility indicator for the + * overall NASA cFS ecosystem. All modular components which are intended to + * interoperate should report the same code name. + * + * @return Code name. This is a fixed string and cannot be NULL. + */ +const char *CFE_PSP_GetVersionCodeName(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Retrieves the numeric PSP version identifier as an array of uint8 values + * + * The array of numeric values is in order of precedence: + * [0] = Major Number + * [1] = Minor Number + * [2] = Revision Number + * [3] = Mission Revision + * + * The "Mission Revision" (last output) also indicates whether this is an + * official release, a patched release, or a development version. + * 0 indicates an official release + * 1-254 local patch level (reserved for mission use) + * 255 indicates a development build + * + * @param[out] VersionNumbers A fixed-size array to be filled with the version numbers + */ +void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Obtain the PSP library numeric build number + * + * The build number is a monotonically increasing number that (coarsely) + * reflects the number of commits/changes that have been merged since the epoch + * release. During development cycles this number should increase after each + * subsequent merge/modification. + * + * Like other version information, this is a fixed number assigned at compile + * time. + * + * @return The OSAL library build number + */ +uint32 CFE_PSP_GetBuildNumber(void); + +#endif diff --git a/fsw/inc/cfe_psp_watchdog_api.h b/fsw/inc/cfe_psp_watchdog_api.h new file mode 100644 index 00000000..34f0e01d --- /dev/null +++ b/fsw/inc/cfe_psp_watchdog_api.h @@ -0,0 +1,190 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Author: A. Cudmore +** +** Purpose: This file contains the cFE Platform Support Package(PSP) +** prototypes. +** The PSP routines serve as the "glue" between the RTOS and +** the cFE Flight Software. The routines fill gaps that are not +** really considered part of the OS Abstraction, but are required +** for the cFE flight software implementation. It is possible that +** some of these routines could migrate into the OS AL. +** +*/ + +#ifndef CFE_PSP_WATCHDOG_API_H +#define CFE_PSP_WATCHDOG_API_H + +/****************************************************************************** + INCLUDE FILES + ******************************************************************************/ + +#include "common_types.h" +#include "osapi.h" + +#include "cfe_psp_error.h" + +/****************************************************************************** + MACRO DEFINITIONS + ******************************************************************************/ + +/* +** Definitions for PSP PANIC types +*/ + +/** @name Definitions for PSP PANIC types */ +/** \{ */ +#define CFE_PSP_PANIC_STARTUP 1 +#define CFE_PSP_PANIC_VOLATILE_DISK 2 +#define CFE_PSP_PANIC_MEMORY_ALLOC 3 +#define CFE_PSP_PANIC_NONVOL_DISK 4 +#define CFE_PSP_PANIC_STARTUP_SEM 5 +#define CFE_PSP_PANIC_CORE_APP 6 +#define CFE_PSP_PANIC_GENERAL_FAILURE 7 +/** \} */ + +/* + * Common definition for reset types at the PSP layer + */ +/** @name Reset Types */ +/** \{ */ +#define CFE_PSP_RST_TYPE_PROCESSOR 1 /**< Volatile disk, CDS and User Reserved memory may be valid */ +#define CFE_PSP_RST_TYPE_POWERON 2 /**< All memory has been cleared */ +#define CFE_PSP_RST_TYPE_MAX 3 /**< Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ +/** \} */ + +/* +** Reset Sub-Types +*/ +/** @name Reset Sub-Types */ +/** \{ */ + +/** @brief Reset caused by power having been removed and restored */ +#define CFE_PSP_RST_SUBTYPE_POWER_CYCLE 1 +/** @brief Reset caused by reset button on the board */ +#define CFE_PSP_RST_SUBTYPE_PUSH_BUTTON 2 +/** @brief Reset was caused by a reset line having been stimulated by a hardware special command */ +#define CFE_PSP_RST_SUBTYPE_HW_SPECIAL_COMMAND 3 +/** @brief Reset was caused by a watchdog timer expiring */ +#define CFE_PSP_RST_SUBTYPE_HW_WATCHDOG 4 +/** @brief Reset was caused by cFE ES processing a @link #CFE_ES_RESTART_CC Reset Command @endlink */ +#define CFE_PSP_RST_SUBTYPE_RESET_COMMAND 5 +/** @brief Reset was caused by a Processor Exception */ +#define CFE_PSP_RST_SUBTYPE_EXCEPTION 6 +/** @brief Reset was caused in an unknown manner */ +#define CFE_PSP_RST_SUBTYPE_UNDEFINED_RESET 7 +/** @brief Reset was caused by a JTAG or BDM connection */ +#define CFE_PSP_RST_SUBTYPE_HWDEBUG_RESET 8 +/** @brief Reset reverted to a cFE POWERON due to a boot bank switch */ +#define CFE_PSP_RST_SUBTYPE_BANKSWITCH_RESET 9 +/** @brief Placeholder to indicate 1+ the maximum value that the PSP will ever use. */ +#define CFE_PSP_RST_SUBTYPE_MAX 10 +/** \} */ + +/****************************************************************************** + FUNCTION PROTOTYPES + ******************************************************************************/ + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Entry point back to the BSP to restart the processor. + * + * The flight software calls this routine to restart the processor. + * + * @param[in] resetType Type of reset + */ +void CFE_PSP_Restart(uint32 resetType); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Returns the last reset type + * + * @note If a pointer to a valid memory space is passed in, it returns the reset + * sub-type in that memory. Right now the reset types are application-specific. + * For the cFE they are defined in the cfe_es.h file. + * + * @param restartSubType + */ +uint32 CFE_PSP_GetRestartType(uint32 *restartSubType); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Configures the watchdog timer. + * + * To set up the timer resolution and/or other settings custom to this platform. + */ +void CFE_PSP_WatchdogInit(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Enables the watchdog timer. + */ +void CFE_PSP_WatchdogEnable(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Disables the watchdog timer. + */ +void CFE_PSP_WatchdogDisable(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Services the watchdog timer according to the value set in WatchDogSet. + * + * Load the watchdog timer with a count that corresponds to the millisecond + * time given in the parameter. + * + * @note Currently an ExpireTime value of zero will result in the minimum reset + * time of 4.5 seconds. All other ExpireTime values will result in a reset time + * of 5.5 seconds. + */ +void CFE_PSP_WatchdogService(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Gets the watchdog time in milliseconds + * + * @return The current watchdog value + */ +uint32 CFE_PSP_WatchdogGet(void); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Sets the watchdog time in milliseconds + * + * @param[in] WatchdogValue New watchdog value to set + */ +void CFE_PSP_WatchdogSet(uint32 WatchdogValue); + +/*--------------------------------------------------------------------------------------*/ +/** + * @brief Aborts the cFE startup + * + * Provides a common interface to abort the cFE startup process and return back + * to the OS. + * + * @note This is called by the cFE Core startup code when it needs to abort the + * cFE startup. This should not be called by applications. + * + * @param[in] ErrorCode Reason for exiting + */ +void CFE_PSP_Panic(int32 ErrorCode); + +#endif diff --git a/fsw/modules/eeprom_direct/CMakeLists.txt b/fsw/modules/eeprom_direct/CMakeLists.txt index fe7a9a57..f3d2bf08 100644 --- a/fsw/modules/eeprom_direct/CMakeLists.txt +++ b/fsw/modules/eeprom_direct/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(eeprom_direct cfe_psp_eeprom_direct.c) diff --git a/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c b/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c index 5a3740ec..a44768b8 100644 --- a/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c +++ b/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c @@ -16,20 +16,6 @@ * limitations under the License. ************************************************************************/ -/* -** File : cfe_psp_eeprom.c -** -** Author : Ezra Yeheskeli -** -** Purpose: -** This file contains some of the OS APIs abstraction layer. -** It contains the processor architecture specific calls. -** -** 16-Nov-2003 Ezra Yeheskeli -** - First Creation. -** -*/ - /* ** Include section */ @@ -80,9 +66,9 @@ int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) *-----------------------------------------------------------------*/ int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) { - uint32 write32; - uint32 temp32; - uint32 aligned_address; + uint32 write32; + uint32 temp32; + cpuaddr aligned_address; /* ** check 16 bit alignment , check the 1st lsb @@ -160,8 +146,8 @@ int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) *-----------------------------------------------------------------*/ int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) { - uint32 aligned_address; - uint16 write16, temp16; + cpuaddr aligned_address; + uint16 write16, temp16; temp16 = ByteValue; diff --git a/fsw/modules/eeprom_mmap_file/CMakeLists.txt b/fsw/modules/eeprom_mmap_file/CMakeLists.txt index 41f69afc..9a808788 100644 --- a/fsw/modules/eeprom_mmap_file/CMakeLists.txt +++ b/fsw/modules/eeprom_mmap_file/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(eeprom_mmap_file cfe_psp_eeprom_mmap_file.c) diff --git a/fsw/modules/eeprom_notimpl/CMakeLists.txt b/fsw/modules/eeprom_notimpl/CMakeLists.txt index a855cfa0..2a2452ad 100644 --- a/fsw/modules/eeprom_notimpl/CMakeLists.txt +++ b/fsw/modules/eeprom_notimpl/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(eeprom_notimpl cfe_psp_eeprom_notimpl.c) diff --git a/fsw/modules/port_direct/CMakeLists.txt b/fsw/modules/port_direct/CMakeLists.txt index 2b712a23..b72294f8 100644 --- a/fsw/modules/port_direct/CMakeLists.txt +++ b/fsw/modules/port_direct/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(port_direct cfe_psp_port_direct.c) diff --git a/fsw/modules/port_direct/cfe_psp_port_direct.c b/fsw/modules/port_direct/cfe_psp_port_direct.c index 61af2c31..c4a67f8b 100644 --- a/fsw/modules/port_direct/cfe_psp_port_direct.c +++ b/fsw/modules/port_direct/cfe_psp_port_direct.c @@ -46,9 +46,25 @@ void port_direct_Init(uint32 PspModuleId) *-----------------------------------------------------------------*/ int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) { - (*ByteValue) = (uint8) * ((uint8 *)PortAddress); + int32 iReturnValue = CFE_PSP_SUCCESS; - return CFE_PSP_SUCCESS; + /* Null check */ + if (ByteValue == NULL) + { + iReturnValue = CFE_PSP_INVALID_POINTER; + } + /* Port Address check */ + else if (PortAddress == 0x00000000) + { + iReturnValue = CFE_PSP_INVALID_MEM_ADDR; + } + else + { + (*ByteValue) = (uint8) * ((uint8 *)PortAddress); + iReturnValue = CFE_PSP_SUCCESS; + } + + return iReturnValue; } /*---------------------------------------------------------------- @@ -59,8 +75,16 @@ int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) *-----------------------------------------------------------------*/ int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) { - *((uint8 *)PortAddress) = ByteValue; - return CFE_PSP_SUCCESS; + int32 iReturnValue = CFE_PSP_INVALID_MEM_ADDR; + + /* Address check */ + if (PortAddress != 0x00000000) + { + *((uint8 *)PortAddress) = ByteValue; + iReturnValue = CFE_PSP_SUCCESS; + } + + return iReturnValue; } /*---------------------------------------------------------------- @@ -71,13 +95,29 @@ int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) *-----------------------------------------------------------------*/ int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) { + int32 iReturnValue = CFE_PSP_SUCCESS; + + /* NULL check */ + if (uint16Value == NULL) + { + iReturnValue = CFE_PSP_INVALID_POINTER; + } + /* Port Address check */ + else if (PortAddress == 0x00000000) + { + iReturnValue = CFE_PSP_INVALID_MEM_ADDR; + } /* check 16 bit alignment , check the 1st lsb */ - if (PortAddress & 0x00000001) + else if (PortAddress & 0x00000001) + { + iReturnValue = CFE_PSP_ERROR_ADDRESS_MISALIGNED; + } + else { - return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + (*uint16Value) = *((uint16 *)PortAddress); } - (*uint16Value) = *((uint16 *)PortAddress); - return CFE_PSP_SUCCESS; + + return iReturnValue; } /*---------------------------------------------------------------- @@ -88,13 +128,24 @@ int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) *-----------------------------------------------------------------*/ int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) { + int32 iReturnValue = CFE_PSP_SUCCESS; + + /* Address check */ + if (PortAddress == 0x00000000) + { + iReturnValue = CFE_PSP_INVALID_MEM_ADDR; + } /* check 16 bit alignment , check the 1st lsb */ - if (PortAddress & 0x00000001) + else if (PortAddress & 0x00000001) { - return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + iReturnValue = CFE_PSP_ERROR_ADDRESS_MISALIGNED; } - *((uint16 *)PortAddress) = uint16Value; - return CFE_PSP_SUCCESS; + else + { + *((uint16 *)PortAddress) = uint16Value; + } + + return iReturnValue; } /*---------------------------------------------------------------- @@ -105,13 +156,29 @@ int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) *-----------------------------------------------------------------*/ int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) { + int32 iReturnValue = CFE_PSP_SUCCESS; + + /* NULL check */ + if (uint32Value == NULL) + { + iReturnValue = CFE_PSP_INVALID_POINTER; + } + /* Port Address check */ + else if (PortAddress == 0x00000000) + { + iReturnValue = CFE_PSP_INVALID_MEM_ADDR; + } /* check 32 bit alignment */ - if (PortAddress & 0x00000003) + else if (PortAddress & 0x00000003) { - return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + iReturnValue = CFE_PSP_ERROR_ADDRESS_MISALIGNED; } - (*uint32Value) = *((uint32 *)PortAddress); - return CFE_PSP_SUCCESS; + else + { + (*uint32Value) = *((uint32 *)PortAddress); + } + + return iReturnValue; } /*---------------------------------------------------------------- @@ -122,11 +189,22 @@ int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) *-----------------------------------------------------------------*/ int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) { + int32 iReturnValue = CFE_PSP_SUCCESS; + + /* Address check */ + if (PortAddress == 0x00000000) + { + iReturnValue = CFE_PSP_INVALID_MEM_ADDR; + } /* check 32 bit alignment */ - if (PortAddress & 0x00000003) + else if (PortAddress & 0x00000003) + { + iReturnValue = CFE_PSP_ERROR_ADDRESS_MISALIGNED; + } + else { - return CFE_PSP_ERROR_ADDRESS_MISALIGNED; + *((uint32 *)PortAddress) = uint32Value; } - *((uint32 *)PortAddress) = uint32Value; - return CFE_PSP_SUCCESS; + + return iReturnValue; } diff --git a/fsw/modules/port_notimpl/CMakeLists.txt b/fsw/modules/port_notimpl/CMakeLists.txt index ddb504b8..92b82d9a 100644 --- a/fsw/modules/port_notimpl/CMakeLists.txt +++ b/fsw/modules/port_notimpl/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(port_notimpl cfe_psp_port_notimpl.c) diff --git a/fsw/modules/ram_direct/CMakeLists.txt b/fsw/modules/ram_direct/CMakeLists.txt index f81bd6b9..f1594100 100644 --- a/fsw/modules/ram_direct/CMakeLists.txt +++ b/fsw/modules/ram_direct/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(ram_direct cfe_psp_ram_direct.c) diff --git a/fsw/modules/ram_notimpl/CMakeLists.txt b/fsw/modules/ram_notimpl/CMakeLists.txt index 6f7ba325..07cb7b70 100644 --- a/fsw/modules/ram_notimpl/CMakeLists.txt +++ b/fsw/modules/ram_notimpl/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(ram_notimpl cfe_psp_ram_notimpl.c) diff --git a/fsw/modules/soft_timebase/CMakeLists.txt b/fsw/modules/soft_timebase/CMakeLists.txt index 29a077dc..bec8968e 100644 --- a/fsw/modules/soft_timebase/CMakeLists.txt +++ b/fsw/modules/soft_timebase/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(soft_timebase cfe_psp_soft_timebase.c) diff --git a/fsw/modules/timebase_posix_clock/CMakeLists.txt b/fsw/modules/timebase_posix_clock/CMakeLists.txt index 7150d1f0..e952a4e6 100644 --- a/fsw/modules/timebase_posix_clock/CMakeLists.txt +++ b/fsw/modules/timebase_posix_clock/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(timebase_posix_clock cfe_psp_timebase_posix_clock.c) diff --git a/fsw/modules/timebase_vxworks/CMakeLists.txt b/fsw/modules/timebase_vxworks/CMakeLists.txt index e8aeecce..90d13786 100644 --- a/fsw/modules/timebase_vxworks/CMakeLists.txt +++ b/fsw/modules/timebase_vxworks/CMakeLists.txt @@ -1,3 +1,8 @@ +###################################################################### +# +# CMAKE build recipe for modular PSP component +# +###################################################################### # Create the module add_psp_module(timebase_vxworks cfe_psp_timebase_vxworks.c) diff --git a/fsw/modules/timebase_vxworks/cfe_psp_timebase_vxworks.c b/fsw/modules/timebase_vxworks/cfe_psp_timebase_vxworks.c index 056b490e..bd7a9ba6 100644 --- a/fsw/modules/timebase_vxworks/cfe_psp_timebase_vxworks.c +++ b/fsw/modules/timebase_vxworks/cfe_psp_timebase_vxworks.c @@ -44,7 +44,6 @@ #include #include #include -#include #include "osapi-clock.h" @@ -61,6 +60,12 @@ */ #define CFE_PSP_TIMER_LOW32_ROLLOVER 0 +/** + ** \brief Timebase structure for VxWorks + ** + ** This is the structure holding the global values configuring the VxWorks + ** timebase + */ typedef struct { uint32 TicksPerSecond; @@ -68,10 +73,16 @@ typedef struct uint32 OSTimeConvDenominator; } PSP_VxWorks_Timebase_Global_t; +/** \brief Timebase global structure */ PSP_VxWorks_Timebase_Global_t PSP_VxWorks_Timebase_Global; CFE_PSP_MODULE_DECLARE_SIMPLE(timebase_vxworks); +/*---------------------------------------------------------------- + * + * Module Initialization + * + *-----------------------------------------------------------------*/ void timebase_vxworks_Init(uint32 PspModuleId) { uint64 TicksPerSec; @@ -162,7 +173,7 @@ uint32 CFE_PSP_GetTimerTicksPerSecond(void) *-----------------------------------------------------------------*/ uint32 CFE_PSP_GetTimerLow32Rollover(void) { - return 0; + return CFE_PSP_TIMER_LOW32_ROLLOVER; } /*---------------------------------------------------------------- @@ -173,7 +184,10 @@ uint32 CFE_PSP_GetTimerLow32Rollover(void) *-----------------------------------------------------------------*/ void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) { - vxTimeBaseGet((UINT32 *)Tbu, (UINT32 *)Tbl); + if ((Tbu != NULL) && (Tbl != NULL)) + { + vxTimeBaseGet((UINT32 *)Tbu, (UINT32 *)Tbl); + } } /****************************************************************************** @@ -193,28 +207,31 @@ void CFE_PSP_GetTime(OS_time_t *LocalTime) uint32 RegUpper; uint32 RegLower; - vxTimeBaseGet(&RegUpper, &RegLower); + if (LocalTime != NULL) + { + vxTimeBaseGet(&RegUpper, &RegLower); - /* - * Convert to a uint64 value. Per the Power ISA definition, this - * register wraps at (2^60)-1. However at the tick rate implemented - * here this would require running continuously (without a power - * cycle or reset) for over 2000 years to reach that point, so - * for all practical purposes it does not roll over. - */ - NormalizedTicks = RegUpper; - NormalizedTicks <<= 32; - NormalizedTicks |= RegLower; + /* + * Convert to a uint64 value. Per the Power ISA definition, this + * register wraps at (2^60)-1. However at the tick rate implemented + * here this would require running continuously (without a power + * cycle or reset) for over 2000 years to reach that point, so + * for all practical purposes it does not roll over. + */ + NormalizedTicks = RegUpper; + NormalizedTicks <<= 32; + NormalizedTicks |= RegLower; - /* - * Apply the pre-computed conversion to OS_time_t. - * - * This ratio has been reduced during init such that it should minimize - * the impact on overall range of the 64-bit value. - */ - NormalizedTicks *= PSP_VxWorks_Timebase_Global.OSTimeConvNumerator; - NormalizedTicks /= PSP_VxWorks_Timebase_Global.OSTimeConvDenominator; + /* + * Apply the pre-computed conversion to OS_time_t. + * + * This ratio has been reduced during init such that it should minimize + * the impact on overall range of the 64-bit value. + */ + NormalizedTicks *= PSP_VxWorks_Timebase_Global.OSTimeConvNumerator; + NormalizedTicks /= PSP_VxWorks_Timebase_Global.OSTimeConvDenominator; - /* Output the value as an OS_time_t */ - *LocalTime = (OS_time_t) {NormalizedTicks}; + /* Output the value as an OS_time_t */ + *LocalTime = (OS_time_t) {NormalizedTicks}; + } } diff --git a/fsw/shared/inc/cfe_psp_exceptionstorage_api.h b/fsw/shared/inc/cfe_psp_exceptionstorage_api.h index fe962a98..f46f1656 100644 --- a/fsw/shared/inc/cfe_psp_exceptionstorage_api.h +++ b/fsw/shared/inc/cfe_psp_exceptionstorage_api.h @@ -47,7 +47,7 @@ struct CFE_PSP_Exception_LogData; * \param seq Sequence number * \returns pointer to buffer. */ -extern struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetBuffer(uint32 seq); +struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetBuffer(uint32 seq); /** * \brief Get the next buffer for exception context storage @@ -58,7 +58,7 @@ extern struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetBuffer(uint32 seq) * * \returns pointer to buffer, or NULL if storage is full. */ -extern struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetNextContextBuffer(void); +struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetNextContextBuffer(void); /** * \brief Finish storage of exception data @@ -67,14 +67,14 @@ extern struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetNextContextBuffer( * once the exception context capture is complete. This should be invoked after a successful * call to CFE_PSP_Exception_GetNextContextBuffer() to commit the information to the log. */ -extern void CFE_PSP_Exception_WriteComplete(void); +void CFE_PSP_Exception_WriteComplete(void); /** * \brief Reset the exception storage buffer * * Marks any pending exceptions as "read". This resets the state of exception processing. */ -extern void CFE_PSP_Exception_Reset(void); +void CFE_PSP_Exception_Reset(void); /* ------------------------------------------------------------- * Functions implemented in impl layer, invoked by shared layer. @@ -91,7 +91,7 @@ extern void CFE_PSP_Exception_Reset(void); * * \returns CFE_PSP_SUCCESS on success */ -extern int32 CFE_PSP_ExceptionGetSummary_Impl(const struct CFE_PSP_Exception_LogData *Buffer, char *ReasonBuf, - uint32 ReasonSize); +int32 CFE_PSP_ExceptionGetSummary_Impl(const struct CFE_PSP_Exception_LogData *Buffer, char *ReasonBuf, + uint32 ReasonSize); #endif /* CFE_PSP_EXCEPTIONSTORAGE_API_H_ */ diff --git a/fsw/shared/inc/cfe_psp_exceptionstorage_types.h b/fsw/shared/inc/cfe_psp_exceptionstorage_types.h index 22ff2a28..7c38d922 100644 --- a/fsw/shared/inc/cfe_psp_exceptionstorage_types.h +++ b/fsw/shared/inc/cfe_psp_exceptionstorage_types.h @@ -46,8 +46,9 @@ struct CFE_PSP_Exception_LogData struct CFE_PSP_ExceptionStorage { - volatile uint32 NumWritten; - volatile uint32 NumRead; + volatile uint32 NumWritten; + volatile uint32 NumRead; + struct CFE_PSP_Exception_LogData Entries[CFE_PSP_MAX_EXCEPTION_ENTRIES]; }; diff --git a/fsw/shared/inc/cfe_psp_memory.h b/fsw/shared/inc/cfe_psp_memory.h index c50c37c0..cfa06477 100644 --- a/fsw/shared/inc/cfe_psp_memory.h +++ b/fsw/shared/inc/cfe_psp_memory.h @@ -38,8 +38,8 @@ #include "cfe_psp_config.h" #include "cfe_psp_exceptionstorage_types.h" -/* -** Memory table type +/** +** \brief Memory Table Type */ typedef struct { @@ -50,12 +50,18 @@ typedef struct uint32 Attributes; } CFE_PSP_MemTable_t; +/** +** \brief Memory Block Type +*/ typedef struct { void * BlockPtr; size_t BlockSize; } CFE_PSP_MemoryBlock_t; +/** +** \brief Reserved Memory Map +*/ typedef struct { CFE_PSP_ReservedMemoryBootRecord_t *BootPtr; @@ -72,7 +78,6 @@ typedef struct * This is the table used for CFE_PSP_MemRangeGet/Set and related ops * that allow CFE applications to query the general system memory map. */ - CFE_PSP_MemTable_t SysMemoryTable[CFE_PSP_MEM_TABLE_SIZE]; } CFE_PSP_ReservedMemoryMap_t; @@ -81,7 +86,7 @@ typedef struct * * This must be called by the startup code before the map is accessed. */ -extern void CFE_PSP_SetupReservedMemoryMap(void); +void CFE_PSP_SetupReservedMemoryMap(void); /* * CFE_PSP_InitProcessorReservedMemory initializes all of the memory in the @@ -93,7 +98,7 @@ extern void CFE_PSP_SetupReservedMemoryMap(void); * is preserved on a processor reset, and cleared/reinitialized on a power-on * reset. */ -extern int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType); +int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType); /** * \brief Unlink the memory segments within the CFE_PSP_ReservedMemoryMap global object @@ -102,7 +107,7 @@ extern int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType); * as kernel shared memory segments. The segments will be marked for deletion * but the local maps remain usable until the process ends. */ -extern void CFE_PSP_DeleteProcessorReservedMemory(void); +void CFE_PSP_DeleteProcessorReservedMemory(void); /* ** External variables diff --git a/fsw/shared/inc/cfe_psp_module.h b/fsw/shared/inc/cfe_psp_module.h index ed410fdf..03cf938f 100644 --- a/fsw/shared/inc/cfe_psp_module.h +++ b/fsw/shared/inc/cfe_psp_module.h @@ -19,18 +19,50 @@ /** * \file * - * Created on: Jul 17, 2015 - * Author: joseph.p.hickey@nasa.gov - * - * Placeholder for file content description + * PSP Module Header */ -#ifndef CFE_PSP_MODULE_H_ -#define CFE_PSP_MODULE_H_ +#ifndef CFE_PSP_MODULE_H +#define CFE_PSP_MODULE_H #include "cfe_psp.h" #include "target_config.h" +/** + * \brief Combines the basic information about a module list + * + * This is the info typically needed when finding a module + * - pointer to first module + * - length of list + * - "id" space used for list (base value) + */ +typedef struct CFE_PSP_ModuleListWrapper +{ + CFE_StaticModuleLoadEntry_t *BasePtr; + uint32 ListLen; + uint32 BaseId; +} CFE_PSP_ModuleListWrapper_t; + +/** + * \brief Combines the fixed and user-selected module lists + * + * This allows the complete set of modules to be expressed + * in a single structure + */ +typedef struct CFE_PSP_ModuleListGlobal +{ + /** The "Std" list has the basic set of modules that must always be present */ + CFE_PSP_ModuleListWrapper_t Std; + + /** The "Ext" list has any additional optional modules that the user has selected */ + CFE_PSP_ModuleListWrapper_t Ext; + +} CFE_PSP_ModuleListGlobal_t; + +/** + ** \brief Enum Module Type + ** May be extended in the future + */ typedef enum { CFE_PSP_MODULE_TYPE_INVALID = 0, @@ -90,6 +122,32 @@ typedef const struct */ void CFE_PSP_ModuleInit(void); +/** + * Search for a specific module name within a module list + * + * This is an internal helper function, but declared in a header for unit testing purposes. + * This facilitates CFE_PSP_Module_FindByName and not intended to be called directly. + * + * \param WrapPtr List to search + * \param ModuleName Name to search for + * + * \returns Module ID of matching entry + * \retval 0 if name does not appear in list + */ +uint32 CFE_PSP_Module_SearchNameInList(const CFE_PSP_ModuleListWrapper_t *WrapPtr, const char *ModuleName); + +/** + * Initialze a module list + * + * This is an internal helper function, but declared in a header for unit testing purposes. + * This facilitates CFE_PSP_ModuleInit and not intended to be called directly. + * + * \param WrapPtr Wrapper to initialize + * \param BaseId Module ID base to use for entries in list + * \param ListPtr Pointer to list. Must be terminated with NULL name entry. + */ +void CFE_PSP_ModuleInitList(CFE_PSP_ModuleListWrapper_t *WrapPtr, uint32 BaseId, CFE_StaticModuleLoadEntry_t *ListPtr); + /** * Obtain the ID for a named module. * diff --git a/fsw/shared/src/cfe_psp_exceptionstorage.c b/fsw/shared/src/cfe_psp_exceptionstorage.c index fea838ff..c23e6317 100644 --- a/fsw/shared/src/cfe_psp_exceptionstorage.c +++ b/fsw/shared/src/cfe_psp_exceptionstorage.c @@ -16,21 +16,6 @@ * limitations under the License. ************************************************************************/ -/****************************************************************************** -** -** File: cfe_psp_exception.c -** -** MCP750 vxWorks 6.2 Version -** -** Purpose: -** cFE PSP Exception related functions. -** -** History: -** 2007/05/29 A. Cudmore | vxWorks 6.2 MCP750 version -** 2016/04/07 M.Grubb | Updated for PSP version 1.3 -** -******************************************************************************/ - /* ** Include Files */ @@ -196,11 +181,8 @@ int32 CFE_PSP_Exception_GetSummary(uint32 *ContextLogId, osal_id_t *TaskId, char */ if (ReasonBuf != NULL && ReasonSize > 0) { - Status = CFE_PSP_ExceptionGetSummary_Impl(Buffer, ReasonBuf, ReasonSize); - if (Status != CFE_PSP_SUCCESS) - { - ReasonBuf[0] = 0; /* failed to get a reason, so return empty string */ - } + ReasonBuf[0] = 0; /* pre-initialize to empty string, will be overwritten */ + CFE_PSP_ExceptionGetSummary_Impl(Buffer, ReasonBuf, ReasonSize); } ++CFE_PSP_ReservedMemoryMap.ExceptionStoragePtr->NumRead; @@ -226,6 +208,18 @@ int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint3 uint32 SeqId; uint32 ActualSize; + if (ContextBuf == NULL) + { + /* Invalid Context Buffer Pointer */ + return CFE_PSP_INVALID_POINTER; + } + + if (ContextLogId < CFE_PSP_EXCEPTION_ID_BASE) + { + /* Supplied ID is not valid */ + return CFE_PSP_NO_EXCEPTION_DATA; + } + SeqId = ContextLogId - CFE_PSP_EXCEPTION_ID_BASE; if (SeqId > OS_OBJECT_INDEX_MASK) { @@ -248,7 +242,7 @@ int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint3 } else { - /* this will truncate, not ideal, but no alternative. + /* This will truncate, not ideal, but no alternative. * If this happens it generally indicates a misconfiguration between CFE and PSP, * where the CFE platform configuration has not allocated enough space for context logs. * Generate a warning message to raise awareness. */ diff --git a/fsw/shared/src/cfe_psp_memrange.c b/fsw/shared/src/cfe_psp_memrange.c index 870f34cb..f845bee1 100644 --- a/fsw/shared/src/cfe_psp_memrange.c +++ b/fsw/shared/src/cfe_psp_memrange.c @@ -16,18 +16,6 @@ * limitations under the License. ************************************************************************/ -/* -** File : cfe_psp_memrange.c -** -** Author : Alan Cudmore -** -** Purpose: -** This file contains the memory range functions for the cFE Platform Support Package. -** The memory range is a table of valid memory address ranges maintained by the cFE. -** -** -*/ - /* ** Include section */ @@ -44,7 +32,7 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) { cpuaddr StartAddressToTest = Address; - cpuaddr EndAddressToTest = Address + Size - 1; + cpuaddr EndAddressToTest = Address + Size; cpuaddr StartAddressInTable; cpuaddr EndAddressInTable; uint32 TypeInTable; @@ -74,13 +62,13 @@ int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) if (SysMemPtr->MemoryType != CFE_PSP_MEM_INVALID) { StartAddressInTable = SysMemPtr->StartAddr; - EndAddressInTable = SysMemPtr->StartAddr + SysMemPtr->Size - 1; + EndAddressInTable = SysMemPtr->StartAddr + SysMemPtr->Size; TypeInTable = SysMemPtr->MemoryType; /* ** Step 1: Get the Address to Fit within the range */ - if ((StartAddressToTest >= StartAddressInTable) && (StartAddressToTest <= EndAddressInTable)) + if ((StartAddressToTest >= StartAddressInTable) && (StartAddressToTest < EndAddressInTable)) { /* ** Step 2: Does the End Address Fit within the Range? diff --git a/fsw/shared/src/cfe_psp_memutils.c b/fsw/shared/src/cfe_psp_memutils.c index 1189f5c0..4fa24ca8 100644 --- a/fsw/shared/src/cfe_psp_memutils.c +++ b/fsw/shared/src/cfe_psp_memutils.c @@ -16,18 +16,6 @@ * limitations under the License. ************************************************************************/ -/* -** File : cfe_psp_memutils.c -** -** Author : Ezra Yeheskeli -** -** Purpose: -** This file contains some of the cFE Platform Support Layer. -** It contains the processor architecture specific calls. -** -** -*/ - /* ** Include section */ @@ -53,8 +41,15 @@ *-----------------------------------------------------------------*/ int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n) { - memcpy(dest, src, n); - return CFE_PSP_SUCCESS; + int32 iReturnValue = CFE_PSP_ERROR; + + if (dest != NULL && src != NULL) + { + memcpy(dest, src, n); + iReturnValue = CFE_PSP_SUCCESS; + } + + return iReturnValue; } /*---------------------------------------------------------------- @@ -65,6 +60,13 @@ int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n) *-----------------------------------------------------------------*/ int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) { - memset(dest, (int)value, (size_t)n); - return CFE_PSP_SUCCESS; + int32 iReturnValue = CFE_PSP_ERROR; + + if (dest != NULL) + { + memset(dest, value, n); + iReturnValue = CFE_PSP_SUCCESS; + } + + return iReturnValue; } diff --git a/fsw/shared/src/cfe_psp_module.c b/fsw/shared/src/cfe_psp_module.c index 71732019..3f5754cf 100644 --- a/fsw/shared/src/cfe_psp_module.c +++ b/fsw/shared/src/cfe_psp_module.c @@ -18,9 +18,7 @@ /** * \file - * - * Created on: Jul 25, 2014 - * Author: jphickey + * Header file for modular PSP code */ #include @@ -29,9 +27,11 @@ #include "cfe_psp_module.h" -/* - * When using an OSAL that also supports "opaque object ids", choose values here - * that will fit in with the OSAL object ID values and not overlap anything. +/** + ** \brief CFE PSP Module Base and Index + ** + ** When using an OSAL that also supports "opaque object ids", choose values here + ** that will fit in with the OSAL object ID values and not overlap anything. */ #ifdef OS_OBJECT_TYPE_USER #define CFE_PSP_MODULE_BASE ((OS_OBJECT_TYPE_USER + 0x100) << OS_OBJECT_TYPE_SHIFT) @@ -41,6 +41,22 @@ #define CFE_PSP_MODULE_INDEX_MASK 0xFFFF #endif +/** + ** \brief Based ID for Modules + ** + ** \par Description: + ** Internal/base modules typically should not be the subject + ** of a call to CFE_PSP_Module_FindByName or GetAPI, + ** so they are assigned IDs at the END of the space, + ** this makes them unique but they are otherwise not used + */ +#define CFE_PSP_INTERNAL_MODULE_BASE ((CFE_PSP_MODULE_BASE | CFE_PSP_MODULE_INDEX_MASK) & ~CFE_PSP_MODULE_STD_MASK) + +/** + ** \brief Reserve the last 256 entries for base modules + */ +#define CFE_PSP_MODULE_STD_MASK 0xFF + /* * Internal/base modules typically should not be the subject * of a call to CFE_PSP_Module_FindByName or GetAPI, @@ -49,17 +65,19 @@ * * Reserve the last 256 entries for base modules */ -#define CFE_PSP_INTERNAL_MODULE_BASE ((CFE_PSP_MODULE_BASE | CFE_PSP_MODULE_INDEX_MASK) & ~0xFF) +#define CFE_PSP_INTERNAL_MODULE_BASE ((CFE_PSP_MODULE_BASE | CFE_PSP_MODULE_INDEX_MASK) & ~CFE_PSP_MODULE_STD_MASK) -static uint32 CFE_PSP_ConfigPspModuleListLength = 0; -static uint32 CFE_PSP_StandardPspModuleListLength = 0; +/** + * \brief Lists of all modules linked into PSP + */ +CFE_PSP_ModuleListGlobal_t CFE_PSP_MODULE_LIST_GLOBAL; /*************************************************** * * Helper function to initialize a list of modules (not externally called) * Returns the number of modules initialized */ -uint32_t CFE_PSP_ModuleInitList(uint32 BaseId, CFE_StaticModuleLoadEntry_t *ListPtr) +void CFE_PSP_ModuleInitList(CFE_PSP_ModuleListWrapper_t *WrapPtr, uint32 BaseId, CFE_StaticModuleLoadEntry_t *ListPtr) { CFE_StaticModuleLoadEntry_t *Entry; CFE_PSP_ModuleApi_t * ApiPtr; @@ -87,102 +105,145 @@ uint32_t CFE_PSP_ModuleInitList(uint32 BaseId, CFE_StaticModuleLoadEntry_t *List } } - return ModuleCount; + WrapPtr->BasePtr = ListPtr; + WrapPtr->ListLen = ModuleCount; + WrapPtr->BaseId = BaseId; + + return; } -/*************************************************** +/********************************************************** * - * See prototype for full description - */ + * Function: CFE_PSP_ModuleInit + * + * Description: See function declaration for info + * + *********************************************************/ void CFE_PSP_ModuleInit(void) { /* First initialize the fixed set of modules for this PSP */ - CFE_PSP_StandardPspModuleListLength = CFE_PSP_ModuleInitList(CFE_PSP_INTERNAL_MODULE_BASE, CFE_PSP_BASE_MODULE_LIST); + CFE_PSP_ModuleInitList(&CFE_PSP_MODULE_LIST_GLOBAL.Std, CFE_PSP_INTERNAL_MODULE_BASE, CFE_PSP_BASE_MODULE_LIST); /* Then initialize any user-selected extension modules */ - CFE_PSP_ConfigPspModuleListLength = CFE_PSP_ModuleInitList(CFE_PSP_MODULE_BASE, GLOBAL_CONFIGDATA.PspModuleList); + CFE_PSP_ModuleInitList(&CFE_PSP_MODULE_LIST_GLOBAL.Ext, CFE_PSP_MODULE_BASE, GLOBAL_CONFIGDATA.PspModuleList); } -/*************************************************** +/********************************************************** * - * See prototype for full description - */ + * Function: CFE_PSP_Module_LookupTableEntry + * + * Description: See function declaration for info + * + *********************************************************/ +CFE_PSP_ModuleApi_t *CFE_PSP_Module_LookupTableEntry(const CFE_PSP_ModuleListWrapper_t *WrapPtr, uint32 Index) +{ + if (Index >= WrapPtr->ListLen) + { + return NULL; + } + + return (CFE_PSP_ModuleApi_t *)WrapPtr->BasePtr[Index].Api; +} + +/********************************************************** + * + * Function: CFE_PSP_Module_GetAPIEntry + * + * Description: See function declaration for info + * + *********************************************************/ int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API) { int32 Result; uint32 LocalId; Result = CFE_PSP_INVALID_MODULE_ID; - if ((PspModuleId & ~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_BASE) + + /* Last 256 enteries are for standard modules */ + if ((PspModuleId & ~CFE_PSP_MODULE_STD_MASK) == CFE_PSP_MODULE_LIST_GLOBAL.Std.BaseId) { - /* Last 256 enteries are for internal modules */ - if((PspModuleId & CFE_PSP_MODULE_INDEX_MASK) >= 0xFF00 ) - { - LocalId = PspModuleId & 0xFF; - if (LocalId < CFE_PSP_StandardPspModuleListLength) - { - *API = (CFE_PSP_ModuleApi_t *)CFE_PSP_BASE_MODULE_LIST[LocalId].Api; - Result = CFE_PSP_SUCCESS; - } - } - else - { - LocalId = PspModuleId & CFE_PSP_MODULE_INDEX_MASK; - if (LocalId < CFE_PSP_ConfigPspModuleListLength) - { - *API = (CFE_PSP_ModuleApi_t *)GLOBAL_CONFIGDATA.PspModuleList[LocalId].Api; - Result = CFE_PSP_SUCCESS; - } - } + LocalId = PspModuleId & CFE_PSP_MODULE_STD_MASK; + *API = CFE_PSP_Module_LookupTableEntry(&CFE_PSP_MODULE_LIST_GLOBAL.Std, LocalId); + } + else if ((PspModuleId & ~CFE_PSP_MODULE_INDEX_MASK) == CFE_PSP_MODULE_LIST_GLOBAL.Ext.BaseId) + { + LocalId = PspModuleId & CFE_PSP_MODULE_INDEX_MASK; + *API = CFE_PSP_Module_LookupTableEntry(&CFE_PSP_MODULE_LIST_GLOBAL.Ext, LocalId); + } + else + { + *API = NULL; + } + + if (*API != NULL) + { + Result = CFE_PSP_SUCCESS; } return Result; } -/*************************************************** +/********************************************************** * - * See prototype for full description - */ -int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId) + * Function: CFE_PSP_Module_SearchNameInList + * + * Description: See function declaration for info + * + *********************************************************/ +uint32 CFE_PSP_Module_SearchNameInList(const CFE_PSP_ModuleListWrapper_t *WrapPtr, const char *ModuleName) { - uint32 i; - int32 Result; CFE_StaticModuleLoadEntry_t *Entry; + uint32 ResultId; + size_t i; - Entry = GLOBAL_CONFIGDATA.PspModuleList; - Result = CFE_PSP_INVALID_MODULE_NAME; - i = 0; + Entry = WrapPtr->BasePtr; + ResultId = 0; + i = 0; - /* Check global list */ - while (i < CFE_PSP_ConfigPspModuleListLength) + while (i < WrapPtr->ListLen) { if (strcmp(Entry->Name, ModuleName) == 0) { - *PspModuleId = CFE_PSP_MODULE_BASE | (i & CFE_PSP_MODULE_INDEX_MASK); - Result = CFE_PSP_SUCCESS; + ResultId = WrapPtr->BaseId | (i & CFE_PSP_MODULE_INDEX_MASK); break; } + ++Entry; ++i; } - /* Check internal list */ - if (Result != CFE_PSP_SUCCESS) + return ResultId; +} + +/********************************************************** + * + * Function: CFE_PSP_Module_FindByName + * + * Description: See function declaration for info + * + *********************************************************/ +int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId) +{ + int32 Result; + uint32 CheckId; + + /* Check global list */ + CheckId = CFE_PSP_Module_SearchNameInList(&CFE_PSP_MODULE_LIST_GLOBAL.Ext, ModuleName); + if (CheckId == 0) + { + CheckId = CFE_PSP_Module_SearchNameInList(&CFE_PSP_MODULE_LIST_GLOBAL.Std, ModuleName); + } + + if (CheckId != 0) { - Entry = CFE_PSP_BASE_MODULE_LIST; - i = 0; - while (i < CFE_PSP_StandardPspModuleListLength) - { - if (strcmp(Entry->Name, ModuleName) == 0) - { - *PspModuleId = CFE_PSP_INTERNAL_MODULE_BASE | (i & CFE_PSP_MODULE_INDEX_MASK); - Result = CFE_PSP_SUCCESS; - break; - } - ++Entry; - ++i; - } + Result = CFE_PSP_SUCCESS; + } + else + { + Result = CFE_PSP_INVALID_MODULE_NAME; } + *PspModuleId = CheckId; + return Result; } diff --git a/unit-test-coverage/mcp750-vxworks/CMakeLists.txt b/unit-test-coverage/mcp750-vxworks/CMakeLists.txt index a701b10d..a0b5ddfa 100644 --- a/unit-test-coverage/mcp750-vxworks/CMakeLists.txt +++ b/unit-test-coverage/mcp750-vxworks/CMakeLists.txt @@ -41,7 +41,12 @@ add_executable(coverage-${CFE_PSP_TARGETNAME}-testrunner src/coveragetest-psp-mcp750-vxworks.c src/coveragetest-cfe-psp-start.c src/coveragetest-cfe-psp-support.c + ${PSPCOVERAGE_SOURCE_DIR}/shared/src/coveragetest-cfe-psp-error.c ${PSPCOVERAGE_SOURCE_DIR}/shared/src/coveragetest-cfe-psp-exceptionstorage.c + ${PSPCOVERAGE_SOURCE_DIR}/shared/src/coveragetest-cfe-psp-memrange.c + ${PSPCOVERAGE_SOURCE_DIR}/shared/src/coveragetest-cfe-psp-memutils.c + ${PSPCOVERAGE_SOURCE_DIR}/shared/src/coveragetest-cfe-psp-module.c + ${PSPCOVERAGE_SOURCE_DIR}/shared/src/coveragetest-cfe-psp-version.c $ $ ) @@ -61,4 +66,3 @@ add_test(coverage-${CFE_PSP_TARGETNAME} coverage-${CFE_PSP_TARGETNAME}-testrunne foreach(TGT ${INSTALL_TARGET_LIST}) install(TARGETS coverage-${CFE_PSP_TARGETNAME}-testrunner DESTINATION ${TGT}/${UT_INSTALL_SUBDIR}) endforeach() - diff --git a/unit-test-coverage/mcp750-vxworks/adaptors/CMakeLists.txt b/unit-test-coverage/mcp750-vxworks/adaptors/CMakeLists.txt index bbc2c766..bd882edf 100644 --- a/unit-test-coverage/mcp750-vxworks/adaptors/CMakeLists.txt +++ b/unit-test-coverage/mcp750-vxworks/adaptors/CMakeLists.txt @@ -9,6 +9,7 @@ add_library(ut-adaptor-${CFE_PSP_TARGETNAME} STATIC src/ut-adaptor-bootrec.c ${PSPCOVERAGE_SOURCE_DIR}/shared/adaptors/src/ut-adaptor-exceptions.c + ${PSPCOVERAGE_SOURCE_DIR}/shared/adaptors/src/ut-adaptor-memrange.c ) # the "override_inc" dir contains replacement versions of the C-library include files. diff --git a/unit-test-coverage/mcp750-vxworks/adaptors/inc/ut-adaptor-bootrec.h b/unit-test-coverage/mcp750-vxworks/adaptors/inc/ut-adaptor-bootrec.h index 87888a38..965b56f1 100644 --- a/unit-test-coverage/mcp750-vxworks/adaptors/inc/ut-adaptor-bootrec.h +++ b/unit-test-coverage/mcp750-vxworks/adaptors/inc/ut-adaptor-bootrec.h @@ -40,8 +40,8 @@ #include "common_types.h" -void UT_Setup_ReservedMem_BootRec(void); -uint32 UT_Get_ReservedMem_BootType(void); -void UT_Set_ReservedMem_BootType(uint32 reset_type); +void UT_BootRecAdaptor_InitDefault(void); +uint32 UT_BootRecAdaptor_Get_BootType(void); +void UT_BootRecAdaptor_Set_BootType(uint32 reset_type); #endif diff --git a/unit-test-coverage/mcp750-vxworks/adaptors/src/ut-adaptor-bootrec.c b/unit-test-coverage/mcp750-vxworks/adaptors/src/ut-adaptor-bootrec.c index 78d89ca1..835ac59e 100644 --- a/unit-test-coverage/mcp750-vxworks/adaptors/src/ut-adaptor-bootrec.c +++ b/unit-test-coverage/mcp750-vxworks/adaptors/src/ut-adaptor-bootrec.c @@ -43,18 +43,18 @@ static CFE_PSP_ReservedMemoryBootRecord_t UT_BOOTREC; static const CFE_PSP_ReservedMemoryBootRecord_t UT_DEFAULT_BOOTREC = {0}; -void UT_Setup_ReservedMem_BootRec(void) +void UT_BootRecAdaptor_InitDefault(void) { UT_BOOTREC = UT_DEFAULT_BOOTREC; CFE_PSP_ReservedMemoryMap.BootPtr = &UT_BOOTREC; } -uint32 UT_Get_ReservedMem_BootType(void) +uint32 UT_BootRecAdaptor_Get_BootType(void) { return UT_BOOTREC.bsp_reset_type; } -void UT_Set_ReservedMem_BootType(uint32 reset_type) +void UT_BootRecAdaptor_Set_BootType(uint32 reset_type) { UT_BOOTREC.bsp_reset_type = reset_type; } diff --git a/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-start.c b/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-start.c index 35aad160..497c6e88 100644 --- a/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-start.c +++ b/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-start.c @@ -81,7 +81,7 @@ void Test_OS_Application_Startup(void) /* Install a hook function to grab the start type parameters from the system main call */ UT_SetHookFunction(UT_KEY(PCS_SystemMain), Test_Hook_ResetSubType, &StartType); - UT_Setup_ReservedMem_BootRec(); + UT_BootRecAdaptor_InitDefault(); /* nominal */ UT_SetDataBuffer(UT_KEY(PCS_sysMemTop), UT_ReservedMemBuffer, sizeof(UT_ReservedMemBuffer), false); @@ -136,13 +136,13 @@ void Test_OS_Application_Startup(void) UtAssert_INT32_EQ(StartType.StartSubtype, CFE_PSP_RST_SUBTYPE_RESET_COMMAND); *PCS_SYS_REG_BLRR = PCS_SYS_REG_BLRR_SWHRST; - UT_Set_ReservedMem_BootType(CFE_PSP_RST_TYPE_POWERON); + UT_BootRecAdaptor_Set_BootType(CFE_PSP_RST_TYPE_POWERON); UT_OS_Application_Startup(); UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(PCS_SystemMain)), 8); UtAssert_INT32_EQ(StartType.StartType, CFE_PSP_RST_TYPE_POWERON); UtAssert_INT32_EQ(StartType.StartSubtype, CFE_PSP_RST_SUBTYPE_RESET_COMMAND); - UT_Set_ReservedMem_BootType(CFE_PSP_RST_TYPE_PROCESSOR); + UT_BootRecAdaptor_Set_BootType(CFE_PSP_RST_TYPE_PROCESSOR); UT_OS_Application_Startup(); UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(PCS_SystemMain)), 9); UtAssert_INT32_EQ(StartType.StartType, CFE_PSP_RST_TYPE_PROCESSOR); diff --git a/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-support.c b/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-support.c index 66804fdf..ca804de6 100644 --- a/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-support.c +++ b/unit-test-coverage/mcp750-vxworks/src/coveragetest-cfe-psp-support.c @@ -52,15 +52,15 @@ void Test_CFE_PSP_Restart(void) * void CFE_PSP_Restart(uint32 resetType) */ - UT_Setup_ReservedMem_BootRec(); + UT_BootRecAdaptor_InitDefault(); CFE_PSP_Restart(CFE_PSP_RST_TYPE_PROCESSOR); - UtAssert_INT32_EQ(UT_Get_ReservedMem_BootType(), CFE_PSP_RST_TYPE_PROCESSOR); + UtAssert_INT32_EQ(UT_BootRecAdaptor_Get_BootType(), CFE_PSP_RST_TYPE_PROCESSOR); UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(PCS_cacheTextUpdate)), 1); UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(PCS_reboot)), 1); - UT_Setup_ReservedMem_BootRec(); + UT_BootRecAdaptor_InitDefault(); CFE_PSP_Restart(CFE_PSP_RST_TYPE_POWERON); - UtAssert_INT32_EQ(UT_Get_ReservedMem_BootType(), CFE_PSP_RST_TYPE_POWERON); + UtAssert_INT32_EQ(UT_BootRecAdaptor_Get_BootType(), CFE_PSP_RST_TYPE_POWERON); UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(PCS_cacheTextUpdate)), 2); UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(PCS_reboot)), 2); } @@ -115,3 +115,18 @@ void Test_CFE_PSP_GetSpacecraftId(void) */ UtAssert_INT32_EQ(CFE_PSP_GetSpacecraftId(), PCS_CONFIG_SPACECRAFT); } + +void Test_CFE_PSP_GetProcessorName(void) +{ + /* + * Test Case For: + * char* CFE_PSP_GetProcessorName (void) + */ + + /* + * Note - the data structure used here is declared as "const" internally so + * there is no way to modify the value at runtime, even in unit test. + */ + + UtAssert_StrCmp(CFE_PSP_GetProcessorName(), PCS_CONFIG_CPUNAME, "CFE_PSP_GetProcessorName - 1/1 Nominal"); +} diff --git a/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.c b/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.c index 9c96da3b..61b44a99 100644 --- a/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.c +++ b/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.c @@ -70,9 +70,30 @@ void UtTest_Setup(void) ADD_TEST(CFE_PSP_FlushCaches); ADD_TEST(CFE_PSP_GetProcessorId); ADD_TEST(CFE_PSP_GetSpacecraftId); + ADD_TEST(CFE_PSP_GetProcessorName); ADD_TEST(CFE_PSP_Exception_GetBuffer); ADD_TEST(CFE_PSP_Exception_GetNextContextBuffer); ADD_TEST(CFE_PSP_Exception_GetSummary); ADD_TEST(CFE_PSP_Exception_CopyContext); + + ADD_TEST(CFE_PSP_StatusToString); + ADD_TEST(CFE_PSP_GetVersionString); + ADD_TEST(CFE_PSP_GetVersionCodeName); + ADD_TEST(CFE_PSP_GetVersionNumber); + ADD_TEST(CFE_PSP_GetBuildNumber); + + ADD_TEST(CFE_PSP_ModuleInitList); + ADD_TEST(CFE_PSP_ModuleInit); + ADD_TEST(CFE_PSP_Module_GetAPIEntry); + ADD_TEST(CFE_PSP_Module_SearchNameInList); + ADD_TEST(CFE_PSP_Module_FindByName); + + ADD_TEST(CFE_PSP_MemCpy); + ADD_TEST(CFE_PSP_MemSet); + + ADD_TEST(CFE_PSP_MemValidateRange); + ADD_TEST(CFE_PSP_MemRanges); + ADD_TEST(CFE_PSP_MemRangeSet); + ADD_TEST(CFE_PSP_MemRangeGet); } diff --git a/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.h b/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.h index ce78b1cc..01fa92f7 100644 --- a/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.h +++ b/unit-test-coverage/mcp750-vxworks/src/coveragetest-psp-mcp750-vxworks.h @@ -62,6 +62,7 @@ void Test_CFE_PSP_Panic(void); void Test_CFE_PSP_FlushCaches(void); void Test_CFE_PSP_GetProcessorId(void); void Test_CFE_PSP_GetSpacecraftId(void); +void Test_CFE_PSP_GetProcessorName(void); void Test_OS_Application_Startup(void); void Test_OS_Application_Run(void); diff --git a/unit-test-coverage/modules/CMakeLists.txt b/unit-test-coverage/modules/CMakeLists.txt index 1745fd94..44207b3b 100644 --- a/unit-test-coverage/modules/CMakeLists.txt +++ b/unit-test-coverage/modules/CMakeLists.txt @@ -28,8 +28,11 @@ function(add_psp_covtest MODULE_NAME TESTCASE_SRC UT_SRCS) ${UT_COVERAGE_COMPILE_FLAGS} ) - target_include_directories(${OBJECT_TARGET} PRIVATE + target_include_directories(${OBJECT_TARGET} BEFORE PRIVATE ${PSPCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc # overrides for system headers + ) + + target_include_directories(${OBJECT_TARGET} PRIVATE ${PSPCOVERAGE_SOURCE_DIR}/shared/inc ${CFEPSP_SOURCE_DIR}/fsw/inc # PSP public API ${CFEPSP_SOURCE_DIR}/fsw/shared/inc # all PSP shared headers @@ -50,6 +53,7 @@ function(add_psp_covtest MODULE_NAME TESTCASE_SRC UT_SRCS) target_link_libraries(${RUNNER_TARGET} ${UT_COVERAGE_LINK_FLAGS} psp_module_api + ut_psp_api_stubs ut_psp_libc_stubs ut_osapi_stubs ut_assert @@ -67,3 +71,13 @@ endfunction() # a list of modules for which there is a coverage test implemented add_subdirectory(timebase_vxworks) add_subdirectory(vxworks_sysmon) +add_subdirectory(ram_notimpl) +add_subdirectory(ram_direct) +add_subdirectory(port_notimpl) +add_subdirectory(port_direct) +add_subdirectory(eeprom_notimpl) +add_subdirectory(eeprom_mmap_file) +add_subdirectory(eeprom_direct) +add_subdirectory(iodriver) +add_subdirectory(soft_timebase) + diff --git a/unit-test-coverage/modules/eeprom_direct/CMakeLists.txt b/unit-test-coverage/modules/eeprom_direct/CMakeLists.txt new file mode 100644 index 00000000..63e30c89 --- /dev/null +++ b/unit-test-coverage/modules/eeprom_direct/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/eeprom_direct") + +add_psp_covtest(eeprom_direct coveragetest-eeprom_direct.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c +) diff --git a/unit-test-coverage/modules/eeprom_direct/coveragetest-eeprom_direct.c b/unit-test-coverage/modules/eeprom_direct/coveragetest-eeprom_direct.c new file mode 100644 index 00000000..44de0dfd --- /dev/null +++ b/unit-test-coverage/modules/eeprom_direct/coveragetest-eeprom_direct.c @@ -0,0 +1,236 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +#define UT_RAMBLOCK_SIZE 32 + +static union +{ + uint8 u8[UT_RAMBLOCK_SIZE]; + uint16 u16[UT_RAMBLOCK_SIZE / sizeof(uint16)]; + uint32 u32[UT_RAMBLOCK_SIZE / sizeof(uint32)]; +} UT_RAM_BLOCK; + +extern void eeprom_direct_Init(uint32 PspModuleId); + +/* + * -------------------------------------------- + * TEST FUNCTIONS + * -------------------------------------------- + */ + +/* ******************************** + * eeprom_direct_Init + * ********************************/ +void Test_eeprom_direct_Init(void) +{ + /* Test For: + * void eeprom_direct_Init(uint32 PspModuleId) + */ + UtAssert_VOIDCALL(eeprom_direct_Init(1)); +} + +/* ******************************** + * CFE_PSP_EepromWrite32 + * ********************************/ +void Test_CFE_PSP_EepromWrite32_Nominal(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u32[0]; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite32(UtAddress, 0x11222211), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_EepromWrite32_AddressMisaligned(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u32[1]; + UtAddress += 1; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite32(UtAddress, 0xAABBCCDD), CFE_PSP_ERROR_ADDRESS_MISALIGNED); +} + +/* ******************************** + * CFE_PSP_EepromWrite16 + * ********************************/ +void Test_CFE_PSP_EepromWrite16_AddressMisaligned(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u16[4]; + UtAddress += 1; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite16(UtAddress, 0x1122), CFE_PSP_ERROR_ADDRESS_MISALIGNED); +} + +void Test_CFE_PSP_EepromWrite16_WriteLowBitOrder(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u16[6]; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite16(UtAddress, 0x3344), CFE_PSP_SUCCESS); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_PSP_MemRead32, 1); +} + +void Test_CFE_PSP_EepromWrite16_WriteHighBitOrder(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u16[8]; + UtAddress += 2; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite16(UtAddress, 0x5566), CFE_PSP_SUCCESS); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_PSP_MemRead32, 1); +} + +/* ******************************** + * CFE_PSP_EepromWrite8 + * ********************************/ +void Test_CFE_PSP_EepromWrite8_WriteLowBitOrder(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u8[20]; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite8(UtAddress, 0x11), CFE_PSP_SUCCESS); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_PSP_MemRead16, 1); +} + +void Test_CFE_PSP_EepromWrite8_WriteHighBitOrder(void) +{ + /* Arrange */ + cpuaddr UtAddress; + + UtAddress = (cpuaddr)&UT_RAM_BLOCK.u8[24]; + UtAddress += 3; + + /* Act */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite8(UtAddress, 0x22), CFE_PSP_SUCCESS); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_PSP_MemRead16, 1); +} + +void Test_CFE_PSP_EepromWriteEnable(void) +{ + /* + int32 CFE_PSP_EepromWriteEnable(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWriteEnable(1), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_EepromWriteDisable(void) +{ + /* + int32 CFE_PSP_EepromWriteDisable(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWriteDisable(1), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_EepromPowerUp(void) +{ + /* + int32 CFE_PSP_EepromPowerUp(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromPowerUp(1), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_EepromPowerDown(void) +{ + /* + int32 CFE_PSP_EepromPowerDown(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromPowerDown(1), CFE_PSP_SUCCESS); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ResetTest, NULL, #test) + +void ResetTest(void) +{ + UT_ResetState(0); + memset(&UT_RAM_BLOCK, 0, sizeof(UT_RAM_BLOCK)); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_eeprom_direct_Init); + ADD_TEST(Test_CFE_PSP_EepromWrite32_Nominal); + ADD_TEST(Test_CFE_PSP_EepromWrite32_AddressMisaligned); + ADD_TEST(Test_CFE_PSP_EepromWrite16_AddressMisaligned); + ADD_TEST(Test_CFE_PSP_EepromWrite16_WriteLowBitOrder); + ADD_TEST(Test_CFE_PSP_EepromWrite16_WriteHighBitOrder); + ADD_TEST(Test_CFE_PSP_EepromWrite8_WriteLowBitOrder); + ADD_TEST(Test_CFE_PSP_EepromWrite8_WriteHighBitOrder); + ADD_TEST(Test_CFE_PSP_EepromWriteEnable); + ADD_TEST(Test_CFE_PSP_EepromWriteDisable); + ADD_TEST(Test_CFE_PSP_EepromPowerUp); + ADD_TEST(Test_CFE_PSP_EepromPowerDown); +} diff --git a/unit-test-coverage/modules/eeprom_mmap_file/CMakeLists.txt b/unit-test-coverage/modules/eeprom_mmap_file/CMakeLists.txt new file mode 100644 index 00000000..19a9ce87 --- /dev/null +++ b/unit-test-coverage/modules/eeprom_mmap_file/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/eeprom_mmap_file") + +add_psp_covtest(eeprom_mmap_file coveragetest-eeprom_mmap_file.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c +) diff --git a/unit-test-coverage/modules/eeprom_mmap_file/coveragetest-eeprom_mmap_file.c b/unit-test-coverage/modules/eeprom_mmap_file/coveragetest-eeprom_mmap_file.c new file mode 100644 index 00000000..ac6d679e --- /dev/null +++ b/unit-test-coverage/modules/eeprom_mmap_file/coveragetest-eeprom_mmap_file.c @@ -0,0 +1,209 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#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_sys_stat.h" +#include "PCS_sys_mman.h" +#include "PCS_unistd.h" + +extern void eeprom_mmap_file_Init(uint32 PspModuleId); + +#define UT_RAMBLOCK_SIZE 32 + +static union +{ + uint8 u8[UT_RAMBLOCK_SIZE]; + uint16 u16[UT_RAMBLOCK_SIZE / sizeof(uint16)]; + uint32 u32[UT_RAMBLOCK_SIZE / sizeof(uint32)]; +} UT_RAM_BLOCK; + +void Test_eeprom_mmap_file_Init(void) +{ + /* + void eeprom_mmap_file_Init(uint32 PspModuleId) + */ + + /* nominal */ + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* fail to mmap file */ + UT_SetDeferredRetcode(UT_KEY(PCS_mmap), 1, -1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* fail to create new file file */ + UT_SetDeferredRetcode(UT_KEY(PCS_open), 1, -1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* file exists */ + UT_SetDefaultReturnValue(UT_KEY(PCS_stat), -1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* fail to open existing file */ + UT_SetDeferredRetcode(UT_KEY(PCS_open), 1, -1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* fail to seek in existing file */ + UT_SetDeferredRetcode(UT_KEY(PCS_lseek), 1, -1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* write success in existing file */ + UT_SetDeferredRetcode(UT_KEY(PCS_write), 1, 1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); + + /* fail to write a byte in existing file */ + UT_SetDeferredRetcode(UT_KEY(PCS_write), 1, -1); + UtAssert_VOIDCALL(eeprom_mmap_file_Init(1)); +} + +void Test_CFE_PSP_EepromWrite32(void) +{ + /* + int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) + */ + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u32[2]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u32[3]; + + UtAssert_INT32_EQ(CFE_PSP_EepromWrite32(UtAddress1, 0xBB997755), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_EepromWrite32(UtAddress2, 0xCCAA8866), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(UT_RAM_BLOCK.u32[2], 0xBB997755); + UtAssert_UINT32_EQ(UT_RAM_BLOCK.u32[3], 0xCCAA8866); +} + +void Test_CFE_PSP_EepromWrite16(void) +{ + /* + int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) + */ + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u16[6]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u16[7]; + + UtAssert_INT32_EQ(CFE_PSP_EepromWrite16(UtAddress1, 0xBBDD), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_EepromWrite16(UtAddress2, 0xCCEE), CFE_PSP_SUCCESS); + UtAssert_UINT16_EQ(UT_RAM_BLOCK.u16[6], 0xBBDD); + UtAssert_UINT16_EQ(UT_RAM_BLOCK.u16[7], 0xCCEE); +} + +void Test_CFE_PSP_EepromWrite8(void) +{ + /* + int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) + */ + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u8[4]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u8[5]; + + UtAssert_INT32_EQ(CFE_PSP_EepromWrite8(UtAddress1, 0xBB), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_EepromWrite8(UtAddress2, 0xCC), CFE_PSP_SUCCESS); + UtAssert_UINT8_EQ(UT_RAM_BLOCK.u8[4], 0xBB); + UtAssert_UINT8_EQ(UT_RAM_BLOCK.u8[5], 0xCC); +} + +void Test_CFE_PSP_EepromWriteEnable(void) +{ + /* + int32 CFE_PSP_EepromWriteEnable(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWriteEnable(1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromWriteDisable(void) +{ + /* + int32 CFE_PSP_EepromWriteDisable(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWriteDisable(1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromPowerUp(void) +{ + /* + int32 CFE_PSP_EepromPowerUp(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromPowerUp(1), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_EepromPowerDown(void) +{ + /* + int32 CFE_PSP_EepromPowerDown(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromPowerDown(1), CFE_PSP_SUCCESS); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ResetTest, NULL, #test) + +void ResetTest(void) +{ + UT_ResetState(0); + memset(&UT_RAM_BLOCK, 0, sizeof(UT_RAM_BLOCK)); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_eeprom_mmap_file_Init); + ADD_TEST(Test_CFE_PSP_EepromWrite32); + ADD_TEST(Test_CFE_PSP_EepromWrite16); + ADD_TEST(Test_CFE_PSP_EepromWrite8); + ADD_TEST(Test_CFE_PSP_EepromWriteEnable); + ADD_TEST(Test_CFE_PSP_EepromWriteDisable); + ADD_TEST(Test_CFE_PSP_EepromPowerUp); + ADD_TEST(Test_CFE_PSP_EepromPowerDown); +} diff --git a/unit-test-coverage/modules/eeprom_notimpl/CMakeLists.txt b/unit-test-coverage/modules/eeprom_notimpl/CMakeLists.txt new file mode 100644 index 00000000..7b462a05 --- /dev/null +++ b/unit-test-coverage/modules/eeprom_notimpl/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/eeprom_notimpl") + +add_psp_covtest(eeprom_notimpl coveragetest-eeprom_notimpl.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/eeprom_notimpl/cfe_psp_eeprom_notimpl.c +) diff --git a/unit-test-coverage/modules/eeprom_notimpl/coveragetest-eeprom_notimpl.c b/unit-test-coverage/modules/eeprom_notimpl/coveragetest-eeprom_notimpl.c new file mode 100644 index 00000000..0e67f53c --- /dev/null +++ b/unit-test-coverage/modules/eeprom_notimpl/coveragetest-eeprom_notimpl.c @@ -0,0 +1,131 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +extern void eeprom_notimpl_Init(uint32 PspModuleId); + +void Test_eeprom_notimpl_Init(void) +{ + /* + void eeprom_notimpl_Init(uint32 PspModuleId) + */ + + UtAssert_VOIDCALL(eeprom_notimpl_Init(1)); +} + +void Test_CFE_PSP_EepromWrite32(void) +{ + /* + int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite32(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromWrite16(void) +{ + /* + int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite16(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromWrite8(void) +{ + /* + int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWrite8(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromWriteEnable(void) +{ + /* + int32 CFE_PSP_EepromWriteEnable(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWriteEnable(1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromWriteDisable(void) +{ + /* + int32 CFE_PSP_EepromWriteDisable(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromWriteDisable(1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromPowerUp(void) +{ + /* + int32 CFE_PSP_EepromPowerUp(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromPowerUp(1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_EepromPowerDown(void) +{ + /* + int32 CFE_PSP_EepromPowerDown(uint32 Bank) + */ + UtAssert_INT32_EQ(CFE_PSP_EepromPowerDown(1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, NULL, NULL, #test) + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_eeprom_notimpl_Init); + ADD_TEST(Test_CFE_PSP_EepromWrite32); + ADD_TEST(Test_CFE_PSP_EepromWrite16); + ADD_TEST(Test_CFE_PSP_EepromWrite8); + ADD_TEST(Test_CFE_PSP_EepromWriteEnable); + ADD_TEST(Test_CFE_PSP_EepromWriteDisable); + ADD_TEST(Test_CFE_PSP_EepromPowerUp); + ADD_TEST(Test_CFE_PSP_EepromPowerDown); +} diff --git a/unit-test-coverage/modules/iodriver/CMakeLists.txt b/unit-test-coverage/modules/iodriver/CMakeLists.txt new file mode 100644 index 00000000..5f639036 --- /dev/null +++ b/unit-test-coverage/modules/iodriver/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(iodriver coveragetest-iodriver.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/iodriver/src/iodriver.c +) diff --git a/unit-test-coverage/modules/iodriver/coveragetest-iodriver.c b/unit-test-coverage/modules/iodriver/coveragetest-iodriver.c new file mode 100644 index 00000000..a8a272ea --- /dev/null +++ b/unit-test-coverage/modules/iodriver/coveragetest-iodriver.c @@ -0,0 +1,280 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +#include "iodriver_base.h" +#include "iodriver_impl.h" + +CFE_PSP_IODriver_API_t Ut_NoopAPI = {NULL, NULL}; + +extern void iodriver_Init(uint32 PspModuleId); +extern CFE_PSP_IODriver_API_t *CFE_PSP_IODriver_GetAPI(uint32 PspModuleId); + +static int32 Stub_DeviceCommand(uint32 CommandCode, uint16 Instance, uint16 SubChannel, CFE_PSP_IODriver_Arg_t arg) +{ + return UT_DEFAULT_IMPL(Stub_DeviceCommand); +} + +static int32 Stub_DeviceMutex(uint32 CommandCode, uint16 Instance, uint16 SubChannel, CFE_PSP_IODriver_Arg_t arg) +{ + return UT_DEFAULT_IMPL(Stub_DeviceMutex); +} + +/* + * -------------------------------------------- + * Instantiation of a Stub IO Driver with no mutex + * -------------------------------------------- + */ +static void StubNoMut_Init(uint32 ModuleID) +{ + UT_DEFAULT_IMPL(StubNoMut_Init); +} + +static CFE_PSP_IODriver_API_t StubNoMut_DevApi = {.DeviceCommand = Stub_DeviceCommand}; + +CFE_PSP_MODULE_DECLARE_IODEVICEDRIVER(StubNoMut); + +/* + * -------------------------------------------- + * Instantiation of a Stub IO Driver with mutex + * -------------------------------------------- + */ +static void StubWithMut_Init(uint32 ModuleID) +{ + UT_DEFAULT_IMPL(StubWithMut_Init); +} + +static CFE_PSP_IODriver_API_t StubWithMut_DevApi = {.DeviceCommand = Stub_DeviceCommand, + .DeviceMutex = Stub_DeviceMutex}; + +CFE_PSP_MODULE_DECLARE_IODEVICEDRIVER(StubWithMut); + +/* + * -------------------------------------------- + * HANDLER FUNCTIONS -- helpers for stubs + * -------------------------------------------- + */ + +static void UtHandler_CFE_PSP_Module_GetAPIEntry(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* Handler for: + * int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API); + */ + + CFE_PSP_ModuleApi_t **API = UT_Hook_GetArgValueByName(Context, "API", CFE_PSP_ModuleApi_t **); + int32 status; + + /* This needs to output a proper value */ + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0) + { + *API = UserObj; + } + else + { + *API = NULL; + } +} + +static void UtHandler_CFE_PSP_Module_FindByName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* Handler for: + * int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId); + */ + uint32 *PspModuleId = UT_Hook_GetArgValueByName(Context, "PspModuleId", uint32 *); + int32 status; + + /* This needs to output a proper value */ + UT_Stub_GetInt32StatusCode(Context, &status); + if (status >= 0 && UserObj != NULL) + { + *PspModuleId = *((uint32 *)UserObj); + } + else + { + *PspModuleId = 0; + } +} + +/* + * -------------------------------------------- + * TEST FUNCTIONS + * -------------------------------------------- + */ + +void Test_iodriver_Init(void) +{ + /* Test For: + * void iodriver_Init(uint32 PspModuleId) + */ + UtAssert_VOIDCALL(iodriver_Init(1)); +} + +void Test_CFE_PSP_IODriver_GetAPI(void) +{ + /* Test For: + * CFE_PSP_IODriver_API_t *CFE_PSP_IODriver_GetAPI(uint32 PspModuleId) + */ + CFE_PSP_IODriver_API_t *ApiPtr; + + /* Requesting a nonexistent module should return a default API */ + UtAssert_NOT_NULL(ApiPtr = CFE_PSP_IODriver_GetAPI(0)); + UtAssert_BOOL_TRUE(ApiPtr->DeviceCommand == NULL); + UtAssert_BOOL_TRUE(ApiPtr->DeviceMutex == NULL); + + UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Module_GetAPIEntry), -1); + UtAssert_NOT_NULL(ApiPtr = CFE_PSP_IODriver_GetAPI(0)); + UtAssert_BOOL_TRUE(ApiPtr->DeviceCommand == NULL); + UtAssert_BOOL_TRUE(ApiPtr->DeviceMutex == NULL); + + UT_ResetState(UT_KEY(CFE_PSP_Module_GetAPIEntry)); + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_GetAPIEntry), UtHandler_CFE_PSP_Module_GetAPIEntry, + (void *)&CFE_PSP_StubNoMut_API); + UtAssert_NOT_NULL(ApiPtr = CFE_PSP_IODriver_GetAPI(0)); + UtAssert_BOOL_TRUE(ApiPtr->DeviceCommand == Stub_DeviceCommand); +} + +void Test_CFE_PSP_IODriver_GetMutex(void) +{ + /* Test For: + * osal_id_t CFE_PSP_IODriver_GetMutex(uint32 PspModuleId, int32 DeviceHash) + */ + UtAssert_BOOL_TRUE(OS_ObjectIdDefined(CFE_PSP_IODriver_GetMutex(1, 2))); + UtAssert_BOOL_TRUE(OS_ObjectIdDefined(CFE_PSP_IODriver_GetMutex(0, 4))); + UtAssert_BOOL_FALSE(OS_ObjectIdDefined(CFE_PSP_IODriver_GetMutex(1, -1))); +} + +void Test_CFE_PSP_IODriver_HashMutex(void) +{ + /* Test For: + * int32 CFE_PSP_IODriver_HashMutex(int32 StartHash, int32 Datum) + */ + + /* + * This is a basic hash function and should modify the value, but do + * so in a way that makes a pseudo-random result. It is not the intent + * to "check" the result here because that would simply be implementing + * the algoritm in reverse. All this will confirm is the output value is + * different than the input (StartHash). There are no branches in this + * routine, it is just a numeric calculation. + */ + UtAssert_INT32_NEQ(CFE_PSP_IODriver_HashMutex(1, 2), 1); + UtAssert_INT32_NEQ(CFE_PSP_IODriver_HashMutex(2, 3), 2); +} + +void Test_CFE_PSP_IODriver_Command(void) +{ + /* Test For: + * int32 CFE_PSP_IODriver_Command(const CFE_PSP_IODriver_Location_t *Location, uint32 CommandCode, + * CFE_PSP_IODriver_Arg_t Arg) + */ + const CFE_PSP_IODriver_Location_t UtLocation = {1, 1, 1}; + + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_GetAPIEntry), UtHandler_CFE_PSP_Module_GetAPIEntry, + (void *)&Ut_NoopAPI); + UtAssert_INT32_EQ(CFE_PSP_IODriver_Command(&UtLocation, 1, CFE_PSP_IODriver_U32ARG(0)), + CFE_PSP_ERROR_NOT_IMPLEMENTED); + + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_GetAPIEntry), UtHandler_CFE_PSP_Module_GetAPIEntry, + (void *)&CFE_PSP_StubNoMut_API); + UtAssert_INT32_EQ(CFE_PSP_IODriver_Command(&UtLocation, 1, CFE_PSP_IODriver_U32ARG(0)), CFE_PSP_SUCCESS); + UtAssert_STUB_COUNT(Stub_DeviceCommand, 1); + UtAssert_STUB_COUNT(Stub_DeviceMutex, 0); + + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_GetAPIEntry), UtHandler_CFE_PSP_Module_GetAPIEntry, + (void *)&CFE_PSP_StubWithMut_API); + UtAssert_INT32_EQ(CFE_PSP_IODriver_Command(&UtLocation, 1, CFE_PSP_IODriver_U32ARG(0)), CFE_PSP_SUCCESS); + UtAssert_STUB_COUNT(Stub_DeviceCommand, 2); + UtAssert_STUB_COUNT(Stub_DeviceMutex, 1); +} + +void Test_CFE_PSP_IODriver_FindByName(void) +{ + /* Test For: + * int32 CFE_PSP_IODriver_FindByName(const char *DriverName, uint32 *PspModuleId) + */ + uint32 ModuleID = 0; + uint32 CheckID = 1234; + + UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Module_FindByName), -100); + UtAssert_INT32_EQ(CFE_PSP_IODriver_FindByName("UT", &ModuleID), -100); + UT_ResetState(UT_KEY(CFE_PSP_Module_FindByName)); + + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_FindByName), UtHandler_CFE_PSP_Module_FindByName, &CheckID); + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_GetAPIEntry), UtHandler_CFE_PSP_Module_GetAPIEntry, + (void *)&Ut_NoopAPI); + UtAssert_INT32_EQ(CFE_PSP_IODriver_FindByName("UT", &ModuleID), CFE_PSP_INVALID_MODULE_NAME); + + UT_SetHandlerFunction(UT_KEY(CFE_PSP_Module_GetAPIEntry), UtHandler_CFE_PSP_Module_GetAPIEntry, + (void *)&CFE_PSP_StubWithMut_API); + UtAssert_INT32_EQ(CFE_PSP_IODriver_FindByName("UT", &ModuleID), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(ModuleID, CheckID); + + UT_ResetState(UT_KEY(CFE_PSP_Module_GetAPIEntry)); + UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_Module_GetAPIEntry), -101); + UtAssert_INT32_EQ(CFE_PSP_IODriver_FindByName("UT", &ModuleID), -101); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ResetTest, NULL, #test) + +void ResetTest(void) +{ + UT_ResetState(0); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_iodriver_Init); + ADD_TEST(Test_CFE_PSP_IODriver_GetAPI); + ADD_TEST(Test_CFE_PSP_IODriver_GetMutex); + ADD_TEST(Test_CFE_PSP_IODriver_HashMutex); + ADD_TEST(Test_CFE_PSP_IODriver_Command); + ADD_TEST(Test_CFE_PSP_IODriver_FindByName); +} diff --git a/unit-test-coverage/modules/linux_sysmon/CMakeLists.txt b/unit-test-coverage/modules/linux_sysmon/CMakeLists.txt new file mode 100644 index 00000000..f510dc51 --- /dev/null +++ b/unit-test-coverage/modules/linux_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/linux_sysmon") + +add_psp_covtest(linux_sysmon src/coveragetest-linux_sysmon.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/linux_sysmon/linux_sysmon.c +) diff --git a/unit-test-coverage/modules/linux_sysmon/coveragetest-linux_sysmon.c b/unit-test-coverage/modules/linux_sysmon/coveragetest-linux_sysmon.c new file mode 100644 index 00000000..d80141c9 --- /dev/null +++ b/unit-test-coverage/modules/linux_sysmon/coveragetest-linux_sysmon.c @@ -0,0 +1,842 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#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_arch_ppc_vxPpcLib.h" + +/* + * Reference to the API entry point for the module + */ +extern CFE_PSP_ModuleApi_t CFE_PSP_timebase_vxworks_API; + +const CFE_PSP_ModuleApi_t *TgtAPI = &CFE_PSP_timebase_vxworks_API; + +UT_PSP_TimeBase_VxWorks_TestConfig_t UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG; + +typedef struct +{ + uint32 u; + uint32 l; +} PSP_VxWorks_TimeBaseVal_t; + +void ModuleTest_ResetState(void) +{ + memset(&UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG, 0, sizeof(UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG)); +} + +int32 UTHOOK_vxTimeBaseGet(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) +{ + PSP_VxWorks_TimeBaseVal_t *val = UserObj; + uint32 * u = UT_Hook_GetArgValueByName(Context, "u", uint32 *); + uint32 * l = UT_Hook_GetArgValueByName(Context, "l", uint32 *); + + *u = val->u; + *l = val->l; + + return StubRetcode; +} + +void Test_Nominal(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Nominal test with a simple 1:1 ratio */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 1; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 1; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 1000000000); + + /* Check operation of CFE_PSP_GetTime() */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0; + VxTime.l = 10000; + CFE_PSP_GetTime(&OsTime); + + UtAssert_UINT32_EQ(OS_TimeGetNanosecondsPart(OsTime), 10000); +} + +void Test_Non_Reducible(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Use an oddball ratio of of some primes, will not be reducible */ + /* Ratio is 43*3 / 53*2 => 129/106 */ + /* This translates to about ~1.217ns per tick */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 43 * 3; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 53 * 2; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 821705426); + + /* + * Check operation of CFE_PSP_GetTime() + * + * This test requires that the conversion uses the actual ratio, + * otherwise a rounding error will be noticed. + * For example: + * Conversion using 1.217ns/tick yields 52269758 usec (wrong). + * Conversion using actual ratio yields 52268947 usec. + */ + + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 10; + VxTime.l = 5000; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 52268947, "CFE_PSP_GetTime() Microseconds (%lld) == 52268947", (long long)TestTime); +} + +void Test_Reducible_1(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Test with a ratio that is also 1:1, but can be reduced */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 1000; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 1000; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 1000000000); + + /* + * Check operation of CFE_PSP_GetTime() + * + * Externally calculated value should be 10376293541461622 usec. + * If overflow occurs then value will be wrong. + */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x90000000; /* nearing 64-bit limit */ + VxTime.l = 0; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 10376293541461622, "CFE_PSP_GetTime() Microseconds (%lld) == 10376293541461622", + (long long)TestTime); +} + +void Test_Reducible_2(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Test with a ratio that can be reduced */ + /* Final reduced ratio should be 12:5 with 100ns OS ticks */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 84000; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 350; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 4166666); + + /* + * Check operation of CFE_PSP_GetTime() + * + * Externally calculated value should be 276701161105643274 usec. + * If overflow occurs then value will be wrong. + */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x10000000; /* nearing 64-bit limit */ + VxTime.l = 0; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 276701161105643274, "CFE_PSP_GetTime() Microseconds(%lld) == 276701161105643274", + (long long)TestTime); +} + +void Test_Rollover(void) +{ + /* This function always returns 0 */ + UtAssert_UINT32_EQ(CFE_PSP_GetTimerLow32Rollover(), 0); +} + +/****************************************************************************** +** +** Purpose: +** Provides a common interface to system timebase. This routine +** is in the BSP because it is sometimes implemented in hardware and +** sometimes taken care of by the RTOS. +** +** Arguments: +** +** Return: +** Timebase register value +*/ +void Test_Get_Timebase(void) +{ + PSP_VxWorks_TimeBaseVal_t VxTime; + uint32 tbu; + uint32 tbl; + + /* The value from vxTimeBaseGet() should be passed through unchanged */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x00112233; + VxTime.l = 0x44556677; + + CFE_PSP_Get_Timebase(&tbu, &tbl); + + UtAssert_UINT32_EQ(tbu, VxTime.u); + UtAssert_UINT32_EQ(tbl, VxTime.l); +} + +/* + * 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_Nominal); + ADD_TEST(Test_Non_Reducible); + ADD_TEST(Test_Reducible_1); + ADD_TEST(Test_Reducible_2); + ADD_TEST(Test_Rollover); + ADD_TEST(Test_Get_Timebase); +} +/*********************************************************************** + * 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. + * + * \file linux_sysmon.c + * + ***********************************************************************/ + +/* + * NOTE: This relies on the Linux Kernel sched stats via the /proc filesystem. + * Documented here: https://docs.kernel.org/scheduler/sched-stats.html + */ + +/************************************************************************ + * Includes + ************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cfe_psp.h" +#include "cfe_psp_module.h" +#include "osapi-clock.h" + +#include "iodriver_impl.h" +#include "iodriver_analog_io.h" + +/******************************************************************** + * Local Defines + ********************************************************************/ + +#define LINUX_SYSMON_AGGREGATE_SUBSYS 0 +#define LINUX_SYSMON_CPULOAD_SUBSYS 1 +#define LINUX_SYSMON_AGGR_CPULOAD_SUBCH 0 +#define LINUX_SYSMON_MAX_CPUS 128 +#define LINUX_SYSMON_SAMPLE_DELAY 30 + +#ifdef DEBUG_BUILD +#define LINUX_SYSMON_DEBUG(...) OS_printf(__VA_ARGS__) +#else +#define LINUX_SYSMON_DEBUG(...) +#endif + +/******************************************************************** + * Local Type Definitions + ********************************************************************/ + +typedef struct linux_sysmon_cpuload_core +{ + CFE_PSP_IODriver_AdcCode_t avg_load; + unsigned long last_run_time; +} linux_sysmon_cpuload_core_t; + +typedef struct linux_sysmon_cpuload_state +{ + volatile bool is_running; + volatile bool should_run; + + uint8_t num_cpus; + pthread_t task_id; + int dev_fd; + uint32_t num_samples; + uint64_t last_sample_time; + + linux_sysmon_cpuload_core_t per_core[LINUX_SYSMON_MAX_CPUS]; +} linux_sysmon_cpuload_state_t; + +typedef struct linux_sysmon_state +{ + uint32_t local_module_id; + linux_sysmon_cpuload_state_t cpu_load; +} linux_sysmon_state_t; + +/******************************************************************** + * Local Function Prototypes + ********************************************************************/ + +static void * linux_sysmon_Task(void *arg); +static int32_t linux_sysmon_Start(linux_sysmon_cpuload_state_t *state); +static int32_t linux_sysmon_Stop(linux_sysmon_cpuload_state_t *state); +static void linux_sysmon_Init(uint32_t local_module_id); + +/* Function that starts up linux_sysmon driver. */ +static int32_t linux_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId, + CFE_PSP_IODriver_Arg_t Arg); + +/******************************************************************** + * Global Data + ********************************************************************/ + +/* linux_sysmon device command that is called by iodriver to start up linux_sysmon */ +CFE_PSP_IODriver_API_t linux_sysmon_DevApi = {.DeviceCommand = linux_sysmon_DevCmd}; + +CFE_PSP_MODULE_DECLARE_IODEVICEDRIVER(linux_sysmon); + +static linux_sysmon_state_t linux_sysmon_global; + +static const char *linux_sysmon_subsystem_names[] = {"aggregate", "per-cpu", NULL}; +static const char *linux_sysmon_subchannel_names[] = {"cpu-load", NULL}; + +/*********************************************************************** + * Global Functions + ********************************************************************/ + +void linux_sysmon_Init(uint32_t local_module_id) +{ + memset(&linux_sysmon_global, 0, sizeof(linux_sysmon_global)); + + linux_sysmon_global.local_module_id = local_module_id; +} + +void linux_sysmon_read_cpuuse_line(const char *line_data, unsigned int *cpu_num, unsigned long *run_time) +{ + unsigned long value; + const char * val_end; + int val_count; + + /* each "cpu" line contains the cpu number followed by 9 values */ + for (val_count = 0; val_count < 10 && *line_data != 0; ++val_count) + { + while (isspace((unsigned char)*line_data)) + { + ++line_data; + } + value = strtoul(line_data, (char **)&val_end, 10); + if (val_end == line_data) + { + /* not a number, something went wrong */ + break; + } + + line_data = val_end; + + switch (val_count) + { + case 0: /* this is the cpu number */ + *cpu_num = value; + break; + + case 7: /* this is the number of nanoseconds spent executing instructions on this CPU */ + *run_time = value; + break; + + default: /* don't care about this one */ + break; + } + } +} + +void linux_sysmon_update_schedstat(linux_sysmon_cpuload_state_t *state, int elapsed_ms) +{ + unsigned int cpu_time_ms; + unsigned int cpu_num; + unsigned int highest_cpu_num; + unsigned long run_time; + char line_data[256]; + size_t line_size; + ssize_t line_rdsz; + char * eol_p; + + linux_sysmon_cpuload_core_t *core_p; + + line_size = 0; + highest_cpu_num = 0; + + /* Reset to beginning of file to re-read it */ + lseek(state->dev_fd, 0, SEEK_SET); + + while (true) + { + line_rdsz = read(state->dev_fd, &line_data[line_size], sizeof(line_data) - line_size); + if (line_rdsz <= 0) + { + /* error (not expected) or EOF, stop reading */ + break; + } + + /* check for newline char */ + eol_p = memchr(&line_data[line_size], '\n', line_rdsz); + line_size += line_rdsz; + + while (eol_p != NULL) + { + *eol_p = 0; + ++eol_p; + + if (strncmp("cpu", line_data, 3) == 0) + { + cpu_num = -1; + run_time = 0; + linux_sysmon_read_cpuuse_line(&line_data[3], &cpu_num, &run_time); + + if (cpu_num < LINUX_SYSMON_MAX_CPUS) + { + core_p = &state->per_core[cpu_num]; + if (cpu_num > highest_cpu_num) + { + highest_cpu_num = cpu_num; + } + } + else + { + core_p = NULL; + } + + if (core_p != NULL) + { + cpu_time_ms = + OS_TimeGetTotalMilliseconds(OS_TimeFromTotalNanoseconds(run_time - core_p->last_run_time)); + core_p->last_run_time = run_time; + if (cpu_time_ms >= elapsed_ms) + { + core_p->avg_load = 0xFFFFFF; /* max */ + } + else if (elapsed_ms == 0) + { + core_p->avg_load = 0; + } + else + { + core_p->avg_load = (0x1000 * cpu_time_ms) / elapsed_ms; + core_p->avg_load |= (core_p->avg_load << 12); /* Expand from 12->24 bit */ + } + LINUX_SYSMON_DEBUG("CFE_PSP(linux_sysmon): CPU%u time_ms=%u ms, load=%06x\n", cpu_num, cpu_time_ms, + (unsigned int)core_p->avg_load); + } + } + + line_rdsz = eol_p - &line_data[0]; + if (line_rdsz < line_size) + { + memmove(line_data, eol_p, line_size - line_rdsz); + line_size -= line_rdsz; + } + else + { + line_size = 0; + } + + eol_p = memchr(line_data, '\n', line_size); + } + + if (line_size >= sizeof(line_data)) + { + /* not supposed to happen, drop data */ + OS_printf("CFE_PSP(linux_sysmon): malformed data from /proc/schedstat\n"); + break; + } + } + + state->num_cpus = 1 + highest_cpu_num; +} + +void *linux_sysmon_Task(void *arg) +{ + linux_sysmon_cpuload_state_t *state = arg; + + OS_time_t last_sample; + OS_time_t curr_sample; + OS_time_t next_sample; + int msec_diff; + struct pollfd pfd; + + CFE_PSP_GetTime(&next_sample); + curr_sample = next_sample; + memset(&pfd, 0, sizeof(pfd)); + + linux_sysmon_update_schedstat(state, 0); + + while (state->should_run) + { + next_sample = OS_TimeAdd(next_sample, OS_TimeFromTotalSeconds(LINUX_SYSMON_SAMPLE_DELAY)); + msec_diff = OS_TimeGetTotalMilliseconds(OS_TimeSubtract(next_sample, curr_sample)); + if (msec_diff > 0) + { + poll(&pfd, 0, msec_diff); + } + + last_sample = curr_sample; + CFE_PSP_GetTime(&curr_sample); + msec_diff = OS_TimeGetTotalMilliseconds(OS_TimeSubtract(curr_sample, last_sample)); + linux_sysmon_update_schedstat(state, msec_diff); + } + + return NULL; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * linux_sysmon_Start() + * ------------------------------------------------------ + * Starts the cpu load watcher function + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +int32_t linux_sysmon_Start(linux_sysmon_cpuload_state_t *state) +{ + int32_t StatusCode; + int32_t DelayCount; + + DelayCount = 0; + if (state->is_running) + { + /* already running, nothing to do */ + StatusCode = CFE_PSP_SUCCESS; + } + else + { + /* start clean */ + memset(state, 0, sizeof(*state)); + StatusCode = CFE_PSP_ERROR; + + state->dev_fd = open("/proc/schedstat", O_RDONLY); + if (state->dev_fd < 0) + { + perror("open(/proc/schedstat)"); + } + else + { + state->should_run = true; + if (pthread_create(&state->task_id, NULL, linux_sysmon_Task, state) < 0) + { + perror("pthread_create()"); + + /* Clean up */ + state->should_run = false; + close(state->dev_fd); + } + else + { + /* wait for the "num_cpus" to become nonzero, this should be + * initialized in the first sample taken by the worker task */ + while (state->num_cpus == 0 && DelayCount < 100000000 /*jphfix*/) + { + ++DelayCount; + OS_TaskDelay(10); + } + + if (state->num_cpus == 0) + { + OS_printf("CFE_PSP(Linux_SysMon): Failed to detect number of CPUs\n"); + + /* Clean up */ + state->should_run = false; + pthread_cancel(state->task_id); + pthread_join(state->task_id, NULL); + close(state->dev_fd); + } + else + { + OS_printf("CFE_PSP(Linux_SysMon): Started CPU utilization monitoring on %u CPU(s)\n", + (unsigned int)state->num_cpus); + + StatusCode = CFE_PSP_SUCCESS; + state->is_running = true; + } + } + } + } + + return StatusCode; +} + +int32_t linux_sysmon_Stop(linux_sysmon_cpuload_state_t *state) +{ + if (state->is_running) + { + state->should_run = false; + state->is_running = false; + pthread_cancel(state->task_id); + pthread_join(state->task_id, NULL); + close(state->dev_fd); + } + + return CFE_PSP_SUCCESS; +} + +int32_t linux_sysmon_calc_aggregate_cpu(linux_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val) +{ + uint8_t cpu; + uint32_t sum; + + sum = 0; + for (cpu = 0; cpu < state->num_cpus; ++cpu) + { + sum += state->per_core[cpu].avg_load; + } + + if (cpu == 0) + { + *Val = 0; + return CFE_PSP_ERROR; + } + + /* average of all cpus */ + sum /= cpu; + LINUX_SYSMON_DEBUG("CFE_PSP(linux_sysmon): Aggregate CPU load=%06x\n", (unsigned int)sum); + *Val = sum; + + return CFE_PSP_SUCCESS; +} + +int32_t linux_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg) +{ + int32_t StatusCode; + linux_sysmon_cpuload_state_t *state; + + /* There is just one global cpuload object */ + state = &linux_sysmon_global.cpu_load; + StatusCode = CFE_PSP_ERROR_NOT_IMPLEMENTED; + switch (CommandCode) + { + case CFE_PSP_IODriver_NOOP: + case CFE_PSP_IODriver_ANALOG_IO_NOOP: + { + /* NO-OP should return success - + * This is a required opcode as "generic" clients may use it to + * determine if a certain set of opcodes are supported or not + */ + StatusCode = CFE_PSP_SUCCESS; + break; + } + /* Start/stop opcodes */ + case CFE_PSP_IODriver_SET_RUNNING: /**< int32_t argument, 0=stop 1=start device */ + { + if (Arg.U32) + { + StatusCode = linux_sysmon_Start(state); + } + else + { + StatusCode = linux_sysmon_Stop(state); + } + break; + } + case CFE_PSP_IODriver_GET_RUNNING: /**< no argument, returns positive nonzero (true) if running and zero (false) + if stopped, negative on error */ + { + StatusCode = state->is_running; + break; + } + case CFE_PSP_IODriver_SET_CONFIGURATION: /**< const string argument (device-dependent content) */ + case CFE_PSP_IODriver_GET_CONFIGURATION: /**< void * argument (device-dependent content) */ + { + /* not implemented for now */ + break; + } + case CFE_PSP_IODriver_LOOKUP_SUBSYSTEM: /**< const char * argument, looks up name and returns positive + value for subsystem number, negative value for error */ + { + uint16_t i; + + for (i = 0; linux_sysmon_subsystem_names[i] != NULL; ++i) + { + if (strcmp(Arg.ConstStr, linux_sysmon_subsystem_names[i]) == 0) + { + StatusCode = i; + break; + } + } + + break; + } + case CFE_PSP_IODriver_LOOKUP_SUBCHANNEL: /**< const char * argument, looks up name and returns positive + value for channel number, negative value for error */ + { + uint16_t i; + + for (i = 0; linux_sysmon_subchannel_names[i] != NULL; ++i) + { + if (strcmp(Arg.ConstStr, linux_sysmon_subchannel_names[i]) == 0) + { + StatusCode = i; + break; + } + } + + break; + } + case CFE_PSP_IODriver_QUERY_DIRECTION: /**< CFE_PSP_IODriver_Direction_t argument */ + { + CFE_PSP_IODriver_Direction_t *DirPtr = (CFE_PSP_IODriver_Direction_t *)Arg.Vptr; + if (DirPtr != NULL) + { + *DirPtr = CFE_PSP_IODriver_Direction_INPUT_ONLY; + StatusCode = CFE_PSP_SUCCESS; + } + break; + } + case CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS: + { + CFE_PSP_IODriver_AnalogRdWr_t *RdWr = Arg.Vptr; + + if (RdWr->NumChannels == 1 && Subchannel == LINUX_SYSMON_AGGR_CPULOAD_SUBCH) + { + StatusCode = linux_sysmon_calc_aggregate_cpu(state, RdWr->Samples); + } + break; + } + default: + break; + } + + return StatusCode; +} + +int32_t linux_sysmon_cpu_load_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg) +{ + int32_t StatusCode; + linux_sysmon_cpuload_state_t *state; + + /* There is just one global cpuload object */ + state = &linux_sysmon_global.cpu_load; + StatusCode = CFE_PSP_ERROR_NOT_IMPLEMENTED; + switch (CommandCode) + { + case CFE_PSP_IODriver_NOOP: + case CFE_PSP_IODriver_ANALOG_IO_NOOP: + { + /* NO-OP should return success - + * This is a required opcode as "generic" clients may use it to + * determine if a certain set of opcodes are supported or not + */ + StatusCode = CFE_PSP_SUCCESS; + break; + } + case CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS: + { + CFE_PSP_IODriver_AnalogRdWr_t *RdWr = Arg.Vptr; + uint32_t ch; + + if (Subchannel < state->num_cpus && (Subchannel + RdWr->NumChannels) <= state->num_cpus) + { + for (ch = Subchannel; ch < (Subchannel + RdWr->NumChannels); ++ch) + { + RdWr->Samples[ch] = state->per_core[ch].avg_load; + } + } + break; + } + default: + break; + } + + return StatusCode; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* linux_sysmon_DevCmd() */ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/** + * \brief Main entry point for API. + * + * This function is called through iodriver to invoke the linux_sysmon module. + * + * \par Assumptions, External Events, and Notes: + * None + * + * \param[in] CommandCode The CFE_PSP_IODriver_xxx command. + * \param[in] SubsystemId The monitor subsystem identifier + * \param[in] SubchannelId The monitor subchannel identifier + * \param[in] Arg The arguments for the corresponding command. + * + * \returns Status code + * \retval #CFE_PSP_SUCCESS if successful + */ +int32_t linux_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId, + CFE_PSP_IODriver_Arg_t Arg) +{ + int32_t StatusCode; + + StatusCode = CFE_PSP_ERROR_NOT_IMPLEMENTED; + switch (SubsystemId) + { + case LINUX_SYSMON_AGGREGATE_SUBSYS: + StatusCode = linux_sysmon_aggregate_dispatch(CommandCode, SubchannelId, Arg); + break; + case LINUX_SYSMON_CPULOAD_SUBSYS: + StatusCode = linux_sysmon_cpu_load_dispatch(CommandCode, SubchannelId, Arg); + break; + default: + /* not implemented */ + break; + } + + return StatusCode; +} diff --git a/unit-test-coverage/modules/modlist.txt b/unit-test-coverage/modules/modlist.txt new file mode 100644 index 00000000..d12b024f --- /dev/null +++ b/unit-test-coverage/modules/modlist.txt @@ -0,0 +1,12 @@ +eeprom_notimpl +iodriver +rtems_sysmon +ram_notimpl +timebase_posix_clock +ram_direct +eeprom_direct +port_notimpl +eeprom_mmap_file +port_direct +linux_sysmon +soft_timebase diff --git a/unit-test-coverage/modules/port_direct/CMakeLists.txt b/unit-test-coverage/modules/port_direct/CMakeLists.txt new file mode 100644 index 00000000..20e9889d --- /dev/null +++ b/unit-test-coverage/modules/port_direct/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/port_direct") + +add_psp_covtest(port_direct coveragetest-port_direct.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/port_direct/cfe_psp_port_direct.c +) diff --git a/unit-test-coverage/modules/port_direct/coveragetest-port_direct.c b/unit-test-coverage/modules/port_direct/coveragetest-port_direct.c new file mode 100644 index 00000000..a0cc90a3 --- /dev/null +++ b/unit-test-coverage/modules/port_direct/coveragetest-port_direct.c @@ -0,0 +1,237 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +/* This does not have a prototype */ +extern void port_direct_Init(uint32 PspModuleId); + +#define UT_RAMBLOCK_SIZE 32 + +static union +{ + uint8 u8[UT_RAMBLOCK_SIZE]; + uint16 u16[UT_RAMBLOCK_SIZE / sizeof(uint16)]; + uint32 u32[UT_RAMBLOCK_SIZE / sizeof(uint32)]; +} UT_RAM_BLOCK; + +void Test_port_direct_Init(void) +{ + /* + Test case for: + void port_direct_Init(uint32 PspModuleId) + */ + UtAssert_VOIDCALL(port_direct_Init(1)); +} + +void Test_CFE_PSP_PortRead8(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) + */ + cpuaddr UtAddress1; + cpuaddr UtAddress2; + uint8 Value1; + uint8 Value2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u8[5]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u8[6]; + UT_RAM_BLOCK.u8[5] = 0xAA; + UT_RAM_BLOCK.u8[6] = 0xBB; + + UtAssert_INT32_EQ(CFE_PSP_PortRead8(UtAddress1, NULL), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_PortRead8(UtAddress1, &Value1), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_PortRead8(UtAddress2, &Value2), CFE_PSP_SUCCESS); + UtAssert_UINT8_EQ(Value1, UT_RAM_BLOCK.u8[5]); + UtAssert_UINT8_EQ(Value2, UT_RAM_BLOCK.u8[6]); + + UtAssert_INT32_EQ(CFE_PSP_PortRead8(0, &Value1), CFE_PSP_INVALID_MEM_ADDR); +} + +void Test_CFE_PSP_PortWrite8(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) + */ + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u8[4]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u8[5]; + + UtAssert_INT32_EQ(CFE_PSP_PortWrite8(UtAddress1, 0xBB), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_PortWrite8(UtAddress2, 0xCC), CFE_PSP_SUCCESS); + UtAssert_UINT8_EQ(UT_RAM_BLOCK.u8[4], 0xBB); + UtAssert_UINT8_EQ(UT_RAM_BLOCK.u8[5], 0xCC); + + UtAssert_INT32_EQ(CFE_PSP_PortWrite8(0, 0), CFE_PSP_INVALID_MEM_ADDR); +} + +void Test_CFE_PSP_PortRead16(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) + */ + uint16 Value1; + uint16 Value2; + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u16[7]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u16[8]; + + UT_RAM_BLOCK.u16[7] = 0x3344; + UT_RAM_BLOCK.u16[8] = 0x99AA; + + UtAssert_INT32_EQ(CFE_PSP_PortRead16(UtAddress1, NULL), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_PortRead16(UtAddress1, &Value1), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_PortRead16(UtAddress2, &Value2), CFE_PSP_SUCCESS); + UtAssert_UINT16_EQ(Value1, UT_RAM_BLOCK.u16[7]); + UtAssert_UINT16_EQ(Value2, UT_RAM_BLOCK.u16[8]); + + UtAssert_INT32_EQ(CFE_PSP_PortRead16(UtAddress1 + 1, &Value1), CFE_PSP_ERROR_ADDRESS_MISALIGNED); + + UtAssert_INT32_EQ(CFE_PSP_PortRead16(0, &Value1), CFE_PSP_INVALID_MEM_ADDR); +} + +void Test_CFE_PSP_PortWrite16(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) + */ + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u16[6]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u16[7]; + + UtAssert_INT32_EQ(CFE_PSP_PortWrite16(UtAddress1, 0xBBDD), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_PortWrite16(UtAddress2, 0xCCEE), CFE_PSP_SUCCESS); + UtAssert_UINT16_EQ(UT_RAM_BLOCK.u16[6], 0xBBDD); + UtAssert_UINT16_EQ(UT_RAM_BLOCK.u16[7], 0xCCEE); + + UtAssert_INT32_EQ(CFE_PSP_PortWrite16(UtAddress1 + 1, 0xEEFF), CFE_PSP_ERROR_ADDRESS_MISALIGNED); + + UtAssert_INT32_EQ(CFE_PSP_PortWrite16(0, 0), CFE_PSP_INVALID_MEM_ADDR); +} + +void Test_CFE_PSP_PortRead32(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) + */ + uint32 Value1; + uint32 Value2; + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u32[3]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u32[4]; + + UT_RAM_BLOCK.u32[3] = 0xAABBCCDD; + UT_RAM_BLOCK.u32[3] = 0x44556677; + + UtAssert_INT32_EQ(CFE_PSP_PortRead32(UtAddress1, NULL), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_PortRead32(UtAddress1, &Value1), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_PortRead32(UtAddress2, &Value2), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(Value1, UT_RAM_BLOCK.u32[3]); + UtAssert_UINT32_EQ(Value2, UT_RAM_BLOCK.u32[4]); + + UtAssert_INT32_EQ(CFE_PSP_PortRead32(UtAddress1 + 3, &Value1), CFE_PSP_ERROR_ADDRESS_MISALIGNED); + + UtAssert_INT32_EQ(CFE_PSP_PortRead32(0, &Value1), CFE_PSP_INVALID_MEM_ADDR); +} + +void Test_CFE_PSP_PortWrite32(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) + */ + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u32[2]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u32[3]; + + UtAssert_INT32_EQ(CFE_PSP_PortWrite32(UtAddress1, 0xBB997755), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_PortWrite32(UtAddress2, 0xCCAA8866), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(UT_RAM_BLOCK.u32[2], 0xBB997755); + UtAssert_UINT32_EQ(UT_RAM_BLOCK.u32[3], 0xCCAA8866); + + UtAssert_INT32_EQ(CFE_PSP_PortWrite32(UtAddress1 + 3, 0xDEADBEEF), CFE_PSP_ERROR_ADDRESS_MISALIGNED); + + UtAssert_INT32_EQ(CFE_PSP_PortWrite32(0, 0), CFE_PSP_INVALID_MEM_ADDR); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ResetTest, NULL, #test) + +void ResetTest(void) +{ + UT_ResetState(0); + memset(&UT_RAM_BLOCK, 0, sizeof(UT_RAM_BLOCK)); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_port_direct_Init); + ADD_TEST(Test_CFE_PSP_PortRead8); + ADD_TEST(Test_CFE_PSP_PortWrite8); + ADD_TEST(Test_CFE_PSP_PortRead16); + ADD_TEST(Test_CFE_PSP_PortWrite16); + ADD_TEST(Test_CFE_PSP_PortRead32); + ADD_TEST(Test_CFE_PSP_PortWrite32); +} diff --git a/unit-test-coverage/modules/port_notimpl/CMakeLists.txt b/unit-test-coverage/modules/port_notimpl/CMakeLists.txt new file mode 100644 index 00000000..5e1fa8d3 --- /dev/null +++ b/unit-test-coverage/modules/port_notimpl/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/port_notimpl") + +add_psp_covtest(port_notimpl coveragetest-port_notimpl.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/port_notimpl/cfe_psp_port_notimpl.c +) diff --git a/unit-test-coverage/modules/port_notimpl/coveragetest-port_notimpl.c b/unit-test-coverage/modules/port_notimpl/coveragetest-port_notimpl.c new file mode 100644 index 00000000..976972a9 --- /dev/null +++ b/unit-test-coverage/modules/port_notimpl/coveragetest-port_notimpl.c @@ -0,0 +1,132 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +/* This does not have a prototype */ +extern void port_notimpl_Init(uint32 PspModuleId); + +void Test_port_notimpl_Init(void) +{ + /* + Test case for: + void port_notimpl_Init(uint32 PspModuleId) + */ + UtAssert_VOIDCALL(port_notimpl_Init(1)); +} + +void Test_CFE_PSP_PortRead8(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) + */ + uint8 Value; + UtAssert_INT32_EQ(CFE_PSP_PortRead8(0, &Value), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_PortWrite8(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) + */ + UtAssert_INT32_EQ(CFE_PSP_PortWrite8(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_PortRead16(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) + */ + uint16 Value; + UtAssert_INT32_EQ(CFE_PSP_PortRead16(0, &Value), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_PortWrite16(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) + */ + UtAssert_INT32_EQ(CFE_PSP_PortWrite16(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_PortRead32(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) + */ + uint32 Value; + UtAssert_INT32_EQ(CFE_PSP_PortRead32(0, &Value), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_PortWrite32(void) +{ + /* + Test Case for: + int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) + */ + UtAssert_INT32_EQ(CFE_PSP_PortWrite32(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, NULL, NULL, #test) + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_port_notimpl_Init); + ADD_TEST(Test_CFE_PSP_PortRead8); + ADD_TEST(Test_CFE_PSP_PortWrite8); + ADD_TEST(Test_CFE_PSP_PortRead16); + ADD_TEST(Test_CFE_PSP_PortWrite16); + ADD_TEST(Test_CFE_PSP_PortRead32); + ADD_TEST(Test_CFE_PSP_PortWrite32); +} diff --git a/unit-test-coverage/modules/ram_direct/CMakeLists.txt b/unit-test-coverage/modules/ram_direct/CMakeLists.txt new file mode 100644 index 00000000..4c32d4c1 --- /dev/null +++ b/unit-test-coverage/modules/ram_direct/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/ram_direct") + +add_psp_covtest(ram_direct coveragetest-ram_direct.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/ram_direct/cfe_psp_ram_direct.c +) diff --git a/unit-test-coverage/modules/ram_direct/coveragetest-ram_direct.c b/unit-test-coverage/modules/ram_direct/coveragetest-ram_direct.c new file mode 100644 index 00000000..c5de0979 --- /dev/null +++ b/unit-test-coverage/modules/ram_direct/coveragetest-ram_direct.c @@ -0,0 +1,220 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +/* This does not have a prototype */ +extern void ram_direct_Init(uint32 PspModuleId); + +#define UT_RAMBLOCK_SIZE 32 + +static union +{ + uint8 u8[UT_RAMBLOCK_SIZE]; + uint16 u16[UT_RAMBLOCK_SIZE / sizeof(uint16)]; + uint32 u32[UT_RAMBLOCK_SIZE / sizeof(uint32)]; +} UT_RAM_BLOCK; + +void Test_ram_direct_Init(void) +{ + /* Test for: + void ram_direct_Init(uint32 PspModuleId) + */ + + UtAssert_VOIDCALL(ram_direct_Init(1)); +} + +void Test_CFE_PSP_MemRead8(void) +{ + /* Test for: + int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) + */ + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + uint8 Value1; + uint8 Value2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u8[5]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u8[6]; + UT_RAM_BLOCK.u8[5] = 0xAA; + UT_RAM_BLOCK.u8[6] = 0xBB; + + UtAssert_INT32_EQ(CFE_PSP_MemRead8(UtAddress1, &Value1), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemRead8(UtAddress2, &Value2), CFE_PSP_SUCCESS); + UtAssert_UINT8_EQ(Value1, UT_RAM_BLOCK.u8[5]); + UtAssert_UINT8_EQ(Value2, UT_RAM_BLOCK.u8[6]); +} + +void Test_CFE_PSP_MemWrite8(void) +{ + /* Test for: + int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) + */ + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u8[4]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u8[5]; + + UtAssert_INT32_EQ(CFE_PSP_MemWrite8(UtAddress1, 0xBB), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemWrite8(UtAddress2, 0xCC), CFE_PSP_SUCCESS); + UtAssert_UINT8_EQ(UT_RAM_BLOCK.u8[4], 0xBB); + UtAssert_UINT8_EQ(UT_RAM_BLOCK.u8[5], 0xCC); +} + +void Test_CFE_PSP_MemRead16(void) +{ + /* Test for: + int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) + */ + + uint16 Value1; + uint16 Value2; + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u16[7]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u16[8]; + + UT_RAM_BLOCK.u16[7] = 0x3344; + UT_RAM_BLOCK.u16[8] = 0x99AA; + + UtAssert_INT32_EQ(CFE_PSP_MemRead16(UtAddress1, &Value1), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemRead16(UtAddress2, &Value2), CFE_PSP_SUCCESS); + UtAssert_UINT16_EQ(Value1, UT_RAM_BLOCK.u16[7]); + UtAssert_UINT16_EQ(Value2, UT_RAM_BLOCK.u16[8]); + + UtAssert_INT32_EQ(CFE_PSP_MemRead16(UtAddress1 + 1, &Value1), CFE_PSP_ERROR_ADDRESS_MISALIGNED); +} + +void Test_CFE_PSP_MemWrite16(void) +{ + /* Test for: + int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) + */ + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u16[6]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u16[7]; + + UtAssert_INT32_EQ(CFE_PSP_MemWrite16(UtAddress1, 0xBBDD), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemWrite16(UtAddress2, 0xCCEE), CFE_PSP_SUCCESS); + UtAssert_UINT16_EQ(UT_RAM_BLOCK.u16[6], 0xBBDD); + UtAssert_UINT16_EQ(UT_RAM_BLOCK.u16[7], 0xCCEE); + + UtAssert_INT32_EQ(CFE_PSP_MemWrite16(UtAddress1 + 1, 0xEEFF), CFE_PSP_ERROR_ADDRESS_MISALIGNED); +} + +void Test_CFE_PSP_MemRead32(void) +{ + /* Test for: + int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) + */ + + uint32 Value1; + uint32 Value2; + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u32[3]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u32[4]; + + UT_RAM_BLOCK.u32[3] = 0xAABBCCDD; + UT_RAM_BLOCK.u32[3] = 0x44556677; + + UtAssert_INT32_EQ(CFE_PSP_MemRead32(UtAddress1, &Value1), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemRead32(UtAddress2, &Value2), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(Value1, UT_RAM_BLOCK.u32[3]); + UtAssert_UINT32_EQ(Value2, UT_RAM_BLOCK.u32[4]); + + UtAssert_INT32_EQ(CFE_PSP_MemRead32(UtAddress1 + 3, &Value1), CFE_PSP_ERROR_ADDRESS_MISALIGNED); +} + +void Test_CFE_PSP_MemWrite32(void) +{ + /* Test for: + int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) + */ + + cpuaddr UtAddress1; + cpuaddr UtAddress2; + + UtAddress1 = (cpuaddr)&UT_RAM_BLOCK.u32[2]; + UtAddress2 = (cpuaddr)&UT_RAM_BLOCK.u32[3]; + + UtAssert_INT32_EQ(CFE_PSP_MemWrite32(UtAddress1, 0xBB997755), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemWrite32(UtAddress2, 0xCCAA8866), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(UT_RAM_BLOCK.u32[2], 0xBB997755); + UtAssert_UINT32_EQ(UT_RAM_BLOCK.u32[3], 0xCCAA8866); + + UtAssert_INT32_EQ(CFE_PSP_MemWrite32(UtAddress1 + 3, 0xDEADBEEF), CFE_PSP_ERROR_ADDRESS_MISALIGNED); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ResetTest, NULL, #test) + +void ResetTest(void) +{ + UT_ResetState(0); + memset(&UT_RAM_BLOCK, 0, sizeof(UT_RAM_BLOCK)); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_ram_direct_Init); + ADD_TEST(Test_CFE_PSP_MemRead8); + ADD_TEST(Test_CFE_PSP_MemWrite8); + ADD_TEST(Test_CFE_PSP_MemRead16); + ADD_TEST(Test_CFE_PSP_MemWrite16); + ADD_TEST(Test_CFE_PSP_MemRead32); + ADD_TEST(Test_CFE_PSP_MemWrite32); +} diff --git a/unit-test-coverage/modules/ram_notimpl/CMakeLists.txt b/unit-test-coverage/modules/ram_notimpl/CMakeLists.txt new file mode 100644 index 00000000..b725db04 --- /dev/null +++ b/unit-test-coverage/modules/ram_notimpl/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/ram_notimpl") + +add_psp_covtest(ram_notimpl coveragetest-ram_notimpl.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/ram_notimpl/cfe_psp_ram_notimpl.c +) diff --git a/unit-test-coverage/modules/ram_notimpl/coveragetest-ram_notimpl.c b/unit-test-coverage/modules/ram_notimpl/coveragetest-ram_notimpl.c new file mode 100644 index 00000000..e0f15699 --- /dev/null +++ b/unit-test-coverage/modules/ram_notimpl/coveragetest-ram_notimpl.c @@ -0,0 +1,132 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 ram_notimpl module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +/* This does not have a header */ +extern void ram_notimpl_Init(uint32 PspModuleId); + +void Test_ram_notimpl_Init(void) +{ + /* Test for: + void ram_notimpl_Init(uint32 PspModuleId) + */ + + UtAssert_VOIDCALL(ram_notimpl_Init(1)); +} + +void Test_CFE_PSP_MemRead8(void) +{ + /* Test for: + int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) + */ + + uint8 Value; + UtAssert_INT32_EQ(CFE_PSP_MemRead8(0, &Value), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_MemWrite8(void) +{ + /* Test for: + int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) + */ + + UtAssert_INT32_EQ(CFE_PSP_MemWrite8(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_MemRead16(void) +{ + /* Test for: + int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) + */ + + uint16 Value; + UtAssert_INT32_EQ(CFE_PSP_MemRead16(0, &Value), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_MemWrite16(void) +{ + /* Test for: + int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) + */ + + UtAssert_INT32_EQ(CFE_PSP_MemWrite16(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_MemRead32(void) +{ + /* Test for: + int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) + */ + + uint32 Value; + UtAssert_INT32_EQ(CFE_PSP_MemRead32(0, &Value), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +void Test_CFE_PSP_MemWrite32(void) +{ + /* Test for: + int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) + */ + + UtAssert_INT32_EQ(CFE_PSP_MemWrite32(0, 1), CFE_PSP_ERROR_NOT_IMPLEMENTED); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, NULL, NULL, #test) + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_ram_notimpl_Init); + ADD_TEST(Test_CFE_PSP_MemRead8); + ADD_TEST(Test_CFE_PSP_MemWrite8); + ADD_TEST(Test_CFE_PSP_MemRead16); + ADD_TEST(Test_CFE_PSP_MemWrite16); + ADD_TEST(Test_CFE_PSP_MemRead32); + ADD_TEST(Test_CFE_PSP_MemWrite32); +} diff --git a/unit-test-coverage/modules/rtems_sysmon/CMakeLists.txt b/unit-test-coverage/modules/rtems_sysmon/CMakeLists.txt new file mode 100644 index 00000000..91d5ab4e --- /dev/null +++ b/unit-test-coverage/modules/rtems_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/rtems_sysmon") + +add_psp_covtest(rtems_sysmon src/coveragetest-rtems_sysmon.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/rtems_sysmon/rtems_sysmon.c +) diff --git a/unit-test-coverage/modules/rtems_sysmon/coveragetest-rtems_sysmon.c b/unit-test-coverage/modules/rtems_sysmon/coveragetest-rtems_sysmon.c new file mode 100644 index 00000000..14875710 --- /dev/null +++ b/unit-test-coverage/modules/rtems_sysmon/coveragetest-rtems_sysmon.c @@ -0,0 +1,758 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#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_arch_ppc_vxPpcLib.h" + +/* + * Reference to the API entry point for the module + */ +extern CFE_PSP_ModuleApi_t CFE_PSP_timebase_vxworks_API; + +const CFE_PSP_ModuleApi_t *TgtAPI = &CFE_PSP_timebase_vxworks_API; + +UT_PSP_TimeBase_VxWorks_TestConfig_t UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG; + +typedef struct +{ + uint32 u; + uint32 l; +} PSP_VxWorks_TimeBaseVal_t; + +void ModuleTest_ResetState(void) +{ + memset(&UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG, 0, sizeof(UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG)); +} + +int32 UTHOOK_vxTimeBaseGet(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) +{ + PSP_VxWorks_TimeBaseVal_t *val = UserObj; + uint32 * u = UT_Hook_GetArgValueByName(Context, "u", uint32 *); + uint32 * l = UT_Hook_GetArgValueByName(Context, "l", uint32 *); + + *u = val->u; + *l = val->l; + + return StubRetcode; +} + +void Test_Nominal(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Nominal test with a simple 1:1 ratio */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 1; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 1; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 1000000000); + + /* Check operation of CFE_PSP_GetTime() */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0; + VxTime.l = 10000; + CFE_PSP_GetTime(&OsTime); + + UtAssert_UINT32_EQ(OS_TimeGetNanosecondsPart(OsTime), 10000); +} + +void Test_Non_Reducible(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Use an oddball ratio of of some primes, will not be reducible */ + /* Ratio is 43*3 / 53*2 => 129/106 */ + /* This translates to about ~1.217ns per tick */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 43 * 3; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 53 * 2; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 821705426); + + /* + * Check operation of CFE_PSP_GetTime() + * + * This test requires that the conversion uses the actual ratio, + * otherwise a rounding error will be noticed. + * For example: + * Conversion using 1.217ns/tick yields 52269758 usec (wrong). + * Conversion using actual ratio yields 52268947 usec. + */ + + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 10; + VxTime.l = 5000; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 52268947, "CFE_PSP_GetTime() Microseconds (%lld) == 52268947", (long long)TestTime); +} + +void Test_Reducible_1(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Test with a ratio that is also 1:1, but can be reduced */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 1000; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 1000; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 1000000000); + + /* + * Check operation of CFE_PSP_GetTime() + * + * Externally calculated value should be 10376293541461622 usec. + * If overflow occurs then value will be wrong. + */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x90000000; /* nearing 64-bit limit */ + VxTime.l = 0; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 10376293541461622, "CFE_PSP_GetTime() Microseconds (%lld) == 10376293541461622", + (long long)TestTime); +} + +void Test_Reducible_2(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Test with a ratio that can be reduced */ + /* Final reduced ratio should be 12:5 with 100ns OS ticks */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 84000; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 350; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 4166666); + + /* + * Check operation of CFE_PSP_GetTime() + * + * Externally calculated value should be 276701161105643274 usec. + * If overflow occurs then value will be wrong. + */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x10000000; /* nearing 64-bit limit */ + VxTime.l = 0; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 276701161105643274, "CFE_PSP_GetTime() Microseconds(%lld) == 276701161105643274", + (long long)TestTime); +} + +void Test_Rollover(void) +{ + /* This function always returns 0 */ + UtAssert_UINT32_EQ(CFE_PSP_GetTimerLow32Rollover(), 0); +} + +/****************************************************************************** +** +** Purpose: +** Provides a common interface to system timebase. This routine +** is in the BSP because it is sometimes implemented in hardware and +** sometimes taken care of by the RTOS. +** +** Arguments: +** +** Return: +** Timebase register value +*/ +void Test_Get_Timebase(void) +{ + PSP_VxWorks_TimeBaseVal_t VxTime; + uint32 tbu; + uint32 tbl; + + /* The value from vxTimeBaseGet() should be passed through unchanged */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x00112233; + VxTime.l = 0x44556677; + + CFE_PSP_Get_Timebase(&tbu, &tbl); + + UtAssert_UINT32_EQ(tbu, VxTime.u); + UtAssert_UINT32_EQ(tbl, VxTime.l); +} + +/* + * 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_Nominal); + ADD_TEST(Test_Non_Reducible); + ADD_TEST(Test_Reducible_1); + ADD_TEST(Test_Reducible_2); + ADD_TEST(Test_Rollover); + ADD_TEST(Test_Get_Timebase); +} +/************************************************************************ + * 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. + ************************************************************************/ +/* + * Based on RTEMS5 cpuusagereport.c + */ + +/************************************************************************ + * Includes + ************************************************************************/ + +#include "cfe_psp.h" + +#include "iodriver_impl.h" +#include "iodriver_analog_io.h" + +#include +#include +#include +#include + +/******************************************************************** + * Local Defines + ********************************************************************/ +#ifdef OS_MAXIMUM_PROCESSORS +#define RTEMS_SYSMON_MAX_CPUS OS_MAXIMUM_PROCESSORS +#else +#define RTEMS_SYSMON_MAX_CPUS 1 +#endif + +#define RTEMS_SYSMON_AGGREGATE_SUBSYS 0 +#define RTEMS_SYSMON_CPULOAD_SUBSYS 1 +#define RTEMS_SYSMON_AGGR_CPULOAD_SUBCH 0 +#define RTEMS_SYSMON_SAMPLE_DELAY 1000 +#define RTEMS_SYSMON_TASK_PRIORITY 100 +#define RTEMS_SYSMON_STACK_SIZE 4096 +#define RTEMS_SYSMON_MAX_SCALE 100000 + +#ifdef DEBUG_BUILD +#define RTEMS_SYSMON_DEBUG(...) OS_printf(__VA_ARGS__) +#else +#define RTEMS_SYSMON_DEBUG(...) +#endif + +/******************************************************************** + * Local Type Definitions + ********************************************************************/ +typedef struct rtems_sysmon_cpuload_core +{ + CFE_PSP_IODriver_AdcCode_t avg_load; + Timestamp_Control last_run_time; + Timestamp_Control idle_last_uptime; + +} rtems_sysmon_cpuload_core_t; + +typedef struct rtems_sysmon_cpuload_state +{ + volatile bool is_running; + volatile bool should_run; + + rtems_id task_id; + rtems_name task_name; + + uint8_t num_cpus; + rtems_sysmon_cpuload_core_t per_core[RTEMS_SYSMON_MAX_CPUS]; + +} rtems_sysmon_cpuload_state_t; + +typedef struct rtems_sysmon_state +{ + uint32_t local_module_id; + rtems_sysmon_cpuload_state_t cpu_load; +} rtems_sysmon_state_t; + +/******************************************************************** + * Local Function Prototypes + ********************************************************************/ +static void rtems_sysmon_Init(uint32_t local_module_id); +static int32_t rtems_sysmon_Start(rtems_sysmon_cpuload_state_t *state); +static int32_t rtems_sysmon_Stop(rtems_sysmon_cpuload_state_t *state); + +int32_t rtems_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg); +int32_t rtems_sysmon_calc_aggregate_cpu(rtems_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val); + +/* Function that starts up rtems_sysmon driver. */ +static int32_t rtems_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId, + CFE_PSP_IODriver_Arg_t Arg); + +/******************************************************************** + * Global Data + ********************************************************************/ +/* This object provides the uptime timestamp at the last CPU usage reset. */ +extern Timestamp_Control CPU_usage_Uptime_at_last_reset; + +/* rtems_sysmon device command that is called by iodriver to start up rtems_sysmon */ +CFE_PSP_IODriver_API_t rtems_sysmon_DevApi = {.DeviceCommand = rtems_sysmon_DevCmd}; + +CFE_PSP_MODULE_DECLARE_IODEVICEDRIVER(rtems_sysmon); + +static rtems_sysmon_state_t rtems_sysmon_global; + +static const char *rtems_sysmon_subsystem_names[] = {"aggregate", "per-cpu", NULL}; +static const char *rtems_sysmon_subchannel_names[] = {"cpu-load", NULL}; + +/*********************************************************************** + * Global Functions + ********************************************************************/ +void rtems_sysmon_Init(uint32_t local_module_id) +{ + memset(&rtems_sysmon_global, 0, sizeof(rtems_sysmon_global)); + + rtems_sysmon_global.local_module_id = local_module_id; +} + +static bool rtems_cpu_usage_vistor(Thread_Control *the_thread, void *arg) +{ + rtems_sysmon_cpuload_state_t *state = (rtems_sysmon_cpuload_state_t *)arg; + rtems_sysmon_cpuload_core_t * core_p = &state->per_core[state->num_cpus]; + + Timestamp_Control uptime_at_last_calc = core_p->last_run_time; + Timestamp_Control idle_uptime_at_last_calc = core_p->idle_last_uptime; + Timestamp_Control current_uptime; + Timestamp_Control idle_task_uptime; + Timestamp_Control idle_uptime_elapsed; + Timestamp_Control total_elapsed; + + char name[38]; + uint32_t ival; + uint32_t fval; + bool status = false; + + _Thread_Get_name(the_thread, name, sizeof(name)); + if (strncmp("IDLE", name, 4) == 0) + { +#if __RTEMS_MAJOR__ == 5 + _Thread_Get_CPU_time_used(the_thread, &idle_task_uptime); +#else /* RTEMS 6 */ + idle_task_uptime = _Thread_Get_CPU_time_used_after_last_reset(the_thread); +#endif + + _TOD_Get_uptime(¤t_uptime); + _Timestamp_Subtract(&idle_uptime_at_last_calc, &idle_task_uptime, &idle_uptime_elapsed); + _Timestamp_Subtract(&uptime_at_last_calc, ¤t_uptime, &total_elapsed); + _Timestamp_Divide(&idle_uptime_elapsed, &total_elapsed, &ival, + &fval); /* ival - points to the integer portion */ + /* fval - points to the thousandths of percentage */ + + core_p->last_run_time = current_uptime; + core_p->idle_last_uptime = idle_task_uptime; + + if (ival >= 100) + { + core_p->avg_load = 0xFFFFFF; /* max */ + } + else if (total_elapsed == 0) + { + core_p->avg_load = 0; + } + else + { + while (fval > 999) + { + fval /= 10; + } /* Keep 3 most significant digits. Should not occur. */ + core_p->avg_load = (RTEMS_SYSMON_MAX_SCALE - ((ival * 1000) + fval)); /* Get percentages as integer */ + + /* + ** Mimic ADC so that "analogio" API can be used with out modification. API assumes 24 bits. + ** First calculate out of 0x1000 and then duplicate it to expand to 24 bits. Doing this prevents + ** an overflow. avg_load has a "real" resolution of 12 bits. + */ + core_p->avg_load = (0x1000 * core_p->avg_load) / RTEMS_SYSMON_MAX_SCALE; + core_p->avg_load |= (core_p->avg_load << 12); + } + +#ifdef DEBUG_BUILD + rtems_cpu_usage_report(); + + uint32_t microsec = _Timestamp_Get_nanoseconds(&idle_uptime_elapsed) / TOD_NANOSECONDS_PER_MICROSECOND; + uint32_t sec = _Timestamp_Get_seconds(&idle_uptime_elapsed); + RTEMS_SYSMON_DEBUG("\nCFE_PSP(rtems_sysmon): IDLE cpu time elapsed = %7u.%06u, IDLE percentages =%4u.%03u\n", + sec, microsec, ival, fval); + + microsec = _Timestamp_Get_nanoseconds(&total_elapsed) / TOD_NANOSECONDS_PER_MICROSECOND; + sec = _Timestamp_Get_seconds(&total_elapsed); + RTEMS_SYSMON_DEBUG("CFE_PSP(rtems_sysmon): Total elapsed CPU time = %7u.%06u, CPU Load =%08X\n", sec, microsec, + core_p->avg_load); +#endif + + state->num_cpus++; + if (state->num_cpus >= RTEMS_SYSMON_MAX_CPUS) + { + /* stop checking when all idle tasks has been found */ + status = true; + } + } + + /* return true to exit iterating tasks */ + return status; +} + +void rtems_sysmon_update_stat(rtems_sysmon_cpuload_state_t *state) +{ + state->num_cpus = 0; + rtems_task_iterate(rtems_cpu_usage_vistor, state); +} + +rtems_task rtems_sysmon_Task(rtems_task_argument arg) +{ + rtems_sysmon_cpuload_state_t *state = (rtems_sysmon_cpuload_state_t *)arg; + int i; + + /* Initialize */ + rtems_cpu_usage_reset(); + + memset(state->per_core, 0, RTEMS_SYSMON_MAX_CPUS * sizeof(rtems_sysmon_cpuload_core_t)); + for (i = 0; i < RTEMS_SYSMON_MAX_CPUS; i++) + { + state->per_core[i].last_run_time = CPU_usage_Uptime_at_last_reset; + } + + while (state->should_run) + { + + OS_TaskDelay(RTEMS_SYSMON_SAMPLE_DELAY); + rtems_sysmon_update_stat(state); + } + + rtems_task_delete(RTEMS_SELF); +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * rtems_sysmon_Start() + * ------------------------------------------------------ + * Starts the cpu load watcher function + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +static int32_t rtems_sysmon_Start(rtems_sysmon_cpuload_state_t *state) +{ + int32_t StatusCode; + rtems_status_code status; + + if (state->is_running) + { + /* already running, nothing to do */ + StatusCode = CFE_PSP_SUCCESS; + } + else + { + /* start clean */ + memset(state, 0, sizeof(*state)); + StatusCode = CFE_PSP_ERROR; + + state->should_run = true; + state->task_name = rtems_build_name('R', 'S', 'M', ' '); + status = rtems_task_create(state->task_name, RTEMS_SYSMON_TASK_PRIORITY, RTEMS_SYSMON_STACK_SIZE, + RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &state->task_id); + if (status != RTEMS_SUCCESSFUL) + { + perror("rtems_task_create()"); + state->should_run = false; + } + else + { + status = rtems_task_start(state->task_id, rtems_sysmon_Task, (rtems_task_argument)state); + if (status != RTEMS_SUCCESSFUL) + { + perror("rtems_task_start()"); + rtems_task_delete(state->task_id); + state->should_run = false; + } + else + { + OS_printf("CFE_PSP(RTEMS_SysMon): Started CPU utilization monitoring\n"); + + StatusCode = CFE_PSP_SUCCESS; + state->is_running = true; + } + } + } + return StatusCode; +} + +int32_t rtems_sysmon_Stop(rtems_sysmon_cpuload_state_t *state) +{ + if (state->is_running) + { + state->should_run = false; + state->is_running = false; + rtems_task_delete(state->task_id); + } + + return CFE_PSP_SUCCESS; +} + +int32_t rtems_sysmon_calc_aggregate_cpu(rtems_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val) +{ + + uint8_t cpu; + uint32_t sum; + + sum = 0; + for (cpu = 0; cpu < RTEMS_SYSMON_MAX_CPUS; cpu++) + { + sum += state->per_core[cpu].avg_load; + } + + sum /= RTEMS_SYSMON_MAX_CPUS; + *Val = sum; + + RTEMS_SYSMON_DEBUG("CFE_PSP(rtems_sysmon): Aggregate CPU load=%08X\n", (unsigned int)sum); + + return CFE_PSP_SUCCESS; +} + +int32_t rtems_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg) +{ + int32_t StatusCode; + rtems_sysmon_cpuload_state_t *state; + + /* There is just one global cpuload object */ + state = &rtems_sysmon_global.cpu_load; + + StatusCode = CFE_PSP_ERROR_NOT_IMPLEMENTED; + switch (CommandCode) + { + case CFE_PSP_IODriver_NOOP: + case CFE_PSP_IODriver_ANALOG_IO_NOOP: + RTEMS_SYSMON_DEBUG("CFE_PSP(RTEMS_SysMon): Noop \n"); + break; + case CFE_PSP_IODriver_SET_RUNNING: + { + if (Arg.U32) + { + StatusCode = rtems_sysmon_Start(state); + } + else + { + StatusCode = rtems_sysmon_Stop(state); + } + break; + } + case CFE_PSP_IODriver_GET_RUNNING: + { + StatusCode = state->is_running; + break; + } + case CFE_PSP_IODriver_SET_CONFIGURATION: /**< const string argument (device-dependent content) */ + case CFE_PSP_IODriver_GET_CONFIGURATION: /**< void * argument (device-dependent content) */ + { + /* not implemented for now */ + break; + } + case CFE_PSP_IODriver_LOOKUP_SUBSYSTEM: /**< const char * argument, looks up name and returns positive + value for subsystem number, negative value for error */ + { + uint16_t i; + + for (i = 0; rtems_sysmon_subsystem_names[i] != NULL; ++i) + { + if (strcmp(Arg.ConstStr, rtems_sysmon_subsystem_names[i]) == 0) + { + StatusCode = i; + break; + } + } + + break; + } + case CFE_PSP_IODriver_LOOKUP_SUBCHANNEL: /**< const char * argument, looks up name and returns positive + value for channel number, negative value for error */ + { + uint16_t i; + + for (i = 0; rtems_sysmon_subchannel_names[i] != NULL; ++i) + { + if (strcmp(Arg.ConstStr, rtems_sysmon_subchannel_names[i]) == 0) + { + StatusCode = i; + break; + } + } + + break; + } + case CFE_PSP_IODriver_QUERY_DIRECTION: /**< CFE_PSP_IODriver_Direction_t argument */ + { + CFE_PSP_IODriver_Direction_t *DirPtr = (CFE_PSP_IODriver_Direction_t *)Arg.Vptr; + if (DirPtr != NULL) + { + *DirPtr = CFE_PSP_IODriver_Direction_INPUT_ONLY; + StatusCode = CFE_PSP_SUCCESS; + } + break; + } + case CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS: + { + CFE_PSP_IODriver_AnalogRdWr_t *RdWr = Arg.Vptr; + + if (RdWr->NumChannels == 1 && Subchannel == RTEMS_SYSMON_AGGR_CPULOAD_SUBCH) + { + StatusCode = rtems_sysmon_calc_aggregate_cpu(state, RdWr->Samples); + } + break; + } + default: + break; + } + + return StatusCode; +} + +int32_t rtems_sysmon_cpu_load_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg) +{ + int32_t StatusCode; + rtems_sysmon_cpuload_state_t *state; + + /* There is just one global cpuload object */ + state = &rtems_sysmon_global.cpu_load; + StatusCode = CFE_PSP_ERROR_NOT_IMPLEMENTED; + switch (CommandCode) + { + case CFE_PSP_IODriver_NOOP: + case CFE_PSP_IODriver_ANALOG_IO_NOOP: + { + /* NO-OP should return success - + * This is a required opcode as "generic" clients may use it to + * determine if a certain set of opcodes are supported or not + */ + StatusCode = CFE_PSP_SUCCESS; + break; + } + case CFE_PSP_IODriver_ANALOG_IO_READ_CHANNELS: + { + CFE_PSP_IODriver_AnalogRdWr_t *RdWr = Arg.Vptr; + uint32_t ch; + + if (Subchannel < RTEMS_SYSMON_MAX_CPUS && (Subchannel + RdWr->NumChannels) <= RTEMS_SYSMON_MAX_CPUS) + { + for (ch = Subchannel; ch < (Subchannel + RdWr->NumChannels); ++ch) + { + RdWr->Samples[ch] = state->per_core[ch].avg_load; + } + } + + break; + } + default: + break; + } + + return StatusCode; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* rtems_sysmon_DevCmd() */ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/** + * \brief Main entry point for API. + * + * This function is called through iodriver to invoke the rtems_sysmon module. + * + * \par Assumptions, External Events, and Notes: + * None + * + * \param[in] CommandCode The CFE_PSP_IODriver_xxx command. + * \param[in] SubsystemId The monitor subsystem identifier + * \param[in] SubchannelId The monitor subchannel identifier + * \param[in] Arg The arguments for the corresponding command. + * + * \returns Status code + * \retval #CFE_PSP_SUCCESS if successful + */ +int32_t rtems_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId, + CFE_PSP_IODriver_Arg_t Arg) +{ + int32_t StatusCode; + + StatusCode = CFE_PSP_ERROR_NOT_IMPLEMENTED; + switch (SubsystemId) + { + case RTEMS_SYSMON_AGGREGATE_SUBSYS: + StatusCode = rtems_sysmon_aggregate_dispatch(CommandCode, SubchannelId, Arg); + break; + case RTEMS_SYSMON_CPULOAD_SUBSYS: + StatusCode = rtems_sysmon_cpu_load_dispatch(CommandCode, SubchannelId, Arg); + break; + default: + /* not implemented */ + break; + } + + return StatusCode; +} diff --git a/unit-test-coverage/modules/soft_timebase/CMakeLists.txt b/unit-test-coverage/modules/soft_timebase/CMakeLists.txt new file mode 100644 index 00000000..78dc6f75 --- /dev/null +++ b/unit-test-coverage/modules/soft_timebase/CMakeLists.txt @@ -0,0 +1,10 @@ +###################################################################### +# +# 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") + +add_psp_covtest(soft_timebase coveragetest-soft_timebase.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/soft_timebase/cfe_psp_soft_timebase.c +) diff --git a/unit-test-coverage/modules/soft_timebase/coveragetest-soft_timebase.c b/unit-test-coverage/modules/soft_timebase/coveragetest-soft_timebase.c new file mode 100644 index 00000000..e7c6a8d9 --- /dev/null +++ b/unit-test-coverage/modules/soft_timebase/coveragetest-soft_timebase.c @@ -0,0 +1,84 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 soft timebase module implementation + */ + +#include "utassert.h" +#include "utstubs.h" +#include "uttest.h" + +#include "cfe_psp.h" +#include "cfe_psp_config.h" +#include "cfe_psp_module.h" + +extern void soft_timebase_Init(uint32 PspModuleId); + +UT_PSP_Soft_TimeBase_TestConfig_t UT_PSP_SOFT_TIMEBASE_TESTCONFIG; + +void Test_soft_timebase_Init(void) +{ + /* Test for: + void soft_timebase_Init(uint32 PspModuleId) + */ + + /* nominal */ + UtAssert_VOIDCALL(soft_timebase_Init(1)); + + /* OS_TimeBaseSet() fail */ + UT_SetDefaultReturnValue(UT_KEY(OS_TimeBaseSet), OS_ERROR); + UtAssert_VOIDCALL(soft_timebase_Init(2)); + + /* OS_TimeBaseCreate() fail */ + UT_SetDefaultReturnValue(UT_KEY(OS_TimeBaseCreate), OS_ERROR); + UtAssert_VOIDCALL(soft_timebase_Init(3)); +} + +/* + * Macro to add a test case to the list of tests to execute + */ +#define ADD_TEST(test) UtTest_Add(test, ResetTest, NULL, #test) + +void ResetTest(void) +{ + UT_ResetState(0); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(Test_soft_timebase_Init); +} diff --git a/unit-test-coverage/modules/soft_timebase/inc/cfe_psp_config.h b/unit-test-coverage/modules/soft_timebase/inc/cfe_psp_config.h new file mode 100644 index 00000000..9ff3fe70 --- /dev/null +++ b/unit-test-coverage/modules/soft_timebase/inc/cfe_psp_config.h @@ -0,0 +1,50 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 + * + * Stub for "cfe_psp_config.h" to use with coverage testing + */ + +#ifndef CFE_PSP_CONFIG_H +#define CFE_PSP_CONFIG_H + +#define CFE_PSP_SOFT_TIMEBASE_PERIOD (UT_PSP_SOFT_TIMEBASE_TESTCONFIG.Period) + +typedef struct +{ + unsigned long Period; +} UT_PSP_Soft_TimeBase_TestConfig_t; + +extern UT_PSP_Soft_TimeBase_TestConfig_t UT_PSP_SOFT_TIMEBASE_TESTCONFIG; + +#endif diff --git a/unit-test-coverage/modules/timebase_posix_clock/CMakeLists.txt b/unit-test-coverage/modules/timebase_posix_clock/CMakeLists.txt new file mode 100644 index 00000000..d1dd4452 --- /dev/null +++ b/unit-test-coverage/modules/timebase_posix_clock/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/timebase_posix_clock") + +add_psp_covtest(timebase_posix_clock src/coveragetest-timebase_posix_clock.c + ${CFEPSP_SOURCE_DIR}/fsw/modules/timebase_posix_clock/timebase_posix_clock.c +) diff --git a/unit-test-coverage/modules/timebase_posix_clock/coveragetest-timebase_posix_clock.c b/unit-test-coverage/modules/timebase_posix_clock/coveragetest-timebase_posix_clock.c new file mode 100644 index 00000000..3486c4ce --- /dev/null +++ b/unit-test-coverage/modules/timebase_posix_clock/coveragetest-timebase_posix_clock.c @@ -0,0 +1,389 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 timebase module implementation + */ + +#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_arch_ppc_vxPpcLib.h" + +/* + * Reference to the API entry point for the module + */ +extern CFE_PSP_ModuleApi_t CFE_PSP_timebase_vxworks_API; + +const CFE_PSP_ModuleApi_t *TgtAPI = &CFE_PSP_timebase_vxworks_API; + +UT_PSP_TimeBase_VxWorks_TestConfig_t UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG; + +typedef struct +{ + uint32 u; + uint32 l; +} PSP_VxWorks_TimeBaseVal_t; + +void ModuleTest_ResetState(void) +{ + memset(&UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG, 0, sizeof(UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG)); +} + +int32 UTHOOK_vxTimeBaseGet(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) +{ + PSP_VxWorks_TimeBaseVal_t *val = UserObj; + uint32 * u = UT_Hook_GetArgValueByName(Context, "u", uint32 *); + uint32 * l = UT_Hook_GetArgValueByName(Context, "l", uint32 *); + + *u = val->u; + *l = val->l; + + return StubRetcode; +} + +void Test_Nominal(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Nominal test with a simple 1:1 ratio */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 1; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 1; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 1000000000); + + /* Check operation of CFE_PSP_GetTime() */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0; + VxTime.l = 10000; + CFE_PSP_GetTime(&OsTime); + + UtAssert_UINT32_EQ(OS_TimeGetNanosecondsPart(OsTime), 10000); +} + +void Test_Non_Reducible(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Use an oddball ratio of of some primes, will not be reducible */ + /* Ratio is 43*3 / 53*2 => 129/106 */ + /* This translates to about ~1.217ns per tick */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 43 * 3; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 53 * 2; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 821705426); + + /* + * Check operation of CFE_PSP_GetTime() + * + * This test requires that the conversion uses the actual ratio, + * otherwise a rounding error will be noticed. + * For example: + * Conversion using 1.217ns/tick yields 52269758 usec (wrong). + * Conversion using actual ratio yields 52268947 usec. + */ + + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 10; + VxTime.l = 5000; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 52268947, "CFE_PSP_GetTime() Microseconds (%lld) == 52268947", (long long)TestTime); +} + +void Test_Reducible_1(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Test with a ratio that is also 1:1, but can be reduced */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 1000; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 1000; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 1000000000); + + /* + * Check operation of CFE_PSP_GetTime() + * + * Externally calculated value should be 10376293541461622 usec. + * If overflow occurs then value will be wrong. + */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x90000000; /* nearing 64-bit limit */ + VxTime.l = 0; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 10376293541461622, "CFE_PSP_GetTime() Microseconds (%lld) == 10376293541461622", + (long long)TestTime); +} + +void Test_Reducible_2(void) +{ + OS_time_t OsTime; + PSP_VxWorks_TimeBaseVal_t VxTime; + int64 TestTime; + + memset(&OsTime, 0, sizeof(OsTime)); + + /* Test with a ratio that can be reduced */ + /* Final reduced ratio should be 12:5 with 100ns OS ticks */ + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodNumerator = 84000; + UT_PSP_TIMEBASE_VXWORKS_TESTCONFIG.PeriodDenominator = 350; + TgtAPI->Init(0); + UtAssert_UINT32_EQ(CFE_PSP_GetTimerTicksPerSecond(), 4166666); + + /* + * Check operation of CFE_PSP_GetTime() + * + * Externally calculated value should be 276701161105643274 usec. + * If overflow occurs then value will be wrong. + */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x10000000; /* nearing 64-bit limit */ + VxTime.l = 0; + CFE_PSP_GetTime(&OsTime); + + TestTime = OS_TimeGetTotalMicroseconds(OsTime); + UtAssert_True(TestTime == 276701161105643274, "CFE_PSP_GetTime() Microseconds(%lld) == 276701161105643274", + (long long)TestTime); +} + +void Test_Rollover(void) +{ + /* This function always returns 0 */ + UtAssert_UINT32_EQ(CFE_PSP_GetTimerLow32Rollover(), 0); +} + +/****************************************************************************** +** +** Purpose: +** Provides a common interface to system timebase. This routine +** is in the BSP because it is sometimes implemented in hardware and +** sometimes taken care of by the RTOS. +** +** Arguments: +** +** Return: +** Timebase register value +*/ +void Test_Get_Timebase(void) +{ + PSP_VxWorks_TimeBaseVal_t VxTime; + uint32 tbu; + uint32 tbl; + + /* The value from vxTimeBaseGet() should be passed through unchanged */ + UT_SetHookFunction(UT_KEY(PCS_vxTimeBaseGet), UTHOOK_vxTimeBaseGet, &VxTime); + VxTime.u = 0x00112233; + VxTime.l = 0x44556677; + + CFE_PSP_Get_Timebase(&tbu, &tbl); + + UtAssert_UINT32_EQ(tbu, VxTime.u); + UtAssert_UINT32_EQ(tbl, VxTime.l); +} + +/* + * 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_Nominal); + ADD_TEST(Test_Non_Reducible); + ADD_TEST(Test_Reducible_1); + ADD_TEST(Test_Reducible_2); + ADD_TEST(Test_Rollover); + ADD_TEST(Test_Get_Timebase); +} +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * \file + * + * A PSP module to satisfy the PSP time API on systems which + * do not have a hardware clock register, but do provide a POSIX + * compliant implementation of clock_gettime() and CLOCK_MONOTONIC + * that can fulfill this role. + * + * The POSIX CLOCK_MONOTONIC is defined as a monotonically increasing + * clock that has no specific epoch. It is not affected by local time + * changes and is not settable. + * + * The POSIX interface uses a "struct timespec" which has units in + * nanoseconds, but this is converted down to units of microseconds for + * consistency with previous versions of PSP where CFE_PSP_Get_Timebase() + * returned units of microseconds. + */ + +/* +** System Include Files +*/ +#include +#include +#include + +#include "cfe_psp.h" +#include "cfe_psp_module.h" + +/* + * The specific clock ID to use with clock_gettime + * + * Linux provides some special (non-posix) clock IDs that also + * could be relevant/useful: + * + * CLOCK_MONOTONIC_COARSE - emphasis on read speed at the (possible?) expense of precision + * CLOCK_MONOTONIC_RAW - possibly hardware based, not affected by NTP or other sync software + * CLOCK_BOOTTIME - includes time the system is suspended. + * + * Defaulting to the POSIX-specified "MONOTONIC" but it should be possible to use + * one of the Linux-specific variants if the target system provides it. + */ +#define CFE_PSP_TIMEBASE_REF_CLOCK CLOCK_MONOTONIC + +CFE_PSP_MODULE_DECLARE_SIMPLE(timebase_posix_clock); + +void timebase_posix_clock_Init(uint32 PspModuleId) +{ + /* Inform the user that this module is in use */ + printf("CFE_PSP: Using POSIX monotonic clock as CFE timebase\n"); +} + +/* + * ---------------------------------------------------------------------- + * The CFE_PSP_Get_Timebase() is a wrapper around clock_gettime() + * + * Reads the value of the monotonic POSIX clock, and output the value with + * the whole seconds in the upper 32 and nanoseconds in the lower 32. + * + * This variant does minimal conversions - just enough to meet the API. + * For a normalized output use CFE_PSP_GetTime() + * ---------------------------------------------------------------------- + */ +void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) +{ + struct timespec now; + + if (clock_gettime(CFE_PSP_TIMEBASE_REF_CLOCK, &now) != 0) + { + /* unlikely - but avoids undefined behavior */ + now.tv_sec = 0; + now.tv_nsec = 0; + } + + *Tbu = now.tv_sec & 0xFFFFFFFF; + *Tbl = now.tv_nsec; +} + +/* + * ---------------------------------------------------------------------- + * The CFE_PSP_GetTime() is also a wrapper around the same clock_gettime() + * + * Reads the value of the monotonic POSIX clock, and output the value + * normalized to an OS_time_t format. + * ---------------------------------------------------------------------- + */ +void CFE_PSP_GetTime(OS_time_t *LocalTime) +{ + struct timespec now; + + if (clock_gettime(CFE_PSP_TIMEBASE_REF_CLOCK, &now) != 0) + { + /* unlikely - but avoids undefined behavior */ + now.tv_sec = 0; + now.tv_nsec = 0; + } + + *LocalTime = OS_TimeAssembleFromNanoseconds(now.tv_sec, now.tv_nsec); +} + +/*---------------------------------------------------------------- + * + * Implemented per public API + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +uint32 CFE_PSP_GetTimerTicksPerSecond(void) +{ + /* POSIX "struct timespec" resolution is defined as nanoseconds */ + return 1000000000; +} + +/*---------------------------------------------------------------- + * + * Implemented per public API + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +uint32 CFE_PSP_GetTimerLow32Rollover(void) +{ + /* POSIX "struct timespec" resolution is defined as nanoseconds */ + return 1000000000; +} diff --git a/unit-test-coverage/modules/timebase_vxworks/src/coveragetest-timebase_vxworks.c b/unit-test-coverage/modules/timebase_vxworks/src/coveragetest-timebase_vxworks.c index 9fc28cc3..cc6f5fcb 100644 --- a/unit-test-coverage/modules/timebase_vxworks/src/coveragetest-timebase_vxworks.c +++ b/unit-test-coverage/modules/timebase_vxworks/src/coveragetest-timebase_vxworks.c @@ -230,6 +230,30 @@ void Test_Get_Timebase(void) UtAssert_UINT32_EQ(tbl, VxTime.l); } +void Test_PSP_Get_Timebase_NullUpperRegister(void) +{ + /* Arrange */ + uint32 tbl; + + /* Act */ + UtAssert_VOIDCALL(CFE_PSP_Get_Timebase(NULL, &tbl)); +} + +void Test_PSP_Get_Timebase_NullLowerRegister(void) +{ + /* Arrange */ + uint32 tbu; + + /* Act */ + UtAssert_VOIDCALL(CFE_PSP_Get_Timebase(&tbu, NULL)); +} + +void Test_PSP_GetTimeNullLocalTime(void) +{ + /* Act */ + UtAssert_VOIDCALL(CFE_PSP_GetTime(NULL)); +} + /* * Macro to add a test case to the list of tests to execute */ @@ -246,4 +270,7 @@ void UtTest_Setup(void) ADD_TEST(Test_Reducible_2); ADD_TEST(Test_Rollover); ADD_TEST(Test_Get_Timebase); + ADD_TEST(Test_PSP_Get_Timebase_NullUpperRegister); + ADD_TEST(Test_PSP_Get_Timebase_NullLowerRegister); + ADD_TEST(Test_PSP_GetTimeNullLocalTime); } 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 index d66fd62a..f722f4b4 100644 --- a/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c +++ b/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c @@ -1,5 +1,5 @@ /************************************************************************ - * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: * Draco * * Copyright (c) 2023 United States Government as represented by the @@ -52,18 +52,17 @@ /* * Reference to the API entry point for the module */ -extern CFE_PSP_ModuleApi_t CFE_PSP_vxworks_sysmon_API; +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; +const CFE_PSP_ModuleApi_t * TgtAPI = &CFE_PSP_vxworks_sysmon_API; /* Hook */ -void UT_TaskDelay_Hook(void *UserObj) +void UT_TaskDelay_Hook(void *UserObj) { - int *DelayCounter = UserObj; + int *DelayCounter = UserObj; vxworks_sysmon_global.cpu_load.should_run = false; - - (*DelayCounter)++; + (*DelayCounter)++; } void ModuleTest_ResetState(void) @@ -75,35 +74,36 @@ 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; + 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)); + 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)); + 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)); + 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};; + 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; + 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 */ @@ -114,82 +114,81 @@ void Test_Aggregate_Nominal(void) 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)); + 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)); + 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)); + 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"); + 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)); + 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"); - + 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)); + 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)); + 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")); + 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")); + 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")); + 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)); + 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)"); + UtAssert_True(QueryDirArg == CFE_PSP_IODriver_Direction_INPUT_ONLY, + "Nominal Case: VxWorks Sysmon Direction (INPUT ONLY)"); /* Nominal Case: Analog IO Read Channel */ - Sample = -1; + 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};; + 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")); + 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")); + 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 */ @@ -197,24 +196,24 @@ void Test_Aggregate_Error(void) 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; + 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; + 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)); + 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)); + 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"); @@ -222,10 +221,10 @@ void Test_Aggregate_Error(void) 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; + 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)); @@ -236,30 +235,32 @@ void Test_Dispatch_Nominal(void) UtAssert_True(StatusCode == CFE_PSP_SUCCESS, "Nominal Case: Dispatch Analog IO NOOP"); /* Nominal Case: Dispatch Analog Read Channels */ - Sample[0] = -1; - Sample[1] = -1; + 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; + 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; + 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"); + 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"); + 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)); @@ -268,16 +269,16 @@ void Test_Dispatch_Error(void) void Test_UpdateStat_Nominal(void) { - const char * fmt = "%s %s %s %s %d ( %d) %d ( %d)"; - uint32 AvgLoad; - uint32 IdleTaskLoad; + 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); + 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 */ @@ -297,7 +298,7 @@ void Test_UpdateStat_Nominal(void) 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; + 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"); @@ -305,9 +306,9 @@ void Test_UpdateStat_Nominal(void) /* 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, + 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) @@ -325,11 +326,10 @@ void Test_Task_Nominal(void) void Test_Task_Error(void) { vxworks_sysmon_global.cpu_load.should_run = true; - UT_SetDeferredRetcode(UT_KEY(PCS_spyClkStartCommon), 1, OS_ERROR); + 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"); - } /* @@ -351,5 +351,4 @@ void UtTest_Setup(void) ADD_TEST(Test_UpdateStat_Nominal); ADD_TEST(Test_Task_Nominal); ADD_TEST(Test_Task_Error); - } diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-bootrec.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-bootrec.h new file mode 100644 index 00000000..44ea72e6 --- /dev/null +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-bootrec.h @@ -0,0 +1,50 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#ifndef UT_ADAPTOR_BOOTREC_H +#define UT_ADAPTOR_BOOTREC_H + +#include "common_types.h" + +void UT_BootRecAdaptor_Init(void *MemPtr); +void UT_BootRecAdaptor_InitDefault(void); + +uint32 UT_BootRecAdaptor_Get_BootType(void); +void UT_BootRecAdaptor_Set_BootType(uint32 reset_type); +uint32 UT_BootRecAdaptor_Get_SizeOfRecord(void); + +#endif diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-cdsmem.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-cdsmem.h new file mode 100644 index 00000000..9d6fd28a --- /dev/null +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-cdsmem.h @@ -0,0 +1,49 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#ifndef UT_ADAPTOR_CDSMEM_H +#define UT_ADAPTOR_CDSMEM_H + +#include "common_types.h" + +void UT_CdsMemAdaptor_Init(void *mem_ptr, size_t mem_size); +void UT_CdsMemAdaptor_CopyOut(void *dst, size_t num_bytes); +void UT_CdsMemAdaptor_SetOffset(size_t offset, uint8 val); +void * UT_CdsMemAdaptor_GetAddress(void); +size_t UT_CdsMemAdaptor_GetSize(void); + +#endif diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-exceptions.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-exceptions.h index 9aa039c5..a7e2e28f 100644 --- a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-exceptions.h +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-exceptions.h @@ -43,7 +43,11 @@ uint32 UT_Get_Exception_MaxEntries(void); size_t UT_Get_Exception_Size(void); +size_t UT_Get_Exception_TotalStorageSize(void); uint32 UT_Get_Exception_Id(struct CFE_PSP_Exception_LogData *Buffer); void UT_Generate_Exception_Context(struct CFE_PSP_Exception_LogData *Buffer, size_t Size); +void UT_Set_Exception_StoragePtr(void *Ptr); +void UT_Set_Exception_StorageReadWrite(uint32 rd, uint32 wr); + #endif diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-memrange.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-memrange.h new file mode 100644 index 00000000..307ab9c1 --- /dev/null +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-memrange.h @@ -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://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) 2020, 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 adaptors + */ + +#ifndef UT_ADAPTOR_MEMRANGE_H +#define UT_ADAPTOR_MEMRANGE_H + +#include "common_types.h" + +void UT_ClearMemRangeTable(void); +uint32 UT_Get_MemRange_MaxEntries(void); +void UT_SetupMemRangeTable(uint32 EntryNum, uint32 MemType, cpuaddr StartAddr, size_t Size, uint32 WordSize); + +#endif diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-resetmem.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-resetmem.h new file mode 100644 index 00000000..90749434 --- /dev/null +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-resetmem.h @@ -0,0 +1,48 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#ifndef UT_ADAPTOR_RESETMEM_H +#define UT_ADAPTOR_RESETMEM_H + +#include "common_types.h" + +void UT_ResetMemAdaptor_Init(void *mem_ptr, size_t mem_size); +void UT_ResetMemAdaptor_SetOffset(size_t offset, uint8 val); +void * UT_ResetMemAdaptor_GetAddress(void); +size_t UT_ResetMemAdaptor_GetSize(void); + +#endif diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-usermem.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-usermem.h new file mode 100644 index 00000000..2e3f3fa8 --- /dev/null +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-usermem.h @@ -0,0 +1,49 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#ifndef UT_ADAPTOR_USERMEM_H +#define UT_ADAPTOR_USERMEM_H + +#include "common_types.h" + +void UT_UserMemAdaptor_Init(void *mem_ptr, size_t mem_size); +void UT_UserMemAdaptor_CopyOut(void *dst, size_t num_bytes); +void UT_UserMemAdaptor_SetOffset(size_t offset, uint8 val); +void * UT_UserMemAdaptor_GetAddress(void); +size_t UT_UserMemAdaptor_GetSize(void); + +#endif diff --git a/unit-test-coverage/shared/adaptors/inc/ut-adaptor-voldisk.h b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-voldisk.h new file mode 100644 index 00000000..01dd00b0 --- /dev/null +++ b/unit-test-coverage/shared/adaptors/inc/ut-adaptor-voldisk.h @@ -0,0 +1,49 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#ifndef UT_ADAPTOR_VOLDISKMEM_H +#define UT_ADAPTOR_VOLDISKMEM_H + +#include "common_types.h" + +void UT_VolDiskAdaptor_Init(void *mem_ptr, size_t mem_size); +void UT_VolDiskAdaptor_CopyOut(void *dst, size_t num_bytes); +void UT_VolDiskAdaptor_SetOffset(size_t offset, uint8 val); +void * UT_VolDiskAdaptor_GetAddress(void); +size_t UT_VolDiskAdaptor_GetSize(void); + +#endif diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-bootrec.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-bootrec.c new file mode 100644 index 00000000..b711d7ca --- /dev/null +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-bootrec.c @@ -0,0 +1,70 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#include "ut-adaptor-bootrec.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" + +static CFE_PSP_ReservedMemoryBootRecord_t UT_BOOTREC; + +static const CFE_PSP_ReservedMemoryBootRecord_t UT_DEFAULT_BOOTREC = {0}; + +void UT_BootRecAdaptor_InitDefault(void) +{ + UT_BOOTREC = UT_DEFAULT_BOOTREC; + CFE_PSP_ReservedMemoryMap.BootPtr = &UT_BOOTREC; +} + +uint32 UT_BootRecAdaptor_Get_BootType(void) +{ + return CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type; +} + +void UT_BootRecAdaptor_Set_BootType(uint32 reset_type) +{ + CFE_PSP_ReservedMemoryMap.BootPtr->bsp_reset_type = reset_type; +} + +uint32 UT_BootRecAdaptor_Get_SizeOfRecord(void) +{ + return sizeof(CFE_PSP_ReservedMemoryBootRecord_t); +} + +void UT_BootRecAdaptor_Init(void *MemPtr) +{ + CFE_PSP_ReservedMemoryMap.BootPtr = MemPtr; +} \ No newline at end of file diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-cdsmem.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-cdsmem.c new file mode 100644 index 00000000..58368f8d --- /dev/null +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-cdsmem.c @@ -0,0 +1,66 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#include "ut-adaptor-cdsmem.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" + +void UT_CdsMemAdaptor_Init(void *mem_ptr, size_t mem_size) +{ + CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr = mem_ptr; + CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize = mem_size; +} + +void UT_CdsMemAdaptor_CopyOut(void *dst, size_t num_bytes) +{ + memcpy(dst, CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr, num_bytes); +} + +void UT_CdsMemAdaptor_SetOffset(size_t offset, uint8 val) +{ + ((uint8 *)CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr)[offset] = val; +} + +void *UT_CdsMemAdaptor_GetAddress(void) +{ + return CFE_PSP_ReservedMemoryMap.CDSMemory.BlockPtr; +} + +size_t UT_CdsMemAdaptor_GetSize(void) +{ + return CFE_PSP_ReservedMemoryMap.CDSMemory.BlockSize; +} \ No newline at end of file diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-exceptions.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-exceptions.c index 6f6c98fc..edd440e6 100644 --- a/unit-test-coverage/shared/adaptors/src/ut-adaptor-exceptions.c +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-exceptions.c @@ -42,6 +42,17 @@ #define CFE_PSP_MAX_EXCEPTION_ENTRIES 4 #define CFE_PSP_MAX_EXCEPTION_BACKTRACE_SIZE 16 +void UT_Set_Exception_StoragePtr(void *Ptr) +{ + CFE_PSP_ReservedMemoryMap.ExceptionStoragePtr = Ptr; +} + +void UT_Set_Exception_StorageReadWrite(uint32 rd, uint32 wr) +{ + CFE_PSP_ReservedMemoryMap.ExceptionStoragePtr->NumRead = rd; + CFE_PSP_ReservedMemoryMap.ExceptionStoragePtr->NumWritten = wr; +} + uint32 UT_Get_Exception_MaxEntries(void) { return CFE_PSP_MAX_EXCEPTION_ENTRIES; @@ -52,6 +63,11 @@ size_t UT_Get_Exception_Size(void) return sizeof(CFE_PSP_Exception_ContextDataEntry_t); } +size_t UT_Get_Exception_TotalStorageSize(void) +{ + return sizeof(CFE_PSP_ExceptionStorage_t); +} + void UT_Generate_Exception_Context(struct CFE_PSP_Exception_LogData *Buffer, size_t Size) { size_t i; diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-memrange.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-memrange.c new file mode 100644 index 00000000..c39b6180 --- /dev/null +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-memrange.c @@ -0,0 +1,61 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * + */ + +#include "ut-adaptor-memrange.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" + +uint32 UT_Get_MemRange_MaxEntries(void) +{ + return CFE_PSP_MEM_TABLE_SIZE; +} + +void UT_ClearMemRangeTable(void) +{ + memset(CFE_PSP_ReservedMemoryMap.SysMemoryTable, 0, sizeof(CFE_PSP_ReservedMemoryMap.SysMemoryTable)); +} + +void UT_SetupMemRangeTable(uint32 EntryNum, uint32 MemType, cpuaddr StartAddr, size_t Size, uint32 WordSize) +{ + CFE_PSP_MemTable_t *SysMemPtr; + + SysMemPtr = &CFE_PSP_ReservedMemoryMap.SysMemoryTable[EntryNum]; + + SysMemPtr->MemoryType = MemType; + SysMemPtr->StartAddr = StartAddr; + SysMemPtr->WordSize = WordSize; + SysMemPtr->Size = Size; +} \ No newline at end of file diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-resetmem.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-resetmem.c new file mode 100644 index 00000000..8767a94a --- /dev/null +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-resetmem.c @@ -0,0 +1,61 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#include "ut-adaptor-resetmem.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" + +void UT_ResetMemAdaptor_Init(void *mem_ptr, size_t mem_size) +{ + CFE_PSP_ReservedMemoryMap.ResetMemory.BlockPtr = mem_ptr; + CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize = mem_size; +} + +void UT_ResetMemAdaptor_SetOffset(size_t offset, uint8 val) +{ + ((uint8 *)CFE_PSP_ReservedMemoryMap.ResetMemory.BlockPtr)[offset] = val; +} + +void *UT_ResetMemAdaptor_GetAddress(void) +{ + return CFE_PSP_ReservedMemoryMap.ResetMemory.BlockPtr; +} + +size_t UT_ResetMemAdaptor_GetSize(void) +{ + return CFE_PSP_ReservedMemoryMap.ResetMemory.BlockSize; +} \ No newline at end of file diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-usermem.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-usermem.c new file mode 100644 index 00000000..db7eee6b --- /dev/null +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-usermem.c @@ -0,0 +1,66 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#include "ut-adaptor-resetmem.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" + +void UT_UserMemAdaptor_Init(void *mem_ptr, size_t mem_size) +{ + CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr = mem_ptr; + CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize = mem_size; +} + +void UT_UserMemAdaptor_CopyOut(void *dst, size_t num_bytes) +{ + memcpy(dst, CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr, num_bytes); +} + +void UT_UserMemAdaptor_SetOffset(size_t offset, uint8 val) +{ + ((uint8 *)CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr)[offset] = val; +} + +void *UT_UserMemAdaptor_GetAddress(void) +{ + return CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockPtr; +} + +size_t UT_UserMemAdaptor_GetSize(void) +{ + return CFE_PSP_ReservedMemoryMap.UserReservedMemory.BlockSize; +} diff --git a/unit-test-coverage/shared/adaptors/src/ut-adaptor-voldisk.c b/unit-test-coverage/shared/adaptors/src/ut-adaptor-voldisk.c new file mode 100644 index 00000000..a6e86dcc --- /dev/null +++ b/unit-test-coverage/shared/adaptors/src/ut-adaptor-voldisk.c @@ -0,0 +1,66 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#include "ut-adaptor-resetmem.h" +#include "cfe_psp_config.h" +#include "cfe_psp_memory.h" + +void UT_VolDiskAdaptor_Init(void *mem_ptr, size_t mem_size) +{ + CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr = mem_ptr; + CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize = mem_size; +} + +void UT_VolDiskAdaptor_CopyOut(void *dst, size_t num_bytes) +{ + memcpy(dst, CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr, num_bytes); +} + +void UT_VolDiskAdaptor_SetOffset(size_t offset, uint8 val) +{ + ((uint8 *)CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr)[offset] = val; +} + +void *UT_VolDiskAdaptor_GetAddress(void) +{ + return CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockPtr; +} + +size_t UT_VolDiskAdaptor_GetSize(void) +{ + return CFE_PSP_ReservedMemoryMap.VolatileDiskMemory.BlockSize; +} diff --git a/unit-test-coverage/shared/inc/coveragetest-psp-shared.h b/unit-test-coverage/shared/inc/coveragetest-psp-shared.h index 82fd5028..14af5213 100644 --- a/unit-test-coverage/shared/inc/coveragetest-psp-shared.h +++ b/unit-test-coverage/shared/inc/coveragetest-psp-shared.h @@ -42,9 +42,30 @@ #include "uttest.h" #include "utstubs.h" +void Test_CFE_PSP_StatusToString(void); + +void Test_CFE_PSP_GetVersionString(void); +void Test_CFE_PSP_GetVersionCodeName(void); +void Test_CFE_PSP_GetVersionNumber(void); +void Test_CFE_PSP_GetBuildNumber(void); + void Test_CFE_PSP_Exception_GetBuffer(void); void Test_CFE_PSP_Exception_GetNextContextBuffer(void); void Test_CFE_PSP_Exception_GetSummary(void); void Test_CFE_PSP_Exception_CopyContext(void); +void Test_CFE_PSP_ModuleInitList(void); +void Test_CFE_PSP_ModuleInit(void); +void Test_CFE_PSP_Module_GetAPIEntry(void); +void Test_CFE_PSP_Module_SearchNameInList(void); +void Test_CFE_PSP_Module_FindByName(void); + +void Test_CFE_PSP_MemCpy(void); +void Test_CFE_PSP_MemSet(void); + +void Test_CFE_PSP_MemValidateRange(void); +void Test_CFE_PSP_MemRanges(void); +void Test_CFE_PSP_MemRangeSet(void); +void Test_CFE_PSP_MemRangeGet(void); + #endif diff --git a/unit-test-coverage/shared/src/coveragetest-cfe-psp-error.c b/unit-test-coverage/shared/src/coveragetest-cfe-psp-error.c new file mode 100644 index 00000000..28f49b87 --- /dev/null +++ b/unit-test-coverage/shared/src/coveragetest-cfe-psp-error.c @@ -0,0 +1,54 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 joseph.p.hickey@nasa.gov + * + */ + +#include "utassert.h" +#include "utstubs.h" + +#include "cfe_psp_error.h" + +void Test_CFE_PSP_StatusToString(void) +{ + /* Test Case for: + * char *CFE_PSP_StatusToString(CFE_PSP_Status_t status, CFE_PSP_StatusString_t *status_string) + */ + CFE_PSP_StatusString_t MyString = {0}; + + UtAssert_ADDRESS_EQ(CFE_PSP_StatusToString(CFE_PSP_STATUS_C(-1), &MyString), MyString); + UtAssert_NONZERO(MyString[0]); + + UtAssert_NULL(CFE_PSP_StatusToString(CFE_PSP_STATUS_C(-1), NULL)); +} diff --git a/unit-test-coverage/shared/src/coveragetest-cfe-psp-exceptionstorage.c b/unit-test-coverage/shared/src/coveragetest-cfe-psp-exceptionstorage.c index 77e876fb..e9a6725f 100644 --- a/unit-test-coverage/shared/src/coveragetest-cfe-psp-exceptionstorage.c +++ b/unit-test-coverage/shared/src/coveragetest-cfe-psp-exceptionstorage.c @@ -128,7 +128,11 @@ void Test_CFE_PSP_Exception_GetSummary(void) UtAssert_NOT_NULL(CFE_PSP_Exception_GetNextContextBuffer()); CFE_PSP_Exception_WriteComplete(); - UtAssert_INT32_EQ(CFE_PSP_Exception_GetSummary(&LogId, &TaskId, NULL, 0), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_Exception_GetSummary(&LogId, &TaskId, NULL, sizeof(ReasonBuf)), CFE_PSP_SUCCESS); + + UtAssert_NOT_NULL(CFE_PSP_Exception_GetNextContextBuffer()); + CFE_PSP_Exception_WriteComplete(); + UtAssert_INT32_EQ(CFE_PSP_Exception_GetSummary(&LogId, &TaskId, ReasonBuf, 0), CFE_PSP_SUCCESS); UtAssert_NOT_NULL(CFE_PSP_Exception_GetNextContextBuffer()); CFE_PSP_Exception_WriteComplete(); @@ -147,8 +151,13 @@ void Test_CFE_PSP_Exception_CopyContext(void) uint32 Count; uint32 SmallBuf[1]; uint32 LargeBuf[4]; + uint32 CFE_PSP_EXCEPTION_ID_BASE; CFE_PSP_Exception_Reset(); + CFE_PSP_EXCEPTION_ID_BASE = ((OS_OBJECT_TYPE_USER + 0x101) << OS_OBJECT_TYPE_SHIFT); + LogId = OS_OBJECT_INDEX_MASK + OS_OBJECT_INDEX_MASK + CFE_PSP_EXCEPTION_ID_BASE; + UtAssert_INT32_EQ(CFE_PSP_Exception_CopyContext(LogId, SmallBuf, sizeof(SmallBuf)), CFE_PSP_NO_EXCEPTION_DATA); + UtAssert_INT32_EQ(CFE_PSP_Exception_CopyContext(0, NULL, sizeof(SmallBuf)), CFE_PSP_INVALID_POINTER); UtAssert_INT32_EQ(CFE_PSP_Exception_CopyContext(0, SmallBuf, sizeof(SmallBuf)), CFE_PSP_NO_EXCEPTION_DATA); Ptr = CFE_PSP_Exception_GetNextContextBuffer(); diff --git a/unit-test-coverage/shared/src/coveragetest-cfe-psp-memrange.c b/unit-test-coverage/shared/src/coveragetest-cfe-psp-memrange.c new file mode 100644 index 00000000..3ccf1a70 --- /dev/null +++ b/unit-test-coverage/shared/src/coveragetest-cfe-psp-memrange.c @@ -0,0 +1,118 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 + */ + +#include "utassert.h" +#include "utstubs.h" + +#include "ut-adaptor-memrange.h" +#include "cfe_psp_memrange_api.h" + +void Test_CFE_PSP_MemValidateRange(void) +{ + /* Test Case For: + * int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) + */ + UT_ClearMemRangeTable(); + + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0, 32, 0), CFE_PSP_INVALID_MEM_TYPE); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(-1, 32, CFE_PSP_MEM_RAM), CFE_PSP_INVALID_MEM_RANGE); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0, 32, CFE_PSP_MEM_RAM), CFE_PSP_INVALID_MEM_ADDR); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0, 32, CFE_PSP_MEM_EEPROM), CFE_PSP_INVALID_MEM_ADDR); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0, 32, CFE_PSP_MEM_ANY), CFE_PSP_INVALID_MEM_ADDR); + + UT_SetupMemRangeTable(1, CFE_PSP_MEM_RAM, 0, 0x1000, 4); + UT_SetupMemRangeTable(2, CFE_PSP_MEM_INVALID, 0x1000, 0x1000, 4); + UT_SetupMemRangeTable(3, CFE_PSP_MEM_EEPROM, 0x2000, 0x1000, 4); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0, 0x100, CFE_PSP_MEM_RAM), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0x100, 0x100, CFE_PSP_MEM_ANY), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0x200, 0x100, CFE_PSP_MEM_EEPROM), CFE_PSP_INVALID_MEM_ADDR); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0x2000, 0x100, CFE_PSP_MEM_RAM), CFE_PSP_INVALID_MEM_ADDR); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0x2000, 0x100, CFE_PSP_MEM_EEPROM), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0x1000, 0x100, CFE_PSP_MEM_RAM), CFE_PSP_INVALID_MEM_ADDR); + + /* Validate a range that crosses from one region into another */ + UtAssert_INT32_EQ(CFE_PSP_MemValidateRange(0x800, 0x1000, CFE_PSP_MEM_RAM), CFE_PSP_INVALID_MEM_ADDR); +} + +void Test_CFE_PSP_MemRanges(void) +{ + /* Test Case For: + * uint32 CFE_PSP_MemRanges(void) + */ + UtAssert_UINT32_EQ(CFE_PSP_MemRanges(), UT_Get_MemRange_MaxEntries()); +} + +void Test_CFE_PSP_MemRangeSet(void) +{ + /* Test Case For: + * int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, size_t Size, size_t WordSize, + * uint32 Attributes) + */ + UT_ClearMemRangeTable(); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(UINT32_MAX, CFE_PSP_MEM_RAM, 0, 32, 1, 0), CFE_PSP_INVALID_MEM_RANGE); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, 0, 0, 32, 1, 0), CFE_PSP_INVALID_MEM_TYPE); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, 32, 1, 0), CFE_PSP_INVALID_MEM_ATTR); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, 32, 1, 0), CFE_PSP_INVALID_MEM_ATTR); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, 32, 2, CFE_PSP_MEM_ATTR_READWRITE), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, 32, 4, CFE_PSP_MEM_ATTR_READWRITE), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, 0, 32, 8, CFE_PSP_MEM_ATTR_READWRITE), + CFE_PSP_INVALID_MEM_WORDSIZE); + + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_EEPROM, 32, 32, 4, CFE_PSP_MEM_ATTR_WRITE), CFE_PSP_SUCCESS); + UtAssert_INT32_EQ(CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_EEPROM, 32, 32, 4, CFE_PSP_MEM_ATTR_READ), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_MemRangeGet(void) +{ + /* Test Case For: + * int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, size_t *Size, size_t + * *WordSize, uint32 *Attributes) + */ + uint32 MemType; + cpuaddr StartAddr; + size_t MemSize; + size_t WordSize; + uint32 Attribs; + + UT_ClearMemRangeTable(); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(UINT32_MAX, &MemType, &StartAddr, &MemSize, &WordSize, &Attribs), + CFE_PSP_INVALID_MEM_RANGE); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(0, NULL, &StartAddr, &MemSize, &WordSize, &Attribs), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(0, &MemType, NULL, &MemSize, &WordSize, &Attribs), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(0, &MemType, &StartAddr, NULL, &WordSize, &Attribs), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(0, &MemType, &StartAddr, &MemSize, NULL, &Attribs), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(0, &MemType, &StartAddr, &MemSize, &WordSize, NULL), CFE_PSP_INVALID_POINTER); + UtAssert_INT32_EQ(CFE_PSP_MemRangeGet(0, &MemType, &StartAddr, &MemSize, &WordSize, &Attribs), CFE_PSP_SUCCESS); +} diff --git a/unit-test-coverage/shared/src/coveragetest-cfe-psp-memutils.c b/unit-test-coverage/shared/src/coveragetest-cfe-psp-memutils.c new file mode 100644 index 00000000..e74964d4 --- /dev/null +++ b/unit-test-coverage/shared/src/coveragetest-cfe-psp-memutils.c @@ -0,0 +1,65 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 joseph.p.hickey@nasa.gov + * + */ + +#include "utassert.h" +#include "utstubs.h" + +#include "cfe_psp_memaccess_api.h" + +void Test_CFE_PSP_MemCpy(void) +{ + /* Test Case For: + * int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n) + */ + const uint8 MySrcBuf[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + uint8 MyDstBuf[16]; + + UtAssert_INT32_EQ(CFE_PSP_MemCpy(NULL, MySrcBuf, sizeof(MyDstBuf)), CFE_PSP_ERROR); + UtAssert_INT32_EQ(CFE_PSP_MemCpy(MyDstBuf, NULL, sizeof(MyDstBuf)), CFE_PSP_ERROR); + UtAssert_INT32_EQ(CFE_PSP_MemCpy(MyDstBuf, MySrcBuf, sizeof(MyDstBuf)), CFE_PSP_SUCCESS); +} + +void Test_CFE_PSP_MemSet(void) +{ + /* Test Case For: + * int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) + */ + uint8 MyBuf[16]; + + UtAssert_INT32_EQ(CFE_PSP_MemSet(NULL, 0x82, sizeof(MyBuf)), CFE_PSP_ERROR); + UtAssert_INT32_EQ(CFE_PSP_MemSet(MyBuf, 0x82, sizeof(MyBuf)), CFE_PSP_SUCCESS); +} diff --git a/unit-test-coverage/shared/src/coveragetest-cfe-psp-module.c b/unit-test-coverage/shared/src/coveragetest-cfe-psp-module.c new file mode 100644 index 00000000..7ca9c80c --- /dev/null +++ b/unit-test-coverage/shared/src/coveragetest-cfe-psp-module.c @@ -0,0 +1,150 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 shared + */ + +#include "utassert.h" +#include "utstubs.h" + +#include "cfe_psp_module.h" + +/* This test needs to set conditions within the global to reach all code */ +extern CFE_PSP_ModuleListGlobal_t CFE_PSP_MODULE_LIST_GLOBAL; + +static void InitStub(uint32 PspModuleId) +{ + UT_DEFAULT_IMPL(InitStub); +} + +CFE_PSP_ModuleApi_t UT_API_INVALID = {.ModuleType = CFE_PSP_MODULE_TYPE_INVALID}; +CFE_PSP_ModuleApi_t UT_API_SIMPLE_NO_INIT = {.ModuleType = CFE_PSP_MODULE_TYPE_SIMPLE}; +CFE_PSP_ModuleApi_t UT_API_SIMPLE_COMPLETE = {.ModuleType = CFE_PSP_MODULE_TYPE_SIMPLE, .Init = InitStub}; + +static CFE_StaticModuleLoadEntry_t UT_STATIC_MODULE_LIST1[] = {{.Name = "UT1", .Api = &UT_API_INVALID}, + {.Name = "UT2", .Api = &UT_API_SIMPLE_NO_INIT}, + {.Name = "UT3", .Api = &UT_API_SIMPLE_COMPLETE}, + {.Name = NULL, .Api = NULL}}; + +static CFE_StaticModuleLoadEntry_t UT_STATIC_MODULE_LIST2[] = {{.Name = "UT4", .Api = &UT_API_SIMPLE_COMPLETE}, + {.Name = "UT5", .Api = &UT_API_SIMPLE_NO_INIT}, + {.Name = NULL, .Api = NULL}}; + +void Test_CFE_PSP_ModuleInitList(void) +{ + /* Test Case for: + * void CFE_PSP_ModuleInitList(CFE_PSP_ModuleListWrapper_t *WrapPtr, uint32 BaseId, CFE_StaticModuleLoadEntry_t + * *ListPtr) + */ + CFE_PSP_ModuleListWrapper_t ModList; + + /* This returns the number of modules in the list */ + UtAssert_VOIDCALL(CFE_PSP_ModuleInitList(&ModList, 0xA0000, UT_STATIC_MODULE_LIST1)); + UtAssert_STUB_COUNT(InitStub, 1); + UtAssert_UINT32_EQ(ModList.ListLen, 3); + + UtAssert_VOIDCALL(CFE_PSP_ModuleInitList(&ModList, 0xB0000, UT_STATIC_MODULE_LIST2)); + UtAssert_STUB_COUNT(InitStub, 2); + UtAssert_UINT32_EQ(ModList.ListLen, 2); +} + +void Test_CFE_PSP_ModuleInit(void) +{ + /* Test Case for: + * void CFE_PSP_ModuleInit(void) + */ + UtAssert_VOIDCALL(CFE_PSP_ModuleInit()); +} + +void Test_CFE_PSP_Module_GetAPIEntry(void) +{ + /* Test Case for: + * int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API) + */ + CFE_PSP_ModuleApi_t *API; + + CFE_PSP_MODULE_LIST_GLOBAL.Std = + (CFE_PSP_ModuleListWrapper_t) {.BasePtr = UT_STATIC_MODULE_LIST1, .ListLen = 3, .BaseId = 0xAFF00}; + CFE_PSP_MODULE_LIST_GLOBAL.Ext = + (CFE_PSP_ModuleListWrapper_t) {.BasePtr = UT_STATIC_MODULE_LIST2, .ListLen = 2, .BaseId = 0xA0000}; + + UtAssert_INT32_EQ(CFE_PSP_Module_GetAPIEntry(0, &API), CFE_PSP_INVALID_MODULE_ID); + UtAssert_NULL(API); + + UtAssert_INT32_EQ(CFE_PSP_Module_GetAPIEntry(0xA0001, &API), CFE_PSP_SUCCESS); + UtAssert_NOT_NULL(API); + UtAssert_INT32_EQ(CFE_PSP_Module_GetAPIEntry(0xA7FFF, &API), CFE_PSP_INVALID_MODULE_ID); + UtAssert_NULL(API); + + UtAssert_INT32_EQ(CFE_PSP_Module_GetAPIEntry(0xAFF01, &API), CFE_PSP_SUCCESS); + UtAssert_NOT_NULL(API); + UtAssert_INT32_EQ(CFE_PSP_Module_GetAPIEntry(0xAFFFF, &API), CFE_PSP_INVALID_MODULE_ID); + UtAssert_NULL(API); +} + +/* CFE_PSP_ModuleApi_t *CFE_PSP_Module_LookupTableEntry(const CFE_PSP_ModuleListWrapper_t *WrapPtr, uint32 Index) */ + +void Test_CFE_PSP_Module_SearchNameInList(void) +{ + /* Test Case for: + * uint32 CFE_PSP_Module_SearchNameInList(const CFE_PSP_ModuleListWrapper_t *WrapPtr, const char *ModuleName) + * const char *ModuleName); + */ + uint32 Id; + CFE_PSP_ModuleListWrapper_t ModList = {.BasePtr = UT_STATIC_MODULE_LIST1, .ListLen = 3, .BaseId = 0xC0000}; + + UtAssert_ZERO(CFE_PSP_Module_SearchNameInList(&ModList, "DoesNotExist")); + UtAssert_NONZERO(Id = CFE_PSP_Module_SearchNameInList(&ModList, "UT2")); + UtAssert_UINT32_EQ(Id, 0xC0001); + UtAssert_NONZERO(Id = CFE_PSP_Module_SearchNameInList(&ModList, "UT3")); + UtAssert_UINT32_EQ(Id, 0xC0002); +} + +void Test_CFE_PSP_Module_FindByName(void) +{ + /* Test Case for: + * int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId) + */ + uint32 ModuleId; + + CFE_PSP_MODULE_LIST_GLOBAL.Std = + (CFE_PSP_ModuleListWrapper_t) {.BasePtr = UT_STATIC_MODULE_LIST1, .ListLen = 3, .BaseId = 0xDFF00}; + CFE_PSP_MODULE_LIST_GLOBAL.Ext = + (CFE_PSP_ModuleListWrapper_t) {.BasePtr = UT_STATIC_MODULE_LIST2, .ListLen = 2, .BaseId = 0xD0000}; + + UtAssert_INT32_EQ(CFE_PSP_Module_FindByName("NameDoesNotExist", &ModuleId), CFE_PSP_INVALID_MODULE_NAME); + + UtAssert_INT32_EQ(CFE_PSP_Module_FindByName("UT3", &ModuleId), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(ModuleId, 0xDFF02); + UtAssert_INT32_EQ(CFE_PSP_Module_FindByName("UT4", &ModuleId), CFE_PSP_SUCCESS); + UtAssert_UINT32_EQ(ModuleId, 0xD0000); +} diff --git a/unit-test-coverage/shared/src/coveragetest-cfe-psp-version.c b/unit-test-coverage/shared/src/coveragetest-cfe-psp-version.c new file mode 100644 index 00000000..530fd97d --- /dev/null +++ b/unit-test-coverage/shared/src/coveragetest-cfe-psp-version.c @@ -0,0 +1,79 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * + * Copyright (c) 2020, 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 shared + */ + +#include "utassert.h" +#include "utstubs.h" + +#include "cfe_psp_version_api.h" + +void Test_CFE_PSP_GetVersionString(void) +{ + /* Test Case For: + * const char *CFE_PSP_GetVersionString(void) + */ + + UtAssert_NOT_NULL(CFE_PSP_GetVersionString()); +} + +void Test_CFE_PSP_GetVersionCodeName(void) +{ + /* Test Case For: + * const char *CFE_PSP_GetVersionCodeName(void) + */ + + UtAssert_NOT_NULL(CFE_PSP_GetVersionCodeName()); +} + +void Test_CFE_PSP_GetVersionNumber(void) +{ + /* Test Case For: + * void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]) + */ + uint8 VersionNumbers[4] = {0, 0, 0, 0}; + + UtAssert_VOIDCALL(CFE_PSP_GetVersionNumber(VersionNumbers)); + + /* Only sanity-check the major version, everything else can be validly zero */ + UtAssert_NONZERO(VersionNumbers[0]); +} + +void Test_CFE_PSP_GetBuildNumber(void) +{ + /* Test Case For: + * uint32 CFE_PSP_GetBuildNumber(void) + */ + + UtAssert_NONZERO(CFE_PSP_GetBuildNumber()); +} diff --git a/unit-test-coverage/ut-stubs/CMakeLists.txt b/unit-test-coverage/ut-stubs/CMakeLists.txt index 538161d0..ffa8208c 100644 --- a/unit-test-coverage/ut-stubs/CMakeLists.txt +++ b/unit-test-coverage/ut-stubs/CMakeLists.txt @@ -2,7 +2,7 @@ # Stub libraries for coverage testing # ---------------------------------------- -# This provides suitable "stub" implementations of every +# This provides suitable "stub" implementations of every # function call used internally by the various OSAL modules # for which there is not a stub already defined. # @@ -13,45 +13,79 @@ # i.e. memset, strcmp, etc - these should be relevant for all # supported operating systems as they are standard C # - Stub versions of internal "shared" OSAL implementation functions -# i.e. everything declared in the internal API. These are needed by +# i.e. everything declared in the internal API. These are needed by # any coverage test referencing on the shared/ng OSAL layer. # # The "ut_libc_stubs" target provides stub versions of C library calls. -# They are prefixed with "OCS_" and target code must be recompiled to -# call the OCS_ version of the syscall instead of the regular syscall. -# This is because in some circumstances for these calls the stub actually -# needs to invoke the real version or else weird things happen. +# They are prefixed with "PCS_" and target code must be recompiled to +# call the PCS_ version of the syscall instead of the regular syscall. +# This is because in some circumstances for these calls the stub actually +# needs to invoke the real version or else weird things happen. # This library includes stubs from all supported operating systems. This # is generally OK as we do not use any actual OS system headers # -# These files are generally organized to match whatever header file +# These files are generally organized to match whatever header file # defines the function. For instance, POSIX defines the "mqueue.h" # header file which in turn provides mq_open, mq_close, etc. So -# the OCS_mq_open, OCS_mq_close declarations are in overrides/mqueue.h, and +# the PCS_mq_open, PCS_mq_close declarations are in overrides/mqueue.h, and # the respective implementation is in posix-mqueue-stubs.c. # -# This keeps things relatively organized, and by keeping the source files +# This keeps things relatively organized, and by keeping the source files # relatively small and targeted like this the linker should only pull in -# the OCS functions that are actually used. +# the PCS functions that are actually used. # add_library(ut_psp_libc_stubs STATIC EXCLUDE_FROM_ALL - src/libc-stdio-stubs.c - src/libc-stdlib-stubs.c - src/libc-string-stubs.c - src/vxworks-ataDrv-stubs.c - src/vxworks-cacheLib-stubs.c - src/vxworks-moduleLib-stubs.c - src/vxworks-taskLib-stubs.c - src/vxworks-excLib-stubs.c - src/vxworks-fppLib-stubs.c + src/PCS_arch_ppc_vxPpcLib_handlers.c + src/PCS_arch_ppc_vxPpcLib_stubs.c + src/PCS_arpa_inet_handlers.c + src/PCS_arpa_inet_stubs.c + src/PCS_bsdnet_handlers.c + src/PCS_bsdnet_stubs.c + src/PCS_cacheLib_stubs.c + src/PCS_cfe_configdata_stubs.c + src/PCS_dosFsLib_stubs.c + src/PCS_drv_hdisk_ataDrv_stubs.c + src/PCS_drv_pci_pciConfigLib_handlers.c + src/PCS_drv_pci_pciConfigLib_stubs.c + src/PCS_errno_globals.c + src/PCS_errnoLib_stubs.c + src/PCS_excLib_stubs.c + src/PCS_fcntl_stubs.c + src/PCS_fppLib_stubs.c + src/PCS_intLib_stubs.c + src/PCS_moduleLib_handlers.c + src/PCS_moduleLib_stubs.c + src/PCS_netinet_in_stubs.c + src/PCS_ramDrv_stubs.c + src/PCS_rebootLib_stubs.c + src/PCS_speLib_stubs.c + src/PCS_spyLibP_stubs.c + src/PCS_spyLib_stubs.c + src/PCS_stdio_handlers.c + src/PCS_stdio_stubs.c + src/PCS_stdlib_handlers.c + src/PCS_stdlib_stubs.c + src/PCS_string_handlers.c + src/PCS_string_stubs.c + src/PCS_sys950Lib_stubs.c + src/PCS_sysApi_stubs.c + src/PCS_sysLib_handlers.c + src/PCS_sysLib_stubs.c + src/PCS_sys_mman_stubs.c + src/PCS_sys_select_stubs.c + src/PCS_sys_socket_handlers.c + src/PCS_sys_socket_stubs.c + src/PCS_sys_stat_handlers.c + src/PCS_sys_stat_stubs.c + src/PCS_taskLib_handlers.c + src/PCS_taskLib_stubs.c + src/PCS_time_handlers.c + src/PCS_time_stubs.c + src/PCS_unistd_handlers.c + src/PCS_unistd_stubs.c + src/PCS_xbdBlkDev_stubs.c src/vxworks-mcpx750-stubs.c - 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 - src/rtems-bsdnet-stubs.c ) target_include_directories(ut_libc_stubs PUBLIC @@ -65,9 +99,12 @@ target_link_libraries(ut_psp_libc_stubs PRIVATE add_library(ut_psp_cfe_stubs STATIC EXCLUDE_FROM_ALL src/cfe-configdata-stubs.c + src/cfe_psp_exceptionstorage_api_stubs.c + src/cfe_psp_memory_stubs.c + src/cfe_psp_module_stubs.c ) target_link_libraries(ut_psp_cfe_stubs PRIVATE psp_module_api ut_assert -) \ No newline at end of file +) diff --git a/unit-test-coverage/ut-stubs/inc/PCS_arch_ppc_vxPpcLib.h b/unit-test-coverage/ut-stubs/inc/PCS_arch_ppc_vxPpcLib.h index fb68b53a..43a49ece 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_arch_ppc_vxPpcLib.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_arch_ppc_vxPpcLib.h @@ -73,9 +73,9 @@ /* prototypes normally declared in vxPpcLib.h */ /* ----------------------------------------- */ extern void PCS_vxTimeBaseGet(uint32_t *u, uint32_t *l); -extern void PCS_vxMsrSet(uint32_t); +extern void PCS_vxMsrSet(uint32_t r); extern uint32_t PCS_vxMsrGet(void); -extern void PCS_vxFpscrSet(uint32_t); +extern void PCS_vxFpscrSet(uint32_t r); extern uint32_t PCS_vxFpscrGet(void); extern uint32_t PCS_vxDecGet(void); diff --git a/unit-test-coverage/ut-stubs/inc/PCS_arpa_inet.h b/unit-test-coverage/ut-stubs/inc/PCS_arpa_inet.h new file mode 100644 index 00000000..a0de82bb --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_arpa_inet.h @@ -0,0 +1,68 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for sys/stat.h */ +#ifndef PCS_ARPA_INET_H +#define PCS_ARPA_INET_H + +#include + +#include "PCS_basetypes.h" +#include "PCS_stdarg.h" +#include "PCS_netinet_in.h" + +/* Include this for va_list */ +#include + +/* ----------------------------------------- */ +/* constants normally defined in arpa/inet.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in arpa/inet.h */ +/* ----------------------------------------- */ + +/* ------------------------------------------- */ +/* prototypes normally declared in arpa/inet.h */ +/* ------------------------------------------- */ +extern uint32_t PCS_inet_addr(const char *cp); +extern char * PCS_inet_ntoa(struct PCS_in_addr in); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h b/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h index 4dd65ea3..6857fa1f 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h @@ -23,9 +23,9 @@ #include "PCS_basetypes.h" #include "PCS_rtems.h" -extern int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *, int); +extern int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *cfg, int x); extern void PCS_rtems_bsdnet_do_dhcp_failsafe(void); extern int PCS_rtems_bsdnet_initialize_network(void); -extern const char *PCS_rtems_status_text(PCS_rtems_status_code); +extern const char *PCS_rtems_status_text(PCS_rtems_status_code sc); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_cfe_configdata.h b/unit-test-coverage/ut-stubs/inc/PCS_cfe_configdata.h index 58430bd6..eb555bb3 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_cfe_configdata.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_cfe_configdata.h @@ -34,7 +34,7 @@ /** * Stub for the main system entry function implemented in CFE ES */ -void PCS_SystemMain(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath); +void PCS_SystemMain(uint32_t StartType, uint32_t StartSubtype, uint32_t ModeId, const char *StartFilePath); /** * Stub for 1Hz ISR function implemented in CFE TIME diff --git a/unit-test-coverage/ut-stubs/inc/PCS_drv_hdisk_ataDrv.h b/unit-test-coverage/ut-stubs/inc/PCS_drv_hdisk_ataDrv.h index 15dce871..513be366 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_drv_hdisk_ataDrv.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_drv_hdisk_ataDrv.h @@ -36,6 +36,6 @@ /* ----------------------------------------- */ /* prototypes normally declared in drv/hdisk/ataDrv.h */ /* ----------------------------------------- */ -extern PCS_device_t PCS_ataXbdDevCreate(int ctrl, int drive, unsigned int nBlks, unsigned int offset, const char *); +extern PCS_device_t PCS_ataXbdDevCreate(int ctrl, int drive, unsigned int nBlks, unsigned int offset, const char *s); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_drv_pci_pciConfigLib.h b/unit-test-coverage/ut-stubs/inc/PCS_drv_pci_pciConfigLib.h new file mode 100644 index 00000000..343b24a8 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_drv_pci_pciConfigLib.h @@ -0,0 +1,40 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +#ifndef PCS_DRV_PCI_PCICONFIGLIB_H +#define PCS_DRV_PCI_PCICONFIGLIB_H + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ---------------------------------------------------- */ +/* constants normally defined in drv/pci/pciConfigLib.h */ +/* ---------------------------------------------------- */ +#define PCS_PCI_CFG_STATUS 0 + +/* ------------------------------------------------ */ +/* types normally defined in drv/pci/pciConfigLib.h */ +/* ------------------------------------------------ */ + +/* ------------------------------------------------------ */ +/* prototypes normally declared in drv/pci/pciConfigLib.h */ +/* ------------------------------------------------------ */ +extern PCS_STATUS PCS_pciFindDevice(int vendorId, int deviceId, int index, int *pBusNo, int *pDeviceNo, int *pFuncNo); +extern PCS_STATUS PCS_pciConfigInWord(int busNo, int deviceNo, int funcNo, int offset, uint16_t *pData); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_errno.h b/unit-test-coverage/ut-stubs/inc/PCS_errno.h new file mode 100644 index 00000000..1f62d424 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_errno.h @@ -0,0 +1,80 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for errno.h + */ + +#ifndef PCS_ERRNO_H +#define PCS_ERRNO_H + +#include "PCS_basetypes.h" + +/* ----------------------------------------- */ +/* constants normally defined in errno.h */ +/* ----------------------------------------- */ +/* POSIX-specific errnos */ +#define PCS_EINTR 0x1801 +#define PCS_EAGAIN 0x1802 +#define PCS_EEXIST 0x180a +#define PCS_EINVAL 0x1803 +#define PCS_EMSGSIZE 0x1804 +#define PCS_ETIMEDOUT 0x1805 +#define PCS_ESPIPE 0x1806 +#define PCS_ENOTSUP 0x1807 +#define PCS_ENOSYS 0x1808 +#define PCS_EROFS 0x1809 +#define PCS_EBADF 0x180b +#define PCS_ENOENT 0x180c + +/* ----------------------------------------- */ +/* types normally defined in errno.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in errno.h */ +/* ----------------------------------------- */ + +extern int PCS_errno; + +#endif /* PCS_ERRNO_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_excLib.h b/unit-test-coverage/ut-stubs/inc/PCS_excLib.h index d3c3b003..b4c3c79f 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_excLib.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_excLib.h @@ -30,11 +30,12 @@ /* ----------------------------------------- */ /* types normally defined in excLib.h */ /* ----------------------------------------- */ +typedef void (*PCS_Hook_t)(PCS_TASK_ID, int, void *); /* ----------------------------------------- */ /* prototypes normally declared in excLib.h */ /* ----------------------------------------- */ -extern void PCS_excHookAdd(void (*Hook)(PCS_TASK_ID, int, void *)); +extern void PCS_excHookAdd(PCS_Hook_t Hook); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_fcntl.h b/unit-test-coverage/ut-stubs/inc/PCS_fcntl.h new file mode 100644 index 00000000..67b64091 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_fcntl.h @@ -0,0 +1,114 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for fcntl.h + */ + +#ifndef PCS_FCNTL_H +#define PCS_FCNTL_H + +#include "PCS_basetypes.h" + +#include "PCS_sys_types.h" + +/* ----------------------------------------- */ +/* constants normally defined in fcntl.h */ +/* ----------------------------------------- */ + +/* + * note these constants are used as bitmasks and so + * they must be single bit flags to work properly. + * + * However, they are defined differently from a typical UNIX + * in order to increase the likelihood that a hard-coded value + * is caught by UT. + * + * These are exposed to apps through fcntl.h and sys/stat.h + */ +#define PCS_S_IRWXO 0x1110 +#define PCS_S_IRWXG 0x2220 +#define PCS_S_IRWXU 0x4440 + +#define PCS_S_IXOTH 0x1000 +#define PCS_S_IXGRP 0x2000 +#define PCS_S_IXUSR 0x4000 + +#define PCS_S_IROTH 0x0100 +#define PCS_S_IRGRP 0x0200 +#define PCS_S_IRUSR 0x0400 + +#define PCS_S_IWOTH 0x0010 +#define PCS_S_IWGRP 0x0020 +#define PCS_S_IWUSR 0x0040 + +#define PCS_S_IFDIR 0x0001 +#define PCS_S_ISDIR(x) (((x)&PCS_S_IFDIR) == PCS_S_IFDIR) + +#define PCS_O_RDONLY 0x1501 +#define PCS_O_WRONLY 0x1502 +#define PCS_O_RDWR 0x1503 +#define PCS_O_CREAT 0x1504 +#define PCS_O_TRUNC 0x1508 +#define PCS_O_NONBLOCK 0x1510 + +#define PCS_F_GETFL 0x1D01 +#define PCS_F_SETFL 0x1D02 +#define PCS_F_GETFD 0x1D03 +#define PCS_F_SETFD 0x1D04 +#define PCS_F_DUPFD 0x1D05 + +/* ----------------------------------------- */ +/* types normally defined in fcntl.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in fcntl.h */ +/* ----------------------------------------- */ + +extern int PCS_fcntl(int fd, int cmd, ...); +extern int PCS_open(const char *file, int oflag, ...); +extern int PCS_creat(const char *pathname, PCS_mode_t mode); +extern int PCS_mkdir(const char *pathname); + +#endif /* PCS_FCNTL_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_intLib.h b/unit-test-coverage/ut-stubs/inc/PCS_intLib.h new file mode 100644 index 00000000..0d427edd --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_intLib.h @@ -0,0 +1,39 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for intLib.h */ +#ifndef PCS_INTLIB_H +#define PCS_INTLIB_H + +#include "PCS_basetypes.h" + +/* ----------------------------------------- */ +/* constants normally defined in intLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in intLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in intLib.h */ +/* ----------------------------------------- */ +extern int PCS_intCpuLock(void); +extern void PCS_intCpuUnlock(int key); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_ioLib.h b/unit-test-coverage/ut-stubs/inc/PCS_ioLib.h new file mode 100644 index 00000000..f1b2c218 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_ioLib.h @@ -0,0 +1,37 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for ioLib.h */ +#ifndef PCS_IOLIB_H +#define PCS_IOLIB_H + +#include "PCS_basetypes.h" + +/* ----------------------------------------- */ +/* constants normally defined in ioLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in ioLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in ioLib.h */ +/* ----------------------------------------- */ + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_net_if.h b/unit-test-coverage/ut-stubs/inc/PCS_net_if.h new file mode 100644 index 00000000..5f505cff --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_net_if.h @@ -0,0 +1,65 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for net/if.h + */ + +#ifndef PCS_NET_IF_H +#define PCS_NET_IF_H + +#include "PCS_basetypes.h" + +/* ----------------------------------------- */ +/* constants normally defined in net/if.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in net/if.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in net/if.h */ +/* ----------------------------------------- */ + +#endif /* PCS_NET_IF_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_netinet_in.h b/unit-test-coverage/ut-stubs/inc/PCS_netinet_in.h new file mode 100644 index 00000000..dbf26559 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_netinet_in.h @@ -0,0 +1,77 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for netinet/in.h + */ + +#ifndef PCS_NETINET_IN_H +#define PCS_NETINET_IN_H + +#include "PCS_basetypes.h" + +/* ----------------------------------------- */ +/* constants normally defined in netinet/in.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in netinet/in.h */ +/* ----------------------------------------- */ + +/* Internet address. */ +typedef uint32_t PCS_in_addr_t; +struct PCS_in_addr +{ + PCS_in_addr_t s_addr; +}; + +/* ----------------------------------------- */ +/* prototypes normally declared in netinet/in.h */ +/* ----------------------------------------- */ + +extern uint16_t PCS_htons(uint16_t hostshort); +extern uint16_t PCS_ntohs(uint16_t netshort); +extern uint32_t PCS_htonl(uint32_t hostlong); +extern uint32_t PCS_ntohl(uint32_t netlong); + +#endif /* PCS_NETINET_IN_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_rebootLib.h b/unit-test-coverage/ut-stubs/inc/PCS_rebootLib.h index 4dfcd2e8..26c05955 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_rebootLib.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_rebootLib.h @@ -35,6 +35,6 @@ /* ----------------------------------------- */ /* prototypes normally declared in rebootLib.h */ /* ----------------------------------------- */ -extern void PCS_reboot(int); +extern void PCS_reboot(int x); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_speLib.h b/unit-test-coverage/ut-stubs/inc/PCS_speLib.h new file mode 100644 index 00000000..cfa4aeb1 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_speLib.h @@ -0,0 +1,70 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for speLib.h */ +#ifndef PCS_SPELIB_H +#define PCS_SPELIB_H + +#include "common_types.h" + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ----------------------------------------- */ +/* constants normally defined in speLib.h */ +/* ----------------------------------------- */ +#define PCS_ACC_SIZE 2 /* UINT32 */ +#define PCS_SPE_NUM_REGS 32 + +/* ----------------------------------------- */ +/* types normally defined in speLib.h */ +/* ----------------------------------------- */ +typedef struct /* SPE_REG_SET */ +{ + uint32 gpr[PCS_SPE_NUM_REGS]; /* general pourpose registers */ + uint32 acc[PCS_ACC_SIZE]; +} PCS_SPE_CONTEXT; + +/* ----------------------------------------- */ +/* prototypes normally declared in speLib.h */ +/* ----------------------------------------- */ +void PCS_speSave(PCS_SPE_CONTEXT *pSpeContext); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_stdlib.h b/unit-test-coverage/ut-stubs/inc/PCS_stdlib.h index ad11bb40..99744e2d 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_stdlib.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_stdlib.h @@ -43,5 +43,6 @@ extern int PCS_system(const char *command); extern void * PCS_malloc(size_t sz); extern void PCS_free(void *ptr); extern void PCS_abort(void); +extern int PCS_abs(int value); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_string.h b/unit-test-coverage/ut-stubs/inc/PCS_string.h index 829746e6..2737ab8c 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_string.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_string.h @@ -34,8 +34,10 @@ /* prototypes normally declared in string.h */ /* ----------------------------------------- */ +extern int PCS_memcmp(void *dest, const void *src, size_t n); extern void * PCS_memcpy(void *dest, const void *src, size_t n); extern void * PCS_memset(void *s, int c, size_t n); +extern void * PCS_memchr(const void *s, int c, size_t n); extern int PCS_strcmp(const char *s1, const char *s2); extern char * PCS_strcpy(char *dest, const char *src); extern size_t PCS_strlen(const char *s); diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys950Lib.h b/unit-test-coverage/ut-stubs/inc/PCS_sys950Lib.h new file mode 100644 index 00000000..06604a00 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys950Lib.h @@ -0,0 +1,63 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for sys950Lib.h */ +#ifndef PCS_SYS950LIB_H +#define PCS_SYS950LIB_H + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ----------------------------------------- */ +/* constants normally defined in sys950Lib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in sys950Lib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in sys950Lib.h */ +/* ----------------------------------------- */ +extern int PCS_sysGetSlotId(void); +extern uint32_t PCS_getCoreClockSpeed(void); +extern double PCS_GetUsecTime(void); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sysApi.h b/unit-test-coverage/ut-stubs/inc/PCS_sysApi.h new file mode 100644 index 00000000..e5621956 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sysApi.h @@ -0,0 +1,81 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for sysApi.h */ +#ifndef PCS_SYSAPI_H +#define PCS_SYSAPI_H + +#include "common_types.h" + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ----------------------------------------- */ +/* constants normally defined in sysApi.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in sysApi.h */ +/* ----------------------------------------- */ +typedef enum +{ + SP0_100 = 1, + SP0_200 = 2 +} PCS_SP0_BOARD_LEVEL_TYPE; + +typedef enum +{ + SP0_ORIGINAL = 1, + SP0_UPGRADE = 2 +} PCS_SP0_BOARD_GENERATION_TYPE; + +/* ----------------------------------------- */ +/* prototypes normally declared in sysApi.h */ +/* ----------------------------------------- */ +int PCS_sysEnableFpgaWdt(bool globalReset); +int PCS_sysDisableFpgaWdt(void); +int PCS_sysSetFpgaWdt(float secs); +void PCS_sysPulseFpgaWdt(void); + +bool PCS_isCpciSysController(void); + +PCS_SP0_BOARD_GENERATION_TYPE PCS_sysGetBoardGeneration(bool talkative); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sysLib.h b/unit-test-coverage/ut-stubs/inc/PCS_sysLib.h index 985da99b..dbf07bdd 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_sysLib.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_sysLib.h @@ -36,6 +36,11 @@ /* ----------------------------------------- */ extern int PCS_sysClkRateGet(void); extern char *PCS_sysMemTop(void); +extern char *PCS_sysPhysMemTop(void); +extern char *PCS_sysModel(void); +extern char *PCS_sysBspRev(void); +extern int PCS_sysProcNumGet(void); +extern int PCS_sysAuxClkRateGet(void); extern void PCS_PciOutByte(uint32_t address, uint8_t data); extern void PCS_PciOutLong(uint32_t address, uint32_t data); diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys_mman.h b/unit-test-coverage/ut-stubs/inc/PCS_sys_mman.h new file mode 100644 index 00000000..9fa15b85 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys_mman.h @@ -0,0 +1,48 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for sys/mman.h */ +#ifndef PCS_SYS_MMAN_H +#define PCS_SYS_MMAN_H + +#include "PCS_basetypes.h" +#include "PCS_sys_types.h" + +/* ----------------------------------------- */ +/* constants normally defined in sys/mman.h */ +/* ----------------------------------------- */ + +#define PCS_PROT_READ 0x1D21 +#define PCS_PROT_WRITE 0x1D22 +#define PCS_PROT_EXEC 0x1D23 +#define PCS_PROT_NONE 0x1D24 +#define PCS_MAP_SHARED 0x1D25 +#define PCS_MAP_PRIVATE 0x1D26 +#define PCS_MAP_FIXED 0x1D27 + +/* ----------------------------------------- */ +/* types normally defined in sys/mman.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in sys/mman.h */ +/* ----------------------------------------- */ + +extern void *PCS_mmap(void *addr, size_t len, int prot, int flags, int fildes, PCS_off_t off); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys_select.h b/unit-test-coverage/ut-stubs/inc/PCS_sys_select.h new file mode 100644 index 00000000..3781cdb7 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys_select.h @@ -0,0 +1,78 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * Declarations and prototypes for PCS_sys_select + */ + +#ifndef PCS_SYS_SELECT_H +#define PCS_SYS_SELECT_H + +#include "PCS_basetypes.h" +#include "PCS_sys_time.h" + +/* ------------------------------------------ */ +/* constants normally defined in sys/select.h */ +/* ------------------------------------------ */ +#define PCS_FD_SETSIZE 10 + +/* ----------------------------------------- */ +/* types normally defined in sys/select.h */ +/* ----------------------------------------- */ +typedef struct +{ + unsigned int fds[PCS_FD_SETSIZE]; +} PCS_fd_set; + +/* ----------------------------------------- */ +/* prototypes normally declared in sys/select.h */ +/* ----------------------------------------- */ + +extern int PCS_select(int nfds, PCS_fd_set *readfds, PCS_fd_set *writefds, PCS_fd_set *exceptfds, + struct PCS_timeval *timeout); +extern void PCS_FD_SET(int fd, PCS_fd_set *set); +extern int PCS_FD_ISSET(int fd, PCS_fd_set *set); +extern void PCS_FD_CLR(int fd, PCS_fd_set *set); +extern void PCS_FD_ZERO(PCS_fd_set *set); + +#endif /* OCS_SYS_SELECT_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys_socket.h b/unit-test-coverage/ut-stubs/inc/PCS_sys_socket.h new file mode 100644 index 00000000..bf5f1c4f --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys_socket.h @@ -0,0 +1,108 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for sys/socket.h + */ + +#ifndef PCS_SYS_SOCKET_H +#define PCS_SYS_SOCKET_H + +#include "PCS_basetypes.h" +#include "PCS_sys_types.h" +#include "PCS_netinet_in.h" + +/* ----------------------------------------- */ +/* constants normally defined in sys/socket.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in sys/socket.h */ +/* ----------------------------------------- */ +typedef size_t PCS_socklen_t; +typedef unsigned short int PCS_sa_family_t; + +struct PCS_sockaddr +{ + PCS_sa_family_t sa_family; +}; + +struct PCS_sockaddr_in +{ + PCS_sa_family_t sin_family; + uint16_t sin_port; + struct PCS_in_addr sin_addr; +}; + +struct PCS_sockaddr_in6 +{ + PCS_sa_family_t sin6_family; + uint16_t sin6_port; + uint32_t sin6_addr[4]; +}; + +enum +{ + PCS_IPPROTO_ICMP = 1, + PCS_AF_INET, + PCS_SOCK_RAW, +}; + +/* ----------------------------------------- */ +/* prototypes normally declared in sys/socket.h */ +/* ----------------------------------------- */ + +extern int PCS_accept(int fd, struct PCS_sockaddr *addr, PCS_socklen_t *addr_len); +extern int PCS_bind(int fd, const struct PCS_sockaddr *addr, PCS_socklen_t len); +extern int PCS_connect(int fd, const struct PCS_sockaddr *addr, PCS_socklen_t len); +extern int PCS_getsockopt(int fd, int level, int optname, void *optval, PCS_socklen_t *optlen); +extern int PCS_listen(int fd, int n); +extern PCS_ssize_t PCS_recvfrom(int fd, void *buf, size_t n, int flags, struct PCS_sockaddr *addr, + PCS_socklen_t *addr_len); +extern PCS_ssize_t PCS_sendto(int fd, const void *buf, size_t n, int flags, const struct PCS_sockaddr *addr, + PCS_socklen_t addr_len); +extern int PCS_setsockopt(int fd, int level, int optname, const void *optval, PCS_socklen_t optlen); +extern int PCS_shutdown(int fd, int how); +extern int PCS_socket(int domain, int type, int protocol); + +#endif /* PCS_SYS_SOCKET_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys_stat.h b/unit-test-coverage/ut-stubs/inc/PCS_sys_stat.h new file mode 100644 index 00000000..af965701 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys_stat.h @@ -0,0 +1,50 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for sys/stat.h */ +#ifndef PCS_SYS_STAT_H +#define PCS_SYS_STAT_H + +#include "PCS_basetypes.h" +#include "PCS_fcntl.h" + +/* ----------------------------------------- */ +/* constants normally defined in sys/stat.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in sys/stat.h */ +/* ----------------------------------------- */ +struct PCS_stat +{ + int value; +}; + +struct PCS_statfs +{ + long f_bsize; + int64_t f_bavail; +}; + +/* ----------------------------------------- */ +/* prototypes normally declared in sys/stat.h */ +/* ----------------------------------------- */ +extern int PCS_stat(const char *path, struct PCS_stat *buf); +extern int PCS_statfs(const char *path, struct PCS_statfs *buf); + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys_time.h b/unit-test-coverage/ut-stubs/inc/PCS_sys_time.h new file mode 100644 index 00000000..67e01093 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys_time.h @@ -0,0 +1,71 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for sys/time.h + */ + +#ifndef PCS_SYS_TIME_H +#define PCS_SYS_TIME_H + +#include "PCS_basetypes.h" +#include "PCS_time.h" + +/* ----------------------------------------- */ +/* constants normally defined in sys/time.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in sys/time.h */ +/* ----------------------------------------- */ +struct PCS_timeval +{ + PCS_time_t tv_sec; + PCS_suseconds_t tv_usec; +}; + +/* ----------------------------------------- */ +/* prototypes normally declared in sys/time.h */ +/* ----------------------------------------- */ + +#endif /* OCS_SYS_TIME_H */ diff --git a/unit-test-coverage/ut-stubs/inc/PCS_sys_types.h b/unit-test-coverage/ut-stubs/inc/PCS_sys_types.h index 4c88b68d..87e23fda 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_sys_types.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_sys_types.h @@ -30,7 +30,7 @@ /* types normally defined in sys/types.h */ /* ----------------------------------------- */ typedef ptrdiff_t PCS_ssize_t; -typedef size_t PCS_off_t; +typedef long PCS_off_t; typedef unsigned int PCS_mode_t; typedef long PCS_time_t; typedef int PCS_pid_t; diff --git a/unit-test-coverage/ut-stubs/inc/PCS_taskLib.h b/unit-test-coverage/ut-stubs/inc/PCS_taskLib.h index ad203d1d..5c158ba3 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_taskLib.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_taskLib.h @@ -67,6 +67,7 @@ extern PCS_STATUS PCS_taskDeleteForce(PCS_TASK_ID tid); extern PCS_STATUS PCS_taskSuspend(PCS_TASK_ID tid); extern PCS_STATUS PCS_taskResume(PCS_TASK_ID tid); extern PCS_STATUS PCS_taskPrioritySet(PCS_TASK_ID tid, int newPriority); +extern PCS_STATUS PCS_taskPriorityGet(PCS_TASK_ID tid, int *pPriority); extern PCS_TASK_ID PCS_taskSpawn(char *name, int priority, int options, int stackSize, PCS_FUNCPTR entryPt, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10); diff --git a/unit-test-coverage/ut-stubs/inc/PCS_taskLibCommon.h b/unit-test-coverage/ut-stubs/inc/PCS_taskLibCommon.h new file mode 100644 index 00000000..f7408e59 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_taskLibCommon.h @@ -0,0 +1,40 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for taskLibCommon.h */ +#ifndef PCS_TASKLIBCOMMON_H +#define PCS_TASKLIBCOMMON_H + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" +#include "PCS_taskLib.h" + +/* ----------------------------------------- */ +/* constants normally defined in taskLibCommon.h */ +/* ----------------------------------------- */ +#define PCS_TASK_ID_ERROR ((PCS_TASK_ID)(-1)) + +/* ----------------------------------------- */ +/* types normally defined in taskLibCommon.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in taskLibCommon.h */ +/* ----------------------------------------- */ + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_tickLib.h b/unit-test-coverage/ut-stubs/inc/PCS_tickLib.h new file mode 100644 index 00000000..1d7b6cb0 --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_tickLib.h @@ -0,0 +1,38 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for tickLib.h */ +#ifndef PCS_TICKLIB_H +#define PCS_TICKLIB_H + +#include "PCS_basetypes.h" +#include "PCS_vxWorks.h" + +/* ----------------------------------------- */ +/* constants normally defined in tickLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in tickLib.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in tickLib.h */ +/* ----------------------------------------- */ + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_time.h b/unit-test-coverage/ut-stubs/inc/PCS_time.h index 5537954b..e44be5ae 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_time.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_time.h @@ -25,13 +25,25 @@ /* ----------------------------------------- */ /* constants normally defined in time.h */ /* ----------------------------------------- */ +#define PCS_CLOCK_REALTIME 0x0 /* system wide realtime clock */ +#define PCS_CLOCK_MONOTONIC 0x1 /* system wide monotonic clock */ /* ----------------------------------------- */ /* types normally defined in time.h */ /* ----------------------------------------- */ +typedef long PCS_time_t; +typedef long PCS_suseconds_t; + +struct PCS_timespec +{ + PCS_time_t tv_sec; + long tv_nsec; +}; /* ----------------------------------------- */ /* prototypes normally declared in time.h */ /* ----------------------------------------- */ +int PCS_clock_settime(int clk_id, struct PCS_timespec *t); +int PCS_clock_gettime(int clk_id, struct PCS_timespec *t); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_timers.h b/unit-test-coverage/ut-stubs/inc/PCS_timers.h new file mode 100644 index 00000000..b38b24dd --- /dev/null +++ b/unit-test-coverage/ut-stubs/inc/PCS_timers.h @@ -0,0 +1,37 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for timers.h */ +#ifndef PCS_TIMERS_H +#define PCS_TIMERS_H + +#include "PCS_basetypes.h" + +/* ----------------------------------------- */ +/* constants normally defined in timers.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in timers.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* prototypes normally declared in timers.h */ +/* ----------------------------------------- */ + +#endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_unistd.h b/unit-test-coverage/ut-stubs/inc/PCS_unistd.h index 8a178912..4804eee8 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_unistd.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_unistd.h @@ -52,6 +52,6 @@ extern PCS_off_t PCS_lseek(int fd, PCS_off_t offset, int whence); extern PCS_ssize_t PCS_read(int fd, void *buf, size_t nbytes); extern int PCS_rmdir(const char *path); extern long int PCS_sysconf(int name); -extern PCS_ssize_t PCS_write(int fd, const void *buf, size_t n); +extern PCS_ssize_t PCS_write(int fd, const void *buf, size_t nbytes); #endif diff --git a/unit-test-coverage/ut-stubs/inc/PCS_vxWorks.h b/unit-test-coverage/ut-stubs/inc/PCS_vxWorks.h index 36bb019c..723f4042 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_vxWorks.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_vxWorks.h @@ -55,6 +55,8 @@ enum PCS_NO_WAIT = 0 }; +#define PCS_EOS '\0' + /* ----------------------------------------- */ /* types normally defined in vxWorks.h */ /* ----------------------------------------- */ @@ -69,6 +71,7 @@ typedef int32_t PCS_INT32; typedef uint32_t PCS_UINT32; typedef long PCS_Vx_usr_arg_t; +typedef long PCS_Vx_exit_code_t; /* Function pointers are used in many VxWorks modules. */ /* diff --git a/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h b/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h new file mode 100644 index 00000000..cbf77b6c --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/arpa/inet.h @@ -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. + ************************************************************************/ + +/* PSP coverage stub replacement for arpa/inet.h */ +#ifndef OVERRIDE_ARPA_INET_H +#define OVERRIDE_ARPA_INET_H + +#include "PCS_arpa_inet.h" + +/* ----------------------------------------- */ +/* mappings for declarations in arpa/inet.h */ +/* ----------------------------------------- */ +#define inet_addr PCS_inet_addr +#define inet_ntoa PCS_inet_ntoa + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/drv/pci/pciConfigLib.h b/unit-test-coverage/ut-stubs/override_inc/drv/pci/pciConfigLib.h new file mode 100644 index 00000000..62b6d908 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/drv/pci/pciConfigLib.h @@ -0,0 +1,32 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for pci_config_lib.h */ +#ifndef OVERRIDE_DRV_PCI_PCICONFIGLIB_H +#define OVERRIDE_DRV_PCI_PCICONFIGLIB_H + +#include "PCS_drv_pci_pciConfigLib.h" + +/* --------------------------------------------- */ +/* mappings for declarations in pci_config_lib.h */ +/* --------------------------------------------- */ +#define pciFindDevice PCS_pciFindDevice +#define pciConfigInWord PCS_pciConfigInWord +#define PCI_CFG_STATUS PCS_PCI_CFG_STATUS + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/errno.h b/unit-test-coverage/ut-stubs/override_inc/errno.h new file mode 100644 index 00000000..70493cb9 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/errno.h @@ -0,0 +1,71 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for errno.h + */ + +#ifndef OVERRIDE_ERRNO_H +#define OVERRIDE_ERRNO_H + +#include "PCS_errno.h" + +/* ----------------------------------------- */ +/* mappings for declarations in errno.h */ +/* ----------------------------------------- */ +#define EINTR PCS_EINTR +#define EAGAIN PCS_EAGAIN +#define EINVAL PCS_EINVAL +#define EEXIST PCS_EEXIST +#define EMSGSIZE PCS_EMSGSIZE +#define ETIMEDOUT PCS_ETIMEDOUT +#define ESPIPE PCS_ESPIPE +#define ENOTSUP PCS_ENOTSUP +#define ENOSYS PCS_ENOSYS +#define EROFS PCS_EROFS +#define EBADF PCS_EBADF +#define ENOENT PCS_ENOENT + +#define errno PCS_errno + +#endif /* OVERRIDE_ERRNO_H */ diff --git a/unit-test-coverage/ut-stubs/override_inc/fcntl.h b/unit-test-coverage/ut-stubs/override_inc/fcntl.h new file mode 100644 index 00000000..f9282e88 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/fcntl.h @@ -0,0 +1,61 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for fcntl.h */ +#ifndef OVERRIDE_FCNTL_H +#define OVERRIDE_FCNTL_H + +#include "PCS_fcntl.h" + +/* ----------------------------------------- */ +/* mappings for declarations in fcntl.h */ +/* ----------------------------------------- */ + +#define S_IRWXU PCS_S_IRWXU +#define S_IRWXG PCS_S_IRWXG +#define S_IRWXO PCS_S_IRWXO +#define S_IXOTH PCS_S_IXOTH +#define S_IXGRP PCS_S_IXGRP +#define S_IXUSR PCS_S_IXUSR +#define S_IROTH PCS_S_IROTH +#define S_IRGRP PCS_S_IRGRP +#define S_IRUSR PCS_S_IRUSR +#define S_IWOTH PCS_S_IWOTH +#define S_IWGRP PCS_S_IWGRP +#define S_IWUSR PCS_S_IWUSR +#define S_IFDIR PCS_S_IFDIR +#define S_ISDIR(x) PCS_S_ISDIR(x) +#define F_GETFL PCS_F_GETFL +#define F_SETFL PCS_F_SETFL +#define F_GETFD PCS_F_GETFD +#define F_SETFD PCS_F_SETFD +#define F_DUPFD PCS_F_DUPFD + +#define O_RDONLY PCS_O_RDONLY +#define O_WRONLY PCS_O_WRONLY +#define O_CREAT PCS_O_CREAT +#define O_RDWR PCS_O_RDWR +#define O_TRUNC PCS_O_TRUNC +#define O_NONBLOCK PCS_O_NONBLOCK + +#define fcntl PCS_fcntl +#define open PCS_open +#define creat PCS_creat +#define mkdir PCS_mkdir + +#endif /* OVERRIDE_FCNTL_H */ diff --git a/unit-test-coverage/ut-stubs/src/vxworks-cacheLib-stubs.c b/unit-test-coverage/ut-stubs/override_inc/intLib.h similarity index 73% rename from unit-test-coverage/ut-stubs/src/vxworks-cacheLib-stubs.c rename to unit-test-coverage/ut-stubs/override_inc/intLib.h index 2fab1476..2c48ccb2 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-cacheLib-stubs.c +++ b/unit-test-coverage/ut-stubs/override_inc/intLib.h @@ -16,14 +16,17 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for cacheLib.h */ -#include -#include -#include "utstubs.h" +/* PSP coverage stub replacement for intLib.h */ +#ifndef OVERRIDE_INTLIB_H +#define OVERRIDE_INTLIB_H -#include "PCS_cacheLib.h" +#include "PCS_intLib.h" -PCS_STATUS PCS_cacheTextUpdate(void *adrs, size_t bytes) -{ - return UT_DEFAULT_IMPL(PCS_cacheTextUpdate); -} +/* ----------------------------------------- */ +/* mappings for declarations in intLib.h */ +/* ----------------------------------------- */ + +#define intCpuLock PCS_intCpuLock +#define intCpuUnlock PCS_intCpuUnlock + +#endif diff --git a/unit-test-coverage/ut-stubs/src/vxworks-excLib-stubs.c b/unit-test-coverage/ut-stubs/override_inc/ioLib.h similarity index 78% rename from unit-test-coverage/ut-stubs/src/vxworks-excLib-stubs.c rename to unit-test-coverage/ut-stubs/override_inc/ioLib.h index 5a717de6..de7d25f6 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-excLib-stubs.c +++ b/unit-test-coverage/ut-stubs/override_inc/ioLib.h @@ -16,14 +16,14 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for excLib.h */ -#include -#include -#include "utstubs.h" +/* PSP coverage stub replacement for ioLib.h */ +#ifndef OVERRIDE_IOLIB_H +#define OVERRIDE_IOLIB_H -#include "PCS_excLib.h" +#include "PCS_ioLib.h" -void PCS_excHookAdd(void (*Hook)(PCS_TASK_ID, int, void *)) -{ - UT_DEFAULT_IMPL(PCS_excHookAdd); -} +/* ----------------------------------------- */ +/* mappings for declarations in ioLib.h */ +/* ----------------------------------------- */ + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/net/if.h b/unit-test-coverage/ut-stubs/override_inc/net/if.h new file mode 100644 index 00000000..fdd02250 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/net/if.h @@ -0,0 +1,57 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * PSP coverage stub replacement for net/if.h + */ + +#ifndef OVERRIDE_NET_IF_H +#define OVERRIDE_NET_IF_H + +#include "PCS_net_if.h" + +/* ----------------------------------------- */ +/* mappings for declarations in net/if.h */ +/* ----------------------------------------- */ + +#endif /* OVERRIDE_NET_IF_H */ diff --git a/unit-test-coverage/ut-stubs/override_inc/netinet/in.h b/unit-test-coverage/ut-stubs/override_inc/netinet/in.h new file mode 100644 index 00000000..13a07c80 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/netinet/in.h @@ -0,0 +1,63 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * PSP coverage stub replacement for netinet/in.h + */ + +#ifndef OVERRIDE_NETINET_IN_H +#define OVERRIDE_NETINET_IN_H + +#include "PCS_netinet_in.h" + +/* ----------------------------------------- */ +/* mappings for declarations in netinet/in.h */ +/* ----------------------------------------- */ +#define in_addr_t PCS_in_addr_t + +#define htons PCS_htons +#define ntohs PCS_ntohs +#define htonl PCS_htonl +#define ntohl PCS_ntohl + +#endif /* OVERRIDE_NETINET_IN_H */ diff --git a/unit-test-coverage/ut-stubs/override_inc/netinet/ip.h b/unit-test-coverage/ut-stubs/override_inc/netinet/ip.h new file mode 100644 index 00000000..adcb28ec --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/netinet/ip.h @@ -0,0 +1,58 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * PSP coverage stub replacement for netinet/ip.h + */ + +#ifndef OVERRIDE_NETINET_IP_H +#define OVERRIDE_NETINET_IP_H + +#include "PCS_netinet_ip.h" + +/* ----------------------------------------- */ +/* mappings for declarations in netinet/ip.h */ +/* ----------------------------------------- */ +#define ip PCS_ip + +#endif /* OVERRIDE_NETINET_IP_H */ diff --git a/unit-test-coverage/ut-stubs/override_inc/speLib.h b/unit-test-coverage/ut-stubs/override_inc/speLib.h new file mode 100644 index 00000000..b6a51e58 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/speLib.h @@ -0,0 +1,55 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for sysLib.h */ +#ifndef OVERRIDE_SPELIB_H +#define OVERRIDE_SPELIB_H + +#include "PCS_speLib.h" +#include + +/* ----------------------------------------- */ +/* mappings for declarations in sysLib.h */ +/* ----------------------------------------- */ +#define SPE_CONTEXT PCS_SPE_CONTEXT + +#define speSave PCS_speSave + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/stdlib.h b/unit-test-coverage/ut-stubs/override_inc/stdlib.h index 8c7dcb9e..500c77ab 100644 --- a/unit-test-coverage/ut-stubs/override_inc/stdlib.h +++ b/unit-test-coverage/ut-stubs/override_inc/stdlib.h @@ -34,5 +34,6 @@ #define malloc PCS_malloc #define free PCS_free #define abort PCS_abort +#define abs PCS_abs #endif diff --git a/unit-test-coverage/ut-stubs/override_inc/string.h b/unit-test-coverage/ut-stubs/override_inc/string.h index 8de70567..39a37cfb 100644 --- a/unit-test-coverage/ut-stubs/override_inc/string.h +++ b/unit-test-coverage/ut-stubs/override_inc/string.h @@ -25,8 +25,10 @@ /* ----------------------------------------- */ /* mappings for declarations in string.h */ /* ----------------------------------------- */ +#define memcmp PCS_memcmp #define memcpy PCS_memcpy #define memset PCS_memset +#define memchr PCS_memchr #define strcmp PCS_strcmp #define strcpy PCS_strcpy #define strlen PCS_strlen diff --git a/unit-test-coverage/ut-stubs/override_inc/sys/mman.h b/unit-test-coverage/ut-stubs/override_inc/sys/mman.h new file mode 100644 index 00000000..2502aabd --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/sys/mman.h @@ -0,0 +1,40 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for sys/mman.h */ +#ifndef OVERRIDE_SYS_MMAN_H +#define OVERRIDE_SYS_MMAN_H + +#include "PCS_sys_mman.h" + +/* ----------------------------------------- */ +/* mappings for declarations in sys/mman.h */ +/* ----------------------------------------- */ + +#define PROT_READ PCS_PROT_READ +#define PROT_WRITE PCS_PROT_WRITE +#define PROT_EXEC PCS_PROT_EXEC +#define PROT_NONE PCS_PROT_NONE +#define MAP_SHARED PCS_MAP_SHARED +#define MAP_PRIVATE PCS_MAP_PRIVATE +#define MAP_FIXED PCS_MAP_FIXED + +#define off_t PCS_off_t +#define mmap PCS_mmap + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/sys/select.h b/unit-test-coverage/ut-stubs/override_inc/sys/select.h new file mode 100644 index 00000000..ccfd6388 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/sys/select.h @@ -0,0 +1,72 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * Declarations and prototypes for select + */ + +#ifndef OVERRIDE_SYS_SELECT_H +#define OVERRIDE_SYS_SELECT_H + +#include "PCS_sys_select.h" + +/* ----------------------------------------- */ +/* constants normally defined in sys/select.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* types normally defined in sys/select.h */ +/* ----------------------------------------- */ + +/* ----------------------------------------- */ +/* mappings for declarations in sys/select.h */ +/* ----------------------------------------- */ +#define fd_set PCS_fd_set +#define select PCS_select + +#define FD_SET PCS_FD_SET +#define FD_ISSET PCS_FD_ISSET +#define FD_CLR PCS_FD_CLR +#define FD_ZERO PCS_FD_ZERO + +#endif /* OVERRIDE_SYS_SELECT_H */ diff --git a/unit-test-coverage/ut-stubs/override_inc/sys/socket.h b/unit-test-coverage/ut-stubs/override_inc/sys/socket.h new file mode 100644 index 00000000..b55f1ac7 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/sys/socket.h @@ -0,0 +1,76 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * OSAL coverage stub replacement for sys/socket.h + */ + +#ifndef OVERRIDE_SYS_SOCKET_H +#define OVERRIDE_SYS_SOCKET_H + +#include "PCS_sys_socket.h" + +/* ----------------------------------------- */ +/* mappings for declarations in sys/socket.h */ +/* ----------------------------------------- */ +#define socklen_t PCS_socklen_t +#define sockaddr PCS_sockaddr +#define sockaddr_in PCS_sockaddr_in +#define sockaddr_in6 PCS_sockaddr_in6 +#define sa_family_t PCS_sa_family_t +#define accept PCS_accept +#define bind PCS_bind +#define connect PCS_connect +#define getsockopt PCS_getsockopt +#define listen PCS_listen +#define recvfrom PCS_recvfrom +#define sendto PCS_sendto +#define setsockopt PCS_setsockopt +#define shutdown PCS_shutdown +#define socket PCS_socket + +#define IPPROTO_ICMP PCS_IPPROTO_ICMP +#define AF_INET PCS_AF_INET +#define SOCK_RAW PCS_SOCK_RAW + +#endif /* OVERRIDE_SYS_SOCKET_H */ diff --git a/unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c b/unit-test-coverage/ut-stubs/override_inc/sys/stat.h similarity index 74% rename from unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c rename to unit-test-coverage/ut-stubs/override_inc/sys/stat.h index 4ee30038..e48af287 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-ataDrv-stubs.c +++ b/unit-test-coverage/ut-stubs/override_inc/sys/stat.h @@ -16,14 +16,16 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for ataDrv.h */ -#include -#include -#include "utstubs.h" +/* PSP coverage stub replacement for sys/stat.h */ +#ifndef OVERRIDE_SYS_STAT_H +#define OVERRIDE_SYS_STAT_H -#include "PCS_drv_hdisk_ataDrv.h" +#include "PCS_sys_stat.h" -PCS_device_t PCS_ataXbdDevCreate(int ctrl, int drive, unsigned int nBlks, unsigned int offset, const char *name) -{ - return UT_DEFAULT_IMPL(PCS_ataXbdDevCreate); -} +/* ----------------------------------------- */ +/* mappings for declarations in sys/stat.h */ +/* ----------------------------------------- */ +#define stat PCS_stat +#define statfs PCS_statfs + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/sys/time.h b/unit-test-coverage/ut-stubs/override_inc/sys/time.h new file mode 100644 index 00000000..96e5881d --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/sys/time.h @@ -0,0 +1,58 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/** + * \file + * \ingroup ut-stubs + * + * PSP coverage stub replacement for sys/time.h + */ + +#ifndef OVERRIDE_SYS_TIME_H +#define OVERRIDE_SYS_TIME_H + +#include "PCS_sys_time.h" + +/* ----------------------------------------- */ +/* mappings for declarations in sys/time.h */ +/* ----------------------------------------- */ +#define timeval PCS_timeval + +#endif /* OVERRIDE_SYS_TIME_H */ diff --git a/unit-test-coverage/ut-stubs/override_inc/sys950Lib.h b/unit-test-coverage/ut-stubs/override_inc/sys950Lib.h new file mode 100644 index 00000000..e4b87469 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/sys950Lib.h @@ -0,0 +1,56 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for sys950Lib.h */ +#ifndef OVERRIDE_SYS950LIB_H +#define OVERRIDE_SYS950LIB_H + +#include "PCS_sys950Lib.h" +#include + +/* ----------------------------------------- */ +/* mappings for declarations in sys950Lib.h */ +/* ----------------------------------------- */ +#define sysGetSlotId PCS_sysGetSlotId +#define getCoreClockSpeed PCS_getCoreClockSpeed + +#define GetUsecTime PCS_GetUsecTime + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/sysApi.h b/unit-test-coverage/ut-stubs/override_inc/sysApi.h new file mode 100644 index 00000000..23f4bd0c --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/sysApi.h @@ -0,0 +1,59 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for sysApi.h */ +#ifndef OVERRIDE_SYSAPI_H +#define OVERRIDE_SYSAPI_H + +#include "PCS_sysApi.h" +#include + +/* ----------------------------------------- */ +/* mappings for declarations in sysApi.h */ +/* ----------------------------------------- */ +#define sysEnableFpgaWdt PCS_sysEnableFpgaWdt +#define sysDisableFpgaWdt PCS_sysDisableFpgaWdt +#define sysSetFpgaWdt PCS_sysSetFpgaWdt +#define sysPulseFpgaWdt PCS_sysPulseFpgaWdt + +#define isCpciSysController PCS_isCpciSysController +#define sysGetBoardGeneration PCS_sysGetBoardGeneration + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/sysLib.h b/unit-test-coverage/ut-stubs/override_inc/sysLib.h index 7071e564..927c28e6 100644 --- a/unit-test-coverage/ut-stubs/override_inc/sysLib.h +++ b/unit-test-coverage/ut-stubs/override_inc/sysLib.h @@ -26,8 +26,13 @@ /* ----------------------------------------- */ /* mappings for declarations in sysLib.h */ /* ----------------------------------------- */ -#define sysClkRateGet PCS_sysClkRateGet -#define sysMemTop PCS_sysMemTop +#define sysClkRateGet PCS_sysClkRateGet +#define sysMemTop PCS_sysMemTop +#define sysPhysMemTop PCS_sysPhysMemTop +#define sysModel PCS_sysModel +#define sysBspRev PCS_sysBspRev +#define sysProcNumGet PCS_sysProcNumGet +#define sysAuxClkRateGet PCS_sysAuxClkRateGet /* * These PCI accessors are related to sysLib but the prototype does not necessarily appear in this file diff --git a/unit-test-coverage/ut-stubs/override_inc/taskLib.h b/unit-test-coverage/ut-stubs/override_inc/taskLib.h index 482a87cf..22c0fc7d 100644 --- a/unit-test-coverage/ut-stubs/override_inc/taskLib.h +++ b/unit-test-coverage/ut-stubs/override_inc/taskLib.h @@ -21,6 +21,7 @@ #define OVERRIDE_TASKLIB_H #include "PCS_taskLib.h" +#include #include /* ----------------------------------------- */ @@ -47,6 +48,7 @@ #define taskSuspend PCS_taskSuspend #define taskResume PCS_taskResume #define taskPrioritySet PCS_taskPrioritySet +#define taskPriorityGet PCS_taskPriorityGet #define taskSpawn PCS_taskSpawn #define taskInit PCS_taskInit #define taskTcb PCS_taskTcb diff --git a/unit-test-coverage/ut-stubs/override_inc/taskLibCommon.h b/unit-test-coverage/ut-stubs/override_inc/taskLibCommon.h new file mode 100644 index 00000000..f355ac7d --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/taskLibCommon.h @@ -0,0 +1,34 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for taskLibCommon.h */ +#ifndef OVERRIDE_TASKLIBCOMMON_H +#define OVERRIDE_TASKLIBCOMMON_H + +#include "PCS_taskLibCommon.h" +#include + +/* ----------------------------------------- */ +/* mappings for declarations in taskLibCommon.h */ +/* ----------------------------------------- */ +#define TASK_ID_ERROR PCS_TASK_ID_ERROR +#define taskCpuAffinitySet PCS_taskCpuAffinitySet +#define taskCpuAffinityGet PCS_taskCpuAffinityGet +#define VX_SPE_TASK PCS_VX_SPE_TASK + +#endif diff --git a/unit-test-coverage/ut-stubs/src/vxworks-fppLib-stubs.c b/unit-test-coverage/ut-stubs/override_inc/tickLib.h similarity index 75% rename from unit-test-coverage/ut-stubs/src/vxworks-fppLib-stubs.c rename to unit-test-coverage/ut-stubs/override_inc/tickLib.h index 1a60c7b9..157523d8 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-fppLib-stubs.c +++ b/unit-test-coverage/ut-stubs/override_inc/tickLib.h @@ -16,14 +16,15 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for fppLib.h */ -#include -#include -#include "utstubs.h" +/* PSP coverage stub replacement for tickLib.h */ +#ifndef OVERRIDE_TICKLIB_H +#define OVERRIDE_TICKLIB_H -#include "PCS_fppLib.h" +#include +#include "PCS_tickLib.h" -void PCS_fppSave(PCS_FP_CONTEXT *fpc) -{ - UT_DEFAULT_IMPL(PCS_fppSave); -} +/* ----------------------------------------- */ +/* mappings for declarations in tickLib.h */ +/* ----------------------------------------- */ + +#endif diff --git a/unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_handlers.c new file mode 100644 index 00000000..2cee627b --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_handlers.c @@ -0,0 +1,38 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for vxLib.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_vxLib.h" +#include "PCS_arch_ppc_vxPpcLib.h" + +void UT_DefaultHandler_PCS_vxTimeBaseGet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void PCS_vxTimeBaseGet(uint32_t *u, uint32_t *l) */ + uint32_t *u = UT_Hook_GetArgValueByName(Context, "u", uint32 *); + uint32_t *l = UT_Hook_GetArgValueByName(Context, "l", uint32 *); + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + *u = 0; + *l = 0; + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_stubs.c new file mode 100644 index 00000000..ba3a3769 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_arch_ppc_vxPpcLib_stubs.c @@ -0,0 +1,107 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_arch_ppc_vxPpcLib header + */ + +#include "PCS_arch_ppc_vxPpcLib.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_vxTimeBaseGet(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vxDecGet() + * ---------------------------------------------------- + */ +uint32_t PCS_vxDecGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_vxDecGet, uint32_t); + + UT_GenStub_Execute(PCS_vxDecGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_vxDecGet, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vxFpscrGet() + * ---------------------------------------------------- + */ +uint32_t PCS_vxFpscrGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_vxFpscrGet, uint32_t); + + UT_GenStub_Execute(PCS_vxFpscrGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_vxFpscrGet, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vxFpscrSet() + * ---------------------------------------------------- + */ +void PCS_vxFpscrSet(uint32_t r) +{ + UT_GenStub_AddParam(PCS_vxFpscrSet, uint32_t, r); + + UT_GenStub_Execute(PCS_vxFpscrSet, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vxMsrGet() + * ---------------------------------------------------- + */ +uint32_t PCS_vxMsrGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_vxMsrGet, uint32_t); + + UT_GenStub_Execute(PCS_vxMsrGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_vxMsrGet, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vxMsrSet() + * ---------------------------------------------------- + */ +void PCS_vxMsrSet(uint32_t r) +{ + UT_GenStub_AddParam(PCS_vxMsrSet, uint32_t, r); + + UT_GenStub_Execute(PCS_vxMsrSet, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vxTimeBaseGet() + * ---------------------------------------------------- + */ +void PCS_vxTimeBaseGet(uint32_t *u, uint32_t *l) +{ + UT_GenStub_AddParam(PCS_vxTimeBaseGet, uint32_t *, u); + UT_GenStub_AddParam(PCS_vxTimeBaseGet, uint32_t *, l); + + UT_GenStub_Execute(PCS_vxTimeBaseGet, Basic, UT_DefaultHandler_PCS_vxTimeBaseGet); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_arpa_inet_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_arpa_inet_handlers.c new file mode 100644 index 00000000..c8ff61b7 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_arpa_inet_handlers.c @@ -0,0 +1,54 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for arpa/inet.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_arpa_inet.h" + +#define MAX_NTOA_LEN 64 + +void UT_DefaultHandler_PCS_inet_addr(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* uint32 PCS_inet_addr(const char *cp) */ + uint32 *pAddr = NULL; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + UT_GetDataBuffer(FuncKey, (void **)&pAddr, NULL, NULL); + if (pAddr != NULL) + { + UT_Stub_SetReturnValue(FuncKey, *pAddr); + } + } +} + +void UT_DefaultHandler_PCS_inet_ntoa(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_inet_ntoa(struct PCS_in_addr in) */ + static char Buf[MAX_NTOA_LEN] = ""; + char * pBuf = Buf; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + UT_Stub_CopyToLocal(FuncKey, pBuf, sizeof(Buf)); + UT_Stub_SetReturnValue(FuncKey, pBuf); + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_arpa_inet_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_arpa_inet_stubs.c new file mode 100644 index 00000000..42fa3685 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_arpa_inet_stubs.c @@ -0,0 +1,61 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_arpa_inet header + */ + +#include "PCS_arpa_inet.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_inet_addr(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_inet_ntoa(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_inet_addr() + * ---------------------------------------------------- + */ +uint32_t PCS_inet_addr(const char *cp) +{ + UT_GenStub_SetupReturnBuffer(PCS_inet_addr, uint32_t); + + UT_GenStub_AddParam(PCS_inet_addr, const char *, cp); + + UT_GenStub_Execute(PCS_inet_addr, Basic, UT_DefaultHandler_PCS_inet_addr); + + return UT_GenStub_GetReturnValue(PCS_inet_addr, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_inet_ntoa() + * ---------------------------------------------------- + */ +char *PCS_inet_ntoa(struct PCS_in_addr in) +{ + UT_GenStub_SetupReturnBuffer(PCS_inet_ntoa, char *); + + UT_GenStub_AddParam(PCS_inet_ntoa, struct PCS_in_addr, in); + + UT_GenStub_Execute(PCS_inet_ntoa, Basic, UT_DefaultHandler_PCS_inet_ntoa); + + return UT_GenStub_GetReturnValue(PCS_inet_ntoa, char *); +} diff --git a/unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_bsdnet_handlers.c similarity index 69% rename from unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_bsdnet_handlers.c index 57499c4f..98ca6fff 100644 --- a/unit-test-coverage/ut-stubs/src/rtems-bsdnet-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_bsdnet_handlers.c @@ -23,31 +23,17 @@ #include "PCS_bsdnet.h" #include "PCS_rtems.h" -void PCS_rtems_bsdnet_do_dhcp_failsafe(void) -{ - UT_DEFAULT_IMPL(PCS_rtems_bsdnet_do_dhcp_failsafe); -} - -const char *PCS_rtems_status_text(PCS_rtems_status_code code) +void UT_DefaultHandler_PCS_rtems_status_text(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { + /* const char *PCS_rtems_status_text(PCS_rtems_status_code code) */ const char *ReturnCode = NULL; int32 Status; - Status = UT_DEFAULT_IMPL(PCS_rtems_status_text); - if (Status == 0) + UT_Stub_GetInt32StatusCode(Context, &Status); + + if (Status >= 0 && + UT_Stub_CopyToLocal(UT_KEY(PCS_rtems_status_text), &ReturnCode, sizeof(ReturnCode)) == sizeof(ReturnCode)) { - UT_Stub_CopyToLocal(UT_KEY(PCS_rtems_status_text), &ReturnCode, sizeof(ReturnCode)); + UT_Stub_SetReturnValue(FuncKey, ReturnCode); } - - return ReturnCode; } - -int PCS_rtems_bsdnet_initialize_network(void) -{ - return UT_DEFAULT_IMPL(PCS_rtems_bsdnet_initialize_network); -} - -int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *config, int attaching) -{ - return UT_DEFAULT_IMPL(PCS_rtems_fxp_attach); -} \ No newline at end of file diff --git a/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c new file mode 100644 index 00000000..81f259d0 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c @@ -0,0 +1,86 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_bsdnet header + */ + +#include "PCS_bsdnet.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_rtems_status_text(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rtems_bsdnet_do_dhcp_failsafe() + * ---------------------------------------------------- + */ +void PCS_rtems_bsdnet_do_dhcp_failsafe(void) +{ + + UT_GenStub_Execute(PCS_rtems_bsdnet_do_dhcp_failsafe, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rtems_bsdnet_initialize_network() + * ---------------------------------------------------- + */ +int PCS_rtems_bsdnet_initialize_network(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_rtems_bsdnet_initialize_network, int); + + UT_GenStub_Execute(PCS_rtems_bsdnet_initialize_network, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_rtems_bsdnet_initialize_network, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rtems_fxp_attach() + * ---------------------------------------------------- + */ +int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *cfg, int x) +{ + UT_GenStub_SetupReturnBuffer(PCS_rtems_fxp_attach, int); + + UT_GenStub_AddParam(PCS_rtems_fxp_attach, struct PCS_rtems_bsdnet_ifconfig *, cfg); + UT_GenStub_AddParam(PCS_rtems_fxp_attach, int, x); + + UT_GenStub_Execute(PCS_rtems_fxp_attach, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_rtems_fxp_attach, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rtems_status_text() + * ---------------------------------------------------- + */ +const char *PCS_rtems_status_text(PCS_rtems_status_code sc) +{ + UT_GenStub_SetupReturnBuffer(PCS_rtems_status_text, const char *); + + UT_GenStub_AddParam(PCS_rtems_status_text, PCS_rtems_status_code, sc); + + UT_GenStub_Execute(PCS_rtems_status_text, Basic, UT_DefaultHandler_PCS_rtems_status_text); + + return UT_GenStub_GetReturnValue(PCS_rtems_status_text, const char *); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_cacheLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_cacheLib_stubs.c new file mode 100644 index 00000000..2023f390 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_cacheLib_stubs.c @@ -0,0 +1,43 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_cacheLib header + */ + +#include "PCS_cacheLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_cacheTextUpdate() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_cacheTextUpdate(void *adrs, size_t bytes) +{ + UT_GenStub_SetupReturnBuffer(PCS_cacheTextUpdate, PCS_STATUS); + + UT_GenStub_AddParam(PCS_cacheTextUpdate, void *, adrs); + UT_GenStub_AddParam(PCS_cacheTextUpdate, size_t, bytes); + + UT_GenStub_Execute(PCS_cacheTextUpdate, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_cacheTextUpdate, PCS_STATUS); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_cfe_configdata_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_cfe_configdata_stubs.c new file mode 100644 index 00000000..e6417d48 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_cfe_configdata_stubs.c @@ -0,0 +1,63 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_cfe_configdata header + */ + +#include "PCS_cfe_configdata.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_System1HzISR() + * ---------------------------------------------------- + */ +void PCS_System1HzISR(void) +{ + + UT_GenStub_Execute(PCS_System1HzISR, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_SystemMain() + * ---------------------------------------------------- + */ +void PCS_SystemMain(uint32_t StartType, uint32_t StartSubtype, uint32_t ModeId, const char *StartFilePath) +{ + UT_GenStub_AddParam(PCS_SystemMain, uint32_t, StartType); + UT_GenStub_AddParam(PCS_SystemMain, uint32_t, StartSubtype); + UT_GenStub_AddParam(PCS_SystemMain, uint32_t, ModeId); + UT_GenStub_AddParam(PCS_SystemMain, const char *, StartFilePath); + + UT_GenStub_Execute(PCS_SystemMain, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_SystemNotify() + * ---------------------------------------------------- + */ +void PCS_SystemNotify(void) +{ + + UT_GenStub_Execute(PCS_SystemNotify, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_dosFsLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_dosFsLib_stubs.c new file mode 100644 index 00000000..6e720e4c --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_dosFsLib_stubs.c @@ -0,0 +1,44 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_dosFsLib header + */ + +#include "PCS_dosFsLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_dosFsVolFormat() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_dosFsVolFormat(char *path, int opt, PCS_FUNCPTR pPromptFunc) +{ + UT_GenStub_SetupReturnBuffer(PCS_dosFsVolFormat, PCS_STATUS); + + UT_GenStub_AddParam(PCS_dosFsVolFormat, char *, path); + UT_GenStub_AddParam(PCS_dosFsVolFormat, int, opt); + UT_GenStub_AddParam(PCS_dosFsVolFormat, PCS_FUNCPTR, pPromptFunc); + + UT_GenStub_Execute(PCS_dosFsVolFormat, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_dosFsVolFormat, PCS_STATUS); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_drv_hdisk_ataDrv_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_drv_hdisk_ataDrv_stubs.c new file mode 100644 index 00000000..10e55bee --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_drv_hdisk_ataDrv_stubs.c @@ -0,0 +1,46 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_drv_hdisk_ataDrv header + */ + +#include "PCS_drv_hdisk_ataDrv.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_ataXbdDevCreate() + * ---------------------------------------------------- + */ +PCS_device_t PCS_ataXbdDevCreate(int ctrl, int drive, unsigned int nBlks, unsigned int offset, const char *s) +{ + UT_GenStub_SetupReturnBuffer(PCS_ataXbdDevCreate, PCS_device_t); + + UT_GenStub_AddParam(PCS_ataXbdDevCreate, int, ctrl); + UT_GenStub_AddParam(PCS_ataXbdDevCreate, int, drive); + UT_GenStub_AddParam(PCS_ataXbdDevCreate, unsigned int, nBlks); + UT_GenStub_AddParam(PCS_ataXbdDevCreate, unsigned int, offset); + UT_GenStub_AddParam(PCS_ataXbdDevCreate, const char *, s); + + UT_GenStub_Execute(PCS_ataXbdDevCreate, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_ataXbdDevCreate, PCS_device_t); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_handlers.c new file mode 100644 index 00000000..bab46493 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_handlers.c @@ -0,0 +1,39 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for rtems_bsdnet.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_drv_pci_pciConfigLib.h" +#include "PCS_vxWorks.h" + +void UT_DefaultHandler_PCS_pciConfigInWord(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_STATUS PCS_pciConfigInWord(int busNo, int deviceNo, int funcNo, int offset, uint16 *pData) */ + uint16 *pData = UT_Hook_GetArgValueByName(Context, "pData", uint16 *); + int32 iRetCode; + + UT_Stub_GetInt32StatusCode(Context, &iRetCode); + + if (iRetCode == PCS_OK) + { + UT_Stub_CopyToLocal(FuncKey, (uint16 *)pData, sizeof(*pData)); + } +} \ No newline at end of file diff --git a/unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_stubs.c new file mode 100644 index 00000000..ea253b2a --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_drv_pci_pciConfigLib_stubs.c @@ -0,0 +1,69 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_drv_pci_pciConfigLib header + */ + +#include "PCS_drv_pci_pciConfigLib.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_pciConfigInWord(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_pciConfigInWord() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_pciConfigInWord(int busNo, int deviceNo, int funcNo, int offset, uint16_t *pData) +{ + UT_GenStub_SetupReturnBuffer(PCS_pciConfigInWord, PCS_STATUS); + + UT_GenStub_AddParam(PCS_pciConfigInWord, int, busNo); + UT_GenStub_AddParam(PCS_pciConfigInWord, int, deviceNo); + UT_GenStub_AddParam(PCS_pciConfigInWord, int, funcNo); + UT_GenStub_AddParam(PCS_pciConfigInWord, int, offset); + UT_GenStub_AddParam(PCS_pciConfigInWord, uint16_t *, pData); + + UT_GenStub_Execute(PCS_pciConfigInWord, Basic, UT_DefaultHandler_PCS_pciConfigInWord); + + return UT_GenStub_GetReturnValue(PCS_pciConfigInWord, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_pciFindDevice() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_pciFindDevice(int vendorId, int deviceId, int index, int *pBusNo, int *pDeviceNo, int *pFuncNo) +{ + UT_GenStub_SetupReturnBuffer(PCS_pciFindDevice, PCS_STATUS); + + UT_GenStub_AddParam(PCS_pciFindDevice, int, vendorId); + UT_GenStub_AddParam(PCS_pciFindDevice, int, deviceId); + UT_GenStub_AddParam(PCS_pciFindDevice, int, index); + UT_GenStub_AddParam(PCS_pciFindDevice, int *, pBusNo); + UT_GenStub_AddParam(PCS_pciFindDevice, int *, pDeviceNo); + UT_GenStub_AddParam(PCS_pciFindDevice, int *, pFuncNo); + + UT_GenStub_Execute(PCS_pciFindDevice, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_pciFindDevice, PCS_STATUS); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_errnoLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_errnoLib_stubs.c new file mode 100644 index 00000000..ae9091ec --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_errnoLib_stubs.c @@ -0,0 +1,40 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_errnoLib header + */ + +#include "PCS_errnoLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_errnoGet() + * ---------------------------------------------------- + */ +int PCS_errnoGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_errnoGet, int); + + UT_GenStub_Execute(PCS_errnoGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_errnoGet, int); +} diff --git a/unit-test-coverage/ut-stubs/inc/PCS_dhcs_failsafe.h b/unit-test-coverage/ut-stubs/src/PCS_errno_globals.c similarity index 84% rename from unit-test-coverage/ut-stubs/inc/PCS_dhcs_failsafe.h rename to unit-test-coverage/ut-stubs/src/PCS_errno_globals.c index 037684f8..1119bd04 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_dhcs_failsafe.h +++ b/unit-test-coverage/ut-stubs/src/PCS_errno_globals.c @@ -1,3 +1,4 @@ + /************************************************************************ * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” * @@ -16,11 +17,6 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for rtems_dhcs_failsafe.h */ -#ifndef PCS_DHCP_FAILSAFE_H -#define PCS_DHCP_FAILSAFE_H - -#include "PCS_basetypes.h" -#include "PCS_rtems.h" +#include "PCS_errno.h" -#endif +int PCS_errno; diff --git a/unit-test-coverage/ut-stubs/src/PCS_excLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_excLib_stubs.c new file mode 100644 index 00000000..f5e90100 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_excLib_stubs.c @@ -0,0 +1,38 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_excLib header + */ + +#include "PCS_excLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_excHookAdd() + * ---------------------------------------------------- + */ +void PCS_excHookAdd(PCS_Hook_t Hook) +{ + UT_GenStub_AddParam(PCS_excHookAdd, PCS_Hook_t, Hook); + + UT_GenStub_Execute(PCS_excHookAdd, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_fcntl_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_fcntl_stubs.c new file mode 100644 index 00000000..d75025cb --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_fcntl_stubs.c @@ -0,0 +1,103 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_fcntl header + */ + +#include + +#include "PCS_fcntl.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_creat() + * ---------------------------------------------------- + */ +int PCS_creat(const char *pathname, PCS_mode_t mode) +{ + UT_GenStub_SetupReturnBuffer(PCS_creat, int); + + UT_GenStub_AddParam(PCS_creat, const char *, pathname); + UT_GenStub_AddParam(PCS_creat, PCS_mode_t, mode); + + UT_GenStub_Execute(PCS_creat, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_creat, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_fcntl() + * ---------------------------------------------------- + */ +int PCS_fcntl(int fd, int cmd, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(PCS_fcntl, int); + + UT_GenStub_AddParam(PCS_fcntl, int, fd); + UT_GenStub_AddParam(PCS_fcntl, int, cmd); + + va_start(UtStub_ArgList, cmd); + UT_GenStub_Execute(PCS_fcntl, Va, NULL, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(PCS_fcntl, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_mkdir() + * ---------------------------------------------------- + */ +int PCS_mkdir(const char *pathname) +{ + UT_GenStub_SetupReturnBuffer(PCS_mkdir, int); + + UT_GenStub_AddParam(PCS_mkdir, const char *, pathname); + + UT_GenStub_Execute(PCS_mkdir, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_mkdir, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_open() + * ---------------------------------------------------- + */ +int PCS_open(const char *file, int oflag, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(PCS_open, int); + + UT_GenStub_AddParam(PCS_open, const char *, file); + UT_GenStub_AddParam(PCS_open, int, oflag); + + va_start(UtStub_ArgList, oflag); + UT_GenStub_Execute(PCS_open, Va, NULL, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(PCS_open, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_fppLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_fppLib_stubs.c new file mode 100644 index 00000000..9e67c81c --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_fppLib_stubs.c @@ -0,0 +1,38 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_fppLib header + */ + +#include "PCS_fppLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_fppSave() + * ---------------------------------------------------- + */ +void PCS_fppSave(PCS_FP_CONTEXT *fpc) +{ + UT_GenStub_AddParam(PCS_fppSave, PCS_FP_CONTEXT *, fpc); + + UT_GenStub_Execute(PCS_fppSave, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_intLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_intLib_stubs.c new file mode 100644 index 00000000..412fff39 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_intLib_stubs.c @@ -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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_intLib header + */ + +#include "PCS_intLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_intCpuLock() + * ---------------------------------------------------- + */ +int PCS_intCpuLock(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_intCpuLock, int); + + UT_GenStub_Execute(PCS_intCpuLock, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_intCpuLock, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_intCpuUnlock() + * ---------------------------------------------------- + */ +void PCS_intCpuUnlock(int key) +{ + UT_GenStub_AddParam(PCS_intCpuUnlock, int, key); + + UT_GenStub_Execute(PCS_intCpuUnlock, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_moduleLib_handlers.c similarity index 59% rename from unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_moduleLib_handlers.c index a3cfccf3..78135c49 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-moduleLib-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_moduleLib_handlers.c @@ -23,32 +23,39 @@ #include "PCS_moduleLib.h" -PCS_MODULE_ID PCS_moduleFindByName(const char *moduleName) +void UT_DefaultHandler_PCS_moduleFindByName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - PCS_MODULE_ID retval; - int32 Status; + /* PCS_MODULE_ID PCS_moduleFindByName(const char *moduleName) */ + static PCS_MODULE UT_MODULE; + PCS_MODULE_ID retval; + int32 Status; retval = NULL; - Status = UT_DEFAULT_IMPL(PCS_moduleFindByName); - if (Status == 0) + + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status >= 0) { - UT_Stub_CopyToLocal(UT_KEY(PCS_moduleFindByName), &retval, sizeof(retval)); + if (UT_Stub_CopyToLocal(FuncKey, &retval, sizeof(retval)) < sizeof(retval)) + { + retval = &UT_MODULE; + } } - return retval; + UT_Stub_SetReturnValue(FuncKey, retval); } -PCS_STATUS PCS_moduleInfoGet(PCS_MODULE_ID moduleId, PCS_MODULE_INFO *pModuleInfo) +void UT_DefaultHandler_PCS_moduleInfoGet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { + /* PCS_STATUS PCS_moduleInfoGet(PCS_MODULE_ID moduleId, PCS_MODULE_INFO *pModuleInfo) */ + PCS_MODULE_INFO *pModuleInfo = UT_Hook_GetArgValueByName(Context, "pModuleInfo", PCS_MODULE_INFO *); + int32 Status; - Status = UT_DEFAULT_IMPL(PCS_moduleInfoGet); + UT_Stub_GetInt32StatusCode(Context, &Status); - if (Status == 0 && + if (Status >= 0 && UT_Stub_CopyToLocal(UT_KEY(PCS_moduleInfoGet), pModuleInfo, sizeof(*pModuleInfo)) < sizeof(*pModuleInfo)) { memset(pModuleInfo, 0, sizeof(*pModuleInfo)); } - - return Status; } diff --git a/unit-test-coverage/ut-stubs/src/PCS_moduleLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_moduleLib_stubs.c new file mode 100644 index 00000000..0df0bbb9 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_moduleLib_stubs.c @@ -0,0 +1,62 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_moduleLib header + */ + +#include "PCS_moduleLib.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_moduleFindByName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_moduleInfoGet(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_moduleFindByName() + * ---------------------------------------------------- + */ +PCS_MODULE_ID PCS_moduleFindByName(const char *moduleName) +{ + UT_GenStub_SetupReturnBuffer(PCS_moduleFindByName, PCS_MODULE_ID); + + UT_GenStub_AddParam(PCS_moduleFindByName, const char *, moduleName); + + UT_GenStub_Execute(PCS_moduleFindByName, Basic, UT_DefaultHandler_PCS_moduleFindByName); + + return UT_GenStub_GetReturnValue(PCS_moduleFindByName, PCS_MODULE_ID); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_moduleInfoGet() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_moduleInfoGet(PCS_MODULE_ID moduleId, PCS_MODULE_INFO *pModuleInfo) +{ + UT_GenStub_SetupReturnBuffer(PCS_moduleInfoGet, PCS_STATUS); + + UT_GenStub_AddParam(PCS_moduleInfoGet, PCS_MODULE_ID, moduleId); + UT_GenStub_AddParam(PCS_moduleInfoGet, PCS_MODULE_INFO *, pModuleInfo); + + UT_GenStub_Execute(PCS_moduleInfoGet, Basic, UT_DefaultHandler_PCS_moduleInfoGet); + + return UT_GenStub_GetReturnValue(PCS_moduleInfoGet, PCS_STATUS); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_netinet_in_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_netinet_in_stubs.c new file mode 100644 index 00000000..0e984b73 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_netinet_in_stubs.c @@ -0,0 +1,90 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_netinet_in header + */ + +#include "PCS_netinet_in.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_htonl() + * ---------------------------------------------------- + */ +uint32_t PCS_htonl(uint32_t hostlong) +{ + UT_GenStub_SetupReturnBuffer(PCS_htonl, uint32_t); + + UT_GenStub_AddParam(PCS_htonl, uint32_t, hostlong); + + UT_GenStub_Execute(PCS_htonl, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_htonl, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_htons() + * ---------------------------------------------------- + */ +uint16_t PCS_htons(uint16_t hostshort) +{ + UT_GenStub_SetupReturnBuffer(PCS_htons, uint16_t); + + UT_GenStub_AddParam(PCS_htons, uint16_t, hostshort); + + UT_GenStub_Execute(PCS_htons, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_htons, uint16_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_ntohl() + * ---------------------------------------------------- + */ +uint32_t PCS_ntohl(uint32_t netlong) +{ + UT_GenStub_SetupReturnBuffer(PCS_ntohl, uint32_t); + + UT_GenStub_AddParam(PCS_ntohl, uint32_t, netlong); + + UT_GenStub_Execute(PCS_ntohl, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_ntohl, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_ntohs() + * ---------------------------------------------------- + */ +uint16_t PCS_ntohs(uint16_t netshort) +{ + UT_GenStub_SetupReturnBuffer(PCS_ntohs, uint16_t); + + UT_GenStub_AddParam(PCS_ntohs, uint16_t, netshort); + + UT_GenStub_Execute(PCS_ntohs, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_ntohs, uint16_t); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_ramDrv_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_ramDrv_stubs.c new file mode 100644 index 00000000..d6701bc0 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_ramDrv_stubs.c @@ -0,0 +1,46 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_ramDrv header + */ + +#include "PCS_ramDrv.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_ramDevCreate() + * ---------------------------------------------------- + */ +PCS_BLK_DEV *PCS_ramDevCreate(char *ramAddr, int bytesPerSec, int secPerTrack, int nSectors, int secOffset) +{ + UT_GenStub_SetupReturnBuffer(PCS_ramDevCreate, PCS_BLK_DEV *); + + UT_GenStub_AddParam(PCS_ramDevCreate, char *, ramAddr); + UT_GenStub_AddParam(PCS_ramDevCreate, int, bytesPerSec); + UT_GenStub_AddParam(PCS_ramDevCreate, int, secPerTrack); + UT_GenStub_AddParam(PCS_ramDevCreate, int, nSectors); + UT_GenStub_AddParam(PCS_ramDevCreate, int, secOffset); + + UT_GenStub_Execute(PCS_ramDevCreate, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_ramDevCreate, PCS_BLK_DEV *); +} diff --git a/unit-test-coverage/ut-stubs/src/vxworks-rebootLib-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_rebootLib_stubs.c similarity index 70% rename from unit-test-coverage/ut-stubs/src/vxworks-rebootLib-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_rebootLib_stubs.c index c85d039f..f96a64d5 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-rebootLib-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_rebootLib_stubs.c @@ -16,14 +16,23 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for rebootLib.h */ -#include -#include -#include "utstubs.h" +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_rebootLib header + */ #include "PCS_rebootLib.h" +#include "utgenstub.h" -void PCS_reboot(int boottype) +/* + * ---------------------------------------------------- + * Generated stub function for PCS_reboot() + * ---------------------------------------------------- + */ +void PCS_reboot(int x) { - UT_DEFAULT_IMPL(PCS_reboot); + UT_GenStub_AddParam(PCS_reboot, int, x); + + UT_GenStub_Execute(PCS_reboot, Basic, NULL); } diff --git a/unit-test-coverage/ut-stubs/src/PCS_speLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_speLib_stubs.c new file mode 100644 index 00000000..a67feed1 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_speLib_stubs.c @@ -0,0 +1,38 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_speLib header + */ + +#include "PCS_speLib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_speSave() + * ---------------------------------------------------- + */ +void PCS_speSave(PCS_SPE_CONTEXT *pSpeContext) +{ + UT_GenStub_AddParam(PCS_speSave, PCS_SPE_CONTEXT *, pSpeContext); + + UT_GenStub_Execute(PCS_speSave, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_spyLibP_stubs.c similarity index 56% rename from unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_spyLibP_stubs.c index ed226f47..bd911111 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-spyLibP-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_spyLibP_stubs.c @@ -16,34 +16,51 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for spyLibP.h */ -#include -#include -#include "utstubs.h" -#include "utgenstub.h" +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_spyLibP header + */ #include "PCS_spyLibP.h" +#include "utgenstub.h" -void PCS_spyReportCommon(PCS_FUNCPTR print) +/* + * ---------------------------------------------------- + * Generated stub function for PCS_spyClkStartCommon() + * ---------------------------------------------------- + */ +int PCS_spyClkStartCommon(int intsPerSec, PCS_FUNCPTR print) { - /* Not Implement*/ + UT_GenStub_SetupReturnBuffer(PCS_spyClkStartCommon, int); + + 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, int); } +/* + * ---------------------------------------------------- + * Generated stub function for PCS_spyClkStopCommon() + * ---------------------------------------------------- + */ void PCS_spyClkStopCommon(void) { - /* Not Implement */ + + UT_GenStub_Execute(PCS_spyClkStopCommon, Basic, NULL); } -int PCS_spyClkStartCommon(int intsPerSec, PCS_FUNCPTR print) +/* + * ---------------------------------------------------- + * Generated stub function for PCS_spyReportCommon() + * ---------------------------------------------------- + */ +void PCS_spyReportCommon(PCS_FUNCPTR print) { + UT_GenStub_AddParam(PCS_spyReportCommon, 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);; + UT_GenStub_Execute(PCS_spyReportCommon, Basic, NULL); } - diff --git a/unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_spyLib_stubs.c similarity index 71% rename from unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_spyLib_stubs.c index ef22cbb2..9fa7fa0b 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-spyLib-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_spyLib_stubs.c @@ -16,16 +16,23 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for spyLib.h */ -#include -#include -#include "utstubs.h" +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_spyLib header + */ #include "PCS_spyLib.h" +#include "utgenstub.h" - +/* + * ---------------------------------------------------- + * Generated stub function for PCS_spyLibInit() + * ---------------------------------------------------- + */ void PCS_spyLibInit(int maxTasks) { - /* Not Implment */ -} + UT_GenStub_AddParam(PCS_spyLibInit, int, maxTasks); + UT_GenStub_Execute(PCS_spyLibInit, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_stdio_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_stdio_handlers.c new file mode 100644 index 00000000..3781d970 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_stdio_handlers.c @@ -0,0 +1,151 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for stdio.h */ +#include +#include +#include +#include "utstubs.h" + +#include "PCS_stdio.h" + +struct PCS_FILE +{ + int f; +}; + +#define PCS_STDIO_MAX_SIZE 0x01000000 + +void UT_DefaultHandler_PCS_fgets(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_fgets(char *s, int n, PCS_FILE *stream) */ + char *s = UT_Hook_GetArgValueByName(Context, "s", char *); + int n = UT_Hook_GetArgValueByName(Context, "n", int); + + int32 Status; + uint32 CopySize; + void * DataBufferPtr; + + Status = 0; + UT_GetDataBuffer(FuncKey, &DataBufferPtr, NULL, NULL); + UT_Stub_GetInt32StatusCode(Context, &Status); + + if (DataBufferPtr != NULL) + { + if (Status > n) + { + CopySize = n; + } + else + { + CopySize = Status; + } + + CopySize = UT_Stub_CopyToLocal(UT_KEY(PCS_fgets), s, CopySize); + } + else + { + CopySize = 0; + } + + if (n < Status) + { + Status = n; + } + + if (UT_GetStubCount(UT_KEY(PCS_fgets) < 4) && Status > 0 && CopySize < Status) + { + memset(&s[CopySize], 'x', Status - CopySize); + CopySize = Status; + } + + if (CopySize <= 0) + { + s = NULL; + } + else + { + s[CopySize - 1] = 0; + } + + UT_Stub_SetReturnValue(FuncKey, s); +} + +void UT_DefaultHandler_PCS_fopen(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_FILE *PCS_fopen(const char *filename, const char *modes) */ + PCS_FILE * retval; + static PCS_FILE FOPEN_FP = {0}; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + retval = &FOPEN_FP; + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +void UT_DefaultHandler_PCS_snprintf(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, + va_list ArgList) +{ + /* int PCS_snprintf(char *s, size_t maxlen, const char *format, ...) */ + char * s = UT_Hook_GetArgValueByName(Context, "s", char *); + size_t maxlen = UT_Hook_GetArgValueByName(Context, "maxlen", size_t); + const char *format = UT_Hook_GetArgValueByName(Context, "format", const char *); + int32 status; + + int retval; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + /* need to actually _do_ the snprintf */ + retval = vsnprintf(s, maxlen, format, ArgList); + + /* It is assumed that zero implies normal snprintf behavior, + * anything else is an intended return value */ + if (status == 0) + { + UT_Stub_SetReturnValue(FuncKey, retval); + } + } +} + +void UT_DefaultHandler_PCS_vsnprintf(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_vsnprintf(char *s, size_t maxlen, const char *format, PCS_va_list arg) */ + char * s = UT_Hook_GetArgValueByName(Context, "s", char *); + size_t maxlen = UT_Hook_GetArgValueByName(Context, "maxlen", size_t); + const char *format = UT_Hook_GetArgValueByName(Context, "format", const char *); + + int retval = 0; + + /* need to actually _do_ something here - + * cannot do the real vsnprintf because we lost the args. */ + retval = snprintf(s, maxlen, "%s", format); + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +static PCS_FILE LOCAL_FP[3] = {{10}, {11}, {12}}; + +PCS_FILE *PCS_stdin = &LOCAL_FP[0]; +PCS_FILE *PCS_stdout = &LOCAL_FP[1]; +PCS_FILE *PCS_stderr = &LOCAL_FP[2]; diff --git a/unit-test-coverage/ut-stubs/src/PCS_stdio_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_stdio_stubs.c new file mode 100644 index 00000000..0d5e8af1 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_stdio_stubs.c @@ -0,0 +1,223 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_stdio header + */ + +#include + +#include "PCS_stdio.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_fgets(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_fopen(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_snprintf(void *, UT_EntryKey_t, const UT_StubContext_t *, va_list); +void UT_DefaultHandler_PCS_vsnprintf(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_fclose() + * ---------------------------------------------------- + */ +int PCS_fclose(PCS_FILE *stream) +{ + UT_GenStub_SetupReturnBuffer(PCS_fclose, int); + + UT_GenStub_AddParam(PCS_fclose, PCS_FILE *, stream); + + UT_GenStub_Execute(PCS_fclose, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_fclose, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_fgets() + * ---------------------------------------------------- + */ +char *PCS_fgets(char *s, int n, PCS_FILE *stream) +{ + UT_GenStub_SetupReturnBuffer(PCS_fgets, char *); + + UT_GenStub_AddParam(PCS_fgets, char *, s); + UT_GenStub_AddParam(PCS_fgets, int, n); + UT_GenStub_AddParam(PCS_fgets, PCS_FILE *, stream); + + UT_GenStub_Execute(PCS_fgets, Basic, UT_DefaultHandler_PCS_fgets); + + return UT_GenStub_GetReturnValue(PCS_fgets, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_fopen() + * ---------------------------------------------------- + */ +PCS_FILE *PCS_fopen(const char *filename, const char *modes) +{ + UT_GenStub_SetupReturnBuffer(PCS_fopen, PCS_FILE *); + + UT_GenStub_AddParam(PCS_fopen, const char *, filename); + UT_GenStub_AddParam(PCS_fopen, const char *, modes); + + UT_GenStub_Execute(PCS_fopen, Basic, UT_DefaultHandler_PCS_fopen); + + return UT_GenStub_GetReturnValue(PCS_fopen, PCS_FILE *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_fputs() + * ---------------------------------------------------- + */ +int PCS_fputs(const char *s, PCS_FILE *stream) +{ + UT_GenStub_SetupReturnBuffer(PCS_fputs, int); + + UT_GenStub_AddParam(PCS_fputs, const char *, s); + UT_GenStub_AddParam(PCS_fputs, PCS_FILE *, stream); + + UT_GenStub_Execute(PCS_fputs, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_fputs, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_perror() + * ---------------------------------------------------- + */ +void PCS_perror(const char *str) +{ + UT_GenStub_AddParam(PCS_perror, const char *, str); + + UT_GenStub_Execute(PCS_perror, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_printf() + * ---------------------------------------------------- + */ +int PCS_printf(const char *format, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(PCS_printf, int); + + UT_GenStub_AddParam(PCS_printf, const char *, format); + + va_start(UtStub_ArgList, format); + UT_GenStub_Execute(PCS_printf, Va, NULL, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(PCS_printf, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_putchar() + * ---------------------------------------------------- + */ +int PCS_putchar(int c) +{ + UT_GenStub_SetupReturnBuffer(PCS_putchar, int); + + UT_GenStub_AddParam(PCS_putchar, int, c); + + UT_GenStub_Execute(PCS_putchar, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_putchar, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_remove() + * ---------------------------------------------------- + */ +int PCS_remove(const char *filename) +{ + UT_GenStub_SetupReturnBuffer(PCS_remove, int); + + UT_GenStub_AddParam(PCS_remove, const char *, filename); + + UT_GenStub_Execute(PCS_remove, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_remove, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rename() + * ---------------------------------------------------- + */ +int PCS_rename(const char *old, const char *nw) +{ + UT_GenStub_SetupReturnBuffer(PCS_rename, int); + + UT_GenStub_AddParam(PCS_rename, const char *, old); + UT_GenStub_AddParam(PCS_rename, const char *, nw); + + UT_GenStub_Execute(PCS_rename, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_rename, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_snprintf() + * ---------------------------------------------------- + */ +int PCS_snprintf(char *s, size_t maxlen, const char *format, ...) +{ + va_list UtStub_ArgList; + + UT_GenStub_SetupReturnBuffer(PCS_snprintf, int); + + UT_GenStub_AddParam(PCS_snprintf, char *, s); + UT_GenStub_AddParam(PCS_snprintf, size_t, maxlen); + UT_GenStub_AddParam(PCS_snprintf, const char *, format); + + va_start(UtStub_ArgList, format); + UT_GenStub_Execute(PCS_snprintf, Va, UT_DefaultHandler_PCS_snprintf, UtStub_ArgList); + va_end(UtStub_ArgList); + + return UT_GenStub_GetReturnValue(PCS_snprintf, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_vsnprintf() + * ---------------------------------------------------- + */ +int PCS_vsnprintf(char *s, size_t maxlen, const char *format, PCS_va_list arg) +{ + UT_GenStub_SetupReturnBuffer(PCS_vsnprintf, int); + + UT_GenStub_AddParam(PCS_vsnprintf, char *, s); + UT_GenStub_AddParam(PCS_vsnprintf, size_t, maxlen); + UT_GenStub_AddParam(PCS_vsnprintf, const char *, format); + UT_GenStub_AddParam(PCS_vsnprintf, PCS_va_list, arg); + + UT_GenStub_Execute(PCS_vsnprintf, Basic, UT_DefaultHandler_PCS_vsnprintf); + + return UT_GenStub_GetReturnValue(PCS_vsnprintf, int); +} diff --git a/unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c similarity index 64% rename from unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c index 1dc56700..381b0b4b 100644 --- a/unit-test-coverage/ut-stubs/src/libc-stdlib-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c @@ -44,51 +44,28 @@ struct MPOOL_REC uint32 Size; }; -void PCS_exit(int c) +void UT_DefaultHandler_PCS_strtoul(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - UT_DEFAULT_IMPL(PCS_exit); + /* unsigned long int PCS_strtoul(const char *nptr, char **endptr, int base) */ + const char *nptr = UT_Hook_GetArgValueByName(Context, "nptr", const char *); + char ** endptr = UT_Hook_GetArgValueByName(Context, "endptr", char **); + int base = UT_Hook_GetArgValueByName(Context, "base", int); - /* - * This call is never supposed to return, but this stub will. - * The application therefore must handle a return from exit() - * - * TBD: IT would be nice if this could use a setjmp-like - * method to avoid returning here. - */ -} + unsigned long Result; -void PCS_abort(void) -{ - UT_DEFAULT_IMPL(PCS_abort); -} - -unsigned long int PCS_strtoul(const char *nptr, char **endptr, int base) -{ - int32 Status; - unsigned long Result = 0; - - Status = UT_DEFAULT_IMPL_RC(PCS_strtoul, -1); - - if (Status < 0) + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) { /* do the real op */ Result = strtoul(nptr, endptr, base); + UT_Stub_SetReturnValue(FuncKey, Result); } - else - { - Result = Status; - } - - return Result; } -int PCS_system(const char *command) +void UT_DefaultHandler_PCS_malloc(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - return UT_DEFAULT_IMPL(PCS_system); -} + /* void *PCS_malloc(size_t sz) */ + size_t sz = UT_Hook_GetArgValueByName(Context, "sz", size_t); -void *PCS_malloc(size_t sz) -{ int32 Status; void * PoolPtr; cpuaddr PoolStart; @@ -97,10 +74,12 @@ void *PCS_malloc(size_t sz) size_t NextSize; size_t PoolSize; uint32 CallCnt; + void * BlockPtr; struct MPOOL_REC *Rec; - Rec = NULL; - CallCnt = UT_GetStubCount(UT_KEY(PCS_malloc)); + Rec = NULL; + BlockPtr = NULL; + CallCnt = UT_GetStubCount(UT_KEY(PCS_malloc)); UT_GetDataBuffer(UT_KEY(PCS_malloc), &PoolPtr, &PoolSize, NULL); if (PoolPtr != NULL) @@ -128,41 +107,45 @@ void *PCS_malloc(size_t sz) } } - Status = UT_DEFAULT_IMPL(PCS_malloc); - - if (Status != 0 || Rec == NULL) - { - return NULL; - } + UT_Stub_GetInt32StatusCode(Context, &Status); - NextSize = Rec->Size + sz + MPOOL_ALIGN; - if (NextSize > PoolSize) + if (Status == 0 && Rec != NULL) { - /* - * This indicates that the application is trying to allocate - * a block larger than the pool. It typically means that the - * emulated heap size is too small, so it is prudent to generate - * a message. - */ - UtAssert_Failed("PCS_malloc() heap has been exhausted"); - return NULL; - } + NextSize = Rec->Size + sz + MPOOL_ALIGN; + if (NextSize > PoolSize) + { + /* + * This indicates that the application is trying to allocate + * a block larger than the pool. It typically means that the + * emulated heap size is too small, so it is prudent to generate + * a message. + */ + UtAssert_Failed("PCS_malloc() heap has been exhausted"); + } + else + { + NextSize = (NextSize + MPOOL_ALIGN - 1) & ~((size_t)MPOOL_ALIGN - 1); + NextBlock = Rec->BlockAddr + MPOOL_ALIGN; + Rec->BlockAddr += NextSize; + Rec->Size += NextSize; - NextSize = (NextSize + MPOOL_ALIGN - 1) & ~((size_t)MPOOL_ALIGN - 1); - NextBlock = Rec->BlockAddr + MPOOL_ALIGN; - Rec->BlockAddr += NextSize; - Rec->Size += NextSize; + Rec = (struct MPOOL_REC *)(NextBlock - sizeof(struct MPOOL_REC)); + Rec->BlockAddr = NextBlock; + Rec->Magic = MPOOL_BLOCK_SIGNATURE; + Rec->Size = sz; - Rec = (struct MPOOL_REC *)(NextBlock - sizeof(struct MPOOL_REC)); - Rec->BlockAddr = NextBlock; - Rec->Magic = MPOOL_BLOCK_SIGNATURE; - Rec->Size = sz; + BlockPtr = (void *)NextBlock; + } - return (void *)NextBlock; + UT_Stub_SetReturnValue(FuncKey, BlockPtr); + } } -void PCS_free(void *ptr) +void UT_DefaultHandler_PCS_free(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { + /* void PCS_free(void *ptr) */ + void *ptr = UT_Hook_GetArgValueByName(Context, "ptr", void *); + int32 Status; cpuaddr BlockAddr; void * PoolPtr; @@ -173,9 +156,11 @@ void PCS_free(void *ptr) * If there is a data buffer associated with free() then this * will sanity-check that the block being freed came from that heap. */ + PoolPtr = NULL; + PoolSize = 0; UT_GetDataBuffer(UT_KEY(PCS_free), &PoolPtr, &PoolSize, NULL); - Status = UT_DEFAULT_IMPL(PCS_free); + UT_Stub_GetInt32StatusCode(Context, &Status); if (Status == 0 && PoolPtr != NULL) { BlockAddr = (cpuaddr)ptr; diff --git a/unit-test-coverage/ut-stubs/src/PCS_stdlib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_stdlib_stubs.c new file mode 100644 index 00000000..5b9f1df5 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_stdlib_stubs.c @@ -0,0 +1,131 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_stdlib header + */ + +#include "PCS_stdlib.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_free(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_malloc(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strtoul(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_abort() + * ---------------------------------------------------- + */ +void PCS_abort(void) +{ + + UT_GenStub_Execute(PCS_abort, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_abs() + * ---------------------------------------------------- + */ +int PCS_abs(int value) +{ + UT_GenStub_SetupReturnBuffer(PCS_abs, int); + + UT_GenStub_AddParam(PCS_abs, int, value); + + UT_GenStub_Execute(PCS_abs, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_abs, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_exit() + * ---------------------------------------------------- + */ +void PCS_exit(int status) +{ + UT_GenStub_AddParam(PCS_exit, int, status); + + UT_GenStub_Execute(PCS_exit, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_free() + * ---------------------------------------------------- + */ +void PCS_free(void *ptr) +{ + UT_GenStub_AddParam(PCS_free, void *, ptr); + + UT_GenStub_Execute(PCS_free, Basic, UT_DefaultHandler_PCS_free); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_malloc() + * ---------------------------------------------------- + */ +void *PCS_malloc(size_t sz) +{ + UT_GenStub_SetupReturnBuffer(PCS_malloc, void *); + + UT_GenStub_AddParam(PCS_malloc, size_t, sz); + + UT_GenStub_Execute(PCS_malloc, Basic, UT_DefaultHandler_PCS_malloc); + + return UT_GenStub_GetReturnValue(PCS_malloc, void *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strtoul() + * ---------------------------------------------------- + */ +unsigned long int PCS_strtoul(const char *nptr, char **endptr, int base) +{ + UT_GenStub_SetupReturnBuffer(PCS_strtoul, unsigned long int); + + UT_GenStub_AddParam(PCS_strtoul, const char *, nptr); + UT_GenStub_AddParam(PCS_strtoul, char **, endptr); + UT_GenStub_AddParam(PCS_strtoul, int, base); + + UT_GenStub_Execute(PCS_strtoul, Basic, UT_DefaultHandler_PCS_strtoul); + + return UT_GenStub_GetReturnValue(PCS_strtoul, unsigned long int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_system() + * ---------------------------------------------------- + */ +int PCS_system(const char *command) +{ + UT_GenStub_SetupReturnBuffer(PCS_system, int); + + UT_GenStub_AddParam(PCS_system, const char *, command); + + UT_GenStub_Execute(PCS_system, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_system, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_string_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_string_handlers.c new file mode 100644 index 00000000..09464655 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_string_handlers.c @@ -0,0 +1,263 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for string.h */ +#include +#include +#include +#include "utstubs.h" + +#include "PCS_string.h" + +/* + * NOTE: Normal behavior of this particular set of C library routines is important. + * + * Case in point - if code relies on something like memset() to clear memory, but that + * memory is not cleared, then behavior of the code thereafter is undefined. Thus, most + * of the handlers here need to implement the real call by default. + */ + +void UT_DefaultHandler_PCS_memset(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void *PCS_memset(void *s, int c, size_t n) */ + void * s = UT_Hook_GetArgValueByName(Context, "s", void *); + int c = UT_Hook_GetArgValueByName(Context, "c", int); + size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t); + + void *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = memset(s, c, n); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_memcpy(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void *PCS_memcpy(void *dest, const void *src, size_t n) */ + void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *); + const void *src = UT_Hook_GetArgValueByName(Context, "src", const void *); + size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t); + + void *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = memcpy(dest, src, n); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_memchr(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void * PCS_memchr(const void *s, int c, size_t n) */ + void * s = UT_Hook_GetArgValueByName(Context, "s", void *); + int c = UT_Hook_GetArgValueByName(Context, "c", int); + size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t); + + void *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = memchr(s, c, n); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_memcmp(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_memcmp(void *dest, const void *src, size_t n) */ + void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *); + const void *src = UT_Hook_GetArgValueByName(Context, "src", const void *); + size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t); + + int Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = memcmp(dest, src, n); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strchr(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strchr(const char *s, int c) */ + const char *s = UT_Hook_GetArgValueByName(Context, "s", const char *); + int c = UT_Hook_GetArgValueByName(Context, "c", int); + + char *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strchr(s, c); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strrchr(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strrchr(const char *s, int c) */ + const char *s = UT_Hook_GetArgValueByName(Context, "s", const char *); + int c = UT_Hook_GetArgValueByName(Context, "c", int); + + char *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strrchr(s, c); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strlen(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* size_t PCS_strlen(const char *s) */ + const char *s = UT_Hook_GetArgValueByName(Context, "s", const char *); + + size_t Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strlen(s); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strcat(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strcat(char *dest, const char *src) */ + void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *); + const void *src = UT_Hook_GetArgValueByName(Context, "src", const void *); + + char *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strcat(dest, src); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strncat(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strncat(char *dest, const char *src, size_t size) */ + void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *); + const void *src = UT_Hook_GetArgValueByName(Context, "src", const void *); + size_t size = UT_Hook_GetArgValueByName(Context, "size", size_t); + + char *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strncat(dest, src, size); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strncmp(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_strncmp(const char *s1, const char *s2, size_t n) */ + const char *s1 = UT_Hook_GetArgValueByName(Context, "s1", const char *); + const char *s2 = UT_Hook_GetArgValueByName(Context, "s2", const char *); + size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t); + + int Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strncmp(s1, s2, n); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strcmp(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_strcmp(const char *s1, const char *s2) */ + const char *s1 = UT_Hook_GetArgValueByName(Context, "s1", const char *); + const char *s2 = UT_Hook_GetArgValueByName(Context, "s2", const char *); + + int Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strcmp(s1, s2); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strcpy(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strcpy(char *dst, const char *src) */ + char * dst = UT_Hook_GetArgValueByName(Context, "dst", char *); + const char *src = UT_Hook_GetArgValueByName(Context, "src", const char *); + + char *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strcpy(dst, src); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strncpy(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strncpy(char *dst, const char *src, size_t size) */ + char * dst = UT_Hook_GetArgValueByName(Context, "dst", char *); + const char *src = UT_Hook_GetArgValueByName(Context, "src", const char *); + size_t size = UT_Hook_GetArgValueByName(Context, "size", size_t); + + char *Result; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform the real operation */ + Result = strncpy(dst, src, size); + UT_Stub_SetReturnValue(FuncKey, Result); + } +} + +void UT_DefaultHandler_PCS_strerror(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* char *PCS_strerror(int errnum) */ + int errnum = UT_Hook_GetArgValueByName(Context, "errnum", int); + + static char str[16]; + char * ret = str; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + /* Perform a substitute operation */ + snprintf(str, sizeof(str), "UT_ERR_%d", errnum); + UT_Stub_SetReturnValue(FuncKey, ret); + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_string_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_string_stubs.c new file mode 100644 index 00000000..ce72771c --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_string_stubs.c @@ -0,0 +1,284 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_string header + */ + +#include "PCS_string.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_memchr(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_memcmp(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_memcpy(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_memset(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strcat(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strchr(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strcmp(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strcpy(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strerror(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strlen(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strncat(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strncmp(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strncpy(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_strrchr(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_memchr() + * ---------------------------------------------------- + */ +void *PCS_memchr(const void *s, int c, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_memchr, void *); + + UT_GenStub_AddParam(PCS_memchr, const void *, s); + UT_GenStub_AddParam(PCS_memchr, int, c); + UT_GenStub_AddParam(PCS_memchr, size_t, n); + + UT_GenStub_Execute(PCS_memchr, Basic, UT_DefaultHandler_PCS_memchr); + + return UT_GenStub_GetReturnValue(PCS_memchr, void *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_memcmp() + * ---------------------------------------------------- + */ +int PCS_memcmp(void *dest, const void *src, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_memcmp, int); + + UT_GenStub_AddParam(PCS_memcmp, void *, dest); + UT_GenStub_AddParam(PCS_memcmp, const void *, src); + UT_GenStub_AddParam(PCS_memcmp, size_t, n); + + UT_GenStub_Execute(PCS_memcmp, Basic, UT_DefaultHandler_PCS_memcmp); + + return UT_GenStub_GetReturnValue(PCS_memcmp, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_memcpy() + * ---------------------------------------------------- + */ +void *PCS_memcpy(void *dest, const void *src, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_memcpy, void *); + + UT_GenStub_AddParam(PCS_memcpy, void *, dest); + UT_GenStub_AddParam(PCS_memcpy, const void *, src); + UT_GenStub_AddParam(PCS_memcpy, size_t, n); + + UT_GenStub_Execute(PCS_memcpy, Basic, UT_DefaultHandler_PCS_memcpy); + + return UT_GenStub_GetReturnValue(PCS_memcpy, void *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_memset() + * ---------------------------------------------------- + */ +void *PCS_memset(void *s, int c, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_memset, void *); + + UT_GenStub_AddParam(PCS_memset, void *, s); + UT_GenStub_AddParam(PCS_memset, int, c); + UT_GenStub_AddParam(PCS_memset, size_t, n); + + UT_GenStub_Execute(PCS_memset, Basic, UT_DefaultHandler_PCS_memset); + + return UT_GenStub_GetReturnValue(PCS_memset, void *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strcat() + * ---------------------------------------------------- + */ +char *PCS_strcat(char *dest, const char *src) +{ + UT_GenStub_SetupReturnBuffer(PCS_strcat, char *); + + UT_GenStub_AddParam(PCS_strcat, char *, dest); + UT_GenStub_AddParam(PCS_strcat, const char *, src); + + UT_GenStub_Execute(PCS_strcat, Basic, UT_DefaultHandler_PCS_strcat); + + return UT_GenStub_GetReturnValue(PCS_strcat, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strchr() + * ---------------------------------------------------- + */ +char *PCS_strchr(const char *s, int c) +{ + UT_GenStub_SetupReturnBuffer(PCS_strchr, char *); + + UT_GenStub_AddParam(PCS_strchr, const char *, s); + UT_GenStub_AddParam(PCS_strchr, int, c); + + UT_GenStub_Execute(PCS_strchr, Basic, UT_DefaultHandler_PCS_strchr); + + return UT_GenStub_GetReturnValue(PCS_strchr, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strcmp() + * ---------------------------------------------------- + */ +int PCS_strcmp(const char *s1, const char *s2) +{ + UT_GenStub_SetupReturnBuffer(PCS_strcmp, int); + + UT_GenStub_AddParam(PCS_strcmp, const char *, s1); + UT_GenStub_AddParam(PCS_strcmp, const char *, s2); + + UT_GenStub_Execute(PCS_strcmp, Basic, UT_DefaultHandler_PCS_strcmp); + + return UT_GenStub_GetReturnValue(PCS_strcmp, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strcpy() + * ---------------------------------------------------- + */ +char *PCS_strcpy(char *dest, const char *src) +{ + UT_GenStub_SetupReturnBuffer(PCS_strcpy, char *); + + UT_GenStub_AddParam(PCS_strcpy, char *, dest); + UT_GenStub_AddParam(PCS_strcpy, const char *, src); + + UT_GenStub_Execute(PCS_strcpy, Basic, UT_DefaultHandler_PCS_strcpy); + + return UT_GenStub_GetReturnValue(PCS_strcpy, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strerror() + * ---------------------------------------------------- + */ +char *PCS_strerror(int errnum) +{ + UT_GenStub_SetupReturnBuffer(PCS_strerror, char *); + + UT_GenStub_AddParam(PCS_strerror, int, errnum); + + UT_GenStub_Execute(PCS_strerror, Basic, UT_DefaultHandler_PCS_strerror); + + return UT_GenStub_GetReturnValue(PCS_strerror, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strlen() + * ---------------------------------------------------- + */ +size_t PCS_strlen(const char *s) +{ + UT_GenStub_SetupReturnBuffer(PCS_strlen, size_t); + + UT_GenStub_AddParam(PCS_strlen, const char *, s); + + UT_GenStub_Execute(PCS_strlen, Basic, UT_DefaultHandler_PCS_strlen); + + return UT_GenStub_GetReturnValue(PCS_strlen, size_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strncat() + * ---------------------------------------------------- + */ +char *PCS_strncat(char *dest, const char *src, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_strncat, char *); + + UT_GenStub_AddParam(PCS_strncat, char *, dest); + UT_GenStub_AddParam(PCS_strncat, const char *, src); + UT_GenStub_AddParam(PCS_strncat, size_t, n); + + UT_GenStub_Execute(PCS_strncat, Basic, UT_DefaultHandler_PCS_strncat); + + return UT_GenStub_GetReturnValue(PCS_strncat, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strncmp() + * ---------------------------------------------------- + */ +int PCS_strncmp(const char *s1, const char *s2, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_strncmp, int); + + UT_GenStub_AddParam(PCS_strncmp, const char *, s1); + UT_GenStub_AddParam(PCS_strncmp, const char *, s2); + UT_GenStub_AddParam(PCS_strncmp, size_t, n); + + UT_GenStub_Execute(PCS_strncmp, Basic, UT_DefaultHandler_PCS_strncmp); + + return UT_GenStub_GetReturnValue(PCS_strncmp, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strncpy() + * ---------------------------------------------------- + */ +char *PCS_strncpy(char *dest, const char *src, size_t n) +{ + UT_GenStub_SetupReturnBuffer(PCS_strncpy, char *); + + UT_GenStub_AddParam(PCS_strncpy, char *, dest); + UT_GenStub_AddParam(PCS_strncpy, const char *, src); + UT_GenStub_AddParam(PCS_strncpy, size_t, n); + + UT_GenStub_Execute(PCS_strncpy, Basic, UT_DefaultHandler_PCS_strncpy); + + return UT_GenStub_GetReturnValue(PCS_strncpy, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_strrchr() + * ---------------------------------------------------- + */ +char *PCS_strrchr(const char *s, int c) +{ + UT_GenStub_SetupReturnBuffer(PCS_strrchr, char *); + + UT_GenStub_AddParam(PCS_strrchr, const char *, s); + UT_GenStub_AddParam(PCS_strrchr, int, c); + + UT_GenStub_Execute(PCS_strrchr, Basic, UT_DefaultHandler_PCS_strrchr); + + return UT_GenStub_GetReturnValue(PCS_strrchr, char *); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys950Lib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sys950Lib_stubs.c new file mode 100644 index 00000000..ef26eddf --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys950Lib_stubs.c @@ -0,0 +1,68 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sys950Lib header + */ + +#include "PCS_sys950Lib.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_GetUsecTime() + * ---------------------------------------------------- + */ +double PCS_GetUsecTime(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_GetUsecTime, double); + + UT_GenStub_Execute(PCS_GetUsecTime, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_GetUsecTime, double); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_getCoreClockSpeed() + * ---------------------------------------------------- + */ +uint32_t PCS_getCoreClockSpeed(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_getCoreClockSpeed, uint32_t); + + UT_GenStub_Execute(PCS_getCoreClockSpeed, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_getCoreClockSpeed, uint32_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysGetSlotId() + * ---------------------------------------------------- + */ +int PCS_sysGetSlotId(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysGetSlotId, int); + + UT_GenStub_Execute(PCS_sysGetSlotId, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysGetSlotId, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sysApi_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sysApi_stubs.c new file mode 100644 index 00000000..de842e31 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sysApi_stubs.c @@ -0,0 +1,113 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sysApi header + */ + +#include "PCS_sysApi.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_isCpciSysController() + * ---------------------------------------------------- + */ +bool PCS_isCpciSysController(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_isCpciSysController, bool); + + UT_GenStub_Execute(PCS_isCpciSysController, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_isCpciSysController, bool); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysDisableFpgaWdt() + * ---------------------------------------------------- + */ +int PCS_sysDisableFpgaWdt(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysDisableFpgaWdt, int); + + UT_GenStub_Execute(PCS_sysDisableFpgaWdt, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysDisableFpgaWdt, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysEnableFpgaWdt() + * ---------------------------------------------------- + */ +int PCS_sysEnableFpgaWdt(bool globalReset) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysEnableFpgaWdt, int); + + UT_GenStub_AddParam(PCS_sysEnableFpgaWdt, bool, globalReset); + + UT_GenStub_Execute(PCS_sysEnableFpgaWdt, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysEnableFpgaWdt, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysGetBoardGeneration() + * ---------------------------------------------------- + */ +PCS_SP0_BOARD_GENERATION_TYPE PCS_sysGetBoardGeneration(bool talkative) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysGetBoardGeneration, PCS_SP0_BOARD_GENERATION_TYPE); + + UT_GenStub_AddParam(PCS_sysGetBoardGeneration, bool, talkative); + + UT_GenStub_Execute(PCS_sysGetBoardGeneration, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysGetBoardGeneration, PCS_SP0_BOARD_GENERATION_TYPE); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysPulseFpgaWdt() + * ---------------------------------------------------- + */ +void PCS_sysPulseFpgaWdt(void) +{ + + UT_GenStub_Execute(PCS_sysPulseFpgaWdt, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysSetFpgaWdt() + * ---------------------------------------------------- + */ +int PCS_sysSetFpgaWdt(float secs) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysSetFpgaWdt, int); + + UT_GenStub_AddParam(PCS_sysSetFpgaWdt, float, secs); + + UT_GenStub_Execute(PCS_sysSetFpgaWdt, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysSetFpgaWdt, int); +} diff --git a/unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sysLib_handlers.c similarity index 55% rename from unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c rename to unit-test-coverage/ut-stubs/src/PCS_sysLib_handlers.c index 07f9cbab..2addda5c 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-sysLib-stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_sysLib_handlers.c @@ -23,52 +23,46 @@ #include "PCS_sysLib.h" -int PCS_sysClkRateGet(void) +void UT_DefaultHandler_PCS_sysClkRateGet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - return UT_DEFAULT_IMPL_RC(PCS_sysClkRateGet, 10000); + /* int PCS_sysClkRateGet(void) */ + int DefaultValue = 10000; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + UT_Stub_SetReturnValue(FuncKey, DefaultValue); + } } -char *PCS_sysMemTop(void) +void UT_DefaultHandler_PCS_sysMemTop(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { + /* char *PCS_sysMemTop(void) */ int32 Status; char *BufPtr; BufPtr = NULL; - Status = UT_DEFAULT_IMPL(PCS_sysMemTop); + UT_Stub_GetInt32StatusCode(Context, &Status); if (Status == 0) { UT_GetDataBuffer(UT_KEY(PCS_sysMemTop), (void **)&BufPtr, NULL, NULL); + if (BufPtr != NULL) + { + UT_Stub_SetReturnValue(FuncKey, BufPtr); + } } - - return BufPtr; -} - -void PCS_PciOutByte(uint32_t address, uint8_t data) -{ - UT_DEFAULT_IMPL(PCS_PciOutByte); -} - -void PCS_PciOutLong(uint32_t address, uint32_t data) -{ - UT_DEFAULT_IMPL(PCS_PciOutLong); } -void PCS_sysPciWrite32(uint32_t address, uint32_t data) +void UT_DefaultHandler_PCS_sysPhysMemTop(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - UT_DEFAULT_IMPL(PCS_sysPciWrite32); -} - -void PCS_sysPciRead32(uint32_t address, uint32_t *data) -{ - UT_DEFAULT_IMPL(PCS_sysPciRead32); -} - -unsigned int PCS_GetWrsKernelTextStart(void) -{ - return UT_DEFAULT_IMPL(PCS_GetWrsKernelTextStart); -} + /* char *PCS_sysPhysMemTop(void) */ + int32 Status; + void *BufPtr; -unsigned int PCS_GetWrsKernelTextEnd(void) -{ - return UT_DEFAULT_IMPL(PCS_GetWrsKernelTextEnd); + BufPtr = NULL; + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status == 0) + { + UT_Stub_CopyToLocal(UT_KEY(PCS_sysPhysMemTop), &BufPtr, sizeof(BufPtr)); + UT_Stub_SetReturnValue(FuncKey, BufPtr); + } } diff --git a/unit-test-coverage/ut-stubs/src/PCS_sysLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sysLib_stubs.c new file mode 100644 index 00000000..71361dc3 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sysLib_stubs.c @@ -0,0 +1,208 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sysLib header + */ + +#include "PCS_sysLib.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_sysClkRateGet(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_sysMemTop(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_sysPhysMemTop(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_GetWrsKernelTextEnd() + * ---------------------------------------------------- + */ +unsigned int PCS_GetWrsKernelTextEnd(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_GetWrsKernelTextEnd, unsigned int); + + UT_GenStub_Execute(PCS_GetWrsKernelTextEnd, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_GetWrsKernelTextEnd, unsigned int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_GetWrsKernelTextStart() + * ---------------------------------------------------- + */ +unsigned int PCS_GetWrsKernelTextStart(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_GetWrsKernelTextStart, unsigned int); + + UT_GenStub_Execute(PCS_GetWrsKernelTextStart, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_GetWrsKernelTextStart, unsigned int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_PciOutByte() + * ---------------------------------------------------- + */ +void PCS_PciOutByte(uint32_t address, uint8_t data) +{ + UT_GenStub_AddParam(PCS_PciOutByte, uint32_t, address); + UT_GenStub_AddParam(PCS_PciOutByte, uint8_t, data); + + UT_GenStub_Execute(PCS_PciOutByte, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_PciOutLong() + * ---------------------------------------------------- + */ +void PCS_PciOutLong(uint32_t address, uint32_t data) +{ + UT_GenStub_AddParam(PCS_PciOutLong, uint32_t, address); + UT_GenStub_AddParam(PCS_PciOutLong, uint32_t, data); + + UT_GenStub_Execute(PCS_PciOutLong, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysAuxClkRateGet() + * ---------------------------------------------------- + */ +int PCS_sysAuxClkRateGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysAuxClkRateGet, int); + + UT_GenStub_Execute(PCS_sysAuxClkRateGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysAuxClkRateGet, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysBspRev() + * ---------------------------------------------------- + */ +char *PCS_sysBspRev(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysBspRev, char *); + + UT_GenStub_Execute(PCS_sysBspRev, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysBspRev, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysClkRateGet() + * ---------------------------------------------------- + */ +int PCS_sysClkRateGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysClkRateGet, int); + + UT_GenStub_Execute(PCS_sysClkRateGet, Basic, UT_DefaultHandler_PCS_sysClkRateGet); + + return UT_GenStub_GetReturnValue(PCS_sysClkRateGet, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysMemTop() + * ---------------------------------------------------- + */ +char *PCS_sysMemTop(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysMemTop, char *); + + UT_GenStub_Execute(PCS_sysMemTop, Basic, UT_DefaultHandler_PCS_sysMemTop); + + return UT_GenStub_GetReturnValue(PCS_sysMemTop, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysModel() + * ---------------------------------------------------- + */ +char *PCS_sysModel(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysModel, char *); + + UT_GenStub_Execute(PCS_sysModel, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysModel, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysPciRead32() + * ---------------------------------------------------- + */ +void PCS_sysPciRead32(uint32_t address, uint32_t *data) +{ + UT_GenStub_AddParam(PCS_sysPciRead32, uint32_t, address); + UT_GenStub_AddParam(PCS_sysPciRead32, uint32_t *, data); + + UT_GenStub_Execute(PCS_sysPciRead32, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysPciWrite32() + * ---------------------------------------------------- + */ +void PCS_sysPciWrite32(uint32_t address, uint32_t data) +{ + UT_GenStub_AddParam(PCS_sysPciWrite32, uint32_t, address); + UT_GenStub_AddParam(PCS_sysPciWrite32, uint32_t, data); + + UT_GenStub_Execute(PCS_sysPciWrite32, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysPhysMemTop() + * ---------------------------------------------------- + */ +char *PCS_sysPhysMemTop(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysPhysMemTop, char *); + + UT_GenStub_Execute(PCS_sysPhysMemTop, Basic, UT_DefaultHandler_PCS_sysPhysMemTop); + + return UT_GenStub_GetReturnValue(PCS_sysPhysMemTop, char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysProcNumGet() + * ---------------------------------------------------- + */ +int PCS_sysProcNumGet(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysProcNumGet, int); + + UT_GenStub_Execute(PCS_sysProcNumGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysProcNumGet, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys_mman_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sys_mman_stubs.c new file mode 100644 index 00000000..4f79a4f0 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys_mman_stubs.c @@ -0,0 +1,47 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sys_mman header + */ + +#include "PCS_sys_mman.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_mmap() + * ---------------------------------------------------- + */ +void *PCS_mmap(void *addr, size_t len, int prot, int flags, int fildes, PCS_off_t off) +{ + UT_GenStub_SetupReturnBuffer(PCS_mmap, void *); + + UT_GenStub_AddParam(PCS_mmap, void *, addr); + UT_GenStub_AddParam(PCS_mmap, size_t, len); + UT_GenStub_AddParam(PCS_mmap, int, prot); + UT_GenStub_AddParam(PCS_mmap, int, flags); + UT_GenStub_AddParam(PCS_mmap, int, fildes); + UT_GenStub_AddParam(PCS_mmap, PCS_off_t, off); + + UT_GenStub_Execute(PCS_mmap, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_mmap, void *); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys_select_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sys_select_stubs.c new file mode 100644 index 00000000..b6537206 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys_select_stubs.c @@ -0,0 +1,101 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sys_select header + */ + +#include "PCS_sys_select.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_FD_CLR() + * ---------------------------------------------------- + */ +void PCS_FD_CLR(int fd, PCS_fd_set *set) +{ + UT_GenStub_AddParam(PCS_FD_CLR, int, fd); + UT_GenStub_AddParam(PCS_FD_CLR, PCS_fd_set *, set); + + UT_GenStub_Execute(PCS_FD_CLR, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_FD_ISSET() + * ---------------------------------------------------- + */ +int PCS_FD_ISSET(int fd, PCS_fd_set *set) +{ + UT_GenStub_SetupReturnBuffer(PCS_FD_ISSET, int); + + UT_GenStub_AddParam(PCS_FD_ISSET, int, fd); + UT_GenStub_AddParam(PCS_FD_ISSET, PCS_fd_set *, set); + + UT_GenStub_Execute(PCS_FD_ISSET, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_FD_ISSET, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_FD_SET() + * ---------------------------------------------------- + */ +void PCS_FD_SET(int fd, PCS_fd_set *set) +{ + UT_GenStub_AddParam(PCS_FD_SET, int, fd); + UT_GenStub_AddParam(PCS_FD_SET, PCS_fd_set *, set); + + UT_GenStub_Execute(PCS_FD_SET, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_FD_ZERO() + * ---------------------------------------------------- + */ +void PCS_FD_ZERO(PCS_fd_set *set) +{ + UT_GenStub_AddParam(PCS_FD_ZERO, PCS_fd_set *, set); + + UT_GenStub_Execute(PCS_FD_ZERO, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_select() + * ---------------------------------------------------- + */ +int PCS_select(int nfds, PCS_fd_set *readfds, PCS_fd_set *writefds, PCS_fd_set *exceptfds, struct PCS_timeval *timeout) +{ + UT_GenStub_SetupReturnBuffer(PCS_select, int); + + UT_GenStub_AddParam(PCS_select, int, nfds); + UT_GenStub_AddParam(PCS_select, PCS_fd_set *, readfds); + UT_GenStub_AddParam(PCS_select, PCS_fd_set *, writefds); + UT_GenStub_AddParam(PCS_select, PCS_fd_set *, exceptfds); + UT_GenStub_AddParam(PCS_select, struct PCS_timeval *, timeout); + + UT_GenStub_Execute(PCS_select, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_select, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys_socket_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_sys_socket_handlers.c new file mode 100644 index 00000000..d4e10a52 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys_socket_handlers.c @@ -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://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 userReservedMem.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_sys_socket.h" + +void UT_DefaultHandler_PCS_recvfrom(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_ssize_t PCS_recvfrom(int fd, void *buf, size_t n, int flags, struct PCS_sockaddr *addr, PCS_socklen_t + * *addr_len) */ + void * buf = UT_Hook_GetArgValueByName(Context, "buf", void *); + size_t n = UT_Hook_GetArgValueByName(Context, "n", size_t); + int32 iStatus; + + UT_Stub_GetInt32StatusCode(Context, &iStatus); + + if (iStatus >= 0) + { + if (n > iStatus) + { + n = iStatus; + } + + UT_Stub_CopyToLocal(UT_KEY(PCS_recvfrom), buf, n); + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys_socket_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sys_socket_stubs.c new file mode 100644 index 00000000..729aa66b --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys_socket_stubs.c @@ -0,0 +1,217 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sys_socket header + */ + +#include "PCS_sys_socket.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_recvfrom(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_accept() + * ---------------------------------------------------- + */ +int PCS_accept(int fd, struct PCS_sockaddr *addr, PCS_socklen_t *addr_len) +{ + UT_GenStub_SetupReturnBuffer(PCS_accept, int); + + UT_GenStub_AddParam(PCS_accept, int, fd); + UT_GenStub_AddParam(PCS_accept, struct PCS_sockaddr *, addr); + UT_GenStub_AddParam(PCS_accept, PCS_socklen_t *, addr_len); + + UT_GenStub_Execute(PCS_accept, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_accept, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_bind() + * ---------------------------------------------------- + */ +int PCS_bind(int fd, const struct PCS_sockaddr *addr, PCS_socklen_t len) +{ + UT_GenStub_SetupReturnBuffer(PCS_bind, int); + + UT_GenStub_AddParam(PCS_bind, int, fd); + UT_GenStub_AddParam(PCS_bind, const struct PCS_sockaddr *, addr); + UT_GenStub_AddParam(PCS_bind, PCS_socklen_t, len); + + UT_GenStub_Execute(PCS_bind, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_bind, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_connect() + * ---------------------------------------------------- + */ +int PCS_connect(int fd, const struct PCS_sockaddr *addr, PCS_socklen_t len) +{ + UT_GenStub_SetupReturnBuffer(PCS_connect, int); + + UT_GenStub_AddParam(PCS_connect, int, fd); + UT_GenStub_AddParam(PCS_connect, const struct PCS_sockaddr *, addr); + UT_GenStub_AddParam(PCS_connect, PCS_socklen_t, len); + + UT_GenStub_Execute(PCS_connect, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_connect, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_getsockopt() + * ---------------------------------------------------- + */ +int PCS_getsockopt(int fd, int level, int optname, void *optval, PCS_socklen_t *optlen) +{ + UT_GenStub_SetupReturnBuffer(PCS_getsockopt, int); + + UT_GenStub_AddParam(PCS_getsockopt, int, fd); + UT_GenStub_AddParam(PCS_getsockopt, int, level); + UT_GenStub_AddParam(PCS_getsockopt, int, optname); + UT_GenStub_AddParam(PCS_getsockopt, void *, optval); + UT_GenStub_AddParam(PCS_getsockopt, PCS_socklen_t *, optlen); + + UT_GenStub_Execute(PCS_getsockopt, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_getsockopt, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_listen() + * ---------------------------------------------------- + */ +int PCS_listen(int fd, int n) +{ + UT_GenStub_SetupReturnBuffer(PCS_listen, int); + + UT_GenStub_AddParam(PCS_listen, int, fd); + UT_GenStub_AddParam(PCS_listen, int, n); + + UT_GenStub_Execute(PCS_listen, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_listen, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_recvfrom() + * ---------------------------------------------------- + */ +PCS_ssize_t PCS_recvfrom(int fd, void *buf, size_t n, int flags, struct PCS_sockaddr *addr, PCS_socklen_t *addr_len) +{ + UT_GenStub_SetupReturnBuffer(PCS_recvfrom, PCS_ssize_t); + + UT_GenStub_AddParam(PCS_recvfrom, int, fd); + UT_GenStub_AddParam(PCS_recvfrom, void *, buf); + UT_GenStub_AddParam(PCS_recvfrom, size_t, n); + UT_GenStub_AddParam(PCS_recvfrom, int, flags); + UT_GenStub_AddParam(PCS_recvfrom, struct PCS_sockaddr *, addr); + UT_GenStub_AddParam(PCS_recvfrom, PCS_socklen_t *, addr_len); + + UT_GenStub_Execute(PCS_recvfrom, Basic, UT_DefaultHandler_PCS_recvfrom); + + return UT_GenStub_GetReturnValue(PCS_recvfrom, PCS_ssize_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sendto() + * ---------------------------------------------------- + */ +PCS_ssize_t PCS_sendto(int fd, const void *buf, size_t n, int flags, const struct PCS_sockaddr *addr, + PCS_socklen_t addr_len) +{ + UT_GenStub_SetupReturnBuffer(PCS_sendto, PCS_ssize_t); + + UT_GenStub_AddParam(PCS_sendto, int, fd); + UT_GenStub_AddParam(PCS_sendto, const void *, buf); + UT_GenStub_AddParam(PCS_sendto, size_t, n); + UT_GenStub_AddParam(PCS_sendto, int, flags); + UT_GenStub_AddParam(PCS_sendto, const struct PCS_sockaddr *, addr); + UT_GenStub_AddParam(PCS_sendto, PCS_socklen_t, addr_len); + + UT_GenStub_Execute(PCS_sendto, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sendto, PCS_ssize_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_setsockopt() + * ---------------------------------------------------- + */ +int PCS_setsockopt(int fd, int level, int optname, const void *optval, PCS_socklen_t optlen) +{ + UT_GenStub_SetupReturnBuffer(PCS_setsockopt, int); + + UT_GenStub_AddParam(PCS_setsockopt, int, fd); + UT_GenStub_AddParam(PCS_setsockopt, int, level); + UT_GenStub_AddParam(PCS_setsockopt, int, optname); + UT_GenStub_AddParam(PCS_setsockopt, const void *, optval); + UT_GenStub_AddParam(PCS_setsockopt, PCS_socklen_t, optlen); + + UT_GenStub_Execute(PCS_setsockopt, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_setsockopt, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_shutdown() + * ---------------------------------------------------- + */ +int PCS_shutdown(int fd, int how) +{ + UT_GenStub_SetupReturnBuffer(PCS_shutdown, int); + + UT_GenStub_AddParam(PCS_shutdown, int, fd); + UT_GenStub_AddParam(PCS_shutdown, int, how); + + UT_GenStub_Execute(PCS_shutdown, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_shutdown, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_socket() + * ---------------------------------------------------- + */ +int PCS_socket(int domain, int type, int protocol) +{ + UT_GenStub_SetupReturnBuffer(PCS_socket, int); + + UT_GenStub_AddParam(PCS_socket, int, domain); + UT_GenStub_AddParam(PCS_socket, int, type); + UT_GenStub_AddParam(PCS_socket, int, protocol); + + UT_GenStub_Execute(PCS_socket, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_socket, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys_stat_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_sys_stat_handlers.c new file mode 100644 index 00000000..2fa80670 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys_stat_handlers.c @@ -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. + ************************************************************************/ + +/* PSP coverage stub replacement for userReservedMem.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_sys_stat.h" + +void UT_DefaultHandler_PCS_stat(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_stat(const char *file, struct PCS_stat *buf) */ + struct PCS_stat *buf = UT_Hook_GetArgValueByName(Context, "buf", struct PCS_stat *); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + + if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(PCS_stat), buf, sizeof(*buf)) < sizeof(*buf)) + { + memset(buf, 0, sizeof(*buf)); + } +} + +void UT_DefaultHandler_PCS_statfs(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_statfs(const char *path, struct PCS_statfs *buf) */ + struct PCS_statfs *buf = UT_Hook_GetArgValueByName(Context, "buf", struct PCS_statfs *); + int32 iStatus; + + UT_Stub_GetInt32StatusCode(Context, &iStatus); + + if (iStatus == 0) + { + UT_Stub_CopyToLocal(UT_KEY(PCS_statfs), (struct PCS_statfs *)buf, sizeof(*buf)); + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_sys_stat_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_sys_stat_stubs.c new file mode 100644 index 00000000..89b3b076 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_sys_stat_stubs.c @@ -0,0 +1,63 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_sys_stat header + */ + +#include "PCS_sys_stat.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_stat(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_statfs(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_stat() + * ---------------------------------------------------- + */ +int PCS_stat(const char *path, struct PCS_stat *buf) +{ + UT_GenStub_SetupReturnBuffer(PCS_stat, int); + + UT_GenStub_AddParam(PCS_stat, const char *, path); + UT_GenStub_AddParam(PCS_stat, struct PCS_stat *, buf); + + UT_GenStub_Execute(PCS_stat, Basic, UT_DefaultHandler_PCS_stat); + + return UT_GenStub_GetReturnValue(PCS_stat, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_statfs() + * ---------------------------------------------------- + */ +int PCS_statfs(const char *path, struct PCS_statfs *buf) +{ + UT_GenStub_SetupReturnBuffer(PCS_statfs, int); + + UT_GenStub_AddParam(PCS_statfs, const char *, path); + UT_GenStub_AddParam(PCS_statfs, struct PCS_statfs *, buf); + + UT_GenStub_Execute(PCS_statfs, Basic, UT_DefaultHandler_PCS_statfs); + + return UT_GenStub_GetReturnValue(PCS_statfs, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_taskLib_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_taskLib_handlers.c new file mode 100644 index 00000000..79bfcf30 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_taskLib_handlers.c @@ -0,0 +1,137 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for taskLib.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_taskLib.h" +#include "PCS_errnoLib.h" + +static PCS_WIND_TCB PCS_LOCAL_TASK = {0}; + +void UT_DefaultHandler_PCS_taskPriorityGet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_STATUS PCS_taskPriorityGet(PCS_TASK_ID tid, int *pPriority) */ + int * pPriority = UT_Hook_GetArgValueByName(Context, "pPriority", int *); + int32 iStatus; + + UT_Stub_GetInt32StatusCode(Context, &iStatus); + if (iStatus >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(PCS_taskPriorityGet), (int32 *)pPriority, sizeof(*pPriority)); + } +} + +void UT_DefaultHandler_PCS_taskName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* const char *PCS_taskName(PCS_TASK_ID task_id) */ + + const char *retval; + void * bufptr; + size_t bufsz; + int32 status; + + retval = NULL; + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(FuncKey, &bufptr, &bufsz, NULL); + retval = bufptr; + } + + UT_Stub_SetReturnValue(FuncKey, retval); +} + +void UT_DefaultHandler_PCS_taskIdSelf(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_TASK_ID PCS_taskIdSelf(void) */ + PCS_TASK_ID retval; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + retval = &PCS_LOCAL_TASK; + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +void UT_DefaultHandler_PCS_taskNameToId(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_TASK_ID PCS_taskNameToId(const char *name) */ + PCS_TASK_ID retval; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + retval = &PCS_LOCAL_TASK; + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +void UT_DefaultHandler_PCS_taskSpawn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_TASK_ID PCS_taskSpawn(char *name, int priority, int options, int stackSize, PCS_FUNCPTR entryPt, int arg1, + int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10) */ + PCS_TASK_ID retval; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + retval = &PCS_LOCAL_TASK; + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +void UT_DefaultHandler_PCS_taskTcb(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_WIND_TCB *PCS_taskTcb(PCS_TASK_ID tid) */ + PCS_TASK_ID tid = UT_Hook_GetArgValueByName(Context, "tid", PCS_TASK_ID); + PCS_WIND_TCB *LocalTcb; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(PCS_taskTcb), &LocalTcb, sizeof(LocalTcb)) < sizeof(LocalTcb)) + { + /* + * On VxWorks the TASK_ID is defined as a direct type cast + * of the TCB address. This is actually documented + * in the API and application code that works with TCBs + * certainly will depend on this being the case. + */ + LocalTcb = (PCS_WIND_TCB *)tid; + } + } + else + { + LocalTcb = NULL; + } + + UT_Stub_SetReturnValue(FuncKey, LocalTcb); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_taskLib_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_taskLib_stubs.c new file mode 100644 index 00000000..550ecc25 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_taskLib_stubs.c @@ -0,0 +1,367 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_taskLib header + */ + +#include "PCS_taskLib.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_taskIdSelf(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_taskName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_taskNameToId(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_taskPriorityGet(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_taskSpawn(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_taskTcb(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskActivate() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskActivate(PCS_TASK_ID tid) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskActivate, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskActivate, PCS_TASK_ID, tid); + + UT_GenStub_Execute(PCS_taskActivate, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskActivate, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskDelay() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskDelay(int ticks) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskDelay, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskDelay, int, ticks); + + UT_GenStub_Execute(PCS_taskDelay, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskDelay, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskDelete() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskDelete(PCS_TASK_ID tid) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskDelete, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskDelete, PCS_TASK_ID, tid); + + UT_GenStub_Execute(PCS_taskDelete, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskDelete, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskDeleteForce() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskDeleteForce(PCS_TASK_ID tid) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskDeleteForce, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskDeleteForce, PCS_TASK_ID, tid); + + UT_GenStub_Execute(PCS_taskDeleteForce, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskDeleteForce, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskExit() + * ---------------------------------------------------- + */ +void PCS_taskExit(int code) +{ + UT_GenStub_AddParam(PCS_taskExit, int, code); + + UT_GenStub_Execute(PCS_taskExit, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskGetInfo() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskGetInfo(PCS_TASK_ID task_id, PCS_TASK_DESC *desc) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskGetInfo, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskGetInfo, PCS_TASK_ID, task_id); + UT_GenStub_AddParam(PCS_taskGetInfo, PCS_TASK_DESC *, desc); + + UT_GenStub_Execute(PCS_taskGetInfo, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskGetInfo, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskIdDefault() + * ---------------------------------------------------- + */ +PCS_TASK_ID PCS_taskIdDefault(PCS_TASK_ID task_id) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskIdDefault, PCS_TASK_ID); + + UT_GenStub_AddParam(PCS_taskIdDefault, PCS_TASK_ID, task_id); + + UT_GenStub_Execute(PCS_taskIdDefault, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskIdDefault, PCS_TASK_ID); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskIdSelf() + * ---------------------------------------------------- + */ +PCS_TASK_ID PCS_taskIdSelf(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskIdSelf, PCS_TASK_ID); + + UT_GenStub_Execute(PCS_taskIdSelf, Basic, UT_DefaultHandler_PCS_taskIdSelf); + + return UT_GenStub_GetReturnValue(PCS_taskIdSelf, PCS_TASK_ID); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskInit() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskInit(PCS_WIND_TCB *pTcb, char *name, int priority, int options, char *pStackBase, int stackSize, + PCS_FUNCPTR entryPt, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, + int arg8, int arg9, int arg10) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskInit, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskInit, PCS_WIND_TCB *, pTcb); + UT_GenStub_AddParam(PCS_taskInit, char *, name); + UT_GenStub_AddParam(PCS_taskInit, int, priority); + UT_GenStub_AddParam(PCS_taskInit, int, options); + UT_GenStub_AddParam(PCS_taskInit, char *, pStackBase); + UT_GenStub_AddParam(PCS_taskInit, int, stackSize); + UT_GenStub_AddParam(PCS_taskInit, PCS_FUNCPTR, entryPt); + UT_GenStub_AddParam(PCS_taskInit, int, arg1); + UT_GenStub_AddParam(PCS_taskInit, int, arg2); + UT_GenStub_AddParam(PCS_taskInit, int, arg3); + UT_GenStub_AddParam(PCS_taskInit, int, arg4); + UT_GenStub_AddParam(PCS_taskInit, int, arg5); + UT_GenStub_AddParam(PCS_taskInit, int, arg6); + UT_GenStub_AddParam(PCS_taskInit, int, arg7); + UT_GenStub_AddParam(PCS_taskInit, int, arg8); + UT_GenStub_AddParam(PCS_taskInit, int, arg9); + UT_GenStub_AddParam(PCS_taskInit, int, arg10); + + UT_GenStub_Execute(PCS_taskInit, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskInit, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskIsReady() + * ---------------------------------------------------- + */ +PCS_BOOL PCS_taskIsReady(PCS_TASK_ID task_id) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskIsReady, PCS_BOOL); + + UT_GenStub_AddParam(PCS_taskIsReady, PCS_TASK_ID, task_id); + + UT_GenStub_Execute(PCS_taskIsReady, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskIsReady, PCS_BOOL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskIsSuspended() + * ---------------------------------------------------- + */ +PCS_BOOL PCS_taskIsSuspended(PCS_TASK_ID task_id) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskIsSuspended, PCS_BOOL); + + UT_GenStub_AddParam(PCS_taskIsSuspended, PCS_TASK_ID, task_id); + + UT_GenStub_Execute(PCS_taskIsSuspended, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskIsSuspended, PCS_BOOL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskName() + * ---------------------------------------------------- + */ +const char *PCS_taskName(PCS_TASK_ID task_id) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskName, const char *); + + UT_GenStub_AddParam(PCS_taskName, PCS_TASK_ID, task_id); + + UT_GenStub_Execute(PCS_taskName, Basic, UT_DefaultHandler_PCS_taskName); + + return UT_GenStub_GetReturnValue(PCS_taskName, const char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskNameToId() + * ---------------------------------------------------- + */ +PCS_TASK_ID PCS_taskNameToId(const char *name) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskNameToId, PCS_TASK_ID); + + UT_GenStub_AddParam(PCS_taskNameToId, const char *, name); + + UT_GenStub_Execute(PCS_taskNameToId, Basic, UT_DefaultHandler_PCS_taskNameToId); + + return UT_GenStub_GetReturnValue(PCS_taskNameToId, PCS_TASK_ID); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskPriorityGet() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskPriorityGet(PCS_TASK_ID tid, int *pPriority) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskPriorityGet, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskPriorityGet, PCS_TASK_ID, tid); + UT_GenStub_AddParam(PCS_taskPriorityGet, int *, pPriority); + + UT_GenStub_Execute(PCS_taskPriorityGet, Basic, UT_DefaultHandler_PCS_taskPriorityGet); + + return UT_GenStub_GetReturnValue(PCS_taskPriorityGet, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskPrioritySet() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskPrioritySet(PCS_TASK_ID tid, int newPriority) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskPrioritySet, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskPrioritySet, PCS_TASK_ID, tid); + UT_GenStub_AddParam(PCS_taskPrioritySet, int, newPriority); + + UT_GenStub_Execute(PCS_taskPrioritySet, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskPrioritySet, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskResume() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskResume(PCS_TASK_ID tid) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskResume, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskResume, PCS_TASK_ID, tid); + + UT_GenStub_Execute(PCS_taskResume, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskResume, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskSpawn() + * ---------------------------------------------------- + */ +PCS_TASK_ID PCS_taskSpawn(char *name, int priority, int options, int stackSize, PCS_FUNCPTR entryPt, int arg1, int arg2, + int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskSpawn, PCS_TASK_ID); + + UT_GenStub_AddParam(PCS_taskSpawn, char *, name); + UT_GenStub_AddParam(PCS_taskSpawn, int, priority); + UT_GenStub_AddParam(PCS_taskSpawn, int, options); + UT_GenStub_AddParam(PCS_taskSpawn, int, stackSize); + UT_GenStub_AddParam(PCS_taskSpawn, PCS_FUNCPTR, entryPt); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg1); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg2); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg3); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg4); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg5); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg6); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg7); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg8); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg9); + UT_GenStub_AddParam(PCS_taskSpawn, int, arg10); + + UT_GenStub_Execute(PCS_taskSpawn, Basic, UT_DefaultHandler_PCS_taskSpawn); + + return UT_GenStub_GetReturnValue(PCS_taskSpawn, PCS_TASK_ID); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskSuspend() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_taskSuspend(PCS_TASK_ID tid) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskSuspend, PCS_STATUS); + + UT_GenStub_AddParam(PCS_taskSuspend, PCS_TASK_ID, tid); + + UT_GenStub_Execute(PCS_taskSuspend, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_taskSuspend, PCS_STATUS); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_taskTcb() + * ---------------------------------------------------- + */ +PCS_WIND_TCB *PCS_taskTcb(PCS_TASK_ID tid) +{ + UT_GenStub_SetupReturnBuffer(PCS_taskTcb, PCS_WIND_TCB *); + + UT_GenStub_AddParam(PCS_taskTcb, PCS_TASK_ID, tid); + + UT_GenStub_Execute(PCS_taskTcb, Basic, UT_DefaultHandler_PCS_taskTcb); + + return UT_GenStub_GetReturnValue(PCS_taskTcb, PCS_WIND_TCB *); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c new file mode 100644 index 00000000..3ad64e40 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c @@ -0,0 +1,38 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* PSP coverage stub replacement for userReservedMem.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_time.h" + +void UT_DefaultHandler_PCS_clock_gettime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_clock_gettime(int clk_id, struct PCS_timespec *t) */ + struct PCS_timespec *t = UT_Hook_GetArgValueByName(Context, "t", struct PCS_timespec *); + int iStatus; + + UT_Stub_GetInt32StatusCode(Context, &iStatus); + + if (iStatus >= 0) + { + UT_Stub_CopyToLocal(UT_KEY(PCS_clock_gettime), (struct PCS_timespec *)t, sizeof(*t)); + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_time_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_time_stubs.c new file mode 100644 index 00000000..52a3544e --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_time_stubs.c @@ -0,0 +1,62 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_time header + */ + +#include "PCS_time.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_clock_gettime(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_clock_gettime() + * ---------------------------------------------------- + */ +int PCS_clock_gettime(int clk_id, struct PCS_timespec *t) +{ + UT_GenStub_SetupReturnBuffer(PCS_clock_gettime, int); + + UT_GenStub_AddParam(PCS_clock_gettime, int, clk_id); + UT_GenStub_AddParam(PCS_clock_gettime, struct PCS_timespec *, t); + + UT_GenStub_Execute(PCS_clock_gettime, Basic, UT_DefaultHandler_PCS_clock_gettime); + + return UT_GenStub_GetReturnValue(PCS_clock_gettime, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_clock_settime() + * ---------------------------------------------------- + */ +int PCS_clock_settime(int clk_id, struct PCS_timespec *t) +{ + UT_GenStub_SetupReturnBuffer(PCS_clock_settime, int); + + UT_GenStub_AddParam(PCS_clock_settime, int, clk_id); + UT_GenStub_AddParam(PCS_clock_settime, struct PCS_timespec *, t); + + UT_GenStub_Execute(PCS_clock_settime, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_clock_settime, int); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_unistd_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_unistd_handlers.c new file mode 100644 index 00000000..adcbaf81 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_unistd_handlers.c @@ -0,0 +1,158 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/************************************************************************ + * Note that this file has been cloned-n-owned from its open-source github + * repository for Gateway as of September 2023. Therefore, it is subject to + * NASA Export Control restrictions, as stated below. + ************************************************************************/ + +/************************************************************************/ +/** \export_control EAR ECCN 9E515.a and/or 9E515.f (HALO) + * + * Export Administration Regulations (EAR) Notice + * + * This document contains information which falls under the purview of the + * Export Administration Regulations (EAR), 15 CFR §730-774 and is export + * controlled. It may be used only to fulfill responsibilities of the Parties + * of, or a Cooperating Agency of a NASA Gateway Program Partner (CSA, ESA, + * JAXA, MBRSC) and their contractors in furtherance of the Gateway MOUs + * with ESA, CSA, and Japan and IA with MBRSC. Any use, re-transfer, or + * disclosure to any party for any purpose other than the designated use of + * fulfilling the responsibilities of the Gateway MOUs and IA requires prior + * U.S. Government authorization. + *************************************************************************/ + +/* PSP coverage stub replacement for unistd.h */ +#include +#include +#include "utstubs.h" + +#include "PCS_unistd.h" + +#define PCS_MAX_RDWR_SIZE 0x01000000 /* 16MB */ + +void UT_DefaultHandler_PCS_gethostname(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int PCS_gethostname(char *name, size_t len) */ + char * name = UT_Hook_GetArgValueByName(Context, "name", char *); + size_t len = UT_Hook_GetArgValueByName(Context, "len", size_t); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + + if (Status == 0 && len > 0) + { + strncpy(name, "ut", len - 1); + name[len - 1] = 0; + } +} + +void UT_DefaultHandler_PCS_read(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_ssize_t PCS_read(int fd, void *buf, size_t nbytes) */ + void * buf = UT_Hook_GetArgValueByName(Context, "buf", void *); + size_t nbytes = UT_Hook_GetArgValueByName(Context, "nbytes", size_t); + int32 Status; + size_t CopySize; + PCS_ssize_t retval; + + if (!UT_Stub_GetInt32StatusCode(Context, &Status)) + { + Status = PCS_MAX_RDWR_SIZE; + } + + if (Status > 0) + { + if (Status > nbytes) + { + CopySize = nbytes; + } + else + { + CopySize = Status; + } + + CopySize = UT_Stub_CopyToLocal(FuncKey, buf, CopySize); + + if (CopySize != 0) + { + retval = CopySize; + } + else if (Status <= nbytes) + { + memset(buf, 'r', Status); + retval = Status; + } + else if (UT_GetStubCount(FuncKey < 4)) + { + memset(buf, 'r', nbytes); + retval = nbytes; + } + else + { + retval = 0; + } + + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +void UT_DefaultHandler_PCS_write(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* PCS_ssize_t PCS_write(int fd, const void *buf, size_t nbytes) */ + const void *buf = UT_Hook_GetArgValueByName(Context, "buf", const void *); + size_t nbytes = UT_Hook_GetArgValueByName(Context, "nbytes", size_t); + int32 Status; + size_t CopySize; + PCS_ssize_t retval; + + if (!UT_Stub_GetInt32StatusCode(Context, &Status)) + { + Status = PCS_MAX_RDWR_SIZE; + } + + if (Status > 0) + { + if (Status > nbytes) + { + CopySize = nbytes; + } + else + { + CopySize = Status; + } + + CopySize = UT_Stub_CopyFromLocal(FuncKey, buf, CopySize); + + if (CopySize != 0) + { + retval = CopySize; + } + else if (Status > nbytes) + { + retval = nbytes; + } + else + { + retval = Status; + } + + UT_Stub_SetReturnValue(FuncKey, retval); + } +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_unistd_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_unistd_stubs.c new file mode 100644 index 00000000..5b046f90 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_unistd_stubs.c @@ -0,0 +1,205 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_unistd header + */ + +#include "PCS_unistd.h" +#include "utgenstub.h" + +void UT_DefaultHandler_PCS_gethostname(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_read(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_PCS_write(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_close() + * ---------------------------------------------------- + */ +int PCS_close(int fd) +{ + UT_GenStub_SetupReturnBuffer(PCS_close, int); + + UT_GenStub_AddParam(PCS_close, int, fd); + + UT_GenStub_Execute(PCS_close, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_close, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_getegid() + * ---------------------------------------------------- + */ +PCS_gid_t PCS_getegid(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_getegid, PCS_gid_t); + + UT_GenStub_Execute(PCS_getegid, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_getegid, PCS_gid_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_geteuid() + * ---------------------------------------------------- + */ +PCS_uid_t PCS_geteuid(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_geteuid, PCS_uid_t); + + UT_GenStub_Execute(PCS_geteuid, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_geteuid, PCS_uid_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_gethostid() + * ---------------------------------------------------- + */ +long int PCS_gethostid(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_gethostid, long int); + + UT_GenStub_Execute(PCS_gethostid, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_gethostid, long int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_gethostname() + * ---------------------------------------------------- + */ +int PCS_gethostname(char *name, size_t len) +{ + UT_GenStub_SetupReturnBuffer(PCS_gethostname, int); + + UT_GenStub_AddParam(PCS_gethostname, char *, name); + UT_GenStub_AddParam(PCS_gethostname, size_t, len); + + UT_GenStub_Execute(PCS_gethostname, Basic, UT_DefaultHandler_PCS_gethostname); + + return UT_GenStub_GetReturnValue(PCS_gethostname, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_getpid() + * ---------------------------------------------------- + */ +PCS_pid_t PCS_getpid(void) +{ + UT_GenStub_SetupReturnBuffer(PCS_getpid, PCS_pid_t); + + UT_GenStub_Execute(PCS_getpid, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_getpid, PCS_pid_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_lseek() + * ---------------------------------------------------- + */ +PCS_off_t PCS_lseek(int fd, PCS_off_t offset, int whence) +{ + UT_GenStub_SetupReturnBuffer(PCS_lseek, PCS_off_t); + + UT_GenStub_AddParam(PCS_lseek, int, fd); + UT_GenStub_AddParam(PCS_lseek, PCS_off_t, offset); + UT_GenStub_AddParam(PCS_lseek, int, whence); + + UT_GenStub_Execute(PCS_lseek, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_lseek, PCS_off_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_read() + * ---------------------------------------------------- + */ +PCS_ssize_t PCS_read(int fd, void *buf, size_t nbytes) +{ + UT_GenStub_SetupReturnBuffer(PCS_read, PCS_ssize_t); + + UT_GenStub_AddParam(PCS_read, int, fd); + UT_GenStub_AddParam(PCS_read, void *, buf); + UT_GenStub_AddParam(PCS_read, size_t, nbytes); + + UT_GenStub_Execute(PCS_read, Basic, UT_DefaultHandler_PCS_read); + + return UT_GenStub_GetReturnValue(PCS_read, PCS_ssize_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rmdir() + * ---------------------------------------------------- + */ +int PCS_rmdir(const char *path) +{ + UT_GenStub_SetupReturnBuffer(PCS_rmdir, int); + + UT_GenStub_AddParam(PCS_rmdir, const char *, path); + + UT_GenStub_Execute(PCS_rmdir, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_rmdir, int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_sysconf() + * ---------------------------------------------------- + */ +long int PCS_sysconf(int name) +{ + UT_GenStub_SetupReturnBuffer(PCS_sysconf, long int); + + UT_GenStub_AddParam(PCS_sysconf, int, name); + + UT_GenStub_Execute(PCS_sysconf, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_sysconf, long int); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_write() + * ---------------------------------------------------- + */ +PCS_ssize_t PCS_write(int fd, const void *buf, size_t nbytes) +{ + UT_GenStub_SetupReturnBuffer(PCS_write, PCS_ssize_t); + + UT_GenStub_AddParam(PCS_write, int, fd); + UT_GenStub_AddParam(PCS_write, const void *, buf); + UT_GenStub_AddParam(PCS_write, size_t, nbytes); + + UT_GenStub_Execute(PCS_write, Basic, UT_DefaultHandler_PCS_write); + + return UT_GenStub_GetReturnValue(PCS_write, PCS_ssize_t); +} diff --git a/unit-test-coverage/ut-stubs/src/PCS_xbdBlkDev_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_xbdBlkDev_stubs.c new file mode 100644 index 00000000..75dc467a --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/PCS_xbdBlkDev_stubs.c @@ -0,0 +1,60 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in PCS_xbdBlkDev header + */ + +#include "PCS_xbdBlkDev.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_xbdBlkDevCreateSync() + * ---------------------------------------------------- + */ +PCS_device_t PCS_xbdBlkDevCreateSync(PCS_BLK_DEV *bd, const char *name) +{ + UT_GenStub_SetupReturnBuffer(PCS_xbdBlkDevCreateSync, PCS_device_t); + + UT_GenStub_AddParam(PCS_xbdBlkDevCreateSync, PCS_BLK_DEV *, bd); + UT_GenStub_AddParam(PCS_xbdBlkDevCreateSync, const char *, name); + + UT_GenStub_Execute(PCS_xbdBlkDevCreateSync, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_xbdBlkDevCreateSync, PCS_device_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_xbdBlkDevDelete() + * ---------------------------------------------------- + */ +PCS_STATUS PCS_xbdBlkDevDelete(PCS_device_t dev, PCS_BLK_DEV **ppbd) +{ + UT_GenStub_SetupReturnBuffer(PCS_xbdBlkDevDelete, PCS_STATUS); + + UT_GenStub_AddParam(PCS_xbdBlkDevDelete, PCS_device_t, dev); + UT_GenStub_AddParam(PCS_xbdBlkDevDelete, PCS_BLK_DEV **, ppbd); + + UT_GenStub_Execute(PCS_xbdBlkDevDelete, Basic, NULL); + + return UT_GenStub_GetReturnValue(PCS_xbdBlkDevDelete, PCS_STATUS); +} diff --git a/unit-test-coverage/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c b/unit-test-coverage/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c new file mode 100644 index 00000000..56c92a58 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c @@ -0,0 +1,97 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_exceptionstorage_api header + */ + +#include "cfe_psp_exceptionstorage_api.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_ExceptionGetSummary_Impl() + * ---------------------------------------------------- + */ +int32 CFE_PSP_ExceptionGetSummary_Impl(const struct CFE_PSP_Exception_LogData *Buffer, char *ReasonBuf, + uint32 ReasonSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_ExceptionGetSummary_Impl, int32); + + UT_GenStub_AddParam(CFE_PSP_ExceptionGetSummary_Impl, const struct CFE_PSP_Exception_LogData *, Buffer); + UT_GenStub_AddParam(CFE_PSP_ExceptionGetSummary_Impl, char *, ReasonBuf); + UT_GenStub_AddParam(CFE_PSP_ExceptionGetSummary_Impl, uint32, ReasonSize); + + UT_GenStub_Execute(CFE_PSP_ExceptionGetSummary_Impl, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_ExceptionGetSummary_Impl, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_GetBuffer() + * ---------------------------------------------------- + */ +struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetBuffer(uint32 seq) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_GetBuffer, struct CFE_PSP_Exception_LogData *); + + UT_GenStub_AddParam(CFE_PSP_Exception_GetBuffer, uint32, seq); + + UT_GenStub_Execute(CFE_PSP_Exception_GetBuffer, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_GetBuffer, struct CFE_PSP_Exception_LogData *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_GetNextContextBuffer() + * ---------------------------------------------------- + */ +struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetNextContextBuffer(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_GetNextContextBuffer, struct CFE_PSP_Exception_LogData *); + + UT_GenStub_Execute(CFE_PSP_Exception_GetNextContextBuffer, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_GetNextContextBuffer, struct CFE_PSP_Exception_LogData *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_Reset() + * ---------------------------------------------------- + */ +void CFE_PSP_Exception_Reset(void) +{ + + UT_GenStub_Execute(CFE_PSP_Exception_Reset, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_WriteComplete() + * ---------------------------------------------------- + */ +void CFE_PSP_Exception_WriteComplete(void) +{ + + UT_GenStub_Execute(CFE_PSP_Exception_WriteComplete, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/cfe_psp_memory_stubs.c b/unit-test-coverage/ut-stubs/src/cfe_psp_memory_stubs.c new file mode 100644 index 00000000..61021c14 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/cfe_psp_memory_stubs.c @@ -0,0 +1,64 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_memory header + */ + +#include "cfe_psp_memory.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_DeleteProcessorReservedMemory() + * ---------------------------------------------------- + */ +void CFE_PSP_DeleteProcessorReservedMemory(void) +{ + + UT_GenStub_Execute(CFE_PSP_DeleteProcessorReservedMemory, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_InitProcessorReservedMemory() + * ---------------------------------------------------- + */ +int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_InitProcessorReservedMemory, int32); + + UT_GenStub_AddParam(CFE_PSP_InitProcessorReservedMemory, uint32, RestartType); + + UT_GenStub_Execute(CFE_PSP_InitProcessorReservedMemory, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_InitProcessorReservedMemory, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_SetupReservedMemoryMap() + * ---------------------------------------------------- + */ +void CFE_PSP_SetupReservedMemoryMap(void) +{ + + UT_GenStub_Execute(CFE_PSP_SetupReservedMemoryMap, Basic, NULL); +} diff --git a/unit-test-coverage/ut-stubs/src/cfe_psp_module_stubs.c b/unit-test-coverage/ut-stubs/src/cfe_psp_module_stubs.c new file mode 100644 index 00000000..714d53e4 --- /dev/null +++ b/unit-test-coverage/ut-stubs/src/cfe_psp_module_stubs.c @@ -0,0 +1,102 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_module header + */ + +#include "cfe_psp_module.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_ModuleInit() + * ---------------------------------------------------- + */ +void CFE_PSP_ModuleInit(void) +{ + + UT_GenStub_Execute(CFE_PSP_ModuleInit, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_ModuleInitList() + * ---------------------------------------------------- + */ +void CFE_PSP_ModuleInitList(CFE_PSP_ModuleListWrapper_t *WrapPtr, uint32 BaseId, CFE_StaticModuleLoadEntry_t *ListPtr) +{ + UT_GenStub_AddParam(CFE_PSP_ModuleInitList, CFE_PSP_ModuleListWrapper_t *, WrapPtr); + UT_GenStub_AddParam(CFE_PSP_ModuleInitList, uint32, BaseId); + UT_GenStub_AddParam(CFE_PSP_ModuleInitList, CFE_StaticModuleLoadEntry_t *, ListPtr); + + UT_GenStub_Execute(CFE_PSP_ModuleInitList, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Module_FindByName() + * ---------------------------------------------------- + */ +int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Module_FindByName, int32); + + UT_GenStub_AddParam(CFE_PSP_Module_FindByName, const char *, ModuleName); + UT_GenStub_AddParam(CFE_PSP_Module_FindByName, uint32 *, PspModuleId); + + UT_GenStub_Execute(CFE_PSP_Module_FindByName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Module_FindByName, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Module_GetAPIEntry() + * ---------------------------------------------------- + */ +int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Module_GetAPIEntry, int32); + + UT_GenStub_AddParam(CFE_PSP_Module_GetAPIEntry, uint32, PspModuleId); + UT_GenStub_AddParam(CFE_PSP_Module_GetAPIEntry, CFE_PSP_ModuleApi_t **, API); + + UT_GenStub_Execute(CFE_PSP_Module_GetAPIEntry, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Module_GetAPIEntry, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Module_SearchNameInList() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_Module_SearchNameInList(const CFE_PSP_ModuleListWrapper_t *WrapPtr, const char *ModuleName) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Module_SearchNameInList, uint32); + + UT_GenStub_AddParam(CFE_PSP_Module_SearchNameInList, const CFE_PSP_ModuleListWrapper_t *, WrapPtr); + UT_GenStub_AddParam(CFE_PSP_Module_SearchNameInList, const char *, ModuleName); + + UT_GenStub_Execute(CFE_PSP_Module_SearchNameInList, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Module_SearchNameInList, uint32); +} diff --git a/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c b/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c deleted file mode 100644 index d5f43c3b..00000000 --- a/unit-test-coverage/ut-stubs/src/libc-stdio-stubs.c +++ /dev/null @@ -1,206 +0,0 @@ -/************************************************************************ - * 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. - ************************************************************************/ - -/* PSP coverage stub replacement for stdio.h */ -#include -#include -#include -#include "utstubs.h" - -#include "PCS_stdio.h" - -struct PCS_FILE -{ - int f; -}; - -#define PCS_STDIO_MAX_SIZE 0x01000000 - -int PCS_fclose(PCS_FILE *stream) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_fclose); - - return Status; -} - -char *PCS_fgets(char *s, int n, PCS_FILE *stream) -{ - int32 Status; - uint32 CopySize; - - Status = UT_DEFAULT_IMPL_RC(PCS_fgets, PCS_STDIO_MAX_SIZE); - - if (Status > 0) - { - if (Status > n) - { - CopySize = n; - } - else - { - CopySize = Status; - } - - CopySize = UT_Stub_CopyToLocal(UT_KEY(PCS_fgets), s, CopySize); - - if (CopySize != 0) - { - Status = CopySize; - } - else if (Status <= n) - { - memset(s, 'x', Status); - } - else if (UT_GetStubCount(UT_KEY(PCS_fgets) < 4)) - { - memset(s, 'x', n); - Status = n; - } - else - { - Status = 0; - } - } - - if (Status <= 0) - { - return NULL; - } - - return s; -} - -PCS_FILE *PCS_fopen(const char *filename, const char *modes) -{ - int32 Status; - PCS_FILE * retval; - static PCS_FILE FOPEN_FP = {0}; - - Status = UT_DEFAULT_IMPL(PCS_fopen); - - if (Status == 0) - { - retval = &FOPEN_FP; - } - else - { - retval = NULL; - } - - return retval; -} - -int PCS_fputs(const char *s, PCS_FILE *stream) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_fputs); - - return Status; -} - -int PCS_putchar(int c) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_putchar); - - return Status; -} - -int PCS_remove(const char *filename) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_remove); - - return Status; -} - -int PCS_rename(const char *old, const char *nw) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_rename); - - return Status; -} - -int PCS_snprintf(char *s, size_t maxlen, const char *format, ...) -{ - int32 Status; - int actual = 0; - va_list ap; - - Status = UT_DEFAULT_IMPL(PCS_snprintf); - - /* need to actually _do_ the snprintf */ - if (Status >= 0) - { - va_start(ap, format); - actual = vsnprintf(s, maxlen, format, ap); - va_end(ap); - } - - if (Status != 0) - { - actual = Status; - } - - return actual; -} - -int PCS_vsnprintf(char *s, size_t maxlen, const char *format, PCS_va_list arg) -{ - int32 Status; - int actual = 0; - - Status = UT_DEFAULT_IMPL(PCS_vsnprintf); - - /* need to actually _do_ something here - - * cannot do the real vsnprintf because we lost the args. */ - if (Status >= 0) - { - actual = snprintf(s, maxlen, "%s", format); - } - - if (Status != 0) - { - actual = Status; - } - - return actual; -} - -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]; -PCS_FILE *PCS_stdout = &LOCAL_FP[1]; -PCS_FILE *PCS_stderr = &LOCAL_FP[2]; diff --git a/unit-test-coverage/ut-stubs/src/libc-string-stubs.c b/unit-test-coverage/ut-stubs/src/libc-string-stubs.c deleted file mode 100644 index adb92ed0..00000000 --- a/unit-test-coverage/ut-stubs/src/libc-string-stubs.c +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************ - * 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. - ************************************************************************/ - -/* PSP coverage stub replacement for string.h */ -#include -#include -#include -#include "utstubs.h" - -#include "PCS_string.h" - -void *PCS_memset(void *s, int c, size_t n) -{ - int32 Status; - void *Result; - - Status = UT_DEFAULT_IMPL(PCS_memset); - - if (Status == 0) - { - Result = memset(s, c, n); - } - else - { - Result = NULL; - } - - return Result; -} - -void *PCS_memcpy(void *dest, const void *src, size_t n) -{ - int32 Status; - void *Result; - - Status = UT_DEFAULT_IMPL(PCS_memcpy); - - if (Status == 0) - { - Result = memcpy(dest, src, n); - } - else - { - Result = NULL; - } - - return Result; -} - -char *PCS_strchr(const char *s, int c) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strchr); - - if (Status == 0) - { - /* "nominal" response */ - return strchr(s, c); - } - if (Status < 0) - { - return (char *)0; - } - - return (char *)&s[Status - 1]; -} - -char *PCS_strrchr(const char *s, int c) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strrchr); - - if (Status == 0) - { - /* "nominal" response */ - return strrchr(s, c); - } - if (Status < 0) - { - return (char *)0; - } - - return (char *)&s[Status - 1]; -} - -size_t PCS_strlen(const char *s) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL_RC(PCS_strlen, strlen(s)); - - return Status; -} - -char *PCS_strcat(char *dest, const char *src) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strcat); - - if (Status == 0) - { - /* "nominal" response */ - return strcat(dest, src); - } - - return (char *)0; -} - -char *PCS_strncat(char *dest, const char *src, size_t size) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strncat); - - if (Status == 0) - { - /* "nominal" response */ - return strncat(dest, src, size); - } - - return (char *)0; -} - -int PCS_strncmp(const char *s1, const char *s2, size_t size) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL_RC(PCS_strncmp, strncmp(s1, s2, size)); - - return Status; -} - -int PCS_strcmp(const char *s1, const char *s2) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL_RC(PCS_strcmp, strcmp(s1, s2)); - - return Status; -} - -char *PCS_strcpy(char *dst, const char *src) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strcpy); - - if (Status == 0) - { - /* "nominal" response */ - return strcpy(dst, src); - } - - return (char *)0; -} - -char *PCS_strncpy(char *dst, const char *src, size_t size) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strncpy); - - if (Status == 0) - { - /* "nominal" response */ - return strncpy(dst, src, size); - } - - return (char *)0; -} - -char *PCS_strerror(int errnum) -{ - static char str[16]; - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_strerror); - - if (Status != 0) - { - return NULL; - } - - /* "nominal" response */ - snprintf(str, sizeof(str), "UT_ERR_%d", errnum); - return str; -} diff --git a/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c b/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c deleted file mode 100644 index 7d433954..00000000 --- a/unit-test-coverage/ut-stubs/src/vxworks-taskLib-stubs.c +++ /dev/null @@ -1,159 +0,0 @@ -/************************************************************************ - * 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. - ************************************************************************/ - -/* PSP coverage stub replacement for taskLib.h */ -#include -#include -#include "utstubs.h" - -#include "PCS_taskLib.h" -#include "PCS_errnoLib.h" - -static PCS_WIND_TCB PCS_LOCAL_TASK = {0}; - -const char *PCS_taskName(PCS_TASK_ID task_id) -{ - const char *retval; - int32 Status; - - retval = NULL; - Status = UT_DEFAULT_IMPL(PCS_taskName); - if (Status == 0) - { - UT_Stub_CopyToLocal(UT_KEY(PCS_taskName), &retval, sizeof(retval)); - } - - return retval; -} - -void PCS_taskExit(int code) -{ - UT_DEFAULT_IMPL(PCS_taskExit); -} - -PCS_TASK_ID PCS_taskIdSelf(void) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_taskIdSelf); - if (Status != 0) - { - return (PCS_TASK_ID)PCS_ERROR; - } - - return &PCS_LOCAL_TASK; -} - -PCS_TASK_ID PCS_taskNameToId(const char *name) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_taskNameToId); - if (Status != 0) - { - return (PCS_TASK_ID)PCS_ERROR; - } - - return &PCS_LOCAL_TASK; -} - -PCS_STATUS PCS_taskDelay(int ticks) -{ - return UT_DEFAULT_IMPL(PCS_taskDelay); -} - -PCS_STATUS PCS_taskDelete(PCS_TASK_ID tid) -{ - return UT_DEFAULT_IMPL(PCS_taskDelete); -} - -PCS_STATUS PCS_taskDeleteForce(PCS_TASK_ID tid) -{ - return UT_DEFAULT_IMPL(PCS_taskDeleteForce); -} - -PCS_STATUS PCS_taskSuspend(PCS_TASK_ID tid) -{ - return UT_DEFAULT_IMPL(PCS_taskSuspend); -} - -PCS_STATUS PCS_taskResume(PCS_TASK_ID tid) -{ - return UT_DEFAULT_IMPL(PCS_taskResume); -} - -PCS_STATUS PCS_taskPrioritySet(PCS_TASK_ID tid, int newPriority) -{ - return UT_DEFAULT_IMPL(PCS_taskPrioritySet); -} - -PCS_STATUS PCS_taskInit(PCS_WIND_TCB *pTcb, char *name, int priority, int options, char *pStackBase, int stackSize, - PCS_FUNCPTR entryPt, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, - int arg8, int arg9, int arg10) -{ - return UT_DEFAULT_IMPL(PCS_taskInit); -} - -PCS_TASK_ID PCS_taskSpawn(char *name, int priority, int options, int stackSize, PCS_FUNCPTR entryPt, int arg1, int arg2, - int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10) - -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_taskSpawn); - if (Status != 0) - { - return (PCS_TASK_ID)PCS_ERROR; - } - - return &PCS_LOCAL_TASK; -} - -PCS_STATUS PCS_taskActivate(PCS_TASK_ID tid) -{ - int32 Status; - - Status = UT_DEFAULT_IMPL(PCS_taskActivate); - - return Status; -} - -PCS_WIND_TCB *PCS_taskTcb(PCS_TASK_ID tid) -{ - int32 Status; - PCS_WIND_TCB *LocalTcb; - - Status = UT_DEFAULT_IMPL(PCS_taskTcb); - if (Status != 0) - { - return NULL; - } - - if (UT_Stub_CopyToLocal(UT_KEY(PCS_taskTcb), &LocalTcb, sizeof(LocalTcb)) < sizeof(LocalTcb)) - { - /* - * On VxWorks the TASK_ID is defined as a direct type cast - * of the TCB address. This is actually documented - * in the API and application code that works with TCBs - * certainly will depend on this being the case. - */ - LocalTcb = (PCS_WIND_TCB *)tid; - } - - return LocalTcb; -} diff --git a/ut-stubs/CMakeLists.txt b/ut-stubs/CMakeLists.txt index 55bab45c..0157c9a5 100644 --- a/ut-stubs/CMakeLists.txt +++ b/ut-stubs/CMakeLists.txt @@ -1,5 +1,39 @@ -add_library(ut_psp-${CFE_PSP_TARGETNAME}_stubs ut_psp_stubs.c) -target_link_libraries(ut_psp-${CFE_PSP_TARGETNAME}_stubs PRIVATE +# +# CMake recipe for PSP unit test stub functions +# + +add_library(ut_psp_api_stubs + src/cfe_psp_cache_api_stubs.c + src/cfe_psp_cds_api_handlers.c + src/cfe_psp_cds_api_stubs.c + src/cfe_psp_eepromaccess_api_stubs.c + src/cfe_psp_error_stubs.c + src/cfe_psp_exception_api_handlers.c + src/cfe_psp_exception_api_stubs.c + src/cfe_psp_exceptionstorage_api_stubs.c + src/cfe_psp_globaldata_stubs.c + src/cfe_psp_id_api_handlers.c + src/cfe_psp_id_api_stubs.c + src/cfe_psp_memaccess_api_handlers.c + src/cfe_psp_memaccess_api_stubs.c + src/cfe_psp_memory_stubs.c + src/cfe_psp_memrange_api_handlers.c + src/cfe_psp_memrange_api_stubs.c + src/cfe_psp_module_stubs.c + src/cfe_psp_port_api_stubs.c + src/cfe_psp_ssr_api_stubs.c + src/cfe_psp_stubs.c + src/cfe_psp_timertick_api_handlers.c + src/cfe_psp_timertick_api_stubs.c + src/cfe_psp_version_api_handlers.c + src/cfe_psp_version_api_stubs.c + src/cfe_psp_watchdog_api_handlers.c + src/cfe_psp_watchdog_api_stubs.c +) + +target_link_libraries(ut_psp_api_stubs PRIVATE psp_module_api - ut_assert + ut_assert ) + +add_library(ut_psp-${CFE_PSP_TARGETNAME}_stubs ALIAS ut_psp_api_stubs) diff --git a/ut-stubs/src/cfe_psp_cache_api_stubs.c b/ut-stubs/src/cfe_psp_cache_api_stubs.c new file mode 100644 index 00000000..d06537de --- /dev/null +++ b/ut-stubs/src/cfe_psp_cache_api_stubs.c @@ -0,0 +1,40 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_cache_api header + */ + +#include "cfe_psp_cache_api.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_FlushCaches() + * ---------------------------------------------------- + */ +void CFE_PSP_FlushCaches(uint32 type, void *address, uint32 size) +{ + UT_GenStub_AddParam(CFE_PSP_FlushCaches, uint32, type); + UT_GenStub_AddParam(CFE_PSP_FlushCaches, void *, address); + UT_GenStub_AddParam(CFE_PSP_FlushCaches, uint32, size); + + UT_GenStub_Execute(CFE_PSP_FlushCaches, Basic, NULL); +} diff --git a/ut-stubs/src/cfe_psp_cds_api_handlers.c b/ut-stubs/src/cfe_psp_cds_api_handlers.c new file mode 100644 index 00000000..696723c3 --- /dev/null +++ b/ut-stubs/src/cfe_psp_cds_api_handlers.c @@ -0,0 +1,152 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +#include "target_config.h" + +/* +** Functions +*/ + +/*****************************************************************************/ +/** +** \brief CFE_PSP_WriteToCDS stub function +** +** \par Description +** This function is used to mimic the response of the PSP function +** CFE_PSP_WriteToCDS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** Returns either OS_SUCCESS, OS_ERROR, or a user-defined value. +** +******************************************************************************/ +void UT_DefaultHandler_CFE_PSP_WriteToCDS(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) */ + const void *PtrToDataToWrite = UT_Hook_GetArgValueByName(Context, "PtrToDataToWrite", const void *); + uint32 CDSOffset = UT_Hook_GetArgValueByName(Context, "CDSOffset", uint32); + uint32 NumBytes = UT_Hook_GetArgValueByName(Context, "NumBytes", uint32); + + uint8 *BufPtr; + size_t CdsSize; + size_t Position; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_WriteToCDS), (void **)&BufPtr, &CdsSize, &Position); + if (BufPtr != NULL && (CDSOffset + NumBytes) <= CdsSize) + { + memcpy(BufPtr + CDSOffset, PtrToDataToWrite, NumBytes); + } + } +} + +/*****************************************************************************/ +/** +** \brief CFE_PSP_ReadFromCDS stub function +** +** \par Description +** This function is used to mimic the response of the PSP function +** CFE_PSP_ReadFromCDS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** Returns either OS_SUCCESS, OS_ERROR, or a user-defined value. +** +******************************************************************************/ +void UT_DefaultHandler_CFE_PSP_ReadFromCDS(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_ReadFromCDS(void *PtrToDataFromRead, uint32 CDSOffset, uint32 NumBytes) */ + void * PtrToDataFromRead = UT_Hook_GetArgValueByName(Context, "PtrToDataFromRead", void *); + uint32 CDSOffset = UT_Hook_GetArgValueByName(Context, "CDSOffset", uint32); + uint32 NumBytes = UT_Hook_GetArgValueByName(Context, "NumBytes", uint32); + + uint8 *BufPtr; + size_t CdsSize; + size_t Position; + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_ReadFromCDS), (void **)&BufPtr, &CdsSize, &Position); + if (BufPtr != NULL && (CDSOffset + NumBytes) <= CdsSize) + { + memcpy(PtrToDataFromRead, BufPtr + CDSOffset, NumBytes); + } + } +} + +/*****************************************************************************/ +/** +** \brief CFE_PSP_GetCDSSize stub function +** +** \par Description +** This function is used to mimic the response of the PSP function +** CFE_PSP_GetCDSSize. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** Returns either OS_SUCCESS or OS_ERROR. +** +******************************************************************************/ +void UT_DefaultHandler_CFE_PSP_GetCDSSize(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) */ + uint32 *SizeOfCDS = UT_Hook_GetArgValueByName(Context, "SizeOfCDS", uint32 *); + + int32 status; + size_t TempSize; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), NULL, &TempSize, NULL); + *SizeOfCDS = TempSize; + } +} diff --git a/ut-stubs/src/cfe_psp_cds_api_stubs.c b/ut-stubs/src/cfe_psp_cds_api_stubs.c new file mode 100644 index 00000000..55e33b62 --- /dev/null +++ b/ut-stubs/src/cfe_psp_cds_api_stubs.c @@ -0,0 +1,82 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_cds_api header + */ + +#include "cfe_psp_cds_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_GetCDSSize(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_ReadFromCDS(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_WriteToCDS(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetCDSSize() + * ---------------------------------------------------- + */ +int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetCDSSize, int32); + + UT_GenStub_AddParam(CFE_PSP_GetCDSSize, uint32 *, SizeOfCDS); + + UT_GenStub_Execute(CFE_PSP_GetCDSSize, Basic, UT_DefaultHandler_CFE_PSP_GetCDSSize); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetCDSSize, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_ReadFromCDS() + * ---------------------------------------------------- + */ +int32 CFE_PSP_ReadFromCDS(void *PtrToDataFromRead, uint32 CDSOffset, uint32 NumBytes) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_ReadFromCDS, int32); + + UT_GenStub_AddParam(CFE_PSP_ReadFromCDS, void *, PtrToDataFromRead); + UT_GenStub_AddParam(CFE_PSP_ReadFromCDS, uint32, CDSOffset); + UT_GenStub_AddParam(CFE_PSP_ReadFromCDS, uint32, NumBytes); + + UT_GenStub_Execute(CFE_PSP_ReadFromCDS, Basic, UT_DefaultHandler_CFE_PSP_ReadFromCDS); + + return UT_GenStub_GetReturnValue(CFE_PSP_ReadFromCDS, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WriteToCDS() + * ---------------------------------------------------- + */ +int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_WriteToCDS, int32); + + UT_GenStub_AddParam(CFE_PSP_WriteToCDS, const void *, PtrToDataToWrite); + UT_GenStub_AddParam(CFE_PSP_WriteToCDS, uint32, CDSOffset); + UT_GenStub_AddParam(CFE_PSP_WriteToCDS, uint32, NumBytes); + + UT_GenStub_Execute(CFE_PSP_WriteToCDS, Basic, UT_DefaultHandler_CFE_PSP_WriteToCDS); + + return UT_GenStub_GetReturnValue(CFE_PSP_WriteToCDS, int32); +} diff --git a/ut-stubs/src/cfe_psp_eepromaccess_api_stubs.c b/ut-stubs/src/cfe_psp_eepromaccess_api_stubs.c new file mode 100644 index 00000000..c329ea66 --- /dev/null +++ b/ut-stubs/src/cfe_psp_eepromaccess_api_stubs.c @@ -0,0 +1,141 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_eepromaccess_api header + */ + +#include "cfe_psp_eepromaccess_api.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromPowerDown() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromPowerDown(uint32 Bank) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromPowerDown, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromPowerDown, uint32, Bank); + + UT_GenStub_Execute(CFE_PSP_EepromPowerDown, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromPowerDown, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromPowerUp() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromPowerUp(uint32 Bank) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromPowerUp, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromPowerUp, uint32, Bank); + + UT_GenStub_Execute(CFE_PSP_EepromPowerUp, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromPowerUp, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromWrite16() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromWrite16(cpuaddr MemoryAddress, uint16 uint16Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromWrite16, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromWrite16, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_EepromWrite16, uint16, uint16Value); + + UT_GenStub_Execute(CFE_PSP_EepromWrite16, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromWrite16, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromWrite32() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromWrite32, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromWrite32, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_EepromWrite32, uint32, uint32Value); + + UT_GenStub_Execute(CFE_PSP_EepromWrite32, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromWrite32, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromWrite8() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromWrite8(cpuaddr MemoryAddress, uint8 ByteValue) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromWrite8, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromWrite8, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_EepromWrite8, uint8, ByteValue); + + UT_GenStub_Execute(CFE_PSP_EepromWrite8, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromWrite8, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromWriteDisable() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromWriteDisable(uint32 Bank) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromWriteDisable, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromWriteDisable, uint32, Bank); + + UT_GenStub_Execute(CFE_PSP_EepromWriteDisable, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromWriteDisable, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_EepromWriteEnable() + * ---------------------------------------------------- + */ +int32 CFE_PSP_EepromWriteEnable(uint32 Bank) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_EepromWriteEnable, int32); + + UT_GenStub_AddParam(CFE_PSP_EepromWriteEnable, uint32, Bank); + + UT_GenStub_Execute(CFE_PSP_EepromWriteEnable, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_EepromWriteEnable, int32); +} diff --git a/ut-stubs/cfe_psp_error_stubs.c b/ut-stubs/src/cfe_psp_error_stubs.c similarity index 98% rename from ut-stubs/cfe_psp_error_stubs.c rename to ut-stubs/src/cfe_psp_error_stubs.c index 323a6c87..f8422057 100644 --- a/ut-stubs/cfe_psp_error_stubs.c +++ b/ut-stubs/src/cfe_psp_error_stubs.c @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. ************************************************************************/ -#define CFE_PSP_ERROR_H /** * @file diff --git a/ut-stubs/src/cfe_psp_exception_api_handlers.c b/ut-stubs/src/cfe_psp_exception_api_handlers.c new file mode 100644 index 00000000..e7e10ba1 --- /dev/null +++ b/ut-stubs/src/cfe_psp_exception_api_handlers.c @@ -0,0 +1,93 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +#include "target_config.h" + +void UT_DefaultHandler_CFE_PSP_Exception_GetSummary(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_Exception_GetSummary(uint32 *ContextLogId, osal_id_t *TaskId, char *ReasonBuf, uint32 ReasonSize) + */ + uint32 * ContextLogId = UT_Hook_GetArgValueByName(Context, "ContextLogId", uint32 *); + osal_id_t *TaskId = UT_Hook_GetArgValueByName(Context, "TaskId", osal_id_t *); + char * ReasonBuf = UT_Hook_GetArgValueByName(Context, "ReasonBuf", char *); + uint32 ReasonSize = UT_Hook_GetArgValueByName(Context, "ReasonSize", uint32); + + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (ReasonBuf != NULL && ReasonSize != 0) + { + *ReasonBuf = 0; + } + + if (ContextLogId != NULL) + { + *ContextLogId = 0; + } + + if (TaskId != NULL) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_Exception_GetSummary), TaskId, sizeof(*TaskId)) < sizeof(*TaskId)) + { + *TaskId = OS_OBJECT_ID_UNDEFINED; + } + } + } +} + +void UT_DefaultHandler_CFE_PSP_Exception_CopyContext(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint32 ContextSize) */ + void * ContextBuf = UT_Hook_GetArgValueByName(Context, "ContextBuf", void *); + uint32 ContextSize = UT_Hook_GetArgValueByName(Context, "ContextSize", uint32); + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0 && ContextBuf != NULL && ContextSize != 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_Exception_CopyContext), ContextBuf, ContextSize) < ContextSize) + { + memset(ContextBuf, 0, ContextSize); + } + } +} diff --git a/ut-stubs/src/cfe_psp_exception_api_stubs.c b/ut-stubs/src/cfe_psp_exception_api_stubs.c new file mode 100644 index 00000000..e52a2a85 --- /dev/null +++ b/ut-stubs/src/cfe_psp_exception_api_stubs.c @@ -0,0 +1,102 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_exception_api header + */ + +#include "cfe_psp_exception_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_Exception_CopyContext(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_Exception_GetSummary(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_AttachExceptions() + * ---------------------------------------------------- + */ +void CFE_PSP_AttachExceptions(void) +{ + + UT_GenStub_Execute(CFE_PSP_AttachExceptions, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_CopyContext() + * ---------------------------------------------------- + */ +int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint32 ContextSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_CopyContext, int32); + + UT_GenStub_AddParam(CFE_PSP_Exception_CopyContext, uint32, ContextLogId); + UT_GenStub_AddParam(CFE_PSP_Exception_CopyContext, void *, ContextBuf); + UT_GenStub_AddParam(CFE_PSP_Exception_CopyContext, uint32, ContextSize); + + UT_GenStub_Execute(CFE_PSP_Exception_CopyContext, Basic, UT_DefaultHandler_CFE_PSP_Exception_CopyContext); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_CopyContext, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_GetCount() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_Exception_GetCount(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_GetCount, uint32); + + UT_GenStub_Execute(CFE_PSP_Exception_GetCount, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_GetCount, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_GetSummary() + * ---------------------------------------------------- + */ +int32 CFE_PSP_Exception_GetSummary(uint32 *ContextLogId, osal_id_t *TaskId, char *ReasonBuf, uint32 ReasonSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_GetSummary, int32); + + UT_GenStub_AddParam(CFE_PSP_Exception_GetSummary, uint32 *, ContextLogId); + UT_GenStub_AddParam(CFE_PSP_Exception_GetSummary, osal_id_t *, TaskId); + UT_GenStub_AddParam(CFE_PSP_Exception_GetSummary, char *, ReasonBuf); + UT_GenStub_AddParam(CFE_PSP_Exception_GetSummary, uint32, ReasonSize); + + UT_GenStub_Execute(CFE_PSP_Exception_GetSummary, Basic, UT_DefaultHandler_CFE_PSP_Exception_GetSummary); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_GetSummary, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_SetDefaultExceptionEnvironment() + * ---------------------------------------------------- + */ +void CFE_PSP_SetDefaultExceptionEnvironment(void) +{ + + UT_GenStub_Execute(CFE_PSP_SetDefaultExceptionEnvironment, Basic, NULL); +} diff --git a/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c b/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c new file mode 100644 index 00000000..56c92a58 --- /dev/null +++ b/ut-stubs/src/cfe_psp_exceptionstorage_api_stubs.c @@ -0,0 +1,97 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_exceptionstorage_api header + */ + +#include "cfe_psp_exceptionstorage_api.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_ExceptionGetSummary_Impl() + * ---------------------------------------------------- + */ +int32 CFE_PSP_ExceptionGetSummary_Impl(const struct CFE_PSP_Exception_LogData *Buffer, char *ReasonBuf, + uint32 ReasonSize) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_ExceptionGetSummary_Impl, int32); + + UT_GenStub_AddParam(CFE_PSP_ExceptionGetSummary_Impl, const struct CFE_PSP_Exception_LogData *, Buffer); + UT_GenStub_AddParam(CFE_PSP_ExceptionGetSummary_Impl, char *, ReasonBuf); + UT_GenStub_AddParam(CFE_PSP_ExceptionGetSummary_Impl, uint32, ReasonSize); + + UT_GenStub_Execute(CFE_PSP_ExceptionGetSummary_Impl, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_ExceptionGetSummary_Impl, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_GetBuffer() + * ---------------------------------------------------- + */ +struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetBuffer(uint32 seq) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_GetBuffer, struct CFE_PSP_Exception_LogData *); + + UT_GenStub_AddParam(CFE_PSP_Exception_GetBuffer, uint32, seq); + + UT_GenStub_Execute(CFE_PSP_Exception_GetBuffer, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_GetBuffer, struct CFE_PSP_Exception_LogData *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_GetNextContextBuffer() + * ---------------------------------------------------- + */ +struct CFE_PSP_Exception_LogData *CFE_PSP_Exception_GetNextContextBuffer(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Exception_GetNextContextBuffer, struct CFE_PSP_Exception_LogData *); + + UT_GenStub_Execute(CFE_PSP_Exception_GetNextContextBuffer, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Exception_GetNextContextBuffer, struct CFE_PSP_Exception_LogData *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_Reset() + * ---------------------------------------------------- + */ +void CFE_PSP_Exception_Reset(void) +{ + + UT_GenStub_Execute(CFE_PSP_Exception_Reset, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Exception_WriteComplete() + * ---------------------------------------------------- + */ +void CFE_PSP_Exception_WriteComplete(void) +{ + + UT_GenStub_Execute(CFE_PSP_Exception_WriteComplete, Basic, NULL); +} diff --git a/ut-stubs/src/cfe_psp_globaldata_stubs.c b/ut-stubs/src/cfe_psp_globaldata_stubs.c new file mode 100644 index 00000000..93f4681a --- /dev/null +++ b/ut-stubs/src/cfe_psp_globaldata_stubs.c @@ -0,0 +1,55 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +#include "target_config.h" + +Target_CfeConfigData GLOBAL_CFE_CONFIGDATA = {0}; + +/** + * Instantiation of global system-wide configuration struct + * This contains build info plus pointers to the PSP and CFE + * configuration structures. Everything will be linked together + * in the final executable. + */ +Target_ConfigData GLOBAL_CONFIGDATA = {.MissionVersion = "MissionUnitTest", + .CfeVersion = "CfeUnitTest", + .OsalVersion = "OsalUnitTest", + .Config = "MissionConfig", + .Date = "MissionBuildDate", + .User = "MissionBuildUser", + .Default_CpuName = "UnitTestCpu", + .Default_CpuId = 1, + .Default_SpacecraftId = 0x42, + .CfeConfig = &GLOBAL_CFE_CONFIGDATA}; diff --git a/unit-test-coverage/ut-stubs/src/vxworks-vxLib-stubs.c b/ut-stubs/src/cfe_psp_id_api_handlers.c similarity index 57% rename from unit-test-coverage/ut-stubs/src/vxworks-vxLib-stubs.c rename to ut-stubs/src/cfe_psp_id_api_handlers.c index ac73b908..d57f1be1 100644 --- a/unit-test-coverage/ut-stubs/src/vxworks-vxLib-stubs.c +++ b/ut-stubs/src/cfe_psp_id_api_handlers.c @@ -16,44 +16,42 @@ * limitations under the License. ************************************************************************/ -/* PSP coverage stub replacement for vxLib.h */ -#include -#include +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" #include "utstubs.h" +#include -#include "PCS_vxLib.h" -#include "PCS_arch_ppc_vxPpcLib.h" - -void PCS_vxTimeBaseGet(uint32_t *u, uint32_t *l) -{ - UT_Stub_RegisterContextGenericArg(UT_KEY(PCS_vxTimeBaseGet), u); - UT_Stub_RegisterContextGenericArg(UT_KEY(PCS_vxTimeBaseGet), l); - *u = 0; - *l = 0; - UT_DEFAULT_IMPL(PCS_vxTimeBaseGet); -} - -void PCS_vxMsrSet(uint32_t val) +void UT_DefaultHandler_CFE_PSP_GetProcessorName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - UT_DEFAULT_IMPL(PCS_vxMsrSet); -} + /* const char *CFE_PSP_GetProcessorName(void) */ + static const char default_retval[] = "UT"; + const char * ptr; -uint32_t PCS_vxMsrGet(void) -{ - return UT_DEFAULT_IMPL(PCS_vxMsrGet); -} + int32 status; -void PCS_vxFpscrSet(uint32_t val) -{ - UT_DEFAULT_IMPL(PCS_vxFpscrSet); -} + UT_Stub_GetInt32StatusCode(Context, &status); -uint32_t PCS_vxFpscrGet(void) -{ - return UT_DEFAULT_IMPL(PCS_vxFpscrGet); -} + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_GetProcessorName), &ptr, sizeof(ptr)) < sizeof(ptr)) + { + ptr = default_retval; + } -uint32_t PCS_vxDecGet(void) -{ - return UT_DEFAULT_IMPL(PCS_vxDecGet); + UT_Stub_SetReturnValue(FuncKey, ptr); + } } diff --git a/ut-stubs/src/cfe_psp_id_api_stubs.c b/ut-stubs/src/cfe_psp_id_api_stubs.c new file mode 100644 index 00000000..d698e1d8 --- /dev/null +++ b/ut-stubs/src/cfe_psp_id_api_stubs.c @@ -0,0 +1,70 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_id_api header + */ + +#include "cfe_psp_id_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_GetProcessorName(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetProcessorId() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_GetProcessorId(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetProcessorId, uint32); + + UT_GenStub_Execute(CFE_PSP_GetProcessorId, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetProcessorId, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetProcessorName() + * ---------------------------------------------------- + */ +const char *CFE_PSP_GetProcessorName(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetProcessorName, const char *); + + UT_GenStub_Execute(CFE_PSP_GetProcessorName, Basic, UT_DefaultHandler_CFE_PSP_GetProcessorName); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetProcessorName, const char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetSpacecraftId() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_GetSpacecraftId(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetSpacecraftId, uint32); + + UT_GenStub_Execute(CFE_PSP_GetSpacecraftId, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetSpacecraftId, uint32); +} diff --git a/ut-stubs/src/cfe_psp_memaccess_api_handlers.c b/ut-stubs/src/cfe_psp_memaccess_api_handlers.c new file mode 100644 index 00000000..bfb93297 --- /dev/null +++ b/ut-stubs/src/cfe_psp_memaccess_api_handlers.c @@ -0,0 +1,140 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* + * Purpose: + * Unit test stubs for BSP routines + * + * NOTE: functions in here need to perform the real operation by default. + * If a fuction invokes CFE_PSP_MemSet() with the expectation that it will + * set an object to safe initial values, then behavior will be undefined + * if this is not actually done. + */ + +/* +** Includes +*/ + +#include +#include "cfe_psp_memaccess_api.h" + +#include "utstubs.h" + +/* + * ---------------------------------------------------- + * Default Handler function for CFE_PSP_MemCpy() + * ---------------------------------------------------- + */ +void UT_DefaultHandler_CFE_PSP_MemCpy(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* CFE_PSP_MemCpy(void *dest, const void *src, uint32 size) */ + void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *); + const void *src = UT_Hook_GetArgValueByName(Context, "src", const void *); + uint32 size = UT_Hook_GetArgValueByName(Context, "size", uint32); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status >= 0) + { + memcpy(dest, src, size); + } +} + +/* + * ---------------------------------------------------- + * Default Handler function for CFE_PSP_MemSet() + * ---------------------------------------------------- + */ +void UT_DefaultHandler_CFE_PSP_MemSet(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 size) */ + void * dest = UT_Hook_GetArgValueByName(Context, "dest", void *); + uint8 value = UT_Hook_GetArgValueByName(Context, "value", uint8); + uint32 size = UT_Hook_GetArgValueByName(Context, "size", uint32); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status >= 0) + { + memset(dest, value, size); + } +} + +/* + * ---------------------------------------------------- + * Default Handler function for CFE_PSP_MemRead8() + * NOTE: historically this was the only "mem read" stub in PSP, and it output a value of 1. + * ---------------------------------------------------- + */ +void UT_DefaultHandler_CFE_PSP_MemRead8(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) */ + uint8 *outptr = UT_Hook_GetArgValueByName(Context, "ByteValue", uint8 *); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status == CFE_PSP_SUCCESS && outptr != NULL) + { + if (UT_Stub_CopyToLocal(FuncKey, outptr, sizeof(*outptr)) != sizeof(*outptr)) + { + *outptr = 1; + } + } +} + +/* + * ---------------------------------------------------- + * Default Handler function for CFE_PSP_MemRead16() + * ---------------------------------------------------- + */ +void UT_DefaultHandler_CFE_PSP_MemRead16(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) */ + uint16 *outptr = UT_Hook_GetArgValueByName(Context, "uint16Value", uint16 *); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status == CFE_PSP_SUCCESS && outptr != NULL) + { + if (UT_Stub_CopyToLocal(FuncKey, outptr, sizeof(*outptr)) != sizeof(*outptr)) + { + *outptr = 0; + } + } +} + +/* + * ---------------------------------------------------- + * Default Handler function for CFE_PSP_MemRead32() + * ---------------------------------------------------- + */ +void UT_DefaultHandler_CFE_PSP_MemRead32(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) */ + uint32 *outptr = UT_Hook_GetArgValueByName(Context, "uint32Value", uint32 *); + int32 Status; + + UT_Stub_GetInt32StatusCode(Context, &Status); + if (Status == CFE_PSP_SUCCESS && outptr != NULL) + { + if (UT_Stub_CopyToLocal(FuncKey, outptr, sizeof(*outptr)) != sizeof(*outptr)) + { + *outptr = 0; + } + } +} diff --git a/ut-stubs/src/cfe_psp_memaccess_api_stubs.c b/ut-stubs/src/cfe_psp_memaccess_api_stubs.c new file mode 100644 index 00000000..b4cf20c6 --- /dev/null +++ b/ut-stubs/src/cfe_psp_memaccess_api_stubs.c @@ -0,0 +1,170 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_memaccess_api header + */ + +#include "cfe_psp_memaccess_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_MemCpy(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_MemRead16(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_MemRead32(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_MemRead8(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_MemSet(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemCpy() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemCpy, int32); + + UT_GenStub_AddParam(CFE_PSP_MemCpy, void *, dest); + UT_GenStub_AddParam(CFE_PSP_MemCpy, const void *, src); + UT_GenStub_AddParam(CFE_PSP_MemCpy, uint32, n); + + UT_GenStub_Execute(CFE_PSP_MemCpy, Basic, UT_DefaultHandler_CFE_PSP_MemCpy); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemCpy, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemRead16() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemRead16(cpuaddr MemoryAddress, uint16 *uint16Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemRead16, int32); + + UT_GenStub_AddParam(CFE_PSP_MemRead16, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_MemRead16, uint16 *, uint16Value); + + UT_GenStub_Execute(CFE_PSP_MemRead16, Basic, UT_DefaultHandler_CFE_PSP_MemRead16); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemRead16, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemRead32() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemRead32(cpuaddr MemoryAddress, uint32 *uint32Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemRead32, int32); + + UT_GenStub_AddParam(CFE_PSP_MemRead32, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_MemRead32, uint32 *, uint32Value); + + UT_GenStub_Execute(CFE_PSP_MemRead32, Basic, UT_DefaultHandler_CFE_PSP_MemRead32); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemRead32, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemRead8() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemRead8(cpuaddr MemoryAddress, uint8 *ByteValue) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemRead8, int32); + + UT_GenStub_AddParam(CFE_PSP_MemRead8, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_MemRead8, uint8 *, ByteValue); + + UT_GenStub_Execute(CFE_PSP_MemRead8, Basic, UT_DefaultHandler_CFE_PSP_MemRead8); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemRead8, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemSet() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemSet, int32); + + UT_GenStub_AddParam(CFE_PSP_MemSet, void *, dest); + UT_GenStub_AddParam(CFE_PSP_MemSet, uint8, value); + UT_GenStub_AddParam(CFE_PSP_MemSet, uint32, n); + + UT_GenStub_Execute(CFE_PSP_MemSet, Basic, UT_DefaultHandler_CFE_PSP_MemSet); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemSet, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemWrite16() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemWrite16(cpuaddr MemoryAddress, uint16 uint16Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemWrite16, int32); + + UT_GenStub_AddParam(CFE_PSP_MemWrite16, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_MemWrite16, uint16, uint16Value); + + UT_GenStub_Execute(CFE_PSP_MemWrite16, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemWrite16, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemWrite32() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemWrite32(cpuaddr MemoryAddress, uint32 uint32Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemWrite32, int32); + + UT_GenStub_AddParam(CFE_PSP_MemWrite32, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_MemWrite32, uint32, uint32Value); + + UT_GenStub_Execute(CFE_PSP_MemWrite32, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemWrite32, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemWrite8() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemWrite8(cpuaddr MemoryAddress, uint8 ByteValue) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemWrite8, int32); + + UT_GenStub_AddParam(CFE_PSP_MemWrite8, cpuaddr, MemoryAddress); + UT_GenStub_AddParam(CFE_PSP_MemWrite8, uint8, ByteValue); + + UT_GenStub_Execute(CFE_PSP_MemWrite8, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemWrite8, int32); +} diff --git a/ut-stubs/src/cfe_psp_memory_stubs.c b/ut-stubs/src/cfe_psp_memory_stubs.c new file mode 100644 index 00000000..61021c14 --- /dev/null +++ b/ut-stubs/src/cfe_psp_memory_stubs.c @@ -0,0 +1,64 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_memory header + */ + +#include "cfe_psp_memory.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_DeleteProcessorReservedMemory() + * ---------------------------------------------------- + */ +void CFE_PSP_DeleteProcessorReservedMemory(void) +{ + + UT_GenStub_Execute(CFE_PSP_DeleteProcessorReservedMemory, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_InitProcessorReservedMemory() + * ---------------------------------------------------- + */ +int32 CFE_PSP_InitProcessorReservedMemory(uint32 RestartType) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_InitProcessorReservedMemory, int32); + + UT_GenStub_AddParam(CFE_PSP_InitProcessorReservedMemory, uint32, RestartType); + + UT_GenStub_Execute(CFE_PSP_InitProcessorReservedMemory, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_InitProcessorReservedMemory, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_SetupReservedMemoryMap() + * ---------------------------------------------------- + */ +void CFE_PSP_SetupReservedMemoryMap(void) +{ + + UT_GenStub_Execute(CFE_PSP_SetupReservedMemoryMap, Basic, NULL); +} diff --git a/ut-stubs/src/cfe_psp_memrange_api_handlers.c b/ut-stubs/src/cfe_psp_memrange_api_handlers.c new file mode 100644 index 00000000..0c679db3 --- /dev/null +++ b/ut-stubs/src/cfe_psp_memrange_api_handlers.c @@ -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. + ************************************************************************/ + +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +/* +** Functions +*/ + +void UT_DefaultHandler_CFE_PSP_GetResetArea(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_GetResetArea() */ + cpuaddr *PtrToResetArea = UT_Hook_GetArgValueByName(Context, "PtrToResetArea", cpuaddr *); + uint32 * SizeOfResetArea = UT_Hook_GetArgValueByName(Context, "SizeOfResetArea", uint32 *); + + int32 status; + size_t TempSize; + void * TempAddr; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), &TempAddr, &TempSize, NULL); + + *PtrToResetArea = (cpuaddr)TempAddr; + *SizeOfResetArea = TempSize; + } +} + +void UT_DefaultHandler_CFE_PSP_GetVolatileDiskMem(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_GetVolatileDiskMem() */ + cpuaddr *PtrToVolDisk = UT_Hook_GetArgValueByName(Context, "PtrToVolDisk", cpuaddr *); + uint32 * SizeOfVolDisk = UT_Hook_GetArgValueByName(Context, "SizeOfVolDisk", uint32 *); + + int32 status; + size_t TempSize; + void * TempAddr; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVolatileDiskMem), &TempAddr, &TempSize, NULL); + + *PtrToVolDisk = (cpuaddr)TempAddr; + *SizeOfVolDisk = TempSize; + } +} + +void UT_DefaultHandler_CFE_PSP_GetCFETextSegmentInfo(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_GetCFETextSegmentInfo() */ + cpuaddr *PtrToCFESegment = UT_Hook_GetArgValueByName(Context, "PtrToCFESegment", cpuaddr *); + uint32 * SizeOfCFESegment = UT_Hook_GetArgValueByName(Context, "SizeOfCFESegment", uint32 *); + + static uint32 LocalTextSegment; + int32 status; + void * TempAddr; + size_t TempSize; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCFETextSegmentInfo), &TempAddr, &TempSize, NULL); + if (TempAddr == NULL) + { + /* Backup -- Set the pointer and size to anything */ + *PtrToCFESegment = (cpuaddr)&LocalTextSegment; + *SizeOfCFESegment = sizeof(LocalTextSegment); + } + else + { + *PtrToCFESegment = (cpuaddr)TempAddr; + *SizeOfCFESegment = TempSize; + } + } +} + +void UT_DefaultHandler_CFE_PSP_GetKernelTextSegmentInfo(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + /* int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) */ + cpuaddr *PtrToKernelSegment = UT_Hook_GetArgValueByName(Context, "PtrToKernelSegment", cpuaddr *); + uint32 * SizeOfKernelSegment = UT_Hook_GetArgValueByName(Context, "SizeOfKernelSegment", uint32 *); + + static uint32 LocalTextSegment; + int32 status; + void * TempAddr; + size_t TempSize; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetKernelTextSegmentInfo), &TempAddr, &TempSize, NULL); + if (TempAddr == NULL) + { + /* Backup -- Set the pointer and size to anything */ + *PtrToKernelSegment = (cpuaddr)&LocalTextSegment; + *SizeOfKernelSegment = sizeof(LocalTextSegment); + } + else + { + *PtrToKernelSegment = (cpuaddr)TempAddr; + *SizeOfKernelSegment = TempSize; + } + } +} diff --git a/ut-stubs/src/cfe_psp_memrange_api_stubs.c b/ut-stubs/src/cfe_psp_memrange_api_stubs.c new file mode 100644 index 00000000..8f823ad9 --- /dev/null +++ b/ut-stubs/src/cfe_psp_memrange_api_stubs.c @@ -0,0 +1,192 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_memrange_api header + */ + +#include "cfe_psp_memrange_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_GetCFETextSegmentInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_GetKernelTextSegmentInfo(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_GetResetArea(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_GetVolatileDiskMem(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetCFETextSegmentInfo() + * ---------------------------------------------------- + */ +int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetCFETextSegmentInfo, int32); + + UT_GenStub_AddParam(CFE_PSP_GetCFETextSegmentInfo, cpuaddr *, PtrToCFESegment); + UT_GenStub_AddParam(CFE_PSP_GetCFETextSegmentInfo, uint32 *, SizeOfCFESegment); + + UT_GenStub_Execute(CFE_PSP_GetCFETextSegmentInfo, Basic, UT_DefaultHandler_CFE_PSP_GetCFETextSegmentInfo); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetCFETextSegmentInfo, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetKernelTextSegmentInfo() + * ---------------------------------------------------- + */ +int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetKernelTextSegmentInfo, int32); + + UT_GenStub_AddParam(CFE_PSP_GetKernelTextSegmentInfo, cpuaddr *, PtrToKernelSegment); + UT_GenStub_AddParam(CFE_PSP_GetKernelTextSegmentInfo, uint32 *, SizeOfKernelSegment); + + UT_GenStub_Execute(CFE_PSP_GetKernelTextSegmentInfo, Basic, UT_DefaultHandler_CFE_PSP_GetKernelTextSegmentInfo); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetKernelTextSegmentInfo, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetResetArea() + * ---------------------------------------------------- + */ +int32 CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetResetArea, int32); + + UT_GenStub_AddParam(CFE_PSP_GetResetArea, cpuaddr *, PtrToResetArea); + UT_GenStub_AddParam(CFE_PSP_GetResetArea, uint32 *, SizeOfResetArea); + + UT_GenStub_Execute(CFE_PSP_GetResetArea, Basic, UT_DefaultHandler_CFE_PSP_GetResetArea); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetResetArea, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetUserReservedArea() + * ---------------------------------------------------- + */ +int32 CFE_PSP_GetUserReservedArea(cpuaddr *PtrToUserArea, uint32 *SizeOfUserArea) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetUserReservedArea, int32); + + UT_GenStub_AddParam(CFE_PSP_GetUserReservedArea, cpuaddr *, PtrToUserArea); + UT_GenStub_AddParam(CFE_PSP_GetUserReservedArea, uint32 *, SizeOfUserArea); + + UT_GenStub_Execute(CFE_PSP_GetUserReservedArea, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetUserReservedArea, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetVolatileDiskMem() + * ---------------------------------------------------- + */ +int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetVolatileDiskMem, int32); + + UT_GenStub_AddParam(CFE_PSP_GetVolatileDiskMem, cpuaddr *, PtrToVolDisk); + UT_GenStub_AddParam(CFE_PSP_GetVolatileDiskMem, uint32 *, SizeOfVolDisk); + + UT_GenStub_Execute(CFE_PSP_GetVolatileDiskMem, Basic, UT_DefaultHandler_CFE_PSP_GetVolatileDiskMem); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetVolatileDiskMem, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemRangeGet() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemRangeGet(uint32 RangeNum, uint32 *MemoryType, cpuaddr *StartAddr, size_t *Size, size_t *WordSize, + uint32 *Attributes) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemRangeGet, int32); + + UT_GenStub_AddParam(CFE_PSP_MemRangeGet, uint32, RangeNum); + UT_GenStub_AddParam(CFE_PSP_MemRangeGet, uint32 *, MemoryType); + UT_GenStub_AddParam(CFE_PSP_MemRangeGet, cpuaddr *, StartAddr); + UT_GenStub_AddParam(CFE_PSP_MemRangeGet, size_t *, Size); + UT_GenStub_AddParam(CFE_PSP_MemRangeGet, size_t *, WordSize); + UT_GenStub_AddParam(CFE_PSP_MemRangeGet, uint32 *, Attributes); + + UT_GenStub_Execute(CFE_PSP_MemRangeGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemRangeGet, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemRangeSet() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemRangeSet(uint32 RangeNum, uint32 MemoryType, cpuaddr StartAddr, size_t Size, size_t WordSize, + uint32 Attributes) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemRangeSet, int32); + + UT_GenStub_AddParam(CFE_PSP_MemRangeSet, uint32, RangeNum); + UT_GenStub_AddParam(CFE_PSP_MemRangeSet, uint32, MemoryType); + UT_GenStub_AddParam(CFE_PSP_MemRangeSet, cpuaddr, StartAddr); + UT_GenStub_AddParam(CFE_PSP_MemRangeSet, size_t, Size); + UT_GenStub_AddParam(CFE_PSP_MemRangeSet, size_t, WordSize); + UT_GenStub_AddParam(CFE_PSP_MemRangeSet, uint32, Attributes); + + UT_GenStub_Execute(CFE_PSP_MemRangeSet, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemRangeSet, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemRanges() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_MemRanges(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemRanges, uint32); + + UT_GenStub_Execute(CFE_PSP_MemRanges, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemRanges, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_MemValidateRange() + * ---------------------------------------------------- + */ +int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_MemValidateRange, int32); + + UT_GenStub_AddParam(CFE_PSP_MemValidateRange, cpuaddr, Address); + UT_GenStub_AddParam(CFE_PSP_MemValidateRange, size_t, Size); + UT_GenStub_AddParam(CFE_PSP_MemValidateRange, uint32, MemoryType); + + UT_GenStub_Execute(CFE_PSP_MemValidateRange, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_MemValidateRange, int32); +} diff --git a/ut-stubs/src/cfe_psp_module_stubs.c b/ut-stubs/src/cfe_psp_module_stubs.c new file mode 100644 index 00000000..dce406d0 --- /dev/null +++ b/ut-stubs/src/cfe_psp_module_stubs.c @@ -0,0 +1,71 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_module header + */ + +#include "cfe_psp_module.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_ModuleInit() + * ---------------------------------------------------- + */ +void CFE_PSP_ModuleInit(void) +{ + + UT_GenStub_Execute(CFE_PSP_ModuleInit, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Module_FindByName() + * ---------------------------------------------------- + */ +int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Module_FindByName, int32); + + UT_GenStub_AddParam(CFE_PSP_Module_FindByName, const char *, ModuleName); + UT_GenStub_AddParam(CFE_PSP_Module_FindByName, uint32 *, PspModuleId); + + UT_GenStub_Execute(CFE_PSP_Module_FindByName, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Module_FindByName, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Module_GetAPIEntry() + * ---------------------------------------------------- + */ +int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_Module_GetAPIEntry, int32); + + UT_GenStub_AddParam(CFE_PSP_Module_GetAPIEntry, uint32, PspModuleId); + UT_GenStub_AddParam(CFE_PSP_Module_GetAPIEntry, CFE_PSP_ModuleApi_t **, API); + + UT_GenStub_Execute(CFE_PSP_Module_GetAPIEntry, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_Module_GetAPIEntry, int32); +} diff --git a/ut-stubs/src/cfe_psp_port_api_stubs.c b/ut-stubs/src/cfe_psp_port_api_stubs.c new file mode 100644 index 00000000..b1ea32c9 --- /dev/null +++ b/ut-stubs/src/cfe_psp_port_api_stubs.c @@ -0,0 +1,128 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_port_api header + */ + +#include "cfe_psp_port_api.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_PortRead16() + * ---------------------------------------------------- + */ +int32 CFE_PSP_PortRead16(cpuaddr PortAddress, uint16 *uint16Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_PortRead16, int32); + + UT_GenStub_AddParam(CFE_PSP_PortRead16, cpuaddr, PortAddress); + UT_GenStub_AddParam(CFE_PSP_PortRead16, uint16 *, uint16Value); + + UT_GenStub_Execute(CFE_PSP_PortRead16, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_PortRead16, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_PortRead32() + * ---------------------------------------------------- + */ +int32 CFE_PSP_PortRead32(cpuaddr PortAddress, uint32 *uint32Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_PortRead32, int32); + + UT_GenStub_AddParam(CFE_PSP_PortRead32, cpuaddr, PortAddress); + UT_GenStub_AddParam(CFE_PSP_PortRead32, uint32 *, uint32Value); + + UT_GenStub_Execute(CFE_PSP_PortRead32, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_PortRead32, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_PortRead8() + * ---------------------------------------------------- + */ +int32 CFE_PSP_PortRead8(cpuaddr PortAddress, uint8 *ByteValue) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_PortRead8, int32); + + UT_GenStub_AddParam(CFE_PSP_PortRead8, cpuaddr, PortAddress); + UT_GenStub_AddParam(CFE_PSP_PortRead8, uint8 *, ByteValue); + + UT_GenStub_Execute(CFE_PSP_PortRead8, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_PortRead8, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_PortWrite16() + * ---------------------------------------------------- + */ +int32 CFE_PSP_PortWrite16(cpuaddr PortAddress, uint16 uint16Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_PortWrite16, int32); + + UT_GenStub_AddParam(CFE_PSP_PortWrite16, cpuaddr, PortAddress); + UT_GenStub_AddParam(CFE_PSP_PortWrite16, uint16, uint16Value); + + UT_GenStub_Execute(CFE_PSP_PortWrite16, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_PortWrite16, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_PortWrite32() + * ---------------------------------------------------- + */ +int32 CFE_PSP_PortWrite32(cpuaddr PortAddress, uint32 uint32Value) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_PortWrite32, int32); + + UT_GenStub_AddParam(CFE_PSP_PortWrite32, cpuaddr, PortAddress); + UT_GenStub_AddParam(CFE_PSP_PortWrite32, uint32, uint32Value); + + UT_GenStub_Execute(CFE_PSP_PortWrite32, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_PortWrite32, int32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_PortWrite8() + * ---------------------------------------------------- + */ +int32 CFE_PSP_PortWrite8(cpuaddr PortAddress, uint8 ByteValue) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_PortWrite8, int32); + + UT_GenStub_AddParam(CFE_PSP_PortWrite8, cpuaddr, PortAddress); + UT_GenStub_AddParam(CFE_PSP_PortWrite8, uint8, ByteValue); + + UT_GenStub_Execute(CFE_PSP_PortWrite8, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_PortWrite8, int32); +} diff --git a/ut-stubs/src/cfe_psp_ssr_api_stubs.c b/ut-stubs/src/cfe_psp_ssr_api_stubs.c new file mode 100644 index 00000000..b898b61f --- /dev/null +++ b/ut-stubs/src/cfe_psp_ssr_api_stubs.c @@ -0,0 +1,44 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_ssr_api header + */ + +#include "cfe_psp_ssr_api.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_InitSSR() + * ---------------------------------------------------- + */ +int32 CFE_PSP_InitSSR(uint32 bus, uint32 device, char *DeviceName) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_InitSSR, int32); + + UT_GenStub_AddParam(CFE_PSP_InitSSR, uint32, bus); + UT_GenStub_AddParam(CFE_PSP_InitSSR, uint32, device); + UT_GenStub_AddParam(CFE_PSP_InitSSR, char *, DeviceName); + + UT_GenStub_Execute(CFE_PSP_InitSSR, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_InitSSR, int32); +} diff --git a/ut-stubs/src/cfe_psp_stubs.c b/ut-stubs/src/cfe_psp_stubs.c new file mode 100644 index 00000000..510edc00 --- /dev/null +++ b/ut-stubs/src/cfe_psp_stubs.c @@ -0,0 +1,37 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp header + */ + +#include "cfe_psp.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Main() + * ---------------------------------------------------- + */ +void CFE_PSP_Main(void) +{ + + UT_GenStub_Execute(CFE_PSP_Main, Basic, NULL); +} diff --git a/ut-stubs/src/cfe_psp_timertick_api_handlers.c b/ut-stubs/src/cfe_psp_timertick_api_handlers.c new file mode 100644 index 00000000..c52bd5f4 --- /dev/null +++ b/ut-stubs/src/cfe_psp_timertick_api_handlers.c @@ -0,0 +1,82 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +/* +** Functions +*/ + +void UT_DefaultHandler_CFE_PSP_GetTime(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void CFE_PSP_GetTime(OS_time_t *LocalTime) */ + OS_time_t *LocalTime = UT_Hook_GetArgValueByName(Context, "LocalTime", OS_time_t *); + int32 status; + + UT_Stub_GetInt32StatusCode(Context, &status); + + if (status >= 0) + { + if (UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_GetTime), (uint8 *)LocalTime, sizeof(*LocalTime)) < sizeof(*LocalTime)) + { + *LocalTime = OS_TimeAssembleFromNanoseconds(100, 200000); + } + } +} + +void UT_DefaultHandler_CFE_PSP_GetTimerTicksPerSecond(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + /* uint32 CFE_PSP_GetTimerTicksPerSecond(void) */ + uint32 retval; + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + retval = 2000; + UT_Stub_SetReturnValue(FuncKey, retval); + } +} + +void UT_DefaultHandler_CFE_PSP_GetTimerLow32Rollover(void *UserObj, UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + /* uint32 CFE_PSP_GetTimerLow32Rollover(void) */ + uint32 retval; + + if (!UT_Stub_GetInt32StatusCode(Context, NULL)) + { + retval = 100000; + UT_Stub_SetReturnValue(FuncKey, retval); + } +} diff --git a/ut-stubs/src/cfe_psp_timertick_api_stubs.c b/ut-stubs/src/cfe_psp_timertick_api_stubs.c new file mode 100644 index 00000000..96c3716f --- /dev/null +++ b/ut-stubs/src/cfe_psp_timertick_api_stubs.c @@ -0,0 +1,83 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_timertick_api header + */ + +#include "cfe_psp_timertick_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_GetTime(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_GetTimerLow32Rollover(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_GetTimerTicksPerSecond(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetTime() + * ---------------------------------------------------- + */ +void CFE_PSP_GetTime(OS_time_t *LocalTime) +{ + UT_GenStub_AddParam(CFE_PSP_GetTime, OS_time_t *, LocalTime); + + UT_GenStub_Execute(CFE_PSP_GetTime, Basic, UT_DefaultHandler_CFE_PSP_GetTime); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetTimerLow32Rollover() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_GetTimerLow32Rollover(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetTimerLow32Rollover, uint32); + + UT_GenStub_Execute(CFE_PSP_GetTimerLow32Rollover, Basic, UT_DefaultHandler_CFE_PSP_GetTimerLow32Rollover); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetTimerLow32Rollover, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetTimerTicksPerSecond() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_GetTimerTicksPerSecond(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetTimerTicksPerSecond, uint32); + + UT_GenStub_Execute(CFE_PSP_GetTimerTicksPerSecond, Basic, UT_DefaultHandler_CFE_PSP_GetTimerTicksPerSecond); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetTimerTicksPerSecond, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Get_Timebase() + * ---------------------------------------------------- + */ +void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) +{ + UT_GenStub_AddParam(CFE_PSP_Get_Timebase, uint32 *, Tbu); + UT_GenStub_AddParam(CFE_PSP_Get_Timebase, uint32 *, Tbl); + + UT_GenStub_Execute(CFE_PSP_Get_Timebase, Basic, NULL); +} diff --git a/ut-stubs/src/cfe_psp_version_api_handlers.c b/ut-stubs/src/cfe_psp_version_api_handlers.c new file mode 100644 index 00000000..07700ce0 --- /dev/null +++ b/ut-stubs/src/cfe_psp_version_api_handlers.c @@ -0,0 +1,80 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +/* +** Functions +*/ + +void UT_DefaultHandler_CFE_PSP_GetVersionString(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* const char *CFE_PSP_GetVersionString(void) */ + static const char DEFAULT[] = "UT"; + void * Buffer; + const char * RetVal; + + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVersionString), &Buffer, NULL, NULL); + if (Buffer == NULL) + { + RetVal = DEFAULT; + } + else + { + RetVal = Buffer; + } + + UT_Stub_SetReturnValue(FuncKey, RetVal); +} + +void UT_DefaultHandler_CFE_PSP_GetVersionCodeName(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* const char *CFE_PSP_GetVersionCodeName(void) */ + static const char DEFAULT[] = "UT"; + void * Buffer; + const char * RetVal; + + UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVersionCodeName), &Buffer, NULL, NULL); + if (Buffer == NULL) + { + RetVal = DEFAULT; + } + else + { + RetVal = Buffer; + } + + UT_Stub_SetReturnValue(FuncKey, RetVal); +} diff --git a/ut-stubs/src/cfe_psp_version_api_stubs.c b/ut-stubs/src/cfe_psp_version_api_stubs.c new file mode 100644 index 00000000..89fc5b6f --- /dev/null +++ b/ut-stubs/src/cfe_psp_version_api_stubs.c @@ -0,0 +1,82 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_version_api header + */ + +#include "cfe_psp_version_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_GetVersionCodeName(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_GetVersionString(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetBuildNumber() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_GetBuildNumber(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetBuildNumber, uint32); + + UT_GenStub_Execute(CFE_PSP_GetBuildNumber, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetBuildNumber, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetVersionCodeName() + * ---------------------------------------------------- + */ +const char *CFE_PSP_GetVersionCodeName(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetVersionCodeName, const char *); + + UT_GenStub_Execute(CFE_PSP_GetVersionCodeName, Basic, UT_DefaultHandler_CFE_PSP_GetVersionCodeName); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetVersionCodeName, const char *); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetVersionNumber() + * ---------------------------------------------------- + */ +void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]) +{ + + UT_GenStub_Execute(CFE_PSP_GetVersionNumber, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetVersionString() + * ---------------------------------------------------- + */ +const char *CFE_PSP_GetVersionString(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetVersionString, const char *); + + UT_GenStub_Execute(CFE_PSP_GetVersionString, Basic, UT_DefaultHandler_CFE_PSP_GetVersionString); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetVersionString, const char *); +} diff --git a/ut-stubs/src/cfe_psp_watchdog_api_handlers.c b/ut-stubs/src/cfe_psp_watchdog_api_handlers.c new file mode 100644 index 00000000..501e1e23 --- /dev/null +++ b/ut-stubs/src/cfe_psp_watchdog_api_handlers.c @@ -0,0 +1,56 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/* +** File: ut_bsp_stubs.c +** +** Purpose: +** Unit test stubs for BSP routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "cfe_psp.h" +#include "utstubs.h" +#include + +/* +** Functions +*/ + +void UT_DefaultHandler_CFE_PSP_Panic(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void CFE_PSP_Panic(int32 ErrorCode) */ + int32 ErrorCode = UT_Hook_GetArgValueByName(Context, "ErrorCode", int32); + + UT_Stub_CopyFromLocal(UT_KEY(CFE_PSP_Panic), (uint8 *)&ErrorCode, sizeof(ErrorCode)); +} + +void UT_DefaultHandler_CFE_PSP_Restart(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + /* void CFE_PSP_Restart(uint32 resetType) */ + uint32 resetType = UT_Hook_GetArgValueByName(Context, "resetType", uint32); + + UT_Stub_CopyFromLocal(UT_KEY(CFE_PSP_Restart), (uint8 *)&resetType, sizeof(resetType)); +} diff --git a/ut-stubs/src/cfe_psp_watchdog_api_stubs.c b/ut-stubs/src/cfe_psp_watchdog_api_stubs.c new file mode 100644 index 00000000..20774273 --- /dev/null +++ b/ut-stubs/src/cfe_psp_watchdog_api_stubs.c @@ -0,0 +1,139 @@ +/************************************************************************ + * 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. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_watchdog_api header + */ + +#include "cfe_psp_watchdog_api.h" +#include "utgenstub.h" + +void UT_DefaultHandler_CFE_PSP_Panic(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_PSP_Restart(void *, UT_EntryKey_t, const UT_StubContext_t *); + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_GetRestartType() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_GetRestartType(uint32 *restartSubType) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_GetRestartType, uint32); + + UT_GenStub_AddParam(CFE_PSP_GetRestartType, uint32 *, restartSubType); + + UT_GenStub_Execute(CFE_PSP_GetRestartType, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_GetRestartType, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Panic() + * ---------------------------------------------------- + */ +void CFE_PSP_Panic(int32 ErrorCode) +{ + UT_GenStub_AddParam(CFE_PSP_Panic, int32, ErrorCode); + + UT_GenStub_Execute(CFE_PSP_Panic, Basic, UT_DefaultHandler_CFE_PSP_Panic); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_Restart() + * ---------------------------------------------------- + */ +void CFE_PSP_Restart(uint32 resetType) +{ + UT_GenStub_AddParam(CFE_PSP_Restart, uint32, resetType); + + UT_GenStub_Execute(CFE_PSP_Restart, Basic, UT_DefaultHandler_CFE_PSP_Restart); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WatchdogDisable() + * ---------------------------------------------------- + */ +void CFE_PSP_WatchdogDisable(void) +{ + + UT_GenStub_Execute(CFE_PSP_WatchdogDisable, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WatchdogEnable() + * ---------------------------------------------------- + */ +void CFE_PSP_WatchdogEnable(void) +{ + + UT_GenStub_Execute(CFE_PSP_WatchdogEnable, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WatchdogGet() + * ---------------------------------------------------- + */ +uint32 CFE_PSP_WatchdogGet(void) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_WatchdogGet, uint32); + + UT_GenStub_Execute(CFE_PSP_WatchdogGet, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_WatchdogGet, uint32); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WatchdogInit() + * ---------------------------------------------------- + */ +void CFE_PSP_WatchdogInit(void) +{ + + UT_GenStub_Execute(CFE_PSP_WatchdogInit, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WatchdogService() + * ---------------------------------------------------- + */ +void CFE_PSP_WatchdogService(void) +{ + + UT_GenStub_Execute(CFE_PSP_WatchdogService, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_WatchdogSet() + * ---------------------------------------------------- + */ +void CFE_PSP_WatchdogSet(uint32 WatchdogValue) +{ + UT_GenStub_AddParam(CFE_PSP_WatchdogSet, uint32, WatchdogValue); + + UT_GenStub_Execute(CFE_PSP_WatchdogSet, Basic, NULL); +} diff --git a/ut-stubs/ut_psp_stubs.c b/ut-stubs/ut_psp_stubs.c deleted file mode 100644 index 2e65ea2b..00000000 --- a/ut-stubs/ut_psp_stubs.c +++ /dev/null @@ -1,831 +0,0 @@ -/************************************************************************ - * 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. - ************************************************************************/ - -/* -** File: ut_bsp_stubs.c -** -** Purpose: -** Unit test stubs for BSP routines -** -** Notes: -** Minimal work is done, only what is required for unit testing -** -*/ - -/* -** Includes -*/ - -#include "cfe_psp.h" -#include "utstubs.h" -#include - -#include "target_config.h" - -Target_CfeConfigData GLOBAL_CFE_CONFIGDATA = {0}; - -/** - * Instantiation of global system-wide configuration struct - * This contains build info plus pointers to the PSP and CFE - * configuration structures. Everything will be linked together - * in the final executable. - */ -Target_ConfigData GLOBAL_CONFIGDATA = {.MissionVersion = "MissionUnitTest", - .CfeVersion = "CfeUnitTest", - .OsalVersion = "OsalUnitTest", - .Config = "MissionConfig", - .Date = "MissionBuildDate", - .User = "MissionBuildUser", - .Default_CpuName = "UnitTestCpu", - .Default_CpuId = 1, - .Default_SpacecraftId = 0x42, - .CfeConfig = &GLOBAL_CFE_CONFIGDATA}; - -/* -** Functions -*/ - -/*****************************************************************************/ -/** -** \brief CFE_PSP_Panic stub function -** -** \par Description -** This function is used to mimic the response of the OS API function -** CFE_PSP_Panic. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_PSP_Panic(int32 ErrorCode) -{ - UT_DEFAULT_IMPL(CFE_PSP_Panic); - UT_Stub_CopyFromLocal(UT_KEY(CFE_PSP_Panic), (uint8 *)&ErrorCode, sizeof(ErrorCode)); -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetProcessorId stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetProcessorId. It is set to return a fixed value for the -** unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns 0. -** -******************************************************************************/ -uint32 CFE_PSP_GetProcessorId(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetProcessorId); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetSpacecraftId stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetSpacecraftId. It is set to return a fixed value for the -** unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns 0. -** -******************************************************************************/ -uint32 CFE_PSP_GetSpacecraftId(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetSpacecraftId); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetProcessorName stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetProcessorName. It is set to return a fixed value for the -** unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns Default_CpuName or passed in address from buffer -** -******************************************************************************/ -const char *CFE_PSP_GetProcessorName(void) -{ - int32 status; - const char *ptr = GLOBAL_CONFIGDATA.Default_CpuName; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetProcessorName); - - if (status >= 0) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_GetProcessorName), &ptr, sizeof(ptr)); - } - - return ptr; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetTime stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetTime. The LocalTime structure is set to the user-defined -** values in BSP_Time. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_PSP_GetTime(OS_time_t *LocalTime) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetTime); - - if (status >= 0) - { - if (UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_GetTime), (uint8 *)LocalTime, sizeof(*LocalTime)) < sizeof(*LocalTime)) - { - *LocalTime = OS_TimeAssembleFromNanoseconds(100, 200000); - } - } -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_WriteToCDS stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_WriteToCDS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either OS_SUCCESS, OS_ERROR, or a user-defined value. -** -******************************************************************************/ -int32 CFE_PSP_WriteToCDS(const void *PtrToDataToWrite, uint32 CDSOffset, uint32 NumBytes) -{ - uint8 *BufPtr; - size_t CdsSize; - size_t Position; - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_WriteToCDS); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_WriteToCDS), (void **)&BufPtr, &CdsSize, &Position); - if (BufPtr != NULL && (CDSOffset + NumBytes) <= CdsSize) - { - memcpy(BufPtr + CDSOffset, PtrToDataToWrite, NumBytes); - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_ReadFromCDS stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_ReadFromCDS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either OS_SUCCESS, OS_ERROR, or a user-defined value. -** -******************************************************************************/ -int32 CFE_PSP_ReadFromCDS(void *PtrToDataToRead, uint32 CDSOffset, uint32 NumBytes) -{ - uint8 *BufPtr; - size_t CdsSize; - size_t Position; - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_ReadFromCDS); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_ReadFromCDS), (void **)&BufPtr, &CdsSize, &Position); - if (BufPtr != NULL && (CDSOffset + NumBytes) <= CdsSize) - { - memcpy(PtrToDataToRead, BufPtr + CDSOffset, NumBytes); - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetCDSSize stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_GetCDSSize. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either OS_SUCCESS or OS_ERROR. -** -******************************************************************************/ -int32 CFE_PSP_GetCDSSize(uint32 *SizeOfCDS) -{ - int32 status; - size_t TempSize; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetCDSSize); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), NULL, &TempSize, NULL); - *SizeOfCDS = TempSize; - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetVolatileDiskMem stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_GetVolatileDiskMem. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either OS_SUCCESS or OS_ERROR. -** -******************************************************************************/ -int32 CFE_PSP_GetVolatileDiskMem(cpuaddr *PtrToVolDisk, uint32 *SizeOfVolDisk) -{ - int32 status; - size_t TempSize; - void * TempAddr; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetVolatileDiskMem); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVolatileDiskMem), &TempAddr, &TempSize, NULL); - - *PtrToVolDisk = (cpuaddr)TempAddr; - *SizeOfVolDisk = TempSize; - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_Restart stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_Restart. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_PSP_Restart(uint32 resetType) -{ - UT_DEFAULT_IMPL(CFE_PSP_Restart); - UT_Stub_CopyFromLocal(UT_KEY(CFE_PSP_Restart), (uint8 *)&resetType, sizeof(resetType)); -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_Get_Timebase stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_Get_Timebase. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_PSP_Get_Timebase(uint32 *Tbu, uint32 *Tbl) -{ - *Tbu = 0; - *Tbl = 0; - - UT_Stub_RegisterContext(UT_KEY(CFE_PSP_Get_Timebase), Tbu); - UT_Stub_RegisterContext(UT_KEY(CFE_PSP_Get_Timebase), Tbl); - UT_DEFAULT_IMPL(CFE_PSP_Get_Timebase); -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetResetArea stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetResetArea. It returns the user-defined value, -** UT_StatusBSP. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns a user-defined status value, UT_StatusBSP. -** -******************************************************************************/ -int32 CFE_PSP_GetResetArea(cpuaddr *PtrToResetArea, uint32 *SizeOfResetArea) -{ - int32 status; - size_t TempSize; - void * TempAddr; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetResetArea); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), &TempAddr, &TempSize, NULL); - - *PtrToResetArea = (cpuaddr)TempAddr; - *SizeOfResetArea = TempSize; - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_AttachExceptions stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_AttachExceptions. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_PSP_AttachExceptions(void) -{ - UT_DEFAULT_IMPL(CFE_PSP_AttachExceptions); -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_SetDefaultExceptionEnvironment stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_SetDefaultExceptionEnvironment. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** This function does not return a value. -** -******************************************************************************/ -void CFE_PSP_SetDefaultExceptionEnvironment(void) -{ - UT_DEFAULT_IMPL(CFE_PSP_SetDefaultExceptionEnvironment); -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetTimerTicksPerSecond stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetTimerTicksPerSecond. It is set to return a fixed value -** for the unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns 2000. -** -******************************************************************************/ -uint32 CFE_PSP_GetTimerTicksPerSecond(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL_RC(CFE_PSP_GetTimerTicksPerSecond, 2000); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetTimerLow32Rollover stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_GetTimerLow32Rollover. It is set to return a fixed value -** for the unit tests. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns 1000000. -** -******************************************************************************/ -uint32 CFE_PSP_GetTimerLow32Rollover(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL_RC(CFE_PSP_GetTimerLow32Rollover, 100000); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetCFETextSegmentInfo stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_GetCFETextSegmentInfo. The user can adjust the response by -** setting the values in the BSPGetCFETextRtn structure prior to this -** function being called. If the value BSPGetCFETextRtn.count is -** greater than zero then the counter is decremented; if it then equals -** zero the return value is set to the user-defined value -** BSPGetCFETextRtn.value. OS_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_PSP_GetCFETextSegmentInfo(cpuaddr *PtrToCFESegment, uint32 *SizeOfCFESegment) -{ - static uint32 LocalTextSegment; - int32 status; - void * TempAddr; - size_t TempSize; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetCFETextSegmentInfo); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetCFETextSegmentInfo), &TempAddr, &TempSize, NULL); - if (TempAddr == NULL) - { - /* Backup -- Set the pointer and size to anything */ - *PtrToCFESegment = (cpuaddr)&LocalTextSegment; - *SizeOfCFESegment = sizeof(LocalTextSegment); - } - else - { - *PtrToCFESegment = (cpuaddr)TempAddr; - *SizeOfCFESegment = TempSize; - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_GetKernelTextSegmentInfo stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_GetKernelTextSegmentInfo. The user can adjust the response by -** setting the values in the BSPGetCFETextRtn structure prior to this -** function being called. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_PSP_GetKernelTextSegmentInfo(cpuaddr *PtrToKernelSegment, uint32 *SizeOfKernelSegment) -{ - static uint32 LocalTextSegment; - int32 status; - void * TempAddr; - size_t TempSize; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetKernelTextSegmentInfo); - - if (status >= 0) - { - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetKernelTextSegmentInfo), &TempAddr, &TempSize, NULL); - if (TempAddr == NULL) - { - /* Backup -- Set the pointer and size to anything */ - *PtrToKernelSegment = (cpuaddr)&LocalTextSegment; - *SizeOfKernelSegment = sizeof(LocalTextSegment); - } - else - { - *PtrToKernelSegment = (cpuaddr)TempAddr; - *SizeOfKernelSegment = TempSize; - } - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_MemRead8 stub function -** -** \par Description -** This function is used as a placeholder for the PSP function -** CFE_PSP_MemRead8. It sets the Data variable to a fixed value and -** always returns OS_SUCCESS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_PSP_MemRead8(cpuaddr Address, uint8 *Data) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_MemRead8); - - if (status >= 0) - { - *Data = 0x01; - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_MemValidateRange stub function -** -** \par Description -** This function is used to mimic the response of the PSP function -** CFE_PSP_MemValidateRange. The user can adjust the response by -** setting the values in the PSPMemValRangeRtn structure prior to this -** function being called. If the value PSPMemValRangeRtn.count is -** greater than zero then the counter is decremented; if it then equals -** zero the return value is set to the user-defined value -** PSPMemValRangeRtn.value. OS_SUCCESS is returned otherwise. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns either a user-defined status flag or OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_PSP_MemValidateRange(cpuaddr Address, size_t Size, uint32 MemoryType) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_MemValidateRange); - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_MemCpy stub function -** -** \par Description -** This function is used to mimic the response of the OS API function -** CFE_PSP_MemCpy. It always returns OS_SUCCESS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_PSP_MemCpy(void *dest, const void *src, uint32 n) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_MemCpy); - - if (status >= 0) - { - /* this is not actually a stub; it actually has to _do_ the intended function */ - memcpy(dest, src, n); - } - - return status; -} - -/*****************************************************************************/ -/** -** \brief CFE_PSP_MemSet stub function -** -** \par Description -** This function is used to mimic the response of the OS API function -** CFE_PSP_MemSet. It always returns OS_SUCCESS. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \returns -** Returns OS_SUCCESS. -** -******************************************************************************/ -int32 CFE_PSP_MemSet(void *dest, uint8 value, uint32 n) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_MemSet); - - if (status >= 0) - { - /* this is not actually a stub; it actually has to _do_ the intended function */ - memset(dest, (int)value, (size_t)n); - } - - return status; -} - -uint32 CFE_PSP_Exception_GetCount(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_Exception_GetCount); - - return status; -} - -int32 CFE_PSP_Exception_GetSummary(uint32 *ContextLogId, osal_id_t *TaskId, char *ReasonBuf, uint32 ReasonSize) -{ - int32 status; - - *ContextLogId = 0; - *TaskId = OS_OBJECT_ID_UNDEFINED; - *ReasonBuf = 0; - - /* allow the testcase to easily set the taskID output, anything more involved needs a hook */ - status = UT_DEFAULT_IMPL_ARGS(CFE_PSP_Exception_GetSummary, ContextLogId, TaskId, ReasonBuf, ReasonSize); - if (status == 0 && !OS_ObjectIdDefined(*TaskId)) - { - UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_Exception_GetSummary), TaskId, sizeof(*TaskId)); - } - - return status; -} - -int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint32 ContextSize) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_Exception_CopyContext); - if (status == 0) - { - status = UT_Stub_CopyToLocal(UT_KEY(CFE_PSP_Exception_CopyContext), ContextBuf, ContextSize); - } - - return status; -} - -/*---------------------------------------------------------------- - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -const char *CFE_PSP_GetVersionString(void) -{ - static const char DEFAULT[] = "UT"; - void * Buffer; - const char * RetVal; - - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVersionString), &Buffer, NULL, NULL); - if (Buffer == NULL) - { - RetVal = DEFAULT; - } - else - { - RetVal = Buffer; - } - - return RetVal; -} - -/*---------------------------------------------------------------- - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -const char *CFE_PSP_GetVersionCodeName(void) -{ - static const char DEFAULT[] = "UT"; - void * Buffer; - const char * RetVal; - - UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVersionCodeName), &Buffer, NULL, NULL); - if (Buffer == NULL) - { - RetVal = DEFAULT; - } - else - { - RetVal = Buffer; - } - - return RetVal; -} - -/*---------------------------------------------------------------- - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]) -{ - UT_Stub_RegisterContext(UT_KEY(CFE_PSP_GetVersionNumber), VersionNumbers); - UT_DEFAULT_IMPL(VersionNumbers); -} - -/*---------------------------------------------------------------- - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -uint32 CFE_PSP_GetBuildNumber(void) -{ - int32 status; - - status = UT_DEFAULT_IMPL(CFE_PSP_GetBuildNumber); - - return status; -} From 8b005cc59c79ceaa3376ea578db10d529c3104cd Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 12 Sep 2024 11:27:58 -0400 Subject: [PATCH 2/6] Fix #432, buffer error in the VxWorks sysmon module The cpu number to poll was not range checked until _after_ the memset. This is not the correct order of operations, it must range the element number in the array before writing/clearing it. --- fsw/modules/vxworks_sysmon/vxworks_sysmon.c | 102 +++++++++--------- fsw/modules/vxworks_sysmon/vxworks_sysmon.h | 2 +- .../src/coveragetest-vxworks_sysmon.c | 13 +-- 3 files changed, 59 insertions(+), 58 deletions(-) diff --git a/fsw/modules/vxworks_sysmon/vxworks_sysmon.c b/fsw/modules/vxworks_sysmon/vxworks_sysmon.c index d1d6c65f..735dd3c7 100644 --- a/fsw/modules/vxworks_sysmon/vxworks_sysmon.c +++ b/fsw/modules/vxworks_sysmon/vxworks_sysmon.c @@ -58,11 +58,19 @@ void vxworks_sysmon_Init(uint32_t local_module_id) int vxworks_sysmon_update_stat(const char *fmt, ...) { - vxworks_sysmon_cpuload_state_t *state = &vxworks_sysmon_global.cpu_load; - vxworks_sysmon_cpuload_core_t *core_p = &state->per_core[state->num_cpus]; - + vxworks_sysmon_cpuload_state_t *state; + vxworks_sysmon_cpuload_core_t *core_p; int curr_load; va_list arg; + + state = &vxworks_sysmon_global.cpu_load; + + if (state->poll_core_no >= VXWORKS_SYSMON_MAX_CPUS) + { + state->poll_core_no = 0; + } + + core_p = &state->per_core[state->poll_core_no]; memset(&core_p->idle_state, 0, sizeof(vxworks_sysmon_va_arg_t)); va_start(arg, fmt); @@ -71,58 +79,55 @@ int vxworks_sysmon_update_stat(const char *fmt, ...) /* only want IDLE string */ if(strncmp("IDLE", core_p->idle_state.name, 4) == 0) { - if(state->num_cpus < VXWORKS_SYSMON_MAX_CPUS) + /* + ** Example format: + ** (* printRtn) (spyFmt2, "IDLE", "", "", "", totalPerCent, spyIdleTicks, + ** incPerCent, tmpIdleIncTicks); + ** + ** NAME ENTRY TID PRI total % (ticks) delta % (ticks) + ** -------- -------- ----- --- --------------- --------------- + ** IDLE 95% ( 7990) 95% ( 1998) + ** + */ + core_p->idle_state.placeholder = va_arg(arg, char *); + core_p->idle_state.placeholder = va_arg(arg, char *); + core_p->idle_state.placeholder = va_arg(arg, char *); + + core_p->idle_state.total_idle_percent = va_arg(arg, int); + core_p->idle_state.total_idle_ticks = va_arg(arg, int); + core_p->idle_state.idle_percent_since_last_report = va_arg(arg, int); + core_p->idle_state.idle_ticks_since_last_report = va_arg(arg, int); + + curr_load = VXWORKS_SYSMON_MAX_SCALE - core_p->idle_state.idle_percent_since_last_report; + + if (curr_load >= 100) { - /* - ** Example format: - ** (* printRtn) (spyFmt2, "IDLE", "", "", "", totalPerCent, spyIdleTicks, - ** incPerCent, tmpIdleIncTicks); - ** - ** NAME ENTRY TID PRI total % (ticks) delta % (ticks) - ** -------- -------- ----- --- --------------- --------------- - ** IDLE 95% ( 7990) 95% ( 1998) - ** - */ - core_p->idle_state.placeholder = va_arg(arg, char *); - core_p->idle_state.placeholder = va_arg(arg, char *); - core_p->idle_state.placeholder = va_arg(arg, char *); - - core_p->idle_state.total_idle_percent = va_arg(arg, int); - core_p->idle_state.total_idle_ticks = va_arg(arg, int); - core_p->idle_state.idle_percent_since_last_report = va_arg(arg, int); - core_p->idle_state.idle_ticks_since_last_report = va_arg(arg, int); - - curr_load = VXWORKS_SYSMON_MAX_SCALE - core_p->idle_state.idle_percent_since_last_report; - - if (curr_load >= 100) - { - core_p->avg_load = 0xFFFFFF; /* max */ - } - else if (curr_load <= 0) - { - core_p->avg_load = 0; - } - else - { - core_p->avg_load = (0x1000 * curr_load) / VXWORKS_SYSMON_MAX_SCALE ; - core_p->avg_load |= (core_p->avg_load << 12); /* Expand from 12->24 bit */ - } - - VXWORKS_SYSMON_DEBUG("CFE_PSP(vxworks_sysmon): load=%06x\n", (unsigned int)core_p->avg_load); - VXWORKS_SYSMON_DEBUG("Name: %s, Total Percent: %d, Total Ticks: %d, Idle Percent: %d, Idle Ticks: %d\n", - core_p->idle_state.name, - core_p->idle_state.total_idle_percent, - core_p->idle_state.total_idle_ticks, - core_p->idle_state.idle_percent_since_last_report, - core_p->idle_state.idle_ticks_since_last_report); + core_p->avg_load = 0xFFFFFF; /* max */ + } + else if (curr_load <= 0) + { + core_p->avg_load = 0; + } + else + { + core_p->avg_load = (0x1000 * curr_load) / VXWORKS_SYSMON_MAX_SCALE ; + core_p->avg_load |= (core_p->avg_load << 12); /* Expand from 12->24 bit */ + } - state->num_cpus++; + VXWORKS_SYSMON_DEBUG("CFE_PSP(vxworks_sysmon): load=%06x\n", (unsigned int)core_p->avg_load); + VXWORKS_SYSMON_DEBUG("Name: %s, Total Percent: %d, Total Ticks: %d, Idle Percent: %d, Idle Ticks: %d\n", + core_p->idle_state.name, + core_p->idle_state.total_idle_percent, + core_p->idle_state.total_idle_ticks, + core_p->idle_state.idle_percent_since_last_report, + core_p->idle_state.idle_ticks_since_last_report); - } /* end of cpu check */ } /* end of idle check */ va_end(arg); + ++state->poll_core_no; + return 0; } @@ -151,7 +156,6 @@ void vxworks_sysmon_Task(void) { OS_TaskDelay(VXWORKS_SYSMON_SAMPLE_DELAY); - state->num_cpus = 0; spyReportCommon( (FUNCPTR)vxworks_sysmon_update_stat); } diff --git a/fsw/modules/vxworks_sysmon/vxworks_sysmon.h b/fsw/modules/vxworks_sysmon/vxworks_sysmon.h index 8a5acf4c..9cae2a09 100644 --- a/fsw/modules/vxworks_sysmon/vxworks_sysmon.h +++ b/fsw/modules/vxworks_sysmon/vxworks_sysmon.h @@ -79,7 +79,7 @@ typedef struct vxworks_sysmon_cpuload_state osal_id_t task_id; - uint8_t num_cpus; + uint8_t poll_core_no; vxworks_sysmon_cpuload_core_t per_core[VXWORKS_SYSMON_MAX_CPUS]; 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 index d66fd62a..6b2484b7 100644 --- a/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c +++ b/unit-test-coverage/modules/vxworks_sysmon/src/coveragetest-vxworks_sysmon.c @@ -297,17 +297,16 @@ void Test_UpdateStat_Nominal(void) 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; + IdleTaskLoad = 0; + vxworks_sysmon_global.cpu_load.poll_core_no = 1 + VXWORKS_SYSMON_MAX_CPUS; 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"); + UtAssert_UINT8_EQ(vxworks_sysmon_global.cpu_load.poll_core_no, 1); /* 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"); - + UtAssert_ZERO(vxworks_sysmon_global.cpu_load.per_core[0].avg_load); + UtAssert_UINT8_EQ(vxworks_sysmon_global.cpu_load.poll_core_no, 1); } void Test_Task_Nominal(void) @@ -329,7 +328,6 @@ void Test_Task_Error(void) vxworks_sysmon_Task(); UtAssert_True(vxworks_sysmon_global.cpu_load.should_run == false, "Error Case: Cannot Start Auxillary Clock"); - } /* @@ -351,5 +349,4 @@ void UtTest_Setup(void) ADD_TEST(Test_UpdateStat_Nominal); ADD_TEST(Test_Task_Nominal); ADD_TEST(Test_Task_Error); - } From 2336ddee131d8d1c40c65989bc317d7a7e2c2486 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 12 Sep 2024 16:32:17 -0400 Subject: [PATCH 3/6] Fix #435, correct init in PCS_malloc call The handler executes after the stub count increments, thus this needs to check for 1 to indicate the first call, not 0. --- unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c index 381b0b4b..7a166ff9 100644 --- a/unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c +++ b/unit-test-coverage/ut-stubs/src/PCS_stdlib_handlers.c @@ -94,7 +94,7 @@ void UT_DefaultHandler_PCS_malloc(void *UserObj, UT_EntryKey_t FuncKey, const UT Rec = (struct MPOOL_REC *)PoolStart; NextBlock = PoolStart + MPOOL_ALIGN; PoolSize -= MPOOL_ALIGN; - if (CallCnt == 0) + if (CallCnt == 1) { Rec->Magic = MPOOL_START_SIGNATURE; Rec->Size = 0; From d2e641fac35cd45f5509456c19e8a26b0276cf07 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 16 Sep 2024 14:37:18 -0400 Subject: [PATCH 4/6] Updating documentation and version numbers for equuleus-rc1+dev49 --- 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 9bd7a0b9..203aa92b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Development Build: equuleus-rc1+dev49 +- buffer error in the VxWorks sysmon module +- add coverage tests for PSP modules +- See and + ## Development Build: equuleus-rc1+dev42 - Adds node20 compatible github actions - See diff --git a/fsw/mcp750-vxworks/inc/psp_version.h b/fsw/mcp750-vxworks/inc/psp_version.h index 9c74268a..28799cc7 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 42 +#define CFE_PSP_IMPL_BUILD_NUMBER 49 #define CFE_PSP_IMPL_BUILD_BASELINE "equuleus-rc1" #define CFE_PSP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ #define CFE_PSP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */ diff --git a/fsw/pc-linux/inc/psp_version.h b/fsw/pc-linux/inc/psp_version.h index 9c74268a..28799cc7 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 42 +#define CFE_PSP_IMPL_BUILD_NUMBER 49 #define CFE_PSP_IMPL_BUILD_BASELINE "equuleus-rc1" #define CFE_PSP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ #define CFE_PSP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */ diff --git a/fsw/pc-rtems/inc/psp_version.h b/fsw/pc-rtems/inc/psp_version.h index 9c74268a..28799cc7 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 42 +#define CFE_PSP_IMPL_BUILD_NUMBER 49 #define CFE_PSP_IMPL_BUILD_BASELINE "equuleus-rc1" #define CFE_PSP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ #define CFE_PSP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */ From fe8a77628ce9e801d44f644f492f51a2e9ab584e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 16 Sep 2024 15:19:28 -0400 Subject: [PATCH 5/6] HOTFIX #437, correct type in UT time handler --- unit-test-coverage/ut-stubs/src/PCS_time_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c index 3ad64e40..a1fdb874 100644 --- a/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c +++ b/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c @@ -27,7 +27,7 @@ void UT_DefaultHandler_PCS_clock_gettime(void *UserObj, UT_EntryKey_t FuncKey, c { /* int PCS_clock_gettime(int clk_id, struct PCS_timespec *t) */ struct PCS_timespec *t = UT_Hook_GetArgValueByName(Context, "t", struct PCS_timespec *); - int iStatus; + int32 iStatus; UT_Stub_GetInt32StatusCode(Context, &iStatus); From b42fc7a298748ba14811f10515dbdebb8c72aab8 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 19 Sep 2024 08:18:53 -0400 Subject: [PATCH 6/6] HOTFIX #437, Additional type fix for RTEMS 4 --- fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c | 2 +- unit-test-coverage/ut-stubs/src/PCS_time_handlers.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c b/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c index 1b93393c..85cd2707 100644 --- a/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c +++ b/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c @@ -190,7 +190,7 @@ void eeprom_mmap_file_Init(uint32 PspModuleId) Status = CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_EEPROM, eeprom_address, eeprom_size, CFE_PSP_MEM_SIZE_DWORD, CFE_PSP_MEM_ATTR_READWRITE); OS_printf("CFE_PSP: EEPROM Range (2) created: Start Address = %08lX, Size = %08X Status = %d\n", - (unsigned long)eeprom_address, (unsigned int)eeprom_size, Status); + (unsigned long)eeprom_address, (unsigned int)eeprom_size, (int)Status); } else { diff --git a/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c b/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c index a1fdb874..6d5ab351 100644 --- a/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c +++ b/unit-test-coverage/ut-stubs/src/PCS_time_handlers.c @@ -27,7 +27,7 @@ void UT_DefaultHandler_PCS_clock_gettime(void *UserObj, UT_EntryKey_t FuncKey, c { /* int PCS_clock_gettime(int clk_id, struct PCS_timespec *t) */ struct PCS_timespec *t = UT_Hook_GetArgValueByName(Context, "t", struct PCS_timespec *); - int32 iStatus; + int32 iStatus; UT_Stub_GetInt32StatusCode(Context, &iStatus);