Skip to content

Commit

Permalink
Refactored yaml tests for Test_TC_S_2_1..4 (#26459)
Browse files Browse the repository at this point in the history
* Resolving conflicts to rebase onto master

* Reverted files creating problems

* Added manual configuration options for AC and now getting the capacity from the maximum number of scenes on DUT.

* Reverted or condition on StoreScene test allowing INSUFFICIENT SPACE, not currently allowing it. Added check on RecallScene return where expected, updated 2_3 and 2_4 to hybrid between automated and manual per app tests

* Restyled by whitespace

* Restyled by prettier-yaml

* Added anyOf to check wether 0x00 or 0x89 was returned for store scenes commands where it was accepted

* Restyled by whitespace

* Restyled by prettier-yaml

* Reverted runIf, anyOf and UnsignedNumberEquals commands for now until the new test backend is implemented.

* Resolved conflicts for : Modified AttribueValue in Scenes::AttributeValuePair to now be a uint32_t according to upcoming spec change

* Restyled by prettier-yaml

* Refactored tests and SceneTable default handlers to the uint32_t type for the AttributePairValue

* Regenerated zap files for all-cluster apps

* Regenerated zap files for chip-tool

* Applied corrections to 2_4 to follo test plan

* Restyled by whitespace

* Restyled by prettier-yaml

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <[email protected]>

* Added missing checks, modified wrong description to match test plan

* Restyled by whitespace

* Restyled by prettier-yaml

* Regenerated after rebase

* Added variable for G1 in Test_TC_s_2_3, changed GroupKeySecurityPolocy to 0 in 2.2 and 2.3 and removed Scene 0x03 from firt scene membership response in 2.3

* Applied restyler

* Restyled by prettier-yaml

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Jan 8, 2024
1 parent ceb82c0 commit 7474613
Show file tree
Hide file tree
Showing 48 changed files with 5,107 additions and 525 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ server cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand All @@ -151,6 +151,9 @@ server cluster Scenes = 5 {
readonly attribute group_id currentGroup = 2;
readonly attribute boolean sceneValid = 3;
readonly attribute bitmap8 nameSupport = 4;
readonly attribute nullable node_id lastConfiguredBy = 5;
readonly attribute int16u sceneTableSize = 6;
readonly attribute int8u remainingCapacity = 7;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -5048,6 +5051,9 @@ endpoint 1 {
ram attribute currentGroup default = 0x0000;
ram attribute sceneValid default = 0x00;
ram attribute nameSupport;
ram attribute lastConfiguredBy;
ram attribute sceneTableSize;
ram attribute remainingCapacity;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;
}
Expand Down
48 changes: 48 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 @@ -9532,6 +9532,54 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "LastConfiguredBy",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "node_id",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SceneTableSize",
"code": 6,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "RemainingCapacity",
"code": 7,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ server cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand All @@ -145,6 +145,9 @@ server cluster Scenes = 5 {
readonly attribute group_id currentGroup = 2;
readonly attribute boolean sceneValid = 3;
readonly attribute bitmap8 nameSupport = 4;
readonly attribute nullable node_id lastConfiguredBy = 5;
readonly attribute int16u sceneTableSize = 6;
readonly attribute int8u remainingCapacity = 7;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -4171,6 +4174,9 @@ endpoint 1 {
ram attribute currentGroup default = 0x0000;
ram attribute sceneValid default = 0x00;
ram attribute nameSupport;
ram attribute lastConfiguredBy;
ram attribute sceneTableSize;
ram attribute remainingCapacity;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 4;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9003,6 +9003,54 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "LastConfiguredBy",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "node_id",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SceneTableSize",
"code": 6,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "RemainingCapacity",
"code": 7,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ client cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand All @@ -200,6 +200,8 @@ client cluster Scenes = 5 {
readonly attribute boolean sceneValid = 3;
readonly attribute bitmap8 nameSupport = 4;
readonly attribute optional nullable node_id lastConfiguredBy = 5;
readonly attribute int16u sceneTableSize = 6;
readonly attribute int8u remainingCapacity = 7;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down
2 changes: 1 addition & 1 deletion examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ server cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand Down
2 changes: 1 addition & 1 deletion examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ server cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand Down
2 changes: 1 addition & 1 deletion examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ server cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand Down
2 changes: 1 addition & 1 deletion examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ server cluster Scenes = 5 {

struct AttributeValuePair {
optional attrib_id attributeID = 0;
int8u attributeValue[] = 1;
int32u attributeValue = 1;
}

struct ExtensionFieldSet {
Expand Down
44 changes: 6 additions & 38 deletions src/app/clusters/scenes/SceneTableImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,9 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler
auto pair_iterator = extensionFieldSet.attributeValueList.begin();
while (pair_iterator.Next())
{
aVPair = pair_iterator.GetValue();
mAVPairs[pairCount].attributeID = aVPair.attributeID;
size_t valueBytesTotal = 0;
uint8_t valueBytesCount = 0;

ReturnErrorOnFailure(aVPair.attributeValue.ComputeSize(&valueBytesTotal));
VerifyOrReturnError(valueBytesTotal <= ArraySize(mValueBuffer[0]), CHIP_ERROR_BUFFER_TOO_SMALL);

auto value_iterator = aVPair.attributeValue.begin();
while (value_iterator.Next())
{
mValueBuffer[pairCount][valueBytesCount] = value_iterator.GetValue();
valueBytesCount++;
}
ReturnErrorOnFailure(value_iterator.GetStatus());

mAVPairs[pairCount].attributeValue = mValueBuffer[pairCount];
mAVPairs[pairCount].attributeValue.reduce_size(valueBytesCount);
aVPair = pair_iterator.GetValue();
mAVPairs[pairCount].attributeID = aVPair.attributeID;
mAVPairs[pairCount].attributeValue = aVPair.attributeValue;
pairCount++;
}
ReturnErrorOnFailure(pair_iterator.GetStatus());
Expand Down Expand Up @@ -132,25 +117,9 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler
auto pair_iterator = attributeValueList.begin();
while (pair_iterator.Next())
{
decodePair = pair_iterator.GetValue();
mAVPairs[pairCount].attributeID = decodePair.attributeID;
size_t valueBytesTotal = 0;
uint8_t valueBytesCount = 0;

// Verify size of attribute value
ReturnErrorOnFailure(decodePair.attributeValue.ComputeSize(&valueBytesTotal));
VerifyOrReturnError(valueBytesTotal <= ArraySize(mValueBuffer[0]), CHIP_ERROR_BUFFER_TOO_SMALL);

auto value_iterator = decodePair.attributeValue.begin();
while (value_iterator.Next())
{
mValueBuffer[pairCount][valueBytesCount] = value_iterator.GetValue();
valueBytesCount++;
}
ReturnErrorOnFailure(value_iterator.GetStatus());

mAVPairs[pairCount].attributeValue = mValueBuffer[pairCount];
mAVPairs[pairCount].attributeValue.reduce_size(valueBytesCount);
decodePair = pair_iterator.GetValue();
mAVPairs[pairCount].attributeID = decodePair.attributeID;
mAVPairs[pairCount].attributeValue = decodePair.attributeValue;
pairCount++;
};
ReturnErrorOnFailure(pair_iterator.GetStatus());
Expand All @@ -164,7 +133,6 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler

private:
app::Clusters::Scenes::Structs::AttributeValuePair::Type mAVPairs[kMaxAvPair];
uint8_t mValueBuffer[kMaxAvPair][kMaxValueSize];
};

/**
Expand Down
50 changes: 4 additions & 46 deletions src/app/tests/TestSceneTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,23 +466,20 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
TLV::TLVType outer;
TLV::TLVType outerRead;

static const uint8_t OO_av_payload[1] = { 0x01 };
static const uint8_t LC_av_payload[2][2] = { { 0x40, 0x00 }, { 0x01, 0xF0 } };
static const uint8_t CC_av_payload[8][2] = { { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 },
{ 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 } };
static const uint8_t OO_av_payload = 0x01;
static const uint16_t LC_av_payload[2] = { 0x64, 0x01F0 };
static const uint16_t CC_av_payload[8] = { 0 };

OOPairs[0].attributeID.SetValue(kOnOffAttId);
OOPairs[0].attributeValue = OO_av_payload;

LCPairs[0].attributeID.SetValue(kCurrentLevelId);
LCPairs[0].attributeValue = LC_av_payload[0];
LCPairs[0].attributeValue.reduce_size(1);
LCPairs[1].attributeID.SetValue(kCurrentFrequencyId);
LCPairs[1].attributeValue = LC_av_payload[1];

CCPairs[0].attributeID.SetValue(kCurrentSaturationId);
CCPairs[0].attributeValue = CC_av_payload[0];
CCPairs[0].attributeValue.reduce_size(1);
CCPairs[1].attributeID.SetValue(kCurrentXId);
CCPairs[1].attributeValue = CC_av_payload[1];
CCPairs[2].attributeID.SetValue(kCurrentYId);
Expand All @@ -493,10 +490,8 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
CCPairs[4].attributeValue = CC_av_payload[4];
CCPairs[5].attributeID.SetValue(kColorLoopActiveId);
CCPairs[5].attributeValue = CC_av_payload[5];
CCPairs[5].attributeValue.reduce_size(1);
CCPairs[6].attributeID.SetValue(kColorLoopDirectionId);
CCPairs[6].attributeValue = CC_av_payload[6];
CCPairs[6].attributeValue.reduce_size(1);
CCPairs[7].attributeID.SetValue(kColorLoopTimeId);
CCPairs[7].attributeValue = CC_av_payload[7];

Expand Down Expand Up @@ -658,21 +653,17 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)
app::Clusters::Scenes::Structs::ExtensionFieldSet::Type extensionFieldFailTestOut;
app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType extensionFieldFailTestIn;
app::Clusters::Scenes::Structs::AttributeValuePair::Type TooManyPairs[16];
app::Clusters::Scenes::Structs::AttributeValuePair::Type TooManyBytesPairs[1];

TLV::TLVType failWrite;
TLV::TLVType failRead;

uint8_t payloadOk[1] = { 0 };
uint8_t payloadTooBig[5] = { 0 };
uint8_t payloadOk = 0;

for (uint8_t i = 0; i < 16; i++)
{
TooManyPairs[i].attributeValue = payloadOk;
}

TooManyBytesPairs[0].attributeValue = payloadTooBig;

extensionFieldFailTestOut.clusterID = kColorControlClusterId;
extensionFieldFailTestOut.attributeValueList = TooManyPairs;

Expand Down Expand Up @@ -708,39 +699,6 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext)

memset(failBuffer, 0, fail_list.size());
memset(buffer, 0, buff_span.size());

extensionFieldFailTestOut.clusterID = kColorControlClusterId;
extensionFieldFailTestOut.attributeValueList = TooManyBytesPairs;

// Serialize Extension Field sets as if they were recovered from memory
writer.Init(failBuffer);
writer.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Structure, failWrite);
NL_TEST_ASSERT(aSuite,
CHIP_NO_ERROR ==
app::DataModel::Encode(writer,
TLV::ContextTag(to_underlying(
app::Clusters::Scenes::Structs::ExtensionFieldSet::Fields::kAttributeValueList)),
extensionFieldFailTestOut.attributeValueList));
writer.EndContainer(failWrite);

// Setup the On Off Extension field set in the expected state from a command
reader.Init(fail_list);
extensionFieldFailTestIn.clusterID = kColorControlClusterId;
NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.EnterContainer(failRead));
NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.Next());
NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == extensionFieldFailTestIn.attributeValueList.Decode(reader));
NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == reader.ExitContainer(failRead));

// Verify failure on both serialize and deserialize
NL_TEST_ASSERT(aSuite,
CHIP_ERROR_BUFFER_TOO_SMALL == sHandler.SerializeAdd(kTestEndpoint1, extensionFieldFailTestIn, buff_span));
NL_TEST_ASSERT(aSuite,
CHIP_ERROR_BUFFER_TOO_SMALL ==
sHandler.Deserialize(kTestEndpoint1, kColorControlClusterId, fail_list, extensionFieldFailTestOut));

memset(failBuffer, 0, fail_list.size());
memset(buffer, 0, buff_span.size());
};

void TestStoreScenes(nlTestSuite * aSuite, void * aContext)
Expand Down
Loading

0 comments on commit 7474613

Please sign in to comment.