当前位置:网站首页>Canoe test: two ways to create CAPL test module
Canoe test: two ways to create CAPL test module
2022-07-04 10:51:00 【picoasis】
Content reference 2:《CANoe Development from entry to mastery 》
After the project is established ( Based on the third simulation project ), There are two ways to create CAPL Test Module.
Catalog
1. stay Test SetUp establish CAPL Test Module
2 be based on Simulation Setup establish CAPL Test Module
1. stay Test SetUp establish CAPL Test Module
1-1 Click on Test-TestSetUp, open Test Setup for Test Modules window .
1-2 Right click in the window , Create or use established Test Environment
1-3 Check the created Test Environment Test environment , establish CAPL TestModule.
1-4 Check the created Test Module Right click editing , Get into .can file , To write CAPL The test case .
1-5 CAPL After editing , double-click Test Module name , You can see in the window CAPL Test cases defined in . After starting the project , Click the triangle in the lower right corner to run the test case .
1-5 TestModule At the end of the run , You can view the test report . The format of the test report can be selected Test Viewer, perhaps XML/HTML Format open .
thus , Use TestSetup establish CAPL Test Module complete .
2 be based on Simulation Setup establish CAPL Test Module
2-1 Directly on the simulation engineering panel Simulation On , Right click on the bus , add to CAPL Test Module
2-2 After creation It will display a CAPL node , Right click on the Configuration This node attribute can be configured ,
2-3 After the configuration is completed, click the small pencil , edit CAPL Document test cases , Save and compile .
2-4 After the operation of the project , Click on CAPL node , May open CAPL TestModule window , Display the edited CAPL The test case . Click triangle , Can run TestModule.
2-5 TestModule At the end of the run , You can view the test report .
thus , Use Simulation Setup establish CAPL Test Module complete .
3. appendix :CAPL Code
/*@!Encoding:936*/
/*
1. The test case —— Detect message cycle
2. The test case —— Detect the message length DLC
3. The test case —— Detect undefined message undefined msg
4. The test case —— A functional test
5. The test case —— Test module entry function
*/
includes
{
}
variables
{
//TC1
dword gCycCheckId;// Declare the... Of the detection event ID
int gUndefinedMsgCheckResult;// Declare the detection result of undefined message
const long kMIN_CYCLE_TIME = 40;// General minimum cycle time constant
const long kMAX_CYCLE_TIME = 60;// General maximum cycle time constant
const long Lingh_MIN_CYCLE_TIME = 490;// Define message Light_Info Minimum cycle time constant
const long Lingh_MAX_CYCLE_TIME = 510;// Define message Light_Info Maximum cycle time constant
const long kTIMEOUT = 4000;// Define the test wait time constant
}
// Cycle time detection result function
CheckMsgCyc(float aCycMinCycleTime, float aCycMaxCycleTime)
{
long lQueryResultProbeAvg;// Average declaration time
long lQueryResultProbeMin;// Declare the minimum measurement time
long lQueryResultProbeMax;// Declare the maximum measurement time
char lbuffer[100];
testAddCondition(gCycCheckId);// Add an event to this function
testWaitForTimeout(kTIMEOUT);// Wait for the test time to end
// Statistical average time
lQueryResultProbeAvg = ChkQuery_StatProbeIntervalAvg(gCycCheckId);
// Statistics min Time
lQueryResultProbeMin = ChkQuery_StatProbeIntervalMin(gCycCheckId);
// Statistics max Time
lQueryResultProbeMax = ChkQuery_StatProbeIntervalMax(gCycCheckId);
if(ChkQuery_NumEvents(gCycCheckId)>0)
{
// Count the number of exceptions // Print report
snprintf(lbuffer,elCount(lbuffer),"Valid values %.0fms - %.0fms",aCycMinCycleTime,aCycMaxCycleTime);
testStepFail("",lbuffer);
snprintf(lbuffer,elCount(lbuffer),"Average cycle time: %dms",lQueryResultProbeAvg);
testStepFail("",lbuffer);
snprintf(lbuffer,elCount(lbuffer),"Min cycle time: %dms",lQueryResultProbeMin);
testStepFail("",lbuffer);
snprintf(lbuffer,elCount(lbuffer),"Average cycle time: %dms",lQueryResultProbeMax);
testStepFail("",lbuffer);
}
else
{
snprintf(lbuffer,elCount(lbuffer),"Valid values %.0fms - %.0fms",aCycMinCycleTime,aCycMaxCycleTime);
testStepPass("",lbuffer);
snprintf(lbuffer,elCount(lbuffer),"Average cycle time: %dms",lQueryResultProbeAvg);
testStepPass("",lbuffer);
snprintf(lbuffer,elCount(lbuffer),"Min cycle time: %dms",lQueryResultProbeMin);
testStepPass("",lbuffer);
snprintf(lbuffer,elCount(lbuffer),"Average cycle time: %dms",lQueryResultProbeMax);
testStepPass("",lbuffer);
}
ChkControl_Destroy(gCycCheckId);// Destruction event
}
//TC1:Check Cycle time of msg EngineData
testcase CheckMsgEngineData()
{
float lCycMinCycleTime;// Declare the minimum cycle time
float lCycMaxCycleTime;// Declare the maximum cycle time
lCycMinCycleTime = kMIN_CYCLE_TIME;// assignment
lCycMaxCycleTime = kMAX_CYCLE_TIME;
// Test report prompt information
testCaseTitle("TC-1","TC-1:Check cycle time of msg EngineData");
// Start to observe the message to be tested
gCycCheckId = ChkStart_MsgAbsCycleTimeViolation(EngineData,lCycMinCycleTime,lCycMaxCycleTime);
CheckMsgCyc(lCycMinCycleTime,lCycMaxCycleTime);// Cycle time detection result function
testRemoveCondition(gCycCheckId);// Remove test conditions
}
//TC-2:Check Cycle time of msg VehicleData
testcase CheckMsgVehicleData()
{
float lCycMinCycleTime;
float lCycMaxCycleTime;
lCycMinCycleTime = kMIN_CYCLE_TIME;
lCycMaxCycleTime = kMAX_CYCLE_TIME;
testCaseTitle("TC-2","TC-2:Check cycle time of msg VehicleData");
gCycCheckId = ChkStart_MsgAbsCycleTimeViolation(VehicleData,lCycMinCycleTime,lCycMaxCycleTime);
CheckMsgCyc(lCycMinCycleTime,lCycMaxCycleTime);
testRemoveCondition(gCycCheckId);
}
//TC-3:Check Cycle time of msg Gear_Info
testcase CheckMsgGear_Info()
{
float lCycMinCycleTime;
float lCycMaxCycleTime;
lCycMinCycleTime = kMIN_CYCLE_TIME;
lCycMaxCycleTime = kMAX_CYCLE_TIME;
testCaseTitle("TC-3","TC-3:Check cycle time of msg Gear_Info");
gCycCheckId = ChkStart_MsgAbsCycleTimeViolation(Gear_Info,lCycMinCycleTime,lCycMaxCycleTime);
CheckMsgCyc(lCycMinCycleTime,lCycMaxCycleTime);
testRemoveCondition(gCycCheckId);
}
//TC-4:Check Cycle time of msg Ignition_Info
testcase CheckMsgIgnition_Info()
{
float lCycMinCycleTime;
float lCycMaxCycleTime;
lCycMinCycleTime = kMIN_CYCLE_TIME;
lCycMaxCycleTime = kMAX_CYCLE_TIME;
testCaseTitle("TC-4","TC-4:Check cycle time of msg Ignition_Info");
gCycCheckId = ChkStart_MsgAbsCycleTimeViolation(Ignition_Info,lCycMinCycleTime,lCycMaxCycleTime);
CheckMsgCyc(lCycMinCycleTime,lCycMaxCycleTime);
testRemoveCondition(gCycCheckId);
}
//TC-5:Check Cycle time of msg Light_Inf
testcase CheckMsgLight_Info()
{
float lCycMinCycleTime;
float lCycMaxCycleTime;
lCycMinCycleTime = kMIN_CYCLE_TIME;
lCycMaxCycleTime = kMAX_CYCLE_TIME;
testCaseTitle("TC-5","TC-5:Check cycle time of msg Light_Info");
gCycCheckId = ChkStart_MsgAbsCycleTimeViolation(Light_Info,lCycMinCycleTime,lCycMaxCycleTime);
CheckMsgCyc(lCycMinCycleTime,lCycMaxCycleTime);
testRemoveCondition(gCycCheckId);
}
//TC6:DLC Message length test
testcase CheckDLCLock_Info()
{
dword checkId;
// Test report prompt information
testCaseTitle("TC-6","TC-6:Check msg DLC of Lock_Info");
// Steward observation message Lock_Info Of DLC
checkId = ChkStart_InconsistentDlc(Lock_Info);
testAddCondition(checkId);
// Wait for the test time to end
testWaitForTimeout(kTIMEOUT);
testRemoveCondition(checkId);
}
//TC-7: Detect undefined signals
testcase CheckUndefinedMessage()
{
long lEventUndefineMessageId;// Declare undefined message Id
char lbuffer[100];
gUndefinedMsgCheckResult = 0;//? The number of initialization undefined messages is 0
testCaseTitle("TC-7","TC-7:Check CAN channel for undefined message");
// Start observing the current bus
gCycCheckId = ChkStart_UndefinedMessageReceived("UndefinedMsgCallback");
// Time delay , That is, measure the time period
testWaitForTimeout(kTIMEOUT);
switch(gUndefinedMsgCheckResult)
{
case 1:
write("Iam case1");
// Get undefined message ID
lEventUndefineMessageId = ChkQuery_EventMessageId(gCycCheckId);
snprintf(lbuffer,elCount(lbuffer),"Undefined message detected: Id 0x%x",lEventUndefineMessageId);
testStepFail("",lbuffer);
break;
default:
write("Iamdefault");
testStepPass("","No undefined message detected!");
break;
}
ChkControl_Destroy(gCycCheckId);// Destruction event
}
UndefinedMsgCallback(dword aCheckId)
{
// Callback function , Call when an undefined message is detected
write("Iam here");
ChkQuery_EventStatusToWrite(aCheckId);
gUndefinedMsgCheckResult=1;// Set the number of undefined messages to 1
}
//TC-8: A functional test
testcase CheckEngine_Speed()
{
dword checkId;
testCaseTitle("TC-8","TC-8:Check Engine Speed Value");
@Vehicle_Key::Unlock_Car = 1;
@Vehicle_Key::Car_Driver = 0;
@Vehicle_Key::Key_State = 2;
@Vehicle_Control::Eng_Speed = 2000;
// Start observing , Whether the signal value is within the range
checkId = ChkStart_MsgSignalValueInvalid(EngineData::EngSpeed,1900,2100);
testWaitForTimeout(kTIMEOUT);
if(ChkQuery_EventSignalValue(checkId))
{
testStepPass("","Correct Engine Speed Value");
}
else
{
testStepFail("","Incorrect Engine Speed Value");
}
}
// Test module entry function
void MainTest()
{
testModuleTitle("NetworkTester");
testModuleDescription("Message Specification Test and Function Test Demo.");
testGroupBegin("Check msg cycle time","Check the differ mesage cycle time");
Init_Test_Condition();
CheckMsgEngineData();
CheckMsgVehicleData();
CheckMsgGear_Info();
CheckMsgIgnition_Info();
CheckMsgLight_Info();
testGroupEnd();
testGroupBegin("Check msg DLC","Check DLC of a message");
CheckDLCLock_Info();
testGroupEnd();
testGroupBegin("Check undefined msg","Check the undefined message");
CheckUndefinedMessage();
testGroupEnd();
testGroupBegin("Fucntion Test","Check the engine speed after setup");
CheckEngine_Speed();
testGroupEnd();
}
// Initialize simulation engineering status , Ensure that each module is in Online
Init_Test_Condition()
{
@Vehicle_Key::Unlock_Car = 1;
@Vehicle_Key::Car_Driver = 0;
@Vehicle_Key::Key_State = 2;
testWaitForTimeout(500);
}
on sysvar_update Test::IPC_Cluster_Info_off
{
if (@this==1)
{
}
}
END
边栏推荐
- DDL statement of MySQL Foundation
- Advanced order of function
- Rhcsa day 10 operation
- Si vous ne connaissez pas ces quatre modes de mise en cache, vous osez dire que vous connaissez la mise en cache?
- JMeter assembly point technology and logic controller
- Application and Optimization Practice of redis in vivo push platform
- Safety testing aspects
- MFC document view framework (relationship between classes)
- 2022 ape circle recruitment project (software development)
- Performance test overview
猜你喜欢
JMeter assembly point technology and logic controller
Canoe - the second simulation engineering - xvehicle - 2panel design (principle, idea)
Ten key performance indicators of software applications
[Galaxy Kirin V10] [server] NFS setup
Linked list operation can never change without its roots
Rhcsa day 9
OSPF comprehensive experiment
RHCE - day one
Summary of several job scheduling problems
Idea SSH channel configuration
随机推荐
Summary of several job scheduling problems
The bamboo shadow sweeps the steps, the dust does not move, and the moon passes through the marsh without trace -- in-depth understanding of the pointer
[Galaxy Kirin V10] [server] failed to start the network
Rhcsa12
/*Rewrite the program, find the value of the element, and return the iterator 9.13: pointing to the found element. Make sure that the program works correctly when the element you are looking for does
Static comprehensive experiment ---hcip1
Common system modules and file operations
Design and common methods of test case documents
OSPF comprehensive experiment
Seven examples to understand the storage rules of shaped data on each bit
[Galaxy Kirin V10] [desktop] cannot add printer
[test theory] test process management
Architecture introduction
Rhcsa day 10 operation
If you don't know these four caching modes, dare you say you understand caching?
On binary tree (C language)
Write a program to define an array with 10 int elements, and take its position in the array as the initial value of each element.
Deepmind proposed a Zuan AI, which specially outputs network attack language
unit testing
[advantages and disadvantages of outsourcing software development in 2022]