From 914d9b32b2d8fac619e3e534db230e775b3026b2 Mon Sep 17 00:00:00 2001 From: Alex Campbell Date: Tue, 24 Aug 2021 11:24:44 -0400 Subject: [PATCH 1/2] Fix #1843, Add Time Clock Test --- modules/cfe_testcase/src/time_current_test.c | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/modules/cfe_testcase/src/time_current_test.c b/modules/cfe_testcase/src/time_current_test.c index 901e6ca7c..db2789840 100644 --- a/modules/cfe_testcase/src/time_current_test.c +++ b/modules/cfe_testcase/src/time_current_test.c @@ -32,6 +32,7 @@ */ #include "cfe_test.h" +#include "cfe_time_msg.h" bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t difference) { @@ -51,6 +52,18 @@ bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t d } } +bool ClockFlagCheck(uint16 info, int flag) +{ + if ((info & flag) == flag) + { + return true; + } + else + { + return false; + } +} + void TestGetTime(void) { UtPrintf("Testing: CFE_TIME_GetTime, CFE_TIME_GetTAI, CFE_TIME_GetUTC, CFE_TIME_GetMET, CFE_TIME_GetSTCF, " @@ -120,7 +133,39 @@ void TestGetTime(void) UtAssert_True(TimeInRange(MET, Buf, difference), "MET (%s) = METSubSeconds (%s)", timeBuf1, timeBuf2); } +void TestClock(void) +{ + UtPrintf("Testing: CFE_TIME_GetClockState, CFE_TIME_GetClockInfo"); + + CFE_TIME_ClockState_Enum_t state = CFE_TIME_GetClockState(); + uint16 ClockInfo = CFE_TIME_GetClockInfo(); + + if (state >= 0) + { + UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_CLKSET)); + + if (state == 0) + { + UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_FLYING)); + } + else + { + UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_FLYING)); + } + } + else + { + UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_CLKSET)); + } + + UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_SRCINT)); + UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_SIGPRI)); + UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_REFERR)); + UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_UNUSED)); +} + void TimeCurrentTestSetup(void) { UtTest_Add(TestGetTime, NULL, NULL, "Test Current Time"); + UtTest_Add(TestClock, NULL, NULL, "Test Clock"); } From 6a8da99fd98dc3922695a66df5af84c77ad701a7 Mon Sep 17 00:00:00 2001 From: Alex Campbell Date: Wed, 25 Aug 2021 12:26:06 -0400 Subject: [PATCH 2/2] Fix #1843, Remove ClockFlagCheck helper method. --- modules/cfe_testcase/src/time_current_test.c | 28 ++++++-------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/modules/cfe_testcase/src/time_current_test.c b/modules/cfe_testcase/src/time_current_test.c index db2789840..d639befbd 100644 --- a/modules/cfe_testcase/src/time_current_test.c +++ b/modules/cfe_testcase/src/time_current_test.c @@ -52,18 +52,6 @@ bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t d } } -bool ClockFlagCheck(uint16 info, int flag) -{ - if ((info & flag) == flag) - { - return true; - } - else - { - return false; - } -} - void TestGetTime(void) { UtPrintf("Testing: CFE_TIME_GetTime, CFE_TIME_GetTAI, CFE_TIME_GetUTC, CFE_TIME_GetMET, CFE_TIME_GetSTCF, " @@ -142,26 +130,26 @@ void TestClock(void) if (state >= 0) { - UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_CLKSET)); + UtAssert_UINT32_EQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_CLKSET); if (state == 0) { - UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_FLYING)); + UtAssert_UINT32_NEQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_FLYING); } else { - UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_FLYING)); + UtAssert_UINT32_EQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_FLYING); } } else { - UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_CLKSET)); + UtAssert_UINT32_NEQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_CLKSET); } - UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_SRCINT)); - UtAssert_BOOL_TRUE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_SIGPRI)); - UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_REFERR)); - UtAssert_BOOL_FALSE(ClockFlagCheck(ClockInfo, CFE_TIME_FLAG_UNUSED)); + UtAssert_UINT32_EQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_SRCINT); + UtAssert_UINT32_EQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_SIGPRI); + UtAssert_UINT32_NEQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_REFERR); + UtAssert_UINT32_NEQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_UNUSED); } void TimeCurrentTestSetup(void)