Skip to content

Commit

Permalink
[YAML] Fix some discovery tests thare are using notValue improperly a…
Browse files Browse the repository at this point in the history
…nd add a codegen check to make sure it does not happens again (#17686)

* [YAML] Fix some discovery tests thare are using notValue improperly and add a codegen check to make sure it does not happens again

* Update generated test code
vivien-apple authored Apr 25, 2022
1 parent baef98a commit 252314f
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app/tests/suites/TestDiscovery.yaml
Original file line number Diff line number Diff line change
@@ -269,7 +269,8 @@ tests:
response:
values:
- name: "pairingHint"
notValue: 0
constraints:
notValue: 0

- label: "Optional TXT key for pairing instructions (PI)"
PICS: PI_KEY
6 changes: 4 additions & 2 deletions src/app/tests/suites/certification/Test_TC_SC_4_2.yaml
Original file line number Diff line number Diff line change
@@ -233,7 +233,8 @@ tests:
response:
values:
- name: "pairingHint"
notValue: 0
constraints:
notValue: 0

- label: "Optional TXT key for pairing instructions (PI)"
PICS: PI_KEY
@@ -457,7 +458,8 @@ tests:
response:
values:
- name: "pairingHint"
notValue: 0
constraints:
notValue: 0

- label: "Optional TXT key for pairing instructions (PI)"
disabled: true
13 changes: 13 additions & 0 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
@@ -249,6 +249,19 @@ function setDefaultResponse(test)
const defaultResponseValues = [];
setDefault(test[kResponseName], kValuesName, defaultResponseValues);

// Ensure only valid keywords are used for response values.
const values = test[kResponseName][kValuesName];
for (let i = 0; i < values.length; i++) {
for (let key in values[i]) {
if (key == "name" || key == "value" || key == kConstraintsName || key == kSaveAsName) {
continue;
}

const errorStr = `Unknown key "${key}"`;
throwError(test, errorStr);
}
}

const defaultResponseConstraints = {};
setDefault(test[kResponseName], kConstraintsName, defaultResponseConstraints);

4 changes: 4 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 252314f

Please sign in to comment.