Skip to content

Commit

Permalink
#26925 change async delays to 0s to not affect certification tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarc committed Jul 21, 2023
1 parent 9c79458 commit 9f91729
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 274 deletions.
62 changes: 31 additions & 31 deletions examples/lock-app/lock-common/src/LockEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct LockActionData
bool moving = false;
};

LockActionData currentAction;
static LockActionData gCurrentAction;

bool LockEndpoint::Lock(const Nullable<chip::FabricIndex> & fabricIdx, const Nullable<chip::NodeId> & nodeId,
const Optional<chip::ByteSpan> & pin, OperationErrorEnum & err, OperationSourceEnum opSource)
Expand Down Expand Up @@ -427,21 +427,21 @@ bool LockEndpoint::setLockState(const Nullable<chip::FabricIndex> & fabricIdx, c
ChipLogProgress(Zcl, "Door Lock App: setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState),
mEndpointId);

if (currentAction.moving == true)
if (gCurrentAction.moving == true)
{
return false;
}

currentAction.moving = true;
currentAction.endpointId = mEndpointId;
currentAction.lockState = lockState;
currentAction.opSource = opSource;
currentAction.userIndex = NullNullable;
currentAction.fabricIdx = fabricIdx;
currentAction.nodeId = nodeId;
gCurrentAction.moving = true;
gCurrentAction.endpointId = mEndpointId;
gCurrentAction.lockState = lockState;
gCurrentAction.opSource = opSource;
gCurrentAction.userIndex = NullNullable;
gCurrentAction.fabricIdx = fabricIdx;
gCurrentAction.nodeId = nodeId;

// simulate 3s lock movement duration
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(3), OnLockActionCompleteCallback, nullptr);
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(0), OnLockActionCompleteCallback, nullptr);

return true;
}
Expand Down Expand Up @@ -506,54 +506,54 @@ bool LockEndpoint::setLockState(const Nullable<chip::FabricIndex> & fabricIdx, c
"Lock App: specified PIN code was found in the database, setting door lock state to \"%s\" [endpointId=%d,userIndex=%u]",
lockStateToString(lockState), mEndpointId, userIndex);

if (currentAction.moving == true)
if (gCurrentAction.moving == true)
{
return false;
}

currentAction.moving = true;
currentAction.endpointId = mEndpointId;
currentAction.lockState = lockState;
currentAction.opSource = opSource;
currentAction.userIndex = MakeNullable(static_cast<uint16_t>(userIndex + 1));
currentAction.credentialIndex = static_cast<uint16_t>(credentialIndex);
currentAction.fabricIdx = fabricIdx;
currentAction.nodeId = nodeId;
gCurrentAction.moving = true;
gCurrentAction.endpointId = mEndpointId;
gCurrentAction.lockState = lockState;
gCurrentAction.opSource = opSource;
gCurrentAction.userIndex = MakeNullable(static_cast<uint16_t>(userIndex + 1));
gCurrentAction.credentialIndex = static_cast<uint16_t>(credentialIndex);
gCurrentAction.fabricIdx = fabricIdx;
gCurrentAction.nodeId = nodeId;

// simulate 3s lock movement duration
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(3), OnLockActionCompleteCallback, nullptr);
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(0), OnLockActionCompleteCallback, nullptr);

return true;
}

void LockEndpoint::OnLockActionCompleteCallback(chip::System::Layer *, void * callbackContext)
{
if (currentAction.userIndex == NullNullable)
if (gCurrentAction.userIndex == NullNullable)
{
DoorLockServer::Instance().SetLockState(currentAction.endpointId, currentAction.lockState, currentAction.opSource,
NullNullable, NullNullable, currentAction.fabricIdx, currentAction.nodeId);
DoorLockServer::Instance().SetLockState(gCurrentAction.endpointId, gCurrentAction.lockState, gCurrentAction.opSource,
NullNullable, NullNullable, gCurrentAction.fabricIdx, gCurrentAction.nodeId);
}
else
{
LockOpCredentials userCredential[] = { { CredentialTypeEnum::kPin, currentAction.credentialIndex } };
LockOpCredentials userCredential[] = { { CredentialTypeEnum::kPin, gCurrentAction.credentialIndex } };
auto userCredentials = MakeNullable<List<const LockOpCredentials>>(userCredential);

DoorLockServer::Instance().SetLockState(currentAction.endpointId, currentAction.lockState, currentAction.opSource,
currentAction.userIndex, userCredentials, currentAction.fabricIdx,
currentAction.nodeId);
DoorLockServer::Instance().SetLockState(gCurrentAction.endpointId, gCurrentAction.lockState, gCurrentAction.opSource,
gCurrentAction.userIndex, userCredentials, gCurrentAction.fabricIdx,
gCurrentAction.nodeId);
}

// move back to Unlocked after Unlatch
if (currentAction.lockState == DlLockState::kUnlatched)
if (gCurrentAction.lockState == DlLockState::kUnlatched)
{
currentAction.lockState = DlLockState::kUnlocked;
gCurrentAction.lockState = DlLockState::kUnlocked;

// simulate 1s lock movement duration
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnLockActionCompleteCallback, nullptr);
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(0), OnLockActionCompleteCallback, nullptr);
}
else
{
currentAction.moving = false;
gCurrentAction.moving = false;
}
}

Expand Down
114 changes: 1 addition & 113 deletions src/app/tests/suites/DL_LockUnlock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ config:
nodeId: 0x12344321
cluster: "Door Lock"
endpoint: 1
timeout: 100
timeout: 25

tests:
- label: "Wait for the commissioned device to be retrieved"
Expand All @@ -33,14 +33,6 @@ tests:
command: "UnlockDoor"
timedInteractionTimeoutMs: 10000

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
Expand All @@ -51,14 +43,6 @@ tests:
command: "LockDoor"
timedInteractionTimeoutMs: 10000

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
Expand All @@ -69,14 +53,6 @@ tests:
command: "UnboltDoor"
timedInteractionTimeoutMs: 10000

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
Expand All @@ -87,14 +63,6 @@ tests:
command: "LockDoor"
timedInteractionTimeoutMs: 10000

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
Expand Down Expand Up @@ -181,14 +149,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Read the LockOperation event list"
command: "readEvent"
event: "LockOperation"
Expand Down Expand Up @@ -307,14 +267,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
Expand Down Expand Up @@ -379,14 +331,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
Expand All @@ -401,14 +345,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
Expand Down Expand Up @@ -443,14 +379,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
Expand All @@ -465,14 +393,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
Expand Down Expand Up @@ -553,14 +473,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
Expand All @@ -575,14 +487,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Create a disabled user and credential"
command: "SetCredential"
timedInteractionTimeoutMs: 10000
Expand Down Expand Up @@ -633,14 +537,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Unlocked"
command: "readAttribute"
attribute: "LockState"
Expand Down Expand Up @@ -671,14 +567,6 @@ tests:
- name: "PINCode"
value: "123456"

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Verify that lock state attribute value is set to Locked"
command: "readAttribute"
attribute: "LockState"
Expand Down
16 changes: 0 additions & 16 deletions src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ tests:
command: "LockDoor"
timedInteractionTimeoutMs: 1000

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Step 1d: TH reads LockState attribute from DUT"
PICS: DRLK.S.A0000
command: "readAttribute"
Expand All @@ -83,14 +75,6 @@ tests:
command: "UnlockDoor"
timedInteractionTimeoutMs: 1000

- label: "Wait for lock action to complete"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 5000

- label: "Step 1e: TH reads LockState attribute from DUT"
PICS: DRLK.S.A0000
command: "readAttribute"
Expand Down
Loading

0 comments on commit 9f91729

Please sign in to comment.