Skip to content

Commit

Permalink
Implemented missing yaml tests cases and added EFS validation in Scen…
Browse files Browse the repository at this point in the history
…eHandlerImpl
  • Loading branch information
lpbeliveau-silabs committed Mar 19, 2024
1 parent 27a478f commit 563cb6c
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/clusters/scenes-server/SceneHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@
namespace chip {
namespace scenes {

namespace {

/// ValideAttribute
/// @brief Validate the attribute exists for a given cluster
/// @param[in] clusterID Cluster ID
/// @param[in] attID Attribute ID
/// @return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if the attribute does not exist for a given cluster or is not scenable
// TODO: Assess if we also want to throw an error if the attribute value is out of range
// TODO: Add check for "S" quality to determine if the attribute is scenable once suported :
// https://github.com/project-chip/connectedhomeip/issues/24177
CHIP_ERROR ValideAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeId)
{
uint16_t attIndex = emberAfGetServerAttributeIndexByAttributeId(endpoint, cluster, attributeId);
if (attIndex == UINT16_MAX)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}
return CHIP_NO_ERROR;
}
} // namespace

CHIP_ERROR
DefaultSceneHandlerImpl::EncodeAttributeValueList(const List<AttributeValuePairType> & aVlist, MutableByteSpan & serializedBytes)
{
Expand Down Expand Up @@ -58,6 +79,7 @@ DefaultSceneHandlerImpl::SerializeAdd(EndpointId endpoint, const ExtensionFieldS
auto pair_iterator = extensionFieldSet.attributeValueList.begin();
while (pair_iterator.Next())
{
ReturnErrorOnFailure(ValideAttribute(endpoint, extensionFieldSet.clusterID, pair_iterator.GetValue().attributeID));
aVPairs[pairCount] = pair_iterator.GetValue();
pairCount++;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/clusters/scenes-server/scenes-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ CHIP_ERROR AddResponseOnError(CommandHandlerInterface::HandlerContext & ctx, Res
{
resp.status = to_underlying(Protocols::InteractionModel::Status::ResourceExhausted);
}
else if (CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE == err)
{
resp.status = to_underlying(Protocols::InteractionModel::Status::InvalidCommand);
}
else
{
resp.status = to_underlying(StatusIB(err).mStatus);
Expand Down
157 changes: 157 additions & 0 deletions src/app/tests/suites/certification/Test_TC_S_2_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,21 @@ tests:
value: G1
- name: "SceneID"
value: 0x01

- label:
"Step 4e: TH sends a RecallScene command to DUT with the GroupID field
set to GI (Where GI is a group currently absent from the group table)
and the SceneID field set to 0x01."
PICS: S.S.C05.Rsp
command: "RecallScene"
arguments:
values:
- name: "GroupID"
value: GI
- name: "SceneID"
value: 0x01
response:
error: INVALID_COMMAND

- label:
"Step 5a: TH sends a ViewScene command to DUT with the GroupID field
Expand Down Expand Up @@ -773,6 +788,148 @@ tests:
- name: "SceneID"
value: 0x01

- label:
"Step 8f: TH sends a AddScene command to DUT with the GroupID field
set to G1, the SceneID field set to 0x01, the TransitionTime field set
to 1000 (1s) and extension field sets holding an invalid ExtensionField
(Invalid attribute ID for given cluster). This should fail and return a
status of 0x85 (INVALID_COMMAND)."
PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY
command: "AddScene"
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x01
- name: "TransitionTime"
value: 1000
- name: "SceneName"
value: "Scene1"
- name: "ExtensionFieldSets"
value: [
{
ClusterID: 0x0006,
AttributeValueList:
[{ AttributeID: 0xFFFF, AttributeValue: 0x01 }],
}
]
response:
values:
- name: "Status"
value: 0x85
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x01

- label:
"Step 8f: TH sends a AddScene command to DUT with the GroupID field
set to G1, the SceneID field set to 0x01, the TransitionTime field set
to 1000 (1s) and extension field sets holding an invalid ExtensionField
(Invalid attribute ID for given cluster). This should fail and return a
status of 0x85 (INVALID_COMMAND)."
verification: |
./chip-tool scenesmanagement add-scene 0x0001 0x01 1000 "scene name" '[{"clusterID": "0x006", "attributeValueList":[{"attributeID": "0xFFFF", "attributeValue": "0x01"}]}]' 1 1
Verify DUT sends a AddSceneResponse command to TH with the Status field set to 0x85 (INVALID_COMMAND), the GroupID field set to G1 and the SceneID field set to 0x01 on the TH(Chip-tool)
Log and below is the sample log provided for the raspi platform:
[1706763610.675038][4232:4234] CHIP:DMG: },
[1706763610.675108][4232:4234] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0000
[1706763610.675134][4232:4234] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0000
[1706763610.675187][4232:4234] CHIP:TOO: AddSceneResponse: {
[1706763610.675215][4232:4234] CHIP:TOO: status: 133
[1706763610.675229][4232:4234] CHIP:TOO: groupID: 1
[1706763610.675244][4232:4234] CHIP:TOO: sceneID: 1
[1706763610.675258][4232:4234] CHIP:TOO: }
cluster: "LogCommands"
command: "UserPrompt"
PICS: PICS_SKIP_SAMPLE_APP
arguments:
values:
- name: "message"
value:
"Please execute the add scene command with an invalid
extensionfieldsets due to an Attribute not existing on a cluster
on DUT and enter 'y' if the command returned a status of 0x85
(INVALID_COMMAND)"
- name: "expectedValue"
value: "y"

- label:
"Step 8g: TH sends a AddScene command to DUT with the GroupID field
set to G1, the SceneID field set to 0x01, the TransitionTime field set
to 1000 (1s) and extension field sets holding an invalid ExtensionField
(Unscenable attribute ID for given cluster). This should fail and return a
status of 0x85 (INVALID_COMMAND)."
## TODO: Enable once scenability check is possible, see issue: https://github.com/project-chip/connectedhomeip/issues/24177
PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY
command: "AddScene"
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x01
- name: "TransitionTime"
value: 1000
- name: "SceneName"
value: "Scene1"
- name: "ExtensionFieldSets"
value: [
{
ClusterID: 0x0006,
AttributeValueList:
[{ AttributeID: 0x4001, AttributeValue: 0x01 }],
}
]
response:
values:
- name: "Status"
value: 0x85
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x01
disabled: true

- label:
"Step 8g: TH sends a AddScene command to DUT with the GroupID field
set to G1, the SceneID field set to 0x01, the TransitionTime field set
to 1000 (1s) and extension field sets holding an invalid ExtensionField
(Unscenable attribute ID for given cluster). This should fail and return a
status of 0x85 (INVALID_COMMAND)."
## TODO: Enable once scenability check is possible, see issue: https://github.com/project-chip/connectedhomeip/issues/24177
verification: |
./chip-tool scenesmanagement add-scene 0x0001 0x01 1000 "scene name" '[{"clusterID": "0x006", "attributeValueList":[{"attributeID": "0x4001", "attributeValue": "0x01"}]}]' 1 1
Verify DUT sends a AddSceneResponse command to TH with the Status field set to 0x85 (INVALID_COMMAND), the GroupID field set to G1 and the SceneID field set to 0x01 on the TH(Chip-tool)
Log and below is the sample log provided for the raspi platform:
[1706763610.675038][4232:4234] CHIP:DMG: },
[1706763610.675108][4232:4234] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0000
[1706763610.675134][4232:4234] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0000
[1706763610.675187][4232:4234] CHIP:TOO: AddSceneResponse: {
[1706763610.675215][4232:4234] CHIP:TOO: status: 133
[1706763610.675229][4232:4234] CHIP:TOO: groupID: 1
[1706763610.675244][4232:4234] CHIP:TOO: sceneID: 1
[1706763610.675258][4232:4234] CHIP:TOO: }
cluster: "LogCommands"
command: "UserPrompt"
PICS: PICS_SKIP_SAMPLE_APP
arguments:
values:
- name: "message"
value:
"Please execute the add scene command with an invalid
extensionfieldsets due to a non sceneable attribute not in an
extensionfieldset on DUT and enter 'y' if the command returned
a status of 0x85 (INVALID_COMMAND)"
- name: "expectedValue"
value: "y"
disabled: true

- label:
"Step 9a: TH sends a RemoveScene command to DUT with the GroupID field
set to G1 and the SceneID field set to 0x01."
Expand Down
75 changes: 75 additions & 0 deletions src/app/tests/suites/certification/Test_TC_S_2_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,81 @@ tests:
value: G1
- name: "SceneID"
value: 0x03

- label:
"Step 6f: TH sends a StoreScene command to to group G1 with the GroupID
field set to G1 and the SceneID field set to 0x03."
PICS: S.S.C04.Rsp
command: "StoreScene"
groupId: G1
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x03

- label:
"Step 6g: TH sends a ViewScene command to DUT with the GroupID field
set to G1 and the SceneID field set to 0x03."
PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY
command: "ViewScene"
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x03
response:
values:
- name: "Status"
value: 0x00
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x03

- label:
"Step 6h: TH sends a RemoveScene command to group G1 with the GroupID
field set to G1 and the SceneID field set to 0x03."
PICS: S.S.C02.Rsp
command: "RemoveScene"
groupId: G1
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x03

- label: "Wait 1+ s to give CI time to process the RemoveScene command."
PICS: PICS_SDK_CI_ONLY
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 1250

- label:
"Step 6i: TH sends a ViewScene command to DUT with the GroupID field
set to G1 and the SceneID field set to 0x03."
PICS: S.S.C01.Rsp
command: "ViewScene"
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x03
response:
values:
- name: "Status"
value: 0x8b
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x03

- label:
"Step 7a: TH sends a CopyScene command to DUT with the mode field set
Expand Down

0 comments on commit 563cb6c

Please sign in to comment.