/* ** Test writing application data */ void Test_WriteApp (void) { CFE_EVS_AppDataCmd_t AppDataCmd; /* TEST: reset counters */ UT_SetSBTotalMsgLen(8); UT_SendMsg((CFE_SB_MsgPtr_t)&AppDataCmd, CFE_EVS_CMD_MID, CFE_EVS_RESET_COUNTERS_CC); UT_SetSBTotalMsgLen(sizeof(CFE_EVS_AppDataCmd_t)); /* TEST: write application data with open failure */ UT_SetOSFail(OS_CREAT_FAIL); UT_SendMsg((CFE_SB_MsgPtr_t)&AppDataCmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_APP_DATA_CC); /* TEST: write application data with write/close failure */ UT_SetOSFail(OS_WRITE_FAIL | OS_CLOSE_FAIL); UT_SendMsg((CFE_SB_MsgPtr_t)&AppDataCmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_APP_DATA_CC); /* TEST: write application data with no failures */ UT_SetOSFail(0); UT_SendMsg((CFE_SB_MsgPtr_t)&AppDataCmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_APP_DATA_CC); AppDataCmd.AppDataFilename[0] = '\0'; UT_SendMsg((CFE_SB_MsgPtr_t)&AppDataCmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_APP_DATA_CC); }
/* ** Test logging */ void Test_Logging (void) { int i; CFE_EVS_ModeCmd_t modecmd; /* TEST: invalid logging mode */ /* NOTE: consider sending an event for invalid logging mode */ modecmd.Mode = -1; UT_SetSBTotalMsgLen(sizeof(CFE_EVS_ModeCmd_t)); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_SET_LOG_MODE_CC); /* TEST: set logging mode to DISCARD */ modecmd.Mode = CFE_EVS_LOG_DISCARD; UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_SET_LOG_MODE_CC); /* TEST: overfill log in CFE_EVS_LOG_DISCARD mode */ /* Ensure log is filled and add one more, implicitly testing EVS_LogFull */ for(i = 0; !EVS_LogFull(); i++) CFE_EVS_SendEvent(0, CFE_EVS_INFORMATION, "log fill event %d", i); CFE_EVS_SendEvent(0, CFE_EVS_INFORMATION, "log overfill event discard"); /* TEST: write log while full and open failure */ UT_SetSBTotalMsgLen(sizeof(CFE_EVS_LogFileCmd_t)); UT_SetOSFail(OS_CREAT_FAIL); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_LOG_DATA_CC); /* TEST: write log while full and write/close failure */ UT_SetOSFail(OS_WRITE_FAIL | OS_CLOSE_FAIL); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_LOG_DATA_CC); /* TEST: write log while full */ UT_SetOSFail(0); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_LOG_DATA_CC); /* TEST: add to overfull log in CFE_EVS_LOG_OVERWRITE */ modecmd.Mode = CFE_EVS_LOG_OVERWRITE; UT_SetSBTotalMsgLen(sizeof(CFE_EVS_ModeCmd_t)); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_SET_LOG_MODE_CC); CFE_EVS_SendEvent(0, CFE_EVS_INFORMATION, "log overfill event overwrite"); /* TEST: verify overfull log gets written out in FIFO order */ UT_SetSBTotalMsgLen(sizeof(CFE_EVS_LogFileCmd_t)); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_LOG_DATA_CC); /* TEST: clear log */ UT_SetSBTotalMsgLen(8); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_CLEAR_LOG_CC); /* TEST: write empty log */ UT_SetSBTotalMsgLen(sizeof(CFE_EVS_LogFileCmd_t)); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_LOG_DATA_CC); /* TEST: no op */ UT_SetSBTotalMsgLen(8); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_NO_OPERATION_CC); /* TEST: write log w/ one message and write failure */ UT_SetSBTotalMsgLen(sizeof(CFE_EVS_LogFileCmd_t)); UT_SetOSFail(OS_WRITE_FAIL); UT_SendMsg((CFE_SB_MsgPtr_t)&modecmd, CFE_EVS_CMD_MID, CFE_EVS_FILE_WRITE_LOG_DATA_CC); }
/* ** Initialize unit test variables */ void UT_InitData(void) { int i; /* Initialize queue */ for (i = 0; i < OS_MAX_QUEUES; i++) { UT_Queue[i].free = TRUE; UT_Queue[i].size = 0; } UT_ClearEventHistory(); UT_ResetPoolBufferIndex(); UT_SetOSFail(OS_NO_FAIL); UT_SetBSPFail(0); /* Initialize values and counters used for forcing return values * from stubs */ UT_SetRtnCode(&CreatePoolRtn, 0, 0); UT_SetRtnCode(&PoolCreateExRtn, 0, 0); UT_SetRtnCode(&PutPoolRtn, 0, 0); UT_SetRtnCode(&GetPoolRtn, 0, 0); UT_SetRtnCode(&QueuePutRtn, 0, 0); UT_SetRtnCode(&MutSemGiveRtn, 0, 0); UT_SetRtnCode(&MutSemTakeRtn, 0, 0); UT_SetRtnCode(&QueueCreateRtn, 0, 0); UT_SetRtnCode(&BSPWriteCDSRtn, 0, 0); UT_SetRtnCode(&BSPReadCDSRtn, 0, 0); UT_SetRtnCode(&QueueDelRtn, 0, 0); UT_SetRtnCode(&QueueGetRtn, 0, 0); UT_SetRtnCode(&QueuePutRtn, 0, 0); UT_SetRtnCode(&FileWriteRtn, 0, 0); UT_SetRtnCode(&OSReadRtn, 0, 0); UT_SetRtnCode(&OSReadRtn2, 0, 0); UT_SetRtnCode(&SBSendMsgRtn, 0, 0); UT_SetRtnCode(&FSSetTimestampRtn, 0, 0); UT_SetRtnCode(&FSWriteHdrRtn, 0, 0); UT_SetRtnCode(&FSReadHdrRtn, 0, 0); UT_SetRtnCode(&ES_RegisterRtn, 0, 0); UT_SetRtnCode(&ES_CreateChildRtn, 0, 0); UT_SetRtnCode(&SB_SubscribeRtn, 0, 0); UT_SetRtnCode(&SB_SubscribeLocalRtn, 0, 0); UT_SetRtnCode(&SB_CreatePipeRtn, 0, 0); UT_SetRtnCode(&OS_BinSemCreateRtn, 0, 0); UT_SetRtnCode(&EVS_SendEventRtn, 0, 0); UT_SetRtnCode(&EVS_RegisterRtn, 0, 0); UT_SetRtnCode(&SB_SubscribeExRtn, 0, 0); UT_SetRtnCode(&MutSemCreateRtn, 0, 0); UT_SetRtnCode(&OSlseekRtn, 0, 0); UT_SetRtnCode(&CountSemDelRtn, 0, 0); UT_SetRtnCode(&MutSemDelRtn, 0, 0); UT_SetRtnCode(&BinSemDelRtn, 0, 0); UT_SetRtnCode(&BlocksFreeRtn, 0, 0); UT_SetRtnCode(&UnmountRtn, 0, 0); UT_SetRtnCode(&RmfsRtn, 0, 0); UT_SetRtnCode(&BSPUnloadAppFileRtn, 0, 0); UT_SetRtnCode(&SBCleanUpRtn, 0, 0); UT_SetRtnCode(&EVSCleanUpRtn, 0, 0); UT_SetRtnCode(&GetAppIDRtn, 0, 0); UT_SetRtnCode(&BSPGetCFETextRtn, 0, 0); UT_SetRtnCode(&FSIsGzFileRtn, 0, 0); UT_SetRtnCode(&ModuleLoadRtn, 0, 0); UT_SetRtnCode(&ModuleUnloadRtn, 0, 0); UT_SetRtnCode(&ModuleInfoRtn, 0, 0); UT_SetRtnCode(&FSDecompressRtn, 0, 0); UT_SetRtnCode(&FSExtractRtn, 0, 0); UT_SetRtnCode(&SymbolLookupRtn, 0, 0); UT_SetRtnCode(&TIMECleanUpRtn, 0, 0); UT_SetRtnCode(&HeapGetInfoRtn, 0, 0); UT_SetRtnCode(&GetPoolInfoRtn, 0, 0); UT_SetRtnCode(&WriteSysLogRtn, -1, 0); UT_SetRtnCode(&GetResetTypeRtn, 0, 0); UT_SetRtnCode(&SendMsgEventIDRtn, -1, 0); UT_SetRtnCode(&OSPrintRtn, 0, -1); UT_SetRtnCode(&SetMsgIdRtn, 0, 0); UT_SetRtnCode(&OSTaskExitRtn, 0, 0); UT_SetRtnCode(&PSPRestartRtn, 0, 0); UT_SetRtnCode(&OSBinSemTimedWaitRtn, -1, 0); UT_SetRtnCode(&OSBinSemFlushRtn, -1, 0); UT_SetRtnCode(&PSPPanicRtn, 0, 0); UT_SetRtnCode(&TBLEarlyInitRtn, 0, 0); UT_SetRtnCode(&OSCloseRtn, 0, 0); UT_SetRtnCode(&PSPMemValRangeRtn, 0, 0); UT_SetRtnCode(&ES_ExitAppRtn, 0, 0); UT_SetRtnCode(&OSTimerGetInfoRtn, 0, 0); UT_ResetCDS(); }