Skip to content

Commit

Permalink
Merge pull request #1860 from zanzaben/fix1843_Time_Clock_Func_Test
Browse files Browse the repository at this point in the history
Fix #1843, Add Time Clock Test
  • Loading branch information
astrogeco authored Aug 25, 2021
2 parents ea38fd2 + 6a8da99 commit 9197270
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/cfe_testcase/src/time_current_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -120,7 +121,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_UINT32_EQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_CLKSET);

if (state == 0)
{
UtAssert_UINT32_NEQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_FLYING);
}
else
{
UtAssert_UINT32_EQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_FLYING);
}
}
else
{
UtAssert_UINT32_NEQ(ClockInfo, ClockInfo | CFE_TIME_FLAG_CLKSET);
}

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)
{
UtTest_Add(TestGetTime, NULL, NULL, "Test Current Time");
UtTest_Add(TestClock, NULL, NULL, "Test Clock");
}

0 comments on commit 9197270

Please sign in to comment.