Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML] Add saveAs keyword for response fields and command arguments #11798

Merged
merged 5 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion examples/chip-tool/commands/tests/TestCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ class TestCommand : public CHIPCommand
{
if (current == expected)
{
Exit(std::string(itemName) + " value == notValue: " + std::to_string(current) + " == " + std::to_string(expected));
if (std::is_same<T, const chip::Span<const uint8_t>>::value || std::is_same<T, const chip::Span<const char>>::value)
{
Exit(std::string(itemName) + " value == notValue");
}
else
{
Exit(std::string(itemName) + " value == notValue: " + std::to_string(current) + " == " + std::to_string(expected));
}
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class {{filename}}: public TestCommand
std::atomic_uint16_t mTestIndex;
const uint16_t mTestCount = {{totalTests}};

{{#chip_tests_items}}
{{#chip_tests_item_response_parameters}}
{{#if saveAs}}
{{chipType}} {{saveAs}};
{{/if}}
{{/chip_tests_item_response_parameters}}
{{/chip_tests_items}}

{{#*inline "failureCallback"}}mOnFailureCallback_{{index}}{{/inline}}
{{#*inline "successCallback"}}mOnSuccessCallback_{{index}}{{/inline}}
{{#*inline "failureResponse"}}OnFailureCallback_{{index}}{{/inline}}
Expand Down Expand Up @@ -231,6 +239,10 @@ class {{filename}}: public TestCommand
{{~#if expectedConstraints.maxValue}}VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{>item}}", {{>item}}, {{expectedConstraints.maxValue}}));{{/if}}
{{~#if expectedConstraints.notValue}}VerifyOrReturn(CheckConstraintNotValue<{{chipType}}>("{{>item}}", {{>item}}, {{expectedConstraints.notValue}}));{{/if}}
{{/if}}

{{#if saveAs}}
{{saveAs}} = {{>item}};
{{/if}}
{{/chip_tests_item_response_parameters}}
{{#unless async}}NextTest();{{/unless}}
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{#if_is_bitmap type}}
static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>({{definedValue}});
{{else}}
{{definedValue}}{{asTypeLiteralSuffix type}};
{{asTypeLiteralSuffix definedValue type}};
{{/if_is_bitmap}}
{{/if_chip_enum}}
{{/if_is_struct}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
VerifyOrReturn(CheckValue
{{~#if (isOctetString type)}}AsString("{{label}}", {{actual}}, chip::ByteSpan(chip::Uint8::from_const_char("{{octetStringEscapedForCLiteral expected}}"), {{expected.length}}))
{{else if (isCharString type)}}AsString("{{label}}", {{actual}}, chip::CharSpan("{{expected}}", {{expected.length}}))
{{else}}<{{chipType}}>("{{label}}", {{actual}}, {{expected}}{{asTypeLiteralSuffix type}})
{{else}}<{{chipType}}>("{{label}}", {{actual}}, {{asTypeLiteralSuffix expected type}})
{{/if}}
);
{{/if_is_struct}}
Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/templates/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function getTests()
'TestConstraints',
'TestDelayCommands',
'TestLogCommands',
'TestSaveAs',
'TestDescriptorCluster',
'TestBasicInformation',
'TestIdentifyCluster',
Expand Down
6 changes: 6 additions & 0 deletions src/app/tests/suites/TestConstraints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ tests:
response:
constraints:
notValue: 6

- label: "Write attribute INT32U Value Back to Default Value"
command: "writeAttribute"
attribute: "int32u"
arguments:
value: 0
Loading