Skip to main content

TestCheckConstraint

Valid for: CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DE

Function Syntax

long TestCheckConstraint (dword aAuxHandle);
long TestCheckConstraint (char aEventText[]);

Description

Checks whether the specified constraint was already injured. This function can be used both within a test case and also on test module level.

Parameters

  • aAuxHandle: Event object, for example a check from the Test Service Library. Specified is the handle that is returned on creation of a check. This function can be used both within a test case and also on the test module level.
  • aEventText: Textual name of an event whose occurrence should be monitored. This event can be triggered with the function TestSupplyTextEvent.

Return Values

  • 1: Condition was already injured at least once
  • 0: Condition was not yet injured
  • < 0: The function cannot be executed because, for example, the specified condition does not exist

Example

Example 1 Add check as constraint
// checks the maximum duration of a sequence of actions
checkId = ChkStart_Timeout (1000);
TestAddConstraint (checkId);
TestWaitForTimeout(1500);
result = TestCheckConstraint(checkId);
if (result == 1)
      TestStepFail("Timeout already occurred after 1500 ms.");
// sequence of different actions and waiting conditions
TestRemoveConstraint (checkId);
Example 2 Add text event as constraint
// test case to check if Error Frames occur
testcase CheckErrorFrameReceived ()
{
    TestAddConstraint ("ErrorFrameReceived");
    TestWaitForTimeout(1000);
    result = TestCheckConstraint("ErrorFrameReceived");
    if (result == 1)
          TestStepFail("Error Frame already occurred after 1000 ms.");
    // sequence of different actions and waiting conditions
    TestRemoveConstraint("ErrorFrameReceived");
}

// handler to supply text event
on errorFrame
{
    TestSupplyTextEvent("ErrorFrameReceived");
}
TestAddConstraintTestSupplyTextEvent