Skip to content

Commit

Permalink
Tests disabled tests (project-chip#7640)
Browse files Browse the repository at this point in the history
* Add more explicit failures when generating tests

* Add the ability to disable some tests in the yaml file

* Replace OnOffCluster yaml test  by Test_3_1_1, Test_3_2_1, Test_3_2_2

* Update gen/ folders
  • Loading branch information
vivien-apple authored Jun 15, 2021
1 parent d39933c commit 5f79529
Show file tree
Hide file tree
Showing 10 changed files with 1,742 additions and 185 deletions.
1,320 changes: 1,199 additions & 121 deletions examples/chip-tool/commands/tests/Commands.h

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{#chip_tests tests}}
class {{asCamelCased filename false}}: public TestCommand
class {{filename}}: public TestCommand
{
public:
{{asCamelCased filename false}}(): TestCommand("{{filename}}"), mTestIndex(0) {}
{{filename}}(): TestCommand("{{filename}}"), mTestIndex(0) {}

/////////// TestCommand Interface /////////
CHIP_ERROR NextTest() override
Expand Down Expand Up @@ -88,7 +88,7 @@ class {{asCamelCased filename false}}: public TestCommand
{
ChipLogProgress(chipTool, "{{cluster}} - {{label}}: Failure Response");

{{asCamelCased parent.filename false}} * runner = reinterpret_cast<{{asCamelCased parent.filename false}} *>(context);
{{parent.filename}} * runner = reinterpret_cast<{{parent.filename}} *>(context);

delete runner->mOnFailureCallback_{{index}};
delete runner->mOnSuccessCallback_{{index}};
Expand All @@ -106,7 +106,7 @@ class {{asCamelCased filename false}}: public TestCommand
{
ChipLogProgress(chipTool, "{{cluster}} - {{label}}: Success Response");

{{asCamelCased parent.filename false}} * runner = reinterpret_cast<{{asCamelCased parent.filename false}} *>(context);
{{parent.filename}} * runner = reinterpret_cast<{{parent.filename}} *>(context);

delete runner->mOnFailureCallback_{{index}};
delete runner->mOnSuccessCallback_{{index}};
Expand Down
6 changes: 4 additions & 2 deletions examples/chip-tool/templates/tests-commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

#include "TestCommand.h"

{{>test_cluster tests="TestCluster, OnOffCluster"}}
{{>test_cluster tests="TestCluster, Test_3_1_1, Test_3_2_1, Test_3_2_2"}}

void registerCommandsTests(Commands & commands)
{
const char * clusterName = "Tests";

commands_list clusterCommands = {
make_unique<TestCluster>(),
make_unique<OnOffCluster>(),
make_unique<Test_3_1_1>(),
make_unique<Test_3_2_1>(),
make_unique<Test_3_2_2>(),
};

commands.Register(clusterName, clusterCommands);
Expand Down
66 changes: 66 additions & 0 deletions src/app/tests/suites/Test_3_1_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (c) 2021 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: 3.1.1. [TC-OO-1] Global attributes with server as DUT

config:
cluster: "On/Off"
endpoint: 1

tests:
- label: "read the global attribute: ClusterRevision"
command: "readAttribute"
attribute: "Cluster Revision"
response:
value: 2

- label:
"write the default values to mandatory global attribute:
ClusterRevision"
disabled: true
command: "writeAttribute"
attribute: "Cluster Revision"
arguments:
value: 2
response:
error: 1

- label: "reads back global attribute: ClusterRevision"
command: "readAttribute"
attribute: "Cluster Revision"
response:
value: 2

- label: "read the optional global attribute: FeatureMap"
disabled: true
command: "readAttribute"
attribute: "Feature Map"
response:
value: 0

- label: "write the default values to optional global attribute: FeatureMap"
disabled: true
command: "writeAttribute"
attribute: "Feature Map"
arguments:
value: 0
response:
error: 1

- label: "reads back optional global attribute: FeatureMap"
disabled: true
command: "readAttribute"
attribute: "Feature Map"
response:
value: 0
127 changes: 127 additions & 0 deletions src/app/tests/suites/Test_3_2_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Copyright (c) 2021 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: 3.2.1. [TC-OO-2] Attributes with server as DUT

config:
cluster: "On/Off"
endpoint: 1

tests:
- label: "read the mandatory attribute: OnOff"
command: "readAttribute"
attribute: "On/Off"
response:
value: 0

- label: "write the default value of mandatory attribute: OnOff"
disabled: true
command: "writeAttribute"
attribute: "On/Off"
arguments:
value: 0
response:
error: 1

- label: "reads back mandatory attribute: OnOff"
command: "readAttribute"
attribute: "On/Off"
response:
value: 0

- label: "read LT attribute: GlobalSceneControl"
disabled: true
command: "readAttribute"
attribute: "Global Scene Control"
response:
value: 1

- label: "read LT attribute: OnTime"
disabled: true
command: "readAttribute"
attribute: "On Time"
response:
value: 0

- label: "read LT attribute: OffWaitTime"
disabled: true
command: "readAttribute"
attribute: "Off Wait Time"
response:
value: 0

- label: "read LT attribute: StartUpOnOff"
disabled: true
command: "readAttribute"
attribute: "Start Up On Off"
response:
value: 0

- label: "write the default value to LT attribute: GlobalSceneControl"
disabled: true
command: "writeAttribute"
attribute: "Global Scene Control"
arguments:
value: 0
response:
error: 1

- label: "write the default value to LT attribute: OnTime"
disabled: true
command: "writeAttribute"
attribute: "On Time"
arguments:
value: 0

- label: "write the default value to LT attribute: OffWaitTime"
disabled: true
command: "writeAttribute"
attribute: "Off Wait Time"
arguments:
value: 0

- label: "write the default value to LT attribute: StartUpOnOff"
disabled: true
command: "writeAttribute"
attribute: "Start Up On Off"
arguments:
value: 0

- label: "reads back LT attribute: GlobalSceneControl"
disabled: true
command: "readAttribute"
attribute: "Global Scene Control"
response:
value: 1

- label: "reads back LT attribute: OnTime"
disabled: true
command: "readAttribute"
attribute: "On Time"
response:
value: 0

- label: "reads back LT attribute: OffWaitTime"
disabled: true
command: "readAttribute"
attribute: "Off Wait Time"
response:
value: 0

- label: "reads back LT attribute: StartUpOnOff"
disabled: true
command: "readAttribute"
attribute: "Start Up On Off"
response:
value: 0
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,53 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: OnOff Tests
name: 3.2.2. [TC-OO-3] Primary functionality with server as DUT

config:
cluster: "On/Off"
endpoint: 1

tests:
- label: "Check on/off attribute value is false when starting"
- label: "Send Off Command"
command: "off"

- label: "Check on/off attribute value is false after off command"
command: "readAttribute"
attribute: "on/off"
response:
value: 0

- label: "Send On Command"
command: "on"

- label: "Check on/off attribute value is true after on command"
command: "readAttribute"
attribute: "on/off"
response:
value: 1

- label: "Send Off Command"
command: "off"

- label: "Check on/off attribute value is false after off command"
command: "readAttribute"
attribute: "on/off"
response:
value: 0

- label: "Send Toggle Command"
command: "toggle"

- label: "Check on/off attribute value is true after toggle command"
command: "readAttribute"
attribute: "on/off"
response:
value: 1

- label: "Send Toggle Command"
command: "toggle"

- label: "Check on/off attribute value is false after toggle command"
command: "readAttribute"
attribute: "on/off"
response:
Expand Down
Loading

0 comments on commit 5f79529

Please sign in to comment.