Skip to content

Commit

Permalink
Add MEI element support to Unit Testing cluster (#31637)
Browse files Browse the repository at this point in the history
* Update XML file

* Regen ZAP

* Update cluster code

* Add test and cluster updates

* Regen tests

* Restyled by clang-format

* Restyled by prettier-yaml

* Update XML

* Regen ZAP

* Update test

* Updated Unit Test cluster code

---------

Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Feb 5, 2024
1 parent f2b5706 commit 5430665
Show file tree
Hide file tree
Showing 53 changed files with 3,349 additions and 1,056 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6616,6 +6616,10 @@ internal cluster UnitTesting = 4294048773 {
fabric_idx fabricIndex = 254;
}

info event TestDifferentVendorMeiEvent = 4294050030 {
int8u arg1 = 1;
}

attribute boolean boolean = 0;
attribute Bitmap8MaskMap bitmap8 = 1;
attribute Bitmap16MaskMap bitmap16 = 2;
Expand Down Expand Up @@ -6698,6 +6702,7 @@ internal cluster UnitTesting = 4294048773 {
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute optional int8u writeOnlyInt8u = 16426;
attribute int8u meiInt8u = 4294070017;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -6893,6 +6898,15 @@ internal cluster UnitTesting = 4294048773 {
int8u fillCharacter = 2;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}

response struct TestDifferentVendorMeiResponse = 4294049979 {
int8u arg1 = 0;
int64u eventNumber = 1;
}

/** Simple command without any parameters and without a specific response.
To aid in unit testing, this command will re-initialize attribute storage to defaults. */
command Test(): DefaultSuccess = 0;
Expand Down Expand Up @@ -6963,6 +6977,8 @@ internal cluster UnitTesting = 4294048773 {
command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22;
/** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */
command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}

/** The Fault Injection Cluster provide a means for a test harness to configure faults(for example triggering a fault in the system). */
Expand Down Expand Up @@ -8710,6 +8726,7 @@ endpoint 1 {
server cluster UnitTesting {
emits event TestEvent;
emits event TestFabricScopedEvent;
emits event TestDifferentVendorMeiEvent;
ram attribute boolean default = false;
ram attribute bitmap8 default = 0;
ram attribute bitmap16 default = 0;
Expand Down Expand Up @@ -8793,6 +8810,7 @@ endpoint 1 {
callback attribute writeOnlyInt8u default = 0;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
ram attribute meiInt8u default = 0;

handle command Test;
handle command TestSpecificResponse;
Expand Down Expand Up @@ -8822,6 +8840,8 @@ endpoint 1 {
handle command TestEmitTestFabricScopedEventRequest;
handle command TestBatchHelperRequest;
handle command TestSecondBatchHelperRequest;
handle command TestDifferentVendorMeiRequest;
handle command TestDifferentVendorMeiResponse;
}
}
endpoint 2 {
Expand Down
39 changes: 39 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -21209,6 +21209,22 @@
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "TestDifferentVendorMeiRequest",
"code": 4294049962,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "TestDifferentVendorMeiResponse",
"code": 4294049979,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
Expand Down Expand Up @@ -22508,6 +22524,22 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "MeiInt8u",
"code": 4294070017,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down Expand Up @@ -22555,6 +22587,13 @@
"mfgCode": null,
"side": "server",
"included": 1
},
{
"name": "TestDifferentVendorMeiEvent",
"code": 4294050030,
"mfgCode": null,
"side": "server",
"included": 1
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5491,6 +5491,10 @@ internal cluster UnitTesting = 4294048773 {
fabric_idx fabricIndex = 254;
}

info event TestDifferentVendorMeiEvent = 4294050030 {
int8u arg1 = 1;
}

attribute boolean boolean = 0;
attribute Bitmap8MaskMap bitmap8 = 1;
attribute Bitmap16MaskMap bitmap16 = 2;
Expand Down Expand Up @@ -5573,6 +5577,7 @@ internal cluster UnitTesting = 4294048773 {
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute optional int8u writeOnlyInt8u = 16426;
attribute int8u meiInt8u = 4294070017;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -5768,6 +5773,15 @@ internal cluster UnitTesting = 4294048773 {
int8u fillCharacter = 2;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}

response struct TestDifferentVendorMeiResponse = 4294049979 {
int8u arg1 = 0;
int64u eventNumber = 1;
}

/** Simple command without any parameters and without a specific response.
To aid in unit testing, this command will re-initialize attribute storage to defaults. */
command Test(): DefaultSuccess = 0;
Expand Down Expand Up @@ -5838,6 +5852,8 @@ internal cluster UnitTesting = 4294048773 {
command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22;
/** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */
command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}

endpoint 0 {
Expand Down Expand Up @@ -6646,6 +6662,7 @@ endpoint 1 {
server cluster UnitTesting {
emits event TestEvent;
emits event TestFabricScopedEvent;
emits event TestDifferentVendorMeiEvent;
ram attribute boolean default = false;
ram attribute bitmap8 default = 0;
ram attribute bitmap16 default = 0;
Expand Down Expand Up @@ -6726,8 +6743,10 @@ endpoint 1 {
ram attribute nullableRangeRestrictedInt8s default = -20;
ram attribute nullableRangeRestrictedInt16u default = 200;
ram attribute nullableRangeRestrictedInt16s default = -100;
callback attribute writeOnlyInt8u default = 0;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
ram attribute meiInt8u default = 0;

handle command Test;
handle command TestSpecificResponse;
Expand Down Expand Up @@ -6755,6 +6774,10 @@ endpoint 1 {
handle command TestSimpleOptionalArgumentRequest;
handle command TestEmitTestEventRequest;
handle command TestEmitTestFabricScopedEventRequest;
handle command TestBatchHelperRequest;
handle command TestSecondBatchHelperRequest;
handle command TestDifferentVendorMeiRequest;
handle command TestDifferentVendorMeiResponse;
}
}
endpoint 2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9088,6 +9088,38 @@
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "TestBatchHelperRequest",
"code": 22,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "TestSecondBatchHelperRequest",
"code": 23,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "TestDifferentVendorMeiRequest",
"code": 4294049962,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "TestDifferentVendorMeiResponse",
"code": 4294049979,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
Expand Down Expand Up @@ -10371,6 +10403,38 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "write_only_int8u",
"code": 16426,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "MeiInt8u",
"code": 4294070017,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down Expand Up @@ -10418,6 +10482,13 @@
"mfgCode": null,
"side": "server",
"included": 1
},
{
"name": "TestDifferentVendorMeiEvent",
"code": 4294050030,
"mfgCode": null,
"side": "server",
"included": 1
}
]
}
Expand Down
22 changes: 22 additions & 0 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,27 @@ static bool SendBooleanResponse(CommandHandler * commandObj, const ConcreteComma
return true;
}

bool emberAfUnitTestingClusterTestDifferentVendorMeiRequestCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::TestDifferentVendorMeiRequest::DecodableType & commandData)
{
Commands::TestDifferentVendorMeiResponse::Type response;

{
Events::TestDifferentVendorMeiEvent::Type event{ commandData.arg1 };

if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, response.eventNumber))
{
commandObj->AddStatus(commandPath, Status::Failure);
return true;
}
}

response.arg1 = commandData.arg1;
commandObj->AddResponse(commandPath, response);
return true;
}

bool emberAfUnitTestingClusterTestStructArgumentRequestCallback(
app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::TestStructArgumentRequest::DecodableType & commandData)
Expand Down Expand Up @@ -833,6 +854,7 @@ bool emberAfUnitTestingClusterTestEmitTestEventRequestCallback(
commandObj->AddStatus(commandPath, Status::Failure);
return true;
}

commandObj->AddResponse(commandPath, responseData);
return true;
}
Expand Down
37 changes: 34 additions & 3 deletions src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,17 @@ tests:
h: 0.1,
}

- label: "Send MEI command in cluster"
command: "TestDifferentVendorMeiRequest"
arguments:
values:
- name: "arg1"
value: 76
response:
values:
- name: "arg1"
value: 76

# Tests for List

- label: "Send Test Command With List of INT8U and none of them is set to 0"
Expand Down Expand Up @@ -3850,7 +3861,19 @@ tests:
# here yet.
error: FAILURE

- label: "read AcceptedCommandList attribute"
- label: "Write different vendor MEI attribute"
command: "writeAttribute"
attribute: "mei_int8u"
arguments:
value: 201

- label: "Verify different vendor MEI attribute"
command: "readAttribute"
attribute: "mei_int8u"
response:
value: 201

- label: "Validate AcceptedCommandList attribute"
command: "readAttribute"
attribute: "AcceptedCommandList"
response:
Expand All @@ -3876,13 +3899,21 @@ tests:
21,
22,
23,
4294049962,
]

- label: "read GeneratedCommandList attribute"
- label: "Validate GeneratedCommandList attribute"
command: "readAttribute"
attribute: "GeneratedCommandList"
response:
value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12]
value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 4294049979]

- label: "Validate presence of MEI attribute"
command: "readAttribute"
attribute: "AttributeList"
response:
constraints:
contains: [4294070017]

# Struct-typed attribute
- label: "Write struct-typed attribute"
Expand Down
Loading

0 comments on commit 5430665

Please sign in to comment.