//***************************************************************************** // (C) Automotive Lighting Reutlingen GmbH // Tuebinger Strasse 123, 72762 Reutlingen, Germany // // Automotive Lighting Reutlingen GmbH owns all the rights to this work. // This work shall not be copied, reproduced, used, modified, transferred // or its information shall not be disclosed without the prior written // authorization of Automotive Lighting Reutlingen GmbH. //***************************************************************************** //----------------------------------------------------------------------------- /// \file Test.c /// /// \brief Unit Test Cases for SBC complex device driver /// /// \author Kai Zhao ALDE-RT (zhk2rt) /// mailTo:kai.zhao[at]marelli.com //----------------------------------------------------------------------------- #include #include #include #include #include #include #include ////static variablen static Mcu_ResetType Mt_MCUResetReason; //external variablen extern uint16* CddSbc_ECCResetReason; //extern teMCUResetType CddSbc_eMCUResetReason; //extern teSBCResetType CddSbc_eSBCResetReason; //extern tieResetReason CddSbc_tResetReason; //STATIC_AL VAR(tieDataStatus, RTE_DATA) Rte_GucppCodMEftCrcStatus0_sVal_ctaaCodM = Rte_GucppCodMEftCrcStatus0_sVal_ctaaCodM_Init_DEF; // ////external functions //extern boolean CddSbc9471_WriteClearReg(uint8 ucAddress, uint16 unDataField); //extern uint16 CddSbc9471_ReadReg(uint8 ucAddress); //extern void CddSbc_SetCanMode(uint8 ucSbcCanChannel, uint8 ucCanMode); //extern void CddSbc_SetSleepMode(void); FUNC(Mcu_ResetType, MCU_CODE) Mcu_GetResetReason(void) { return Mt_MCUResetReason; } STATIC_AL uint8 Mt_ucCanUV; STATIC_AL uint8 Mt_SBCResetReason; STATIC_AL uint8 Mt_ucCanChannel; STATIC_AL uint8 Mt_ucCanMode; STATIC_AL boolean Mt_boCddTle94x1_InitIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_DeInitIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_SetSleepModeIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_SetCanModeIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_GetCanModeIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_GetCanUVIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_GetWakeUpStatusIsCalled = FALSE; STATIC_AL boolean Mt_boCddTle94x1_GetSBCResetReasonIsCalled = FALSE; STATIC_AL boolean Mt_boSetWdgWindowModeAnd10msIsCalled = FALSE; STATIC_AL boolean Mt_boSetWdgWindowModeAnd200msIsCalled = FALSE; STATIC_AL boolean Mt_boSetWdgTimeoutModeAnd200msIsCalled = FALSE; STATIC_AL boolean Mt_WakeUpStatus = FALSE; STATIC_AL VAR(tisCddSbcStatus, RTE_DATA) Rte_GstppaseCddSbcStatus_sStatus_ctadCddSbc = Rte_GstppaseCddSbcStatus_sStatus_ctadCddSbc_Init_DEF; FUNC(void, RTE_CODE) Rte_Memcpy (void * LpDestination, const void * LpSource, uint32 LulDataSize) { uint32 LulIndex; uint8* LpDest = (uint8*)LpDestination; const uint8* LpSrc = (const uint8*)LpSource; if ((NULL != LpDest) && (NULL != LpSrc)) { for (LulIndex = 0; LulIndex < LulDataSize; LulIndex++) { LpDest[LulIndex] = LpSrc[LulIndex]; } } } FUNC(Std_ReturnType, RTE_CODE) Rte_Write_ctadCddSbc_ppaseCddSbcStatus_sStatus (P2CONST(tisCddSbcStatus, AUTOMATIC, RTE_APPL_DATA) Data) { VAR(Std_ReturnType, RTE_DATA) LddRetVal; (void)Rte_Memcpy(&Rte_GstppaseCddSbcStatus_sStatus_ctadCddSbc, Data, sizeof(tisCddSbcStatus)); LddRetVal = RTE_E_OK; return LddRetVal; } void CddTle94x1_Init(void) { Mt_boCddTle94x1_InitIsCalled = TRUE; } void CddTle94x1_DeInit(void) { Mt_boCddTle94x1_DeInitIsCalled = TRUE; } void CddTle94x1_SetSleepMode(void) { Mt_boCddTle94x1_SetSleepModeIsCalled = TRUE; } void CddTle94x1_SetCanMode(uint8 ucCanChannel, uint8 ucCanMode) { Mt_ucCanChannel = ucCanChannel; Mt_ucCanMode = ucCanMode; Mt_boCddTle94x1_SetCanModeIsCalled = TRUE; } uint8 CddTle94x1_GetCanMode(uint8 ucCanChannel) { (void)ucCanChannel; Mt_boCddTle94x1_GetCanModeIsCalled = TRUE; return Mt_ucCanMode; } uint8 CddTle94x1_GetCanUV(void) { Mt_boCddTle94x1_GetCanUVIsCalled = TRUE; return Mt_ucCanUV; } boolean CddTle94x1_GetWakeUpStatus(void) { Mt_boCddTle94x1_GetWakeUpStatusIsCalled = TRUE; return Mt_WakeUpStatus; } //void CddSbc_InsertDefaultMessage(void) {} //void CddSbc_ScheduleTableFull(boolean boStatus) { (void)boStatus; } uint8 CddTle94x1_GetSBCResetReason(void) { Mt_boCddTle94x1_GetSBCResetReasonIsCalled = TRUE; return Mt_SBCResetReason; } void CddTle94x1_SetWdgWindowModeAnd10ms(void) { Mt_boSetWdgWindowModeAnd10msIsCalled = TRUE; } void CddTle94x1_SetWdgTimeoutModeAnd200ms(void) { Mt_boSetWdgTimeoutModeAnd200msIsCalled = TRUE; } void CddTle94x1_SetWdgWindowModeAnd200ms(void) { Mt_boSetWdgWindowModeAnd200msIsCalled = TRUE; } void Mt_CddSbc_DataInitialization(void) { Mt_ucCanChannel = 0U; Mt_ucCanMode = 0U; Mt_ucCanUV = 0U; Mt_WakeUpStatus = FALSE; Mt_boCddTle94x1_InitIsCalled = FALSE; Mt_boCddTle94x1_DeInitIsCalled = FALSE; Mt_boCddTle94x1_SetSleepModeIsCalled = FALSE; Mt_boCddTle94x1_SetCanModeIsCalled = FALSE; Mt_boCddTle94x1_GetCanModeIsCalled = FALSE; Mt_boCddTle94x1_GetCanUVIsCalled = FALSE; Mt_boCddTle94x1_GetWakeUpStatusIsCalled = FALSE; Mt_boCddTle94x1_GetSBCResetReasonIsCalled = FALSE; Mt_boSetWdgWindowModeAnd10msIsCalled = FALSE; Mt_boSetWdgWindowModeAnd200msIsCalled = FALSE; Mt_boSetWdgTimeoutModeAnd200msIsCalled = FALSE; } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_Init /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Call the API function CddSbc_Init(). This function is to be tested with Failed InitStateRead() . /// /// - Test Design Technique: DT (Decision Table) /// The Decision Table asTestCaseData[] is used in this test case. This DT contains all possible values of all inputs /// which are taken into account by the algorithm of the FUT, as well as the expected values of all outputs which are /// set by the FUT. Every DT-entry represents a different Test Case interaction. /// - DT-Info: /// - Inputs: /// - Mt_uclen: Buffer length provided to the Spi driver /// - Mt_boReturn[]: Buffer return value provided to the Spi driver /// - Mt_unRxData[]: Buffer data provided to the Spi driver /// - Outputs: /// - boErrorType_InitStatRead: Error flag /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values of the DT need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_Init(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_Init(); //Step3: check if the CddTle94x1_Init() is called. AL_UNITTEST_CHECK(Mt_boCddTle94x1_InitIsCalled, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_riCddSbcInit /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// riCddSbcInit write reset reason in RTE port. /// /// - Test Design Technique: None /// /// - Preconditions: none /// //----------------------------------------------------------------------------- void Mt_riCddSbcInit(void) { riCddSbcInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_SetSleepMode /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Check if the CddSbc_SetSleepMode writes the correct commands to control registers for the sleep mode sussessful. /// Check the error flag CddSbc9471_ErrorType.boGotoSleep_SpiFailure. /// /// - Test Design Technique: DT (Decision Table) /// The Decision Table asTestCaseData[] is used in this test case. This DT contains all possible values of all inputs /// which are taken into account by the algorithm of the FUT, as well as the expected values of all outputs which are /// set by the FUT. Every DT-entry represents a different Test Case interaction. /// - DT-Info: /// - Inputs: /// - Mt_uclen: Buffer length provided to the Spi driver /// - Mt_boReturn[]: Buffer return value provided to the Spi driver /// - Mt_unRxData[]: Buffer data provided to the Spi driver /// - Outputs: /// - boGotoSleep_SpiFailure: error flag for SPI-Failure (goto sleep mode) /// - boGoToSleep_Failure: error flag for goto sleep failure /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values of the DT need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_SetSleepMode(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_SetSleepMode(); //Step3: check if the CddTle94x1_SetSleepMode() is called. AL_UNITTEST_CHECK(Mt_boCddTle94x1_SetSleepModeIsCalled, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_SetCanMode /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Set the can mode with different index and modes. Call the CddSbc_SetCanMode() and /// check if the error flag CddSbc9471_ErrorType.boCanModeError is set correctly. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step2 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_SetCanMode(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_SetCanMode(0U, 3U); //Step3: check if the CddTle94x1_SetCanMode() is called and Can mode is set correctly. AL_UNITTEST_CHECK(Mt_boCddTle94x1_SetCanModeIsCalled, TRUE, == ); AL_UNITTEST_CHECK(Mt_ucCanChannel, 0, == ); AL_UNITTEST_CHECK(Mt_ucCanMode, 3, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_GetCanMode /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_GetCanMode() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_GetCanMode(void) { uint8 ucCanMode; //Step1: Initialize Mt_CddSbc_DataInitialization(); Mt_ucCanMode = 2U; //Step2: call function and get the return value ucCanMode = CddSbc_GetCanMode(0U); //Step3: check if the CddTle94x1_GetCanMode() is called and Can mode. AL_UNITTEST_CHECK(Mt_boCddTle94x1_GetCanModeIsCalled, TRUE, == ); AL_UNITTEST_CHECK(ucCanMode, 2, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_GetCanUV /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_GetCanUV() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_GetCanUV(void) { uint8 ucCanUV; //Step1: Initialize Mt_CddSbc_DataInitialization(); Mt_ucCanUV = 1U; //Step2: call function and get the return value ucCanUV = CddSbc_GetCanUV(); //Step3: check if the CddTle94x1_GetCanUv() is called and Can UV bit AL_UNITTEST_CHECK(Mt_boCddTle94x1_GetCanUVIsCalled, TRUE, == ); AL_UNITTEST_CHECK(ucCanUV, 1, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_GetWakeUpStatus /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_Rou_GetWakeUpStatus() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_GetWakeUpStatus(void) { uint8 ucCanUV; //Step1: Initialize Mt_CddSbc_DataInitialization(); Mt_WakeUpStatus = TRUE; //Step2: call function and get the return value Mt_WakeUpStatus = CddSbc_GetWakeUpStatus(); //Step3: check if the CddTle94x1_GetCanUv() is called and Can UV bit AL_UNITTEST_CHECK(Mt_boCddTle94x1_GetWakeUpStatusIsCalled, TRUE, == ); AL_UNITTEST_CHECK(Mt_WakeUpStatus, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_Rou_GetSBCResetReason /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_Rou_GetSBCResetReason() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_Rou_GetSBCResetReason(void) { uint8 ucResetReason; //Step1: Initialize Mt_CddSbc_DataInitialization(); Mt_SBCResetReason = ePowerOnResetSBC; //Step2: call function and get the return value ucResetReason = CddSbc_Rou_GetSBCResetReason(); //Step3: check if the CddTle94x1_GetSBCResetReason() is called AL_UNITTEST_CHECK(Mt_boCddTle94x1_GetSBCResetReasonIsCalled, TRUE, == ); AL_UNITTEST_CHECK(ucResetReason, ePowerOnResetSBC, == ); } ////----------------------------------------------------------------------------- ///// \Test Case : Mt_CddSbc9471_StoreResetReason ///// ///// \Functional Safety: NA ///// ///// \Test methods: ///// - Requirements-based test ///// ///// \Test Case Description ///// - Test subject: ///// Call the Mt_CddSbc9471_StoreResetReason to check if the reset reason is ///// saved properly in the static variables ///// ///// - Test Design Technique: DT (Decision Table) ///// The Decision Table asTestCaseData[] is used in this test case. This DT contains all possible values of all inputs ///// which are taken into account by the algorithm of the FUT, as well as the expected values of all outputs which are ///// set by the FUT. Every DT-entry represents a different Test Case interaction. ///// - DT-Info: ///// - Inputs: ///// - tMCUResetReason: reset reason of MCU ///// - WK_STAT_0_CANWU: SBC wakeup status ///// - SUP_STAT_0_POR: SBC power on reset ///// - WDG_RESET: SBC watchdog reset ///// - ECC_Error: ECC Error ///// - MCU_Selftest_Err: MCU selftest Error ///// - Outputs: ///// - tResetReason: variable for reset reason ///// - MCUResetReason: variable for reset reason of MCU ///// - SBCResetReason: variable for reset reason of SBC ///// ///// - Preconditions: none ///// ///// - Expected test results: ///// - All conditions and assigned values of the DT need to be reached and passed. ///// ////----------------------------------------------------------------------------- //void Mt_CddSbc9471_StoreResetReason(void) //{ // tieResetReason ResetReason; // // test step // int nStep; // // typedef struct // { // Mcu_ResetType tMCUResetReason; // uint8 WK_STAT_0_CANWU; // uint8 SUP_STAT_0_POR; // uint8 WDG_RESET; // uint16 Ecc_Error; // uint16 Mcu_Selftest_Err; // } tSetValues_FixData; // // typedef struct // { // tieResetReason tResetReason; // teMCUResetType MCUResetReason; // teSBCResetType SBCResetReason; // } tCheckValues_FixData; // // typedef struct // { // tSetValues_FixData SetValues; // tCheckValues_FixData CheckValues; // } tUtCddSbc_TestSteps_FixData; // // static const tUtCddSbc_TestSteps_FixData aTestSteps[] = // { // Intputs || Outputs // // tMCUResetReason, WK_STAT_0_CANWU , SUP_STAT_0_POR, WDG_RESET, ECC_ERROR, MCU_SELFTEST_ERR || CddSbc_tResetReason, MCUResetReason , SBCResetReason ; // /* 0 */{ { MCU_RESET_UNDEFINED, 0, 0, 0, 0, 0 }, { RESET_UNDEFINED, eNoResetMCU, eNoResetSBC } }, // /* 1 */{ { MCU_XRES_RESET, 1, 0, 0, 0, 0 }, { eRESET_WAKEUP, eNoResetMCU, eCANWakeUpReset } }, // /* 2 */{ { MCU_WATCHDOG_RESET, 0, 0, 0, 0, 0 }, { eRESET_WATCHDOG, eWatchdogResetMCU, eNoResetSBC } }, // /* 3 */{ { MCU_CSV_HF_RESET, 0, 0, 0, 0, 0 }, { eRESET_PLL_ERROR, ePLLReset, eNoResetSBC } }, // /* 4 */{ { MCU_SW_RESET, 0, 0, 0, 0, 0 }, { eRESET_SOFTWARE, eSoftwareReset, eNoResetSBC } }, // /* 5 */{ { MCU_CSV_REF_RESET, 0, 0, 0, 0, 0 }, { eRESET_PLL_ERROR, ePLLReset, eNoResetSBC } }, // /* 6 */{ { MCU_XRES_RESET, 0, 1, 0, 0, 0 }, { eRESET_POWER_ON, eNoResetMCU, ePowerOnResetSBC } }, // /* 7 */{ { MCU_ACT_FAULT_RESET, 0, 0, 0, 0, 0 }, { OTHER_RESET, eOtherReasons, eNoResetSBC } }, // /* 8 */{ { MCU_XRES_RESET, 0, 0, 1, 0, 0 }, { eRESET_WATCHDOG, eNoResetMCU, eNoResetSBC } }, // /* 9 */{ { MCU_SW_RESET, 0, 0, 0, ERROR_ACTIVE, 0 }, { eRESET_ECC_ERROR, eECCReset, eNoResetSBC } }, // /*10 */{ { MCU_XRES_RESET, 0, 0, 0, ERROR_ACTIVE, 0 }, { eRESET_ECC_ERROR, eECCReset, eNoResetSBC } }, // /*11 */{ { MCU_SW_RESET, 1, 0, 0, ERROR_ACTIVE, 0 }, { eRESET_ECC_ERROR, eECCReset, eNoResetSBC } }, // /*12 */{ { MCU_SW_RESET, 0, 0, 0, 0, ERROR_ACTIVE }, { eRESET_MPU_SELFTEST_ERROR, eMCUSelfTestReset, eNoResetSBC } }, // /*13 */{ { MCU_SW_RESET, 0, 0, 0, 0, ERROR_ACTIVE }, { eRESET_MPU_SELFTEST_ERROR, eMCUSelfTestReset, eNoResetSBC } }, // /* 14 */{ { MCU_XRES_RESET, 0, 0, 0, 0, 0 }, { OTHER_RESET, eNoResetMCU, eNoResetSBC } }, // }; // const int nNrSteps = sizeof(aTestSteps) / sizeof(tUtCddSbc_TestSteps_FixData); // // for (nStep = 0; nStep < nNrSteps; nStep++) // { // //Initialize the variables // CddSbc_eMCUResetReason = eNoResetMCU; // CddSbc_eSBCResetReason = eNoResetSBC; // // //Step1: simulate the reset reason // CddSbc9471_ECCResetReason = &aTestSteps[nStep].SetValues.Ecc_Error; // CddSbc9471_MPUSelfTestResetReason = aTestSteps[nStep].SetValues.Mcu_Selftest_Err; // Mt_MCUResetReason = aTestSteps[nStep].SetValues.tMCUResetReason; // CddSbc9471_ucWK_STAT_0_CANWU = aTestSteps[nStep].SetValues.WK_STAT_0_CANWU; // CddSbc9471_ucSUP_STAT_0_POR = aTestSteps[nStep].SetValues.SUP_STAT_0_POR; // CddSbc9471_boIsWdgReset = aTestSteps[nStep].SetValues.WDG_RESET; // // //Step2: call the function with set data in test steps // CddSbc9471_StoreResetReason(); // (void)CddSbc_GetResetReason(&ResetReason); // // //Step3: compare the return and received RxData value with the check values in test steps // AL_UNITTEST_CHECK(CddSbc_tResetReason, aTestSteps[nStep].CheckValues.tResetReason, == ); // AL_UNITTEST_CHECK(CddSbc_eMCUResetReason, aTestSteps[nStep].CheckValues.MCUResetReason, == ); // AL_UNITTEST_CHECK(CddSbc_eSBCResetReason, aTestSteps[nStep].CheckValues.SBCResetReason, == ); // } //} // //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_GetResetReason /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Call the Mt_CddSbc_GetResetReason to check if the reset reason and return value is /// properly provided. /// /// - Test Design Technique: DT (Decision Table) /// The Decision Table asTestCaseData[] is used in this test case. This DT contains all possible values of all inputs /// which are taken into account by the algorithm of the FUT, as well as the expected values of all outputs which are /// set by the FUT. Every DT-entry represents a different Test Case interaction. /// - DT-Info: /// - Inputs: /// - tMCUResetReason: reset reason of MCU /// - tSBCResetReason: reset reason of SBC /// - Outputs: /// - tResetReason: variable for reset reason /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values of the DT need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_GetResetReason(void) { tieResetReason ResetReason; // test step int nStep; typedef struct { Mcu_ResetType tMCUResetReason; tieResetReason tSBCResetReason; uint16 Ecc_Error; } tSetValues_FixData; typedef struct { tieResetReason tResetReason; } tCheckValues_FixData; typedef struct { tSetValues_FixData SetValues; tCheckValues_FixData CheckValues; } tUtCddSbc_TestSteps_FixData; static const tUtCddSbc_TestSteps_FixData aTestSteps[] = { // Intputs || Outputs // tMCUResetReason, tSBCResetReason , Ecc_Error || tResetReason ; /* 0 */{ { MCU_XRES_RESET, ePowerOnResetSBC, 0 }, { RESET_POWER_ON } }, /* 1 */{ { MCU_XRES_RESET, eCANWakeUpReset, 0 }, { RESET_WAKEUP } }, /* 2 */{ { MCU_XRES_RESET, eWatchdogReset, 0 }, { RESET_WATCHDOG } }, /* 3 */{ { MCU_XRES_RESET, eInputWakeUpReset, 0 }, { RESET_WAKEUP_HW } }, /* 4 */{ { MCU_XRES_RESET, eNoResetSBC, 0 }, { RESET_UNDEFINED } }, /* 5 */{ { MCU_CSV_HF_RESET, eInputWakeUpReset, 0 }, { RESET_PLL_ERROR } }, /* 6 */{ { MCU_SW_RESET, eInputWakeUpReset, 0 }, { RESET_SOFTWARE } }, /* 7 */{ { MCU_SW_RESET, eNoResetSBC, 0x5A01 }, { RESET_ECC_ERROR } }, /* 8 */{ { MCU_WAKEUP_RESET, eWatchdogReset, 0 }, { RESET_UNDEFINED } }, }; const int nNrSteps = sizeof(aTestSteps) / sizeof(tUtCddSbc_TestSteps_FixData); for (nStep = 0; nStep < nNrSteps; nStep++) { //Step1: simulate the reset reason Mt_MCUResetReason = aTestSteps[nStep].SetValues.tMCUResetReason; Mt_SBCResetReason = aTestSteps[nStep].SetValues.tSBCResetReason; CddSbc_ECCResetReason = &aTestSteps[nStep].SetValues.Ecc_Error; //Step2: call the function with set data in test steps ResetReason = CddSbc_GetResetReason(); //Step3: compare the return and received RxData value with the check values in test steps AL_UNITTEST_CHECK(ResetReason, aTestSteps[nStep].CheckValues.tResetReason, == ); } } //----------------------------------------------------------------------------- /// \Test Case : Mt_riCddSbcDeInit /// /// \Functional Safety: NA /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// riCddSbcDeInit is a dummy function /// /// - Test Design Technique: None /// /// - Preconditions: none /// //----------------------------------------------------------------------------- void Mt_riCddSbcDeInit(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_DeInit(); //Step3: check if the CddTle94x1_DeInit() is called. AL_UNITTEST_CHECK(Mt_boCddTle94x1_DeInitIsCalled, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_SetWdgWindowModeAnd10ms /// /// \Functional Safety: ASIL-B /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_SetWdgWindowModeAnd10ms() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_SetWdgWindowModeAnd10ms(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_SetWdgWindowModeAnd10ms(); //Step3: check if the SetWdgWindowModeAnd10ms() is called. AL_UNITTEST_CHECK(Mt_boSetWdgWindowModeAnd10msIsCalled, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_SetWdgWindowModeAnd200ms /// /// \Functional Safety: ASIL-B /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_SetWdgWindowModeAnd200ms() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_SetWdgWindowModeAnd200ms(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_SetWdgWindowModeAnd200ms(); //Step3: check if the SetWdgWindowModeAnd10ms() is called. AL_UNITTEST_CHECK(Mt_boSetWdgWindowModeAnd200msIsCalled, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddSbc_SetWdgTimeoutModeAnd200ms /// /// \Functional Safety: ASIL-B /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// Simulate the can mode in Data mirror. Call the CddSbc_SetWdgTimeoutModeAnd200ms() and /// check the return value. /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values in the step3 need to be reached and passed. /// //----------------------------------------------------------------------------- void Mt_CddSbc_SetWdgTimeoutModeAnd200ms(void) { //Step1: Initialize Mt_CddSbc_DataInitialization(); //Step2: call function and get the return value CddSbc_SetWdgTimeoutModeAnd200ms(); //Step3: check if the SetWdgWindowModeAnd10ms() is called. AL_UNITTEST_CHECK(Mt_boSetWdgTimeoutModeAnd200msIsCalled, TRUE, == ); } ////----------------------------------------------------------------------------- ///// \Test Case : Mt_CddSbc9471_GetWatchdogFlag ///// ///// \Functional Safety: NA ///// ///// \Test methods: ///// - Requirements-based test ///// ///// \Test Case Description ///// - Test subject: ///// Call the Mt_CddSbc9471_GetWatchdogFlag to check if the watchdog reset reason is ///// saved properly in the static variables ///// ///// - Test Design Technique: DT (Decision Table) ///// The Decision Table asTestCaseData[] is used in this test case. This DT contains all possible values of all inputs ///// which are taken into account by the algorithm of the FUT, as well as the expected values of all outputs which are ///// set by the FUT. Every DT-entry represents a different Test Case interaction. ///// - DT-Info: ///// - Inputs: ///// - CddSbc9471_WdgResetReason: watchdog reset information in Retention RAM ///// - Outputs: ///// - WDG_RESET: SBC watchdog reset ///// ///// - Preconditions: none ///// ///// - Expected test results: ///// - All conditions and assigned values of the DT need to be reached and passed. ///// ////----------------------------------------------------------------------------- //void Mt_CddSbc9471_GetWatchdogFlag(void) //{ // // test step // int nStep; // // typedef struct // { // uint16 CddSbc9471_WdgResetReason; // } tSetValues_FixData; // // typedef struct // { // uint8 WDG_RESET; // } tCheckValues_FixData; // // typedef struct // { // tSetValues_FixData SetValues; // tCheckValues_FixData CheckValues; // } tUtCddSbc_TestSteps_FixData; // // static const tUtCddSbc_TestSteps_FixData aTestSteps[] = // { // // Intputs || Outputs // // CddSbc9471_WdgResetReasonV; || WDG_RESET; // /* 0 */{ { 0xFDFD }, { 0 } }, // /* 1 */{ { 0x5A01 }, { 1 } }, // /* 2 */{ { 0x5A10 }, { 0 } }, // }; // // const int nNrSteps = sizeof(aTestSteps) / sizeof(tUtCddSbc_TestSteps_FixData); // // for (nStep = 0; nStep < nNrSteps; nStep++) // { // //Step1: simulate the watchdog reset value in retention RAM // CddSbc9471_WdgResetReason = aTestSteps[nStep].SetValues.CddSbc9471_WdgResetReason; // // //Step2: call function // CddSbc9471_GetWatchdogFlag(); // // //Step3: compare the variable value with the check values in TestSteps // AL_UNITTEST_CHECK(CddSbc9471_boIsWdgReset, aTestSteps[nStep].CheckValues.WDG_RESET, == ); // } //} // void ALUnitTest_AddTests(void) { ALUnitTest_AddFunction("Mt_CddSbc_Init", Mt_CddSbc_Init); ALUnitTest_AddFunction("Mt_riCddSbcInit", Mt_riCddSbcInit); ALUnitTest_AddFunction("Mt_riCddSbcDeInit", Mt_riCddSbcDeInit); ALUnitTest_AddFunction("Mt_CddSbc_SetSleepMode", Mt_CddSbc_SetSleepMode); ALUnitTest_AddFunction("Mt_CddSbc_SetCanMode", Mt_CddSbc_SetCanMode); ALUnitTest_AddFunction("Mt_CddSbc_GetCanMode", Mt_CddSbc_GetCanMode); ALUnitTest_AddFunction("Mt_CddSbc_GetCanUV", Mt_CddSbc_GetCanUV); ALUnitTest_AddFunction("Mt_CddSbc_GetWakeUpStatus", Mt_CddSbc_GetWakeUpStatus); ALUnitTest_AddFunction("Mt_CddSbc_SetWdgWindowModeAnd10ms", Mt_CddSbc_SetWdgWindowModeAnd10ms); ALUnitTest_AddFunction("Mt_CddSbc_SetWdgWindowModeAnd200ms", Mt_CddSbc_SetWdgWindowModeAnd200ms); ALUnitTest_AddFunction("Mt_CddSbc_SetWdgTimeoutModeAnd200ms", Mt_CddSbc_SetWdgTimeoutModeAnd200ms); ALUnitTest_AddFunction("Mt_CddSbc_Rou_GetSBCResetReason", Mt_CddSbc_Rou_GetSBCResetReason); ALUnitTest_AddFunction("Mt_CddSbc_GetResetReason", Mt_CddSbc_GetResetReason); }