diff --git a/README.md b/README.md index 660436101..3d19f22e2 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,15 @@ The detailed cFE user's guide can be viewed at + ### Development Build: 6.8.0-rc1+dev236 - Resolved doxygen warnings for osalguide and updated header file references diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c index 28653956c..db2254b4c 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/fsw/cfe-core/src/es/cfe_es_backgroundtask.c @@ -136,25 +136,12 @@ void CFE_ES_BackgroundTask(void) { /* * compute the elapsed time (difference) between last - * execution and now, in microseconds. - * - * Note this calculation is done as a uint32 which will overflow - * after about 35 minutes, but the max delays ensure that this - * executes at least every few seconds, so that should never happen. + * execution and now, in milliseconds. */ CFE_PSP_GetTime(&CurrTime); - ElapsedTime = 1000000 * (CurrTime.seconds - LastTime.seconds); - ElapsedTime += CurrTime.microsecs; - ElapsedTime -= LastTime.microsecs; + ElapsedTime = OS_TimeGetTotalMilliseconds(OS_TimeSubtract(CurrTime, LastTime)); LastTime = CurrTime; - /* - * convert to milliseconds. - * we do not really need high precision - * for background task timings - */ - ElapsedTime /= 1000; - NextDelay = CFE_ES_BACKGROUND_MAX_IDLE_DELAY; /* default; will be adjusted based on active jobs */ JobPtr = CFE_ES_BACKGROUND_JOB_TABLE; JobTotal = CFE_ES_BACKGROUND_NUM_JOBS; diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/fsw/cfe-core/src/es/cfe_es_start.c index 2a883ef13..560fc259d 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/fsw/cfe-core/src/es/cfe_es_start.c @@ -494,11 +494,11 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo */ void CFE_ES_InitializeFileSystems(uint32 StartType) { - int32 RetStatus; - cpuaddr RamDiskMemoryAddress; - uint32 RamDiskMemorySize; - int32 BlocksFree; - int32 PercentFree; + int32 RetStatus; + cpuaddr RamDiskMemoryAddress; + uint32 RamDiskMemorySize; + int32 PercentFree; + OS_statvfs_t StatBuf; /* ** Get the memory area for the RAM disk @@ -601,25 +601,13 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** See how many blocks are free in the RAM disk */ - BlocksFree = OS_fsBlocksFree(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if ( BlocksFree >= 0 ) + RetStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf); + if ( RetStatus == OS_SUCCESS && StatBuf.total_blocks > 0 ) { - /* - ** Need a sanity check for the desktop systems. - ** Because the desktop ports map the volatile disk to the host - ** hard disk, it will report more free blocks than the defined number - ** of sectors ( blocks ). Therefore it must be truncated. - */ - if ( BlocksFree > CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS ) - { - BlocksFree = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS - 1; - } - /* ** Determine if the disk is too full */ - BlocksFree = BlocksFree * 100; - PercentFree = BlocksFree / CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS; + PercentFree = (StatBuf.blocks_free * 100) / StatBuf.total_blocks; CFE_ES_WriteToSysLog("Volatile Disk has %d Percent free space.\n",(int)PercentFree); if ( PercentFree < CFE_PLATFORM_ES_RAM_DISK_PERCENT_RESERVED ) @@ -721,7 +709,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else /* could not determine free blocks */ { /* Log error message -- note that BlocksFree returns the error code in this case */ - CFE_ES_WriteToSysLog("ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n",(unsigned int)BlocksFree); + CFE_ES_WriteToSysLog("ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n",(unsigned int)RetStatus); /* ** Delay to allow the message to be read @@ -983,4 +971,3 @@ int32 CFE_ES_MainTaskSyncDelay(uint32 AppStateId, uint32 TimeOutMilliseconds) return Status; } - diff --git a/fsw/cfe-core/src/inc/cfe_sb.h b/fsw/cfe-core/src/inc/cfe_sb.h index 551fd71b5..2d01e1ef3 100644 --- a/fsw/cfe-core/src/inc/cfe_sb.h +++ b/fsw/cfe-core/src/inc/cfe_sb.h @@ -152,14 +152,6 @@ typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t; #define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */ #endif /* CFE_OMIT_DEPRECATED_6_8 */ -/** \brief CFE_SB_TimeOut_t to primitive type definition -** -** Internally used by SB in the #CFE_SB_ReceiveBuffer API. Translated from the -** input parmater named TimeOut which specifies the maximum time in -** milliseconds that the caller wants to wait for a message. -*/ -typedef uint32 CFE_SB_TimeOut_t; - /** \brief CFE_SB_PipeId_t to primitive type definition ** ** Software Bus pipe identifier used in many SB APIs @@ -646,7 +638,7 @@ CFE_Status_t CFE_SB_PassMsg(CFE_MSG_Message_t *MsgPtr); **/ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut); -#if CFE_OMIT_DEPRECATED_6_8 +#ifndef CFE_OMIT_DEPRECATED_6_8 /** * \brief DEPRECATED: receive buffer * \deprecated use CFE_SB_ReceiveBuffer diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index 1212ec4c7..b27ec7c51 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -35,7 +35,7 @@ /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 236 /*!< Development Build: Number of commits since baseline */ +#define CFE_BUILD_NUMBER 248 /*!< Development Build: Number of commits since baseline */ #define CFE_BUILD_BASELINE "v6.8.0-rc1" /*!< Development Build: git tag that is the base for the current development */ /* Version Macro Definitions */ diff --git a/fsw/cfe-core/src/inc/network_includes.h b/fsw/cfe-core/src/inc/network_includes.h deleted file mode 100644 index 4ba4c9513..000000000 --- a/fsw/cfe-core/src/inc/network_includes.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 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: network_includes.h -** -** Purpose: -** This header file contains the correct set of network include -** files, which are dependant on the operating system. -** -** Author: R.McGraw/SSI -** -** Notes: -** -******************************************************************************/ - -#ifndef _network_includes_ -#define _network_includes_ - -#ifdef _VXWORKS_OS_ - #include - #include - #include - #include - #include - #include - #include - -#elif _RTEMS_OS_ - #define _USING_RTEMS_INCLUDES_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - #ifndef MSG_DONTWAIT - #define MSG_DONTWAIT 0 - #endif -#elif _MAC_OS_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - -#elif _LINUX_OS_ - #include - #include - #include - #include - #include - #include - #include - #define _HAVE_FCNTL_ - #ifndef MSG_DONTWAIT - #define MSG_DONTWAIT 0 - #endif - -#else - #error "No OS defined!" -#endif - -#endif /* _network_includes_ */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index 62fd41809..f05161ad1 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -1455,7 +1455,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr, } -#if CFE_OMIT_DEPRECATED_6_8 +#ifndef CFE_OMIT_DEPRECATED_6_8 int32 CFE_SB_RcvMsg(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) @@ -1891,7 +1891,7 @@ int32 CFE_SB_ZeroCopyPass(CFE_SB_Buffer_t *BufPtr, int32 CFE_SB_ReadQueue (CFE_SB_PipeD_t *PipeDscPtr, CFE_ES_ResourceID_t TskId, - CFE_SB_TimeOut_t Time_Out, + uint32 Time_Out, CFE_SB_BufferD_t **Message) { int32 Status,TimeOut; diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/fsw/cfe-core/src/sb/cfe_sb_priv.h index a70d658fe..f8a0ff05a 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/fsw/cfe-core/src/sb/cfe_sb_priv.h @@ -239,7 +239,7 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber); void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber); void CFE_SB_ReleaseBuffer (CFE_SB_BufferD_t *bd, CFE_SB_DestinationD_t *dest); int32 CFE_SB_ReadQueue(CFE_SB_PipeD_t *PipeDscPtr,CFE_ES_ResourceID_t TskId, - CFE_SB_TimeOut_t Time_Out,CFE_SB_BufferD_t **Message ); + uint32 Time_Out,CFE_SB_BufferD_t **Message ); int32 CFE_SB_WriteQueue(CFE_SB_PipeD_t *pd,uint32 TskId, const CFE_SB_BufferD_t *bd,CFE_SB_MsgId_t MsgId ); uint8 CFE_SB_GetPipeIdx(CFE_SB_PipeId_t PipeId); diff --git a/fsw/cfe-core/src/time/cfe_time_api.c b/fsw/cfe-core/src/time/cfe_time_api.c index 37e8060d7..96b39ca09 100644 --- a/fsw/cfe-core/src/time/cfe_time_api.c +++ b/fsw/cfe-core/src/time/cfe_time_api.c @@ -489,57 +489,16 @@ CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_ */ uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds) { - uint32 MicroSeconds; - - /* 0xffffdf00 subseconds = 999999 microseconds, so anything greater - * than that we set to 999999 microseconds, so it doesn't get to - * a million microseconds */ - - if (SubSeconds > 0xffffdf00) - { - MicroSeconds = 999999; - } - else - { - /* - ** Convert a 1/2^32 clock tick count to a microseconds count - ** - ** Conversion factor is ( ( 2 ** -32 ) / ( 10 ** -6 ) ). - ** - ** Logic is as follows: - ** x * ( ( 2 ** -32 ) / ( 10 ** -6 ) ) - ** = x * ( ( 10 ** 6 ) / ( 2 ** 32 ) ) - ** = x * ( ( 5 ** 6 ) ( 2 ** 6 ) / ( 2 ** 26 ) ( 2 ** 6) ) - ** = x * ( ( 5 ** 6 ) / ( 2 ** 26 ) ) - ** = x * ( ( 5 ** 3 ) ( 5 ** 3 ) / ( 2 ** 7 ) ( 2 ** 7 ) (2 ** 12) ) - ** - ** C code equivalent: - ** = ( ( ( ( ( x >> 7) * 125) >> 7) * 125) >> 12 ) - */ - - MicroSeconds = (((((SubSeconds >> 7) * 125) >> 7) * 125) >> 12); - + OS_time_t tm; - /* if the Subseconds % 0x4000000 != 0 then we will need to - * add 1 to the result. the & is a faster way of doing the % */ - if ((SubSeconds & 0x3ffffff) != 0) - { - MicroSeconds++; - } - - /* In the Micro2SubSecs conversion, we added an extra anomaly - * to get the subseconds to bump up against the end point, - * 0xFFFFF000. This must be accounted for here. Since we bumped - * at the half way mark, we must "unbump" at the same mark - */ - if (MicroSeconds > 500000) - { - MicroSeconds --; - } - - } /* end else */ - - return(MicroSeconds); + /* + ** Convert using the OSAL method. Note that there + ** is no range check here because any uint32 value is valid, + ** and OSAL will handle and properly convert any input. + */ + tm = OS_TimeAssembleFromSubseconds(0, SubSeconds); + + return OS_TimeGetMicrosecondsPart(tm); } /* End of CFE_TIME_Sub2MicroSecs() */ @@ -549,10 +508,12 @@ uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds) */ uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds) { + OS_time_t tm; uint32 SubSeconds; /* ** Conversion amount must be less than one second + ** (preserves existing behavior where output saturates at max value) */ if (MicroSeconds > 999999) { @@ -560,40 +521,11 @@ uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds) } else { - /* - ** Convert micro-seconds count to sub-seconds (1/2^32) count - ** - ** Conversion factor is ( ( 10 ** -6 ) / ( 2 ** -20 ). - ** - ** Logic is as follows: - ** x * ( ( 10 ** -6 ) / ( 2 ** -32 ) ) - ** = x * ( ( 2 ** 32 ) / ( 10 ** 6 ) ) - ** = x * ( ( ( 2 ** 26 ) ( 2 ** 6) ) / ( ( 5 ** 6 ) ( 2 ** 6 ) ) ) - ** = x * ( ( 2 ** 26 ) / ( 5 ** 6 ) ) - ** = x * ( ( ( 2 ** 11) ( 2 ** 3) (2 ** 12) ) / ( 5( 5 ** 5 ) ) ) - ** = x * ( ( ( ( ( 2 ** 11 ) / 5 ) * ( 2 ** 3 ) ) / ( 5 ** 5 ) ) * (2 ** 12) ) - ** - ** C code equivalent: - ** = ( ( ( ( ( x << 11 ) / 5 ) << 3 ) / 3125 ) << 12 ) - ** - ** Conversion factor was reduced and factored accordingly - ** to minimize precision loss and register overflow. - */ - SubSeconds = ( ( ( ( MicroSeconds << 11 ) / 5 ) << 3 ) / 3125 ) << 12; - - /* To get the SubSeconds to "bump up" against 0xFFFFF000 when - * MicroSeconds = 9999999, we add in another anomaly to the - * conversion at the half-way point (500000 us). This will bump - * all of the subseconds up by 0x1000, so 999999 us == 0xFFFFF00, - * 999998 == 0xFFFFE000, etc. This extra anomaly is accounted for - * in the Sub2MicroSecs conversion as well. - */ - - if (SubSeconds > 0x80001000) - { - SubSeconds += 0x1000; - } - + /* + ** Convert micro-seconds count to sub-seconds (1/2^32) count using OSAL + */ + tm = OS_TimeAssembleFromNanoseconds(0, MicroSeconds * 1000); + SubSeconds = OS_TimeGetSubsecondsPart(tm); } return(SubSeconds); diff --git a/fsw/cfe-core/src/time/cfe_time_utils.c b/fsw/cfe-core/src/time/cfe_time_utils.c index aeaeebeef..a29623875 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.c +++ b/fsw/cfe-core/src/time/cfe_time_utils.c @@ -91,8 +91,8 @@ CFE_TIME_SysTime_t CFE_TIME_LatchClock(void) /* ** Convert time to cFE format (seconds : 1/2^32 subseconds)... */ - LatchTime.Seconds = LocalTime.seconds; - LatchTime.Subseconds = CFE_TIME_Micro2SubSecs(LocalTime.microsecs); + LatchTime.Seconds = OS_TimeGetTotalSeconds(LocalTime); + LatchTime.Subseconds = OS_TimeGetSubsecondsPart(LocalTime); return(LatchTime); diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index 2190e3851..bff84dc8b 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -711,6 +711,7 @@ void TestStartupErrorPaths(void) ES_UT_SetAppStateHook_t StateHook; uint32 PanicStatus; uint32 ResetType; + OS_statvfs_t StatBuf; CFE_ES_TaskRecord_t *TaskRecPtr; CFE_ES_AppRecord_t *AppRecPtr; @@ -886,6 +887,11 @@ void TestStartupErrorPaths(void) "CFE_ES_InitializeFileSystems", "Power on reset; error creating volatile (RAM) volume"); + /* prepare the StatBuf to reflect a RAM disk that is 99% full */ + StatBuf.block_size = 1024; + StatBuf.total_blocks = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS; + StatBuf.blocks_free = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS / 100; + /* Test initialization of the file systems specifying a processor reset * following a failure to reformat the RAM volume */ @@ -893,6 +899,7 @@ void TestStartupErrorPaths(void) UT_SetDefaultReturnValue(UT_KEY(OS_initfs), OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_mount), OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_mkfs), OS_ERROR); + UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume), &StatBuf, sizeof(StatBuf), false); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_INSUFF_FREE_SPACE]) && @@ -909,6 +916,7 @@ void TestStartupErrorPaths(void) */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_GetVolatileDiskMem), CFE_PSP_ERROR); + UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume), &StatBuf, sizeof(StatBuf), false); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_INSUFF_FREE_SPACE]) && @@ -916,24 +924,12 @@ void TestStartupErrorPaths(void) "CFE_ES_InitializeFileSystems", "Processor reset; cannot get memory for volatile disk"); - /* Test initialization of the file systems where the number of free blocks - * reported is greater than the number of RAM disk sectors - */ - ES_ResetUnitTest(); - UT_SetDefaultReturnValue(UT_KEY(OS_mount), OS_ERROR); - UT_SetDeferredRetcode(UT_KEY(OS_fsBlocksFree), 1, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS + 1); - CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); - UT_Report(__FILE__, __LINE__, - UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_MOUNT_VOLATILE]) && - UT_GetStubCount(UT_KEY(OS_printf)) == 2, - "CFE_ES_InitializeFileSystems", - "Processor reset; truncate free block count"); - /* Test initialization of the file systems specifying a processor reset * following a failure to remove the RAM volume */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(OS_rmfs), OS_ERROR); + UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume), &StatBuf, sizeof(StatBuf), false); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_INSUFF_FREE_SPACE]) && @@ -947,6 +943,7 @@ void TestStartupErrorPaths(void) */ ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_unmount), 1, -1); + UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume), &StatBuf, sizeof(StatBuf), false); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_INSUFF_FREE_SPACE]) && @@ -968,6 +965,7 @@ void TestStartupErrorPaths(void) */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(OS_mount), OS_ERROR); + UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume), &StatBuf, sizeof(StatBuf), false); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_INSUFF_FREE_SPACE]) && @@ -981,7 +979,7 @@ void TestStartupErrorPaths(void) * number of blocks that are free on the volume */ ES_ResetUnitTest(); - UT_SetDeferredRetcode(UT_KEY(OS_fsBlocksFree), 1, -1); + UT_SetDeferredRetcode(UT_KEY(OS_FileSysStatVolume), 1, -1); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_DETERMINE_BLOCKS]) && @@ -1106,6 +1104,7 @@ void TestStartupErrorPaths(void) ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(OS_initfs), OS_ERROR); UT_SetDefaultReturnValue(UT_KEY(OS_mount), OS_ERROR); + UT_SetDataBuffer(UT_KEY(OS_FileSysStatVolume), &StatBuf, sizeof(StatBuf), false); CFE_ES_InitializeFileSystems(CFE_PSP_RST_TYPE_PROCESSOR); UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_INSUFF_FREE_SPACE]) && diff --git a/fsw/cfe-core/unit-test/time_UT.c b/fsw/cfe-core/unit-test/time_UT.c index 79455f147..91c922c53 100644 --- a/fsw/cfe-core/unit-test/time_UT.c +++ b/fsw/cfe-core/unit-test/time_UT.c @@ -1056,6 +1056,14 @@ void Test_ConvertTime(void) "CFE_TIME_MET2SCTime", testDesc); + /* NOTE: Microseconds <-> Subseconds conversion routines are implemented + * as part of OS_time_t in OSAL, and are coverage tested there. CFE time + * conversions are now just wrappers of these OSAL routines. + + * This should only sanity-check basic values to get coverage of the CFE + * wrappers. Testing of value corner cases / rounding should be limited to + * OSAL coverage test. */ + /* Test subseconds to microseconds conversion; zero subsecond value */ UT_InitData(); UT_Report(__FILE__, __LINE__, @@ -1063,31 +1071,13 @@ void Test_ConvertTime(void) "CFE_TIME_Sub2MicroSecs", "Convert 0 subsecond value"); - /* Test subseconds to microseconds conversion; positive microsecond - * adjust - */ - UT_InitData(); - UT_Report(__FILE__, __LINE__, - CFE_TIME_Sub2MicroSecs(0xffff) == 16, - "CFE_TIME_Sub2MicroSecs", - "+1 microsecond adjustment"); - - /* Test subseconds to microseconds conversion; no microsecond adjust */ + /* Test subseconds to microseconds conversion; half second */ UT_InitData(); UT_Report(__FILE__, __LINE__, CFE_TIME_Sub2MicroSecs(0x80000000) == 500000, "CFE_TIME_Sub2MicroSecs", "No microsecond adjustment"); - /* Test subseconds to microseconds conversion; negative microsecond - * adjust - */ - UT_InitData(); - UT_Report(__FILE__, __LINE__, - CFE_TIME_Sub2MicroSecs(0x80002000) == 500001, - "CFE_TIME_Sub2MicroSecs", - "-1 microsecond adjustment"); - /* Test subseconds to microseconds conversion; subseconds exceeds * microseconds limit */ @@ -1104,31 +1094,6 @@ void Test_ConvertTime(void) "CFE_TIME_Micro2SubSecs", "Convert 0 microseconds to 0 subseconds"); - /* Test microseconds to subseconds conversion; no subsecond adjust */ - UT_InitData(); - UT_Report(__FILE__, __LINE__, - CFE_TIME_Micro2SubSecs(0xffff) == 281468928, - "CFE_TIME_Micro2SubSecs", - "Microseconds below maximum value (no subsecond adjustment)"); - - /* Test microseconds to subseconds conversion; microseconds below - * maximum limit - */ - UT_InitData(); - UT_Report(__FILE__, __LINE__, - CFE_TIME_Micro2SubSecs(999998) == 0xffffe000, - "CFE_TIME_Micro2SubSecs", - "Microseconds below maximum value (subsecond adjustment)"); - - /* Test microseconds to subseconds conversion; microseconds equals - * maximum limit - */ - UT_InitData(); - UT_Report(__FILE__, __LINE__, - CFE_TIME_Micro2SubSecs(999999) == 0xfffff000, - "CFE_TIME_Micro2SubSecs", - "Microseconds equals maximum value (subsecond adjustment)"); - /* Test microseconds to subseconds conversion; microseconds exceeds * maximum limit */ diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index 7c545dcc3..e42dda886 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -373,8 +373,7 @@ void UT_SetBSP_Time(uint32 seconds, uint32 microsecs) { OS_time_t BSP_Time; - BSP_Time.seconds = seconds; - BSP_Time.microsecs = microsecs; + BSP_Time = OS_TimeAssembleFromNanoseconds(seconds, microsecs * 1000); UT_SetDataBuffer(UT_KEY(CFE_PSP_GetTime), &BSP_Time, sizeof(BSP_Time), true); }