//***************************************************************************** // (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 CodM /// /// \author /// //----------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include uint8 setCRCTestValue; extern STATIC_AL boolean CodM_boCodingDataIsValidated; extern STATIC_AL boolean CodM_boECUIsCoded; extern STATIC_AL boolean CodM_boCrcCodingTestResultIsOk; extern STATIC_AL boolean CodM_boCodingLabelsCompatible; extern STATIC_AL tisCodingStatus tCodingStatus; extern STATIC_AL boolean flag_MT_CodMCycle; extern STATIC_AL boolean flag_MT_CodMDeInit; void setCodingLabel(unsigned char *CodingLabel) { tRomPara_CodingArea *p = &applicationCodingData; (void)memcpy(p->CodingLabels, CodingLabel, sizeof(p->CodingLabels)); } FUNC(uint32, CRC_CODE) Crc_CalculateCRCTest(uint8 setValue) { return (setValue == 1) ? TRUE : FALSE; } FUNC(Std_ReturnType, RTE_CODE) Rte_Write_ctaaCodM_PpaseCodMCodingStatus_sCodingStatus(P2CONST(tisCodingStatus, AUTOMATIC, RTE_CTAACODM_APPL_DATA) data) /* PRQA S 1505, 2982 */ /* MD_MSR_Rule8.7, MD_Rte_2982 */ { return RTE_E_OK; } // ----------------------------------------------------------------------------------------------------------------- /// \Test Case : Mt_riCodMInit /// /// \Test Case Description /// - Test subject: /// To call riCodMInit function and check Coding Data Status /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// // ----------------------------------------------------------------------------------------------------------------- void Mt_riCodMInit(void) { //======================================================================================== // Pre-Condition 1: wrong coding header in coding label (based on SW_R3.1.9); wrong CRC; //======================================================================================== setCodingLabel((unsigned char *)"000_00000_CODD_0000.0000.00_High"); setCRCTestValue = 0; Rte_riCodMInit(); AL_UNITTEST_CHECK(CodM_boCrcCodingTestResultIsOk, FALSE, == ); AL_UNITTEST_CHECK(CodM_boCodingLabelsCompatible, FALSE, == ); AL_UNITTEST_CHECK(CodM_boECUIsCoded, FALSE, == ); AL_UNITTEST_CHECK(CodM_boCodingDataIsValidated, FALSE, == ); AL_UNITTEST_CHECK(tCodingStatus.eCodingStatus, CODING_STATUS_ECUNOTCODED, == ); //======================================================================================== // Pre-Condition 2: wrong coding header in coding label (based on SW_R3.1.9); correct CRC; //======================================================================================== setCodingLabel((unsigned char *)"000_00000_CODD_0000.0000.00_High"); setCRCTestValue = 1; Rte_riCodMInit(); AL_UNITTEST_CHECK(CodM_boCrcCodingTestResultIsOk, TRUE, == ); AL_UNITTEST_CHECK(CodM_boCodingLabelsCompatible, FALSE, == ); AL_UNITTEST_CHECK(CodM_boECUIsCoded, FALSE, == ); AL_UNITTEST_CHECK(CodM_boCodingDataIsValidated, FALSE, == ); AL_UNITTEST_CHECK(tCodingStatus.eCodingStatus, CODING_STATUS_ECUNOTCODED, == ); //======================================================================================== // Pre-Condition 3: wrong coding version in coding label (based on SW_R3.1.9); correct CRC; //======================================================================================== setCodingLabel((unsigned char *)"Z03_HH002_CODD_0004.0000.00_High"); setCRCTestValue = 1; Rte_riCodMInit(); AL_UNITTEST_CHECK(CodM_boCrcCodingTestResultIsOk, TRUE, == ); AL_UNITTEST_CHECK(CodM_boCodingLabelsCompatible, FALSE, == ); AL_UNITTEST_CHECK(CodM_boECUIsCoded, TRUE, == ); AL_UNITTEST_CHECK(CodM_boCodingDataIsValidated, FALSE, == ); AL_UNITTEST_CHECK(tCodingStatus.eCodingStatus, CODING_STATUS_LABELNOTCOMPATIBLE, == ); //======================================================================================== // Pre-Condition 4: correct coding label (based on SW_R3.1.9); wrong CRC; //======================================================================================== setCodingLabel((unsigned char *)"Z03_HH002_CODD_0003.0001.00_High"); setCRCTestValue = 0; Rte_riCodMInit(); AL_UNITTEST_CHECK(CodM_boCrcCodingTestResultIsOk, FALSE, == ); AL_UNITTEST_CHECK(CodM_boCodingLabelsCompatible, TRUE, == ); AL_UNITTEST_CHECK(CodM_boECUIsCoded, TRUE, == ); AL_UNITTEST_CHECK(CodM_boCodingDataIsValidated, FALSE, == ); AL_UNITTEST_CHECK(tCodingStatus.eCodingStatus, CODING_STATUS_CRCCHECKERR, == ); //======================================================================================== // Pre-Condition 5: correct coding label (based on SW_R3.1.9); correct CRC; //======================================================================================== setCodingLabel((unsigned char *)"Z03_HH002_CODD_0003.0001.00_High"); setCRCTestValue = 1; Rte_riCodMInit(); AL_UNITTEST_CHECK(CodM_boCrcCodingTestResultIsOk, TRUE, == ); AL_UNITTEST_CHECK(CodM_boCodingLabelsCompatible, TRUE, == ); AL_UNITTEST_CHECK(CodM_boECUIsCoded, TRUE, == ); AL_UNITTEST_CHECK(CodM_boCodingDataIsValidated, TRUE, == ); AL_UNITTEST_CHECK(tCodingStatus.eCodingStatus, CODING_STATUS_VALID, == ); } // ----------------------------------------------------------------------------------------------------------------- /// \Test Case : Mt_rpCodM20ms /// /// \Test Case Description /// - Test subject: /// To call rpCodM20ms function /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// // ----------------------------------------------------------------------------------------------------------------- void Mt_rpCodM20ms(void) { //======================================================================================== // Pre-Condition 1: coding data has not been validated or failed; // Expected Result: CodM_Cycle20ms() will be called; //======================================================================================== flag_MT_CodMCycle = FALSE; CodM_boCodingDataIsValidated = FALSE; Rte_rpCodM20ms(); AL_UNITTEST_CHECK(flag_MT_CodMCycle, TRUE, == ); //======================================================================================== // Pre-Condition 2: coding data has been validated and pass; // Expected Result: CodM_Cycle20ms() will not be called; //======================================================================================== flag_MT_CodMCycle = FALSE; CodM_boCodingDataIsValidated = TRUE; Rte_rpCodM20ms(); AL_UNITTEST_CHECK(flag_MT_CodMCycle, FALSE, == ); } // ----------------------------------------------------------------------------------------------------------------- /// \Test Case : Mt_rdCodMDeInit /// /// \Test Case Description /// - Test subject: /// To call rdCodMDeInit function /// /// - Preconditions: none /// /// - Expected test results: /// - CodM_DeInit() will be called; /// // ----------------------------------------------------------------------------------------------------------------- void Mt_rdCodMDeInit(void) { Rte_rdCodMDeInit(); AL_UNITTEST_CHECK(flag_MT_CodMDeInit, TRUE, == ); } // ----------------------------------------------------------------------------------------------------------------- /// \Test Case : Mt_roCodMStartCodingDataVerification /// /// \Test Case Description /// - Test subject: /// To call roCodMStartCodingDataVerification function /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// // ----------------------------------------------------------------------------------------------------------------- void Mt_roCodMStartCodingDataVerification(void) { Rte_roCodMStartCodingDataVerification(); } // ----------------------------------------------------------------------------------------------------------------- // Add Test Cases //------------------------------------------------------------------------------------------------------------------ void ALUnitTest_AddTests(void) { ALUnitTest_AddFunction("Mt_riCodMInit", Mt_riCodMInit); ALUnitTest_AddFunction("Mt_rpCodM20ms", Mt_rpCodM20ms); ALUnitTest_AddFunction("Mt_rdCodMDeInit", Mt_rdCodMDeInit); ALUnitTest_AddFunction("Mt_roCodMStartCodingDataVerification", Mt_roCodMStartCodingDataVerification); }