//***************************************************************************** // (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 Avac /// /// \author /// //----------------------------------------------------------------------------- #define RTE_MICROSAR_PIM_EXPORT #include #include #include #include #include #include #include #include #include #include //extern extern const tRomPara_AvacAlgoDynCfg* CodBlockDavacPara; extern const tRomPara_AvacAlgoGenCfg* CodBlockAvacGenGfg; extern tisAvacPosition AvacPositionOutput; extern uint16 VehicleWheelBase; extern sint16 NvmSensorCaliData; //variable VAR(Dcm_Data4ByteType, RTE_VAR_DEFAULT_RTE_PIM_GROUP_INIT) Rte_ctaaAvac_PimCalibrationZeroLevel; static tisCodingStatus Coding_Sta; static tisLightCmd LightCmd_test; tisVehicleDynamic VehicleDynamic_test; //fuction void Mt_rpAvacCycle(uint8 condition); //input FUNC(Std_ReturnType, RTE_CODE) Rte_Read_ctaaAvac_PpareCodMCodingStatus_sCodingStatus(P2VAR(tisCodingStatus, AUTOMATIC, RTE_CTAAAVAC_APPL_VAR) data) /* PRQA S 1505, 3206 */ /* MD_MSR_Rule8.7, MD_Rte_3206 */ { Std_ReturnType ret = RTE_E_OK; /* PRQA S 2981 */ /* MD_MSR_RetVal */ *data = Coding_Sta; return ret; } FUNC(Std_ReturnType, RTE_CTAAVEHICLEHUB_APPL_CODE) PpasvVehHubLightCmd_ReadData(P2VAR(tisLightCmd, AUTOMATIC, RTE_CTAAVEHICLEHUB_APPL_VAR) data) { Std_ReturnType ret = RTE_E_OK; *data = LightCmd_test; return ret; } FUNC(Std_ReturnType, RTE_CTAAVEHICLEHUB_APPL_CODE) PpasvVehHubVehicleDynamic_ReadData(P2VAR(tisVehicleDynamic, AUTOMATIC, RTE_CTAAVEHICLEHUB_APPL_VAR) data) { Std_ReturnType ret = RTE_E_OK; *data = VehicleDynamic_test; return ret; } //output FUNC(Std_ReturnType, RTE_CODE) Rte_Write_ctaaAvac_PpaseAVACAvacPosition_sValue(P2CONST(tisAvacPosition, AUTOMATIC, RTE_CTAAAVAC_APPL_DATA) data) /* PRQA S 1505, 2982 */ /* MD_MSR_Rule8.7, MD_Rte_2982 */ { Std_ReturnType ret = RTE_E_OK; /* PRQA S 2981 */ /* MD_MSR_RetVal */ return ret; } void SwcNvmWrapper_WriteNvmReq(uint8 blockId, uint8* ValPtr) { memcpy(&Rte_ctaaAvac_PimCalibrationZeroLevel[0], ValPtr, sizeof(Rte_ctaaAvac_PimCalibrationZeroLevel)); } //----------------------------------------------------------------------------- /// \Test Case : Mt_riAvacInit /// /// \Test Case Description /// - Test subject: /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// //----------------------------------------------------------------------------- void Mt_riAvacInit(void) { tRomPara_CodingArea* coding_data = &applicationCodingData; Coding_Sta.eCodingStatus = 1; Mt_rpAvacCycle(1); AvacData_Init(); (void)AvacData_GetLowBeamOn(); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[0], 0xff, == ); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[1], 0xff, == ); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[2], 0xff, == ); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[3], 0xff, == ); coding_data->System.AvacAlgoDynCfg.HighDynamicLimit = 15; coding_data->System.AvacAlgoGenCfg.OutputAngleMax = 875; coding_data->System.VehicleData.WheelBase = 2950; Coding_Sta.eCodingStatus = 0; Mt_rpAvacCycle(0); AvacData_Init(); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[0], 0x7f, == ); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[1], 0x7f, == ); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[2], 0x7f, == ); AL_UNITTEST_CHECK(Rte_ctaaAvac_PimCalibrationZeroLevel[3], 0x7f, == ); AL_UNITTEST_CHECK(CodBlockDavacPara->HighDynamicLimit, 15, == ); AL_UNITTEST_CHECK(VehicleWheelBase, 2950, == ); AL_UNITTEST_CHECK(NvmSensorCaliData, 0, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_rpAvacCycle /// /// \Test Case Description /// - Test subject: The number of actual runs simulated /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// //----------------------------------------------------------------------------- void Mt_rpAvacCycle(uint8 condition) { uint8 data[4] = { 0, 0, 0, 0 }; uint8 i; if (condition) { for (i = 0; i < 4; i++) { data[i] = 0xff; } } else { for (i = 0; i < 4; i++) { data[i] = 0x7f; } } SwcNvmWrapper_WriteNvmReq(1, &data[0]); } //----------------------------------------------------------------------------- /// \Test Case : Mt_rrAvacEnable /// /// \Test Case Description /// - Test subject: /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// //----------------------------------------------------------------------------- void Mt_rrAvacEnable(void) { boolean Avacsta1, Avacsta2, Avacsta3, Avacsta4; tAvac_AccelPreDetect AccelPreDetect_test; tAvac_BrakePreDetect BrakePreDetect_test; Avacsta1 = AvacData_GetAvacS_Ok(); Avacsta2 = AvacData_GetAvacS_En(); Avacsta3 = AvacData_GetAvacD_Ok(); Avacsta4 = AvacData_GetAvacD_En(); AvacData_ReadAccelPreDetect(&AccelPreDetect_test); AvacData_ReadBrakePreDetect(&BrakePreDetect_test); Avac_GetInput(); AL_UNITTEST_CHECK(Avacsta1, TRUE, == ); AL_UNITTEST_CHECK(Avacsta2, TRUE, == ); AL_UNITTEST_CHECK(Avacsta3, TRUE, == ); AL_UNITTEST_CHECK(Avacsta4, TRUE, == ); AL_UNITTEST_CHECK(AccelPreDetect_test.eSigQty, SIG_INVALID, == ); AL_UNITTEST_CHECK(BrakePreDetect_test.eSigQty, SIG_INVALID, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_rrAvacToAlgorithm /// /// \Test Case Description /// - Test subject: /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// //----------------------------------------------------------------------------- void Mt_rrAvacToAlgorithm(void) { boolean LowBeamState; tAvac_Pitch Avac_Pitch_test; tAvac_Speed Avac_Speed_test; LightCmd_test.sLowerBeam.boValue = 1; LightCmd_test.sLowerBeam.eQty = 0; LowBeamState = AvacData_GetLowBeamOn(); AL_UNITTEST_CHECK(LowBeamState, TRUE, == ); VehicleDynamic_test.sSuspensionHeight.usValueFL = 127; VehicleDynamic_test.sSuspensionHeight.usValueFR = 127; VehicleDynamic_test.sSuspensionHeight.usValueRL = 127; VehicleDynamic_test.sSuspensionHeight.usValueRR = 127; VehicleDynamic_test.sSuspensionHeight.eQty = SIG_VALID; AvacData_ReadPitch(&Avac_Pitch_test); AL_UNITTEST_CHECK(Avac_Pitch_test.nAngle, 0, == ); AL_UNITTEST_CHECK(Avac_Pitch_test.eSigQty, SIG_VALID, == ); VehicleDynamic_test.sSpeed.eQty = SIG_INVALID; VehicleDynamic_test.sAccelerationRate.eQtyX = SIG_INVALID; AvacData_ReadSpeed(&Avac_Speed_test); AL_UNITTEST_CHECK(Avac_Speed_test.eSigQty, SIG_INVALID, == ); VehicleDynamic_test.sSpeed.eQty = SIG_VALID; VehicleDynamic_test.sSpeed.usValue = 50; AvacData_ReadSpeed(&Avac_Speed_test); AL_UNITTEST_CHECK(Avac_Speed_test.eSigQty, SIG_VALID, == ); AL_UNITTEST_CHECK(Avac_Speed_test.nSpeed, 50, == ); AL_UNITTEST_CHECK(Avac_Speed_test.nAcceleration, 138, == ); VehicleDynamic_test.sAccelerationRate.eQtyX = SIG_VALID; VehicleDynamic_test.sAccelerationRate.usAccValueX = 5; AvacData_ReadSpeed(&Avac_Speed_test); AL_UNITTEST_CHECK(Avac_Speed_test.nAcceleration, 5, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_rrAvacOutput /// /// \Test Case Description /// - Test subject: /// /// - Preconditions: none /// /// - Expected test results: /// - All conditions and assigned values mentioned for each test case/step shall be reached and passed /// //----------------------------------------------------------------------------- void Mt_rrAvacOutput() { tAvac_Out Avac_Out_test = { 875, 0 }; const tAvac_Out* pAvacOut_test = &Avac_Out_test; AvacData_WriteAvacOut(pAvacOut_test); AL_UNITTEST_CHECK(AvacPositionOutput.ssVerAngle0, 502, == ); AL_UNITTEST_CHECK(AvacPositionOutput.eAvacSigQty, SIG_VALID, == ); Avac_Out_test.nAngle = -875; AvacData_WriteAvacOut(pAvacOut_test); AL_UNITTEST_CHECK(AvacPositionOutput.ssVerAngle0, -502, == ); } // ---------------------------------------------------------------------------- // Add Test Cases //----------------------------------------------------------------------------- void ALUnitTest_AddTests(void) { ALUnitTest_AddFunction("Mt_riAvacInit", Mt_riAvacInit); ALUnitTest_AddFunction("Mt_rrAvacEnable", Mt_rrAvacEnable); ALUnitTest_AddFunction("Mt_rrAvacToAlgorithm", Mt_rrAvacToAlgorithm); ALUnitTest_AddFunction("Mt_rrAvacOutput", Mt_rrAvacOutput); }