//***************************************************************************** // (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.cpp /// /// \brief Unit Test Cases for software component FctR /// /// \author /// //----------------------------------------------------------------------------- #include extern "C" { #include #include #include #include #include } tRomPara_CodingArea coding_data; const tRomPara_CodingArea applicationCodingData = coding_data; //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_LowBeam /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of LowBeam /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_LowBeam, Mt_FctR_Test_01_LowBeam) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_LowBeam(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Low Beam */ Rte_ppLowBeamFct.bfLowBeamQty = QUALITY_OK; Rte_ppLowBeamFct.eLowBeamReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[3].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[3].eErr = ERR_NO; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppLowBeamFctSts.eLowBeamStsLamp1, (tieActivationSts)ACT_STS_ON, == ); AL_UNITTEST_CHECK(Rte_ppLowBeamFctSts.eLowBeamModeStsLamp1, (tieActivationMode)CLASS_C_COUNTRY, == ); /* Set ECU variant: Low */ Rte_ucVarInfo = 1; riFctRInit(); /* Turn on Low Beam */ Rte_ppLowBeamFct.bfLowBeamQty = QUALITY_OK; Rte_ppLowBeamFct.eLowBeamReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); /* Turn off Low Beam */ Rte_ppLowBeamFct.eLowBeamReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_HighBeam /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of HighBeam /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_HighBeam, Mt_FctR_Test_01_HighBeam) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_HighBeam(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on High Beam */ Rte_ppHighBeamFct.eHighBeamQty = QUALITY_OK; Rte_ppHighBeamFct.eHighBeamReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[4].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[7].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[3].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[4].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[7].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[3].eErr = ERR_NO; Rte_ppVirtLsStatusFault[4].eErr = ERR_NO; Rte_ppVirtLsStatusFault[7].eErr = ERR_NO; rpFctR10ms(); /* HQGIF-789: No feedback to LDM for High variant */ AL_UNITTEST_CHECK(Rte_ppHighBeamFctSts.eHighBeamStsLamp1, (tieActivationSts)ACT_STS_OFF, == ); /* Turn off High Beam */ Rte_ppHighBeamFct.eHighBeamReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[4].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[7].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_TurnIndicator /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of TurnIndicator /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_TurnIndicator, Mt_FctR_Test_01_TurnIndicator) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_TurnIndicator(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Turn Indicator */ Rte_ppTurnIndicatorFct.bfTurnIndQty = QUALITY_OK; Rte_ppTurnIndicatorFct.eTurnIndReq = ACTIVATION_REQUEST_ON; Rte_ppTurnIndicatorFct.bfTurnIndModeQty = QUALITY_OK; Rte_ppTurnIndicatorFct.eTurnIndMode = ACTIVATION_MODE_NORMAL; rpFctR10ms(); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[0].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[0].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[0].eErr = ERR_NO; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppTurnIndFctSts.eTurnIndStsLamp1, (tieActivationSts)ACT_STS_ON, == ); AL_UNITTEST_CHECK(Rte_ppTurnIndFctSts.eTurnIndModeStsLamp1, (tieActivationMode)NORMAL_ACTIVATION, == ); /* Turn off Turn Indicator */ Rte_ppTurnIndicatorFct.eTurnIndReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[0].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_CornerLight /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of CornerLight /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_CornerLight, Mt_FctR_Test_01_CornerLight) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_CornerLight(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Corner Light */ Rte_ppCornerLightFct.bfCornerLightQty = QUALITY_OK; Rte_ppCornerLightFct.eCornerLightReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[6].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[6].eErr = ERR_NO; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppCornerLightFctSts.eCornerLightStsLamp1, (tieActivationSts)ACT_STS_ON, == ); /* Turn off Corner Light */ Rte_ppCornerLightFct.eCornerLightReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_DayTimeRunningLight /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of DayTimeRunningLight /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_DayTimeRunningLight, Mt_FctR_Test_01_DayTimeRunningLight) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_DayTimeRunningLight(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Day Time Running Light */ Rte_ppDayTimeRunningLightFct.bfDrlReqQty = QUALITY_OK; Rte_ppDayTimeRunningLightFct.eDrlReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[1].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[2].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[5].unBrightness, (FctR_tiu16Percent_1_328)24600u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[1].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[2].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[5].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[1].eErr = ERR_NO; Rte_ppVirtLsStatusFault[2].eErr = ERR_NO; Rte_ppVirtLsStatusFault[5].eErr = ERR_NO; rpFctR10ms(); //AL_UNITTEST_CHECK(Rte_ppDayTimeRunningLightFctSts.eDrlStsLamp1, (tieActivationSts)ACT_STS_ON, == ); /* Turn off Day Time Running Light */ Rte_ppDayTimeRunningLightFct.eDrlReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[1].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[2].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[5].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_PositionLight /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of PositionLight /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_PositionLight, Mt_FctR_Test_01_PositionLight) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_PositionLight(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Position Light */ Rte_ppPositionLightFct.bfFrontPosLightQty = QUALITY_OK; Rte_ppPositionLightFct.eFrontPosLightReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[1].unBrightness, (FctR_tiu16Percent_1_328)3280u, == ); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[2].unBrightness, (FctR_tiu16Percent_1_328)3280u, == ); //AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[5].unBrightness, (FctR_tiu16Percent_1_328)2624u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[1].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[2].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[5].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[1].eErr = ERR_NO; Rte_ppVirtLsStatusFault[2].eErr = ERR_NO; Rte_ppVirtLsStatusFault[5].eErr = ERR_NO; rpFctR10ms(); //AL_UNITTEST_CHECK(Rte_ppPositionLightFctSts.eFrontPosLightStsLamp1, (tieActivationSts)ACT_STS_ON, == ); /* Turn off Position Light */ Rte_ppPositionLightFct.eFrontPosLightReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[1].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[2].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[5].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_FogLight /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of FogLight /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_FogLight, Mt_FctR_Test_01_FogLight) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_FogLight(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Fog Light */ Rte_ppFogLightFct.bfFrontFogLightQty = QUALITY_OK; Rte_ppFogLightFct.eFrontFogLightReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); /* Set LED status */ Rte_ppVirtLsStatusFault[6].eStatOn = eStatusOnOff_STAT_ON; Rte_ppVirtLsStatusFault[6].eErr = ERR_NO; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFogLightFctSts.eFrontFogLightStsLamp1, (tieActivationSts)ACT_STS_ON, == ); /* Turn off Fog Light */ Rte_ppFogLightFct.eFrontFogLightReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); rdFctRDeInit(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_FctR_Test_01_AfsMode /// /// \Test Case Description /// - Test subject: /// To call functions riFctRInit & rpFctR10ms and check the behavior of lights in AfsMode /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values need to be reached and passed /// //----------------------------------------------------------------------------- #if defined(TYP_TEST_GoogleTest) TEST(Mt_FctR_Test_01_AfsMode, Mt_FctR_Test_01_AfsMode) #endif #if defined(TYP_TEST_CUnit) extern "C" void Mt_FctR_Test_01_AfsMode(void) #endif { /* Set ECU variant: High */ Rte_ucVarInfo = 4; riFctRInit(); /* Turn on Low Beam - Class V */ Rte_ppAfsModeReq.bfAfsModeReqQty = QUALITY_OK; Rte_ppAfsModeReq.eAfsMode = 0x2u; Rte_ppLowBeamFct.bfLowBeamQty = QUALITY_OK; Rte_ppLowBeamFct.eLowBeamReq = ACTIVATION_REQUEST_ON; Rte_ppFogLightFct.bfFrontFogLightQty = QUALITY_OK; Rte_ppFogLightFct.eFrontFogLightReq = ACTIVATION_REQUEST_OFF; Rte_ppCornerLightFct.bfCornerLightQty = QUALITY_OK; Rte_ppCornerLightFct.eCornerLightReq = ACTIVATION_REQUEST_OFF; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)21320u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)11808u, == ); /* Turn on Low Beam - Class C */ Rte_ppAfsModeReq.eAfsMode = 0x3u; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); /* Turn on Low Beam - Class E */ Rte_ppAfsModeReq.eAfsMode = 0x4u; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)0u, == ); /* Turn on Low Beam - Class T */ Rte_ppAfsModeReq.eAfsMode = 0x5u; Rte_ppCornerLightFct.eCornerLightReq = ACTIVATION_REQUEST_ON; rpFctR10ms(); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[3].unBrightness, (FctR_tiu16Percent_1_328)32800u, == ); AL_UNITTEST_CHECK(Rte_ppFctRLsLmmTarget[6].unBrightness, (FctR_tiu16Percent_1_328)21320u, == ); rdFctRDeInit(); } // ---------------------------------------------------------------------------- // Add Test Cases //----------------------------------------------------------------------------- #if defined(TYP_TEST_CUnit) extern "C" void ALUnitTest_AddTests(void) { ALUnitTest_AddFunction("Mt_FctR_Test_01_LowBeam" , Mt_FctR_Test_01_LowBeam); ALUnitTest_AddFunction("Mt_FctR_Test_01_HighBeam" , Mt_FctR_Test_01_HighBeam); ALUnitTest_AddFunction("Mt_FctR_Test_01_TurnIndicator" , Mt_FctR_Test_01_TurnIndicator); ALUnitTest_AddFunction("Mt_FctR_Test_01_CornerLight" , Mt_FctR_Test_01_CornerLight); ALUnitTest_AddFunction("Mt_FctR_Test_01_DayTimeRunningLight" , Mt_FctR_Test_01_DayTimeRunningLight); ALUnitTest_AddFunction("Mt_FctR_Test_01_PositionLight" , Mt_FctR_Test_01_PositionLight); ALUnitTest_AddFunction("Mt_FctR_Test_01_FogLight" , Mt_FctR_Test_01_FogLight); ALUnitTest_AddFunction("Mt_FctR_Test_01_AfsMode" , Mt_FctR_Test_01_AfsMode); } #endif