Skip to content

Commit

Permalink
Update TestListStructOctet to use member names that are generic (#19321)
Browse files Browse the repository at this point in the history
Update TestListStructOctet to use member names that are generic
  • Loading branch information
tehampson authored and pull[bot] committed Jun 27, 2023
1 parent ab3148b commit 1919081
Show file tree
Hide file tree
Showing 29 changed files with 166 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3084,8 +3084,8 @@ server cluster TestCluster = 4294048773 {
}

struct TestListStructOctet {
int64u fabricIndex = 0;
octet_string<32> operationalCert = 1;
int64u member1 = 0;
octet_string<32> member2 = 1;
}

struct NullablesAndOptionalsStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2554,8 +2554,8 @@ server cluster TestCluster = 4294048773 {
}

struct TestListStructOctet {
int64u fabricIndex = 0;
octet_string<32> operationalCert = 1;
int64u member1 = 0;
octet_string<32> member2 = 1;
}

struct NullablesAndOptionalsStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1897,8 +1897,8 @@ server cluster TestCluster = 4294048773 {
}

struct TestListStructOctet {
int64u fabricIndex = 0;
octet_string<32> operationalCert = 1;
int64u member1 = 0;
octet_string<32> member2 = 1;
}

info event TestEvent = 1 {
Expand Down
30 changes: 15 additions & 15 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ CHIP_ERROR TestAttrAccess::ReadListStructOctetStringAttribute(AttributeValueEnco
for (size_t index = 0; index < gListOperationalCertLen; index++)
{
Structs::TestListStructOctet::Type structOctet;
structOctet.fabricIndex = listStructOctetStringData[index].fabricIndex;
structOctet.operationalCert = listStructOctetStringData[index].operationalCert;
structOctet.member1 = listStructOctetStringData[index].member1;
structOctet.member2 = listStructOctetStringData[index].member2;
ReturnErrorOnFailure(encoder.Encode(structOctet));
}

Expand All @@ -409,12 +409,12 @@ CHIP_ERROR TestAttrAccess::WriteListStructOctetStringAttribute(const ConcreteDat
const auto & entry = iter.GetValue();

VerifyOrReturnError(index < kAttributeListLength, CHIP_ERROR_BUFFER_TOO_SMALL);
VerifyOrReturnError(entry.operationalCert.size() <= kAttributeEntryLength, CHIP_ERROR_BUFFER_TOO_SMALL);
memcpy(gListOperationalCert[index].Data(), entry.operationalCert.data(), entry.operationalCert.size());
gListOperationalCert[index].SetLength(entry.operationalCert.size());
VerifyOrReturnError(entry.member2.size() <= kAttributeEntryLength, CHIP_ERROR_BUFFER_TOO_SMALL);
memcpy(gListOperationalCert[index].Data(), entry.member2.data(), entry.member2.size());
gListOperationalCert[index].SetLength(entry.member2.size());

listStructOctetStringData[index].fabricIndex = entry.fabricIndex;
listStructOctetStringData[index].operationalCert = gListOperationalCert[index].AsSpan();
listStructOctetStringData[index].member1 = entry.member1;
listStructOctetStringData[index].member2 = gListOperationalCert[index].AsSpan();

index++;
}
Expand All @@ -435,12 +435,12 @@ CHIP_ERROR TestAttrAccess::WriteListStructOctetStringAttribute(const ConcreteDat
size_t index = gListOperationalCertLen;

VerifyOrReturnError(index < kAttributeListLength, CHIP_ERROR_BUFFER_TOO_SMALL);
VerifyOrReturnError(entry.operationalCert.size() <= kAttributeEntryLength, CHIP_ERROR_BUFFER_TOO_SMALL);
memcpy(gListOperationalCert[index].Data(), entry.operationalCert.data(), entry.operationalCert.size());
gListOperationalCert[index].SetLength(entry.operationalCert.size());
VerifyOrReturnError(entry.member2.size() <= kAttributeEntryLength, CHIP_ERROR_BUFFER_TOO_SMALL);
memcpy(gListOperationalCert[index].Data(), entry.member2.data(), entry.member2.size());
gListOperationalCert[index].SetLength(entry.member2.size());

listStructOctetStringData[index].fabricIndex = entry.fabricIndex;
listStructOctetStringData[index].operationalCert = gListOperationalCert[index].AsSpan();
listStructOctetStringData[index].member1 = entry.member1;
listStructOctetStringData[index].member2 = gListOperationalCert[index].AsSpan();

gListOperationalCertLen++;
return CHIP_NO_ERROR;
Expand Down Expand Up @@ -681,9 +681,9 @@ bool emberAfTestClusterClusterTestCallback(app::CommandHandler *, const app::Con
gListUint8Data[i] = 0;
gListOctetStringData[i].SetLength(0);
gListOperationalCert[i].SetLength(0);
listStructOctetStringData[i].fabricIndex = 0;
listStructOctetStringData[i].operationalCert = ByteSpan();
gSimpleEnums[i] = SimpleEnum::kUnspecified;
listStructOctetStringData[i].member1 = 0;
listStructOctetStringData[i].member2 = ByteSpan();
gSimpleEnums[i] = SimpleEnum::kUnspecified;
}
gSimpleEnumCount = 0;

Expand Down
6 changes: 3 additions & 3 deletions src/app/tests/TestBufferedReadCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void DataSeriesValidator::OnAttributeData(const ConcreteDataAttributePath & aPat
while (iter.Next() && index < expectedListLength)
{
auto & iterValue = iter.GetValue();
NL_TEST_ASSERT(gSuite, iterValue.fabricIndex == (index));
NL_TEST_ASSERT(gSuite, iterValue.member1 == (index));
index++;
}

Expand Down Expand Up @@ -353,7 +353,7 @@ void DataSeriesGenerator::Generate()
uint8_t index2 = 0;
for (auto & item : listData)
{
item.fabricIndex = index2;
item.member1 = index2;
index2++;
}

Expand Down Expand Up @@ -446,7 +446,7 @@ void DataSeriesGenerator::Generate()
path.mAttributeId = Clusters::TestCluster::Attributes::ListStructOctetString::Id;
path.mListOp = ConcreteDataAttributePath::ListOperation::AppendItem;

listItem.fabricIndex = (uint64_t) i;
listItem.member1 = (uint64_t) i;

NL_TEST_ASSERT(gSuite, DataModel::Encode(writer, TLV::AnonymousTag(), listItem) == CHIP_NO_ERROR);

Expand Down
6 changes: 3 additions & 3 deletions src/app/tests/TestClusterStateCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void DataSeriesGenerator::Generate(ForwardedDataCallbackValidator & dataCallback

for (auto & i : buf)
{
i.fabricIndex = instruction.mInstructionId;
i.member1 = instruction.mInstructionId;
}

Clusters::TestCluster::Attributes::ListStructOctetString::TypeInfo::Type value;
Expand Down Expand Up @@ -384,7 +384,7 @@ class CacheValidator : public ClusterStateCache::Callback
auto listIter = v.begin();
while (listIter.Next())
{
NL_TEST_ASSERT(gSuite, listIter.GetValue().fabricIndex == instruction.mInstructionId);
NL_TEST_ASSERT(gSuite, listIter.GetValue().member1 == instruction.mInstructionId);
}

NL_TEST_ASSERT(gSuite, listIter.GetStatus() == CHIP_NO_ERROR);
Expand Down Expand Up @@ -438,7 +438,7 @@ class CacheValidator : public ClusterStateCache::Callback
auto listIter = clusterValue.listStructOctetString.begin();
while (listIter.Next())
{
NL_TEST_ASSERT(gSuite, listIter.GetValue().fabricIndex == instruction.mInstructionId);
NL_TEST_ASSERT(gSuite, listIter.GetValue().member1 == instruction.mInstructionId);
}

NL_TEST_ASSERT(gSuite, listIter.GetStatus() == CHIP_NO_ERROR);
Expand Down
16 changes: 8 additions & 8 deletions src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1562,10 +1562,10 @@ tests:
arguments:
value:
[
{ fabricIndex: 0, operationalCert: "Test0" },
{ fabricIndex: 1, operationalCert: "Test1" },
{ fabricIndex: 2, operationalCert: "Test2" },
{ fabricIndex: 3, operationalCert: "Test3" },
{ member1: 0, member2: "Test0" },
{ member1: 1, member2: "Test1" },
{ member1: 2, member2: "Test2" },
{ member1: 3, member2: "Test3" },
]

- label: "Read attribute LIST With List of LIST_STRUCT_OCTET_STRING"
Expand All @@ -1574,10 +1574,10 @@ tests:
response:
value:
[
{ fabricIndex: 0, operationalCert: "Test0" },
{ fabricIndex: 1, operationalCert: "Test1" },
{ fabricIndex: 2, operationalCert: "Test2" },
{ fabricIndex: 3, operationalCert: "Test3" },
{ member1: 0, member2: "Test0" },
{ member1: 1, member2: "Test1" },
{ member1: 2, member2: "Test2" },
{ member1: 3, member2: "Test3" },
]

# Tests for Nullables and Optionals
Expand Down
4 changes: 2 additions & 2 deletions src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ limitations under the License.
<domain name="CHIP"/>
<struct name="TestListStructOctet">
<cluster code="0xFFF1FC05"/>
<item name="fabricIndex" type="INT64U"/>
<item name="operationalCert" type="OCTET_STRING" length="32"/>
<item name="member1" type="INT64U"/>
<item name="member2" type="OCTET_STRING" length="32"/>
</struct>

<struct name="TestFabricScoped">
Expand Down
4 changes: 2 additions & 2 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3518,8 +3518,8 @@ client cluster TestCluster = 4294048773 {
}

struct TestListStructOctet {
int64u fabricIndex = 0;
octet_string<32> operationalCert = 1;
int64u member1 = 0;
octet_string<32> member2 = 1;
}

struct NullablesAndOptionalsStruct {
Expand Down
28 changes: 13 additions & 15 deletions src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions src/controller/java/zap-generated/CHIPClustersWrite-JNI.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions src/controller/java/zap-generated/CHIPReadCallbacks.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/controller/tests/data_model/TestRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescr
uint8_t i = 0;
for (auto & item : valueBuf)
{
item.fabricIndex = i;
item.member1 = i;
i++;
}

Expand Down Expand Up @@ -328,7 +328,7 @@ void TestReadInteraction::TestReadAttributeResponse(nlTestSuite * apSuite, void
while (iter.Next())
{
auto & item = iter.GetValue();
NL_TEST_ASSERT(apSuite, item.fabricIndex == i);
NL_TEST_ASSERT(apSuite, item.member1 == i);
i++;
}
NL_TEST_ASSERT(apSuite, i == 4);
Expand Down
Loading

0 comments on commit 1919081

Please sign in to comment.