Skip to content

Commit

Permalink
Update readme with additional functionality. (project-chip#15160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh V [Apple] authored Feb 17, 2022
1 parent fba7434 commit 5cbe293
Show file tree
Hide file tree
Showing 16 changed files with 667 additions and 37 deletions.
109 changes: 107 additions & 2 deletions .github/.wordlist.txt

Large diffs are not rendered by default.

359 changes: 324 additions & 35 deletions src/app/tests/suites/README.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/app/tests/suites/examples/Config_Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
config:
cluster: "ExampleCluster"
endpoint: 1
identity: "beta" # Uses secondary commissioner
exampleVariable: # See Config variables example
type: INT16U
defaultValue: 110
31 changes: 31 additions & 0 deletions src/app/tests/suites/examples/Config_Variables_Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
config:
exampleVariable:
type: INT16U
defaultValue: 110
coolVariables:
type: CHAR_STRING
defaultValue: "I am a super cool variable"
aBigNumber:
type: INT64U
defaultValue: 1.8446744e+19
aBool:
type: BOOLEAN
defaultValue: false

tests:
- label: "Examples Test Step 1"
cluster: "ExampleCluster"
command: "ExamplesCommand"
disabled: false # Disables the test step if true
arguments: # User variable as arguments
values:
- name: "exampleVariable"
value: exampleVariable

- label: "Examples Test Step 2"
cluster: "ExampleCluster2"
command: "ExamplesCommand2"
response: # User variable as response value checks
values:
- name: "aBool"
value: aBool
15 changes: 15 additions & 0 deletions src/app/tests/suites/examples/PICS_Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tests:
- label: "Examples Test Step 1"
cluster: "ExampleCluster"
command: "writeAttribute"
PICS: WILL_NOT_RUN

- label: "Examples Test Step 2"
cluster: "ExampleCluster"
command: "readAttribute"
PICS: WILL_RUN

- label: "Examples Test Step 3"
cluster: "ExampleCluster"
command: "ExamplesCommand"
PICS: WILL_NOT_RUN || WILL_RUN # Conditional will run
8 changes: 8 additions & 0 deletions src/app/tests/suites/examples/Response_Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests:
- label: "Examples Test Step 1"
cluster: "ExampleCluster"
command: "ExamplesCommand"
response: # Validates the response variables of the commands
values:
- name: "exampleResponseVariable"
value: 1
8 changes: 8 additions & 0 deletions src/app/tests/suites/examples/TestGenExample.zapt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#chip_tests (getTests)}}
{{#chip_tests_config}}
"Argument Name {{name}}"
"Argument Type {{type}}"
"Argument Type {{defaultValue}}"

{{/chip_tests_config}}
{{/chip_tests}}
2 changes: 2 additions & 0 deletions src/app/tests/suites/examples/TestPICS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WILL_NOT_RUN=0
WILL_RUN=1
36 changes: 36 additions & 0 deletions src/app/tests/suites/examples/Test_Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
tests:
- label: "Examples Test Step 1"
cluster: "ExampleCluster"
command: "writeAttribute"
attribute: "exampleAttribute"
arguments:
value: 255

- label: "Examples Test Step 2"
cluster: "ExampleCluster"
command: "readAttribute"
attribute: "exampleAttribute"
response: # Validates the response variables of the commands
value: 255

- label: "Examples Test Step 3"
cluster: "ExampleCluster"
command: "ExamplesCommand"
response: # Validates the response variables of the commands
saveAs: nameOfSaveVariable
value: 0
values:
- name: "exampleResponseVariable"
value: 1
timedInteractionTimeoutMs: 10000
PICS: RUN_ONLY_IF_ENABLED
arguments:
values:
- name: "arg1"
value: 0
- name: "arg2"
value: { Key1: 1, Key2: 2 }
- name: "stringExamples"
value: "Hello World"
- name: "fromSaveAs"
value: nameOfSaveVariable
10 changes: 10 additions & 0 deletions src/app/tests/suites/examples/Test_Example_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
config:
cluster: "Basic"
endpoint: 0
testOneVariable:
type: INT16U
defaultValue: 1
tests:
- label: "Examples Test Step 1"
cluster: "LogCommands"
command: "Log"
10 changes: 10 additions & 0 deletions src/app/tests/suites/examples/Test_Example_2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
config:
cluster: "Basic"
endpoint: 0
testTwoVariable:
type: INT16U
defaultValue: 2
tests:
- label: "Examples Test Step 1"
cluster: "LogCommands"
command: "Log"
10 changes: 10 additions & 0 deletions src/app/tests/suites/examples/Test_Example_3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
config:
cluster: "Basic"
endpoint: 0
testThreeVariable:
type: INT16U
defaultValue: 3
tests:
- label: "Examples Test Step 1"
cluster: "LogCommands"
command: "Log"
29 changes: 29 additions & 0 deletions src/app/tests/suites/examples/gen_readme_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

#
# 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.
#

CHIP_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"/../../../../..
echo "$CHIP_ROOT"
INPUT_ZAP="$CHIP_ROOT/src/controller/data_model/controller-clusters.zap"
INPUT_TEMPLATE="$CHIP_ROOT/src/app/tests/suites/examples/templates/templates.json"
OUTPUT_DIR="$CHIP_ROOT/src/app/tests/suites/examples/out"

source "$CHIP_ROOT/scripts/activate.sh"

mkdir -p "$OUTPUT_DIR"

"$CHIP_ROOT"/scripts/tools/zap/generate.py "$INPUT_ZAP" -t "$INPUT_TEMPLATE" -o "$OUTPUT_DIR"
16 changes: 16 additions & 0 deletions src/app/tests/suites/examples/templates/templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "CHIP README Templates",
"version": "chip-v1",
"helpers": [
"../../../../zap-templates/common/ClusterTestGeneration.js",
"tests.js"
],

"templates": [
{
"path": "../TestGenExample.zapt",
"name": "Test Generate Example",
"output": "TestGenExample.out"
}
]
}
49 changes: 49 additions & 0 deletions src/app/tests/suites/examples/templates/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
*
* 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.
*/

function getManualTests()
{
const ExampleManualCataCategory = [
'examples/Test_Example',
];

const tests = [
ExampleManualCataCategory, //

];
return tests.flat(1);
}

function getTests()
{
const TestExample = [
'examples/Test_Example_1',
'examples/Test_Example_2',
'examples/Test_Example_3',
];

const tests = [
TestExample, //
];
return tests.flat(1);
}

//
// Module exports
//
exports.getTests = getTests;
exports.getManualTests = getManualTests;
5 changes: 5 additions & 0 deletions src/controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ The Android chip-tool is located in [../android/CHIPTool](../android/CHIPTool).
The POSIX CLI chip-tool is located in
[../../examples/chip-tool](../../examples/chip-tool).

### Darwin CLI

The POSIX CLI chip-tool is located in
[../../examples/chip-tool-darwin](../../examples/chip-tool).

### Python

The Python chip-device-ctrl is located in
Expand Down

0 comments on commit 5cbe293

Please sign in to comment.