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
  • Loading branch information
vivien-apple authored and pull[bot] committed Sep 29, 2023
1 parent cf4658c commit 4531503
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Down
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
Expand Up @@ -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
Expand Down Expand Up @@ -457,7 +458,8 @@ tests:
response:
values:
- name: "pairingHint"
notValue: 0
constraints:
notValue: 0

- label: "Optional TXT key for pairing instructions (PI)"
disabled: true
Expand Down
13 changes: 13 additions & 0 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
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 4531503

Please sign in to comment.