Skip to content

Commit

Permalink
Add yaml test for ArmFailSafe
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Apr 15, 2022
1 parent 4967c0e commit 40112a7
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/tests/run_test_suite.py \
--chip-tool ./out/darwin-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT}/chip-tool \
--target-skip-glob '{TestGroupMessaging}' \
--target-skip-glob '{TestGroupMessaging,TestArmFailSafe}' \
run \
--iterations 1 \
--all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/templates/tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ function getTests()
'TestSystemCommands',
'TestBinding',
'TestUserLabelCluster',
'TestArmFailSafe',
];

const MultiAdmin = [
Expand Down
78 changes: 78 additions & 0 deletions src/app/tests/suites/TestArmFailSafe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright (c) 2022 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: ArmFailSafe Tests

config:
nodeId: 0x12344321
nodeId2:
type: NODE_ID
defaultValue: 0xCAFE
endpoint: 0
discriminator:
type: INT16U
defaultValue: 3840
payload:
type: CHAR_STRING
defaultValue: "MT:-24J0AFN00KA0648G00" # This value needs to be generated automatically

tests:
- label: "Reboot target device"
cluster: "SystemCommands"
command: "Reboot"
arguments:
values:
- name: "discriminator"
value: discriminator

- label: "Wait for the alpha device to be retrieved "
cluster: "DelayCommands"
command: "WaitForCommissionee"
arguments:
values:
- name: "nodeId"
value: nodeId

- label: "Opens a commissioning window on alpha device"
cluster: "AdministratorCommissioning"
command: "OpenBasicCommissioningWindow"
timedInteractionTimeoutMs: 10000
arguments:
values:
- name: "CommissioningTimeout"
value: 180

- label: "Query fabrics list"
command: "readAttribute"
cluster: "Operational Credentials"
attribute: "Fabrics"
response:
value: [{ Label: "", nodeId: nodeId }]
constraints:
type: list

- label: "Commission from beta device"
identity: "beta"
cluster: "CommissionerCommands"
command: "PairDevice"
arguments:
values:
- name: "nodeId"
value: nodeId2
- name: "payload"
value: payload
- name: "timeout"
value: 0
response:
error: UNSUPPORTED_ACCESS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@

constexpr uint16_t kPayloadMaxSize = 64;

CHIP_ERROR CommissionerCommands::PairDevice(chip::NodeId nodeId, const chip::CharSpan payload, uint16_t timeout)
{
VerifyOrReturnError(payload.size() > 0 && payload.size() < kPayloadMaxSize, CHIP_ERROR_INVALID_ARGUMENT);

GetCurrentCommissioner().RegisterPairingDelegate(this);

char qrCode[kPayloadMaxSize];
memcpy(qrCode, payload.data(), payload.size());

chip::Controller::CommissioningParameters commissioningParams;
commissioningParams.SetFailsafeTimerSeconds(timeout);

return GetCurrentCommissioner().PairDevice(nodeId, qrCode, commissioningParams);
}

CHIP_ERROR CommissionerCommands::PairWithQRCode(chip::NodeId nodeId, const chip::CharSpan payload)
{
VerifyOrReturnError(payload.size() > 0 && payload.size() < kPayloadMaxSize, CHIP_ERROR_INVALID_ARGUMENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CommissionerCommands : public chip::Controller::DevicePairingDelegate
virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0;
virtual chip::Controller::DeviceCommissioner & GetCurrentCommissioner() = 0;

CHIP_ERROR PairDevice(chip::NodeId nodeId, const chip::CharSpan payload, uint16_t timeout);
CHIP_ERROR PairWithQRCode(chip::NodeId nodeId, const chip::CharSpan payload);
CHIP_ERROR PairWithManualCode(chip::NodeId nodeId, const chip::CharSpan payload);
CHIP_ERROR Unpair(chip::NodeId nodeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
*
*/

const PairDevice = {
name : 'PairDevice',
arguments :
[ { type : 'NODE_ID', name : 'nodeId' }, { type : 'CHAR_STRING', name : 'payload' }, { type : 'INT16U', name : 'timeout' } ],
response : { arguments : [] }
};

const PairWithQRCode = {
name : 'PairWithQRCode',
arguments : [ { type : 'NODE_ID', name : 'nodeId' }, { type : 'CHAR_STRING', name : 'payload' } ],
Expand All @@ -43,7 +50,7 @@ const Unpair = {
};

const name = 'CommissionerCommands';
const commands = [ PairWithQRCode, PairWithManualCode, Unpair ];
const commands = [ PairDevice, PairWithQRCode, PairWithManualCode, Unpair ];

const CommissionerCommands = {
name,
Expand Down
212 changes: 212 additions & 0 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40112a7

Please sign in to comment.