From 41ca72450907081e414e5ad32decaee0f8a78b5c Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 11 Jul 2022 09:10:52 -0400 Subject: [PATCH 1/5] Mark constraint error as the error to return on overly long values --- src/app/tests/suites/TestUserLabelClusterConstraints.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tests/suites/TestUserLabelClusterConstraints.yaml b/src/app/tests/suites/TestUserLabelClusterConstraints.yaml index 2072b91f8df64b..51d938583f1c06 100644 --- a/src/app/tests/suites/TestUserLabelClusterConstraints.yaml +++ b/src/app/tests/suites/TestUserLabelClusterConstraints.yaml @@ -40,7 +40,7 @@ tests: }, ] response: - error: FAILURE + error: CONSTRAINT_ERROR - label: "Attempt to write overly long item for value" command: "writeAttribute" @@ -54,4 +54,4 @@ tests: }, ] response: - error: FAILURE + error: CONSTRAINT_ERROR From a3e26d596071495dd48de218ca0773e44527f854 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 11 Jul 2022 09:30:40 -0400 Subject: [PATCH 2/5] Zap regen --- zzz_generated/chip-tool/zap-generated/test/Commands.h | 4 ++-- .../darwin-framework-tool/zap-generated/test/Commands.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 35dc4236d77909..e07ef01708f03c 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -51936,10 +51936,10 @@ class TestUserLabelClusterConstraintsSuite : public TestCommand shouldContinue = true; break; case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 57ab8802b38cdd..d8f42d26729669 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -89305,10 +89305,10 @@ class TestUserLabelClusterConstraints : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; } @@ -89356,7 +89356,7 @@ class TestUserLabelClusterConstraints : public TestCommandBridge { completionHandler:^(NSError * _Nullable err) { NSLog(@"Attempt to write overly long item for label Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); NextTest(); }]; @@ -89382,7 +89382,7 @@ class TestUserLabelClusterConstraints : public TestCommandBridge { completionHandler:^(NSError * _Nullable err) { NSLog(@"Attempt to write overly long item for value Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); NextTest(); }]; From 6a2c8573aa8ceee9a1afcbcedf2e525bf5ac3b23 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 11 Jul 2022 09:45:46 -0400 Subject: [PATCH 3/5] Fix return code --- src/app/clusters/user-label-server/user-label-server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/user-label-server/user-label-server.cpp b/src/app/clusters/user-label-server/user-label-server.cpp index f1e6f5d66ae9fc..8c09b782a06677 100644 --- a/src/app/clusters/user-label-server/user-label-server.cpp +++ b/src/app/clusters/user-label-server/user-label-server.cpp @@ -129,7 +129,7 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath & LabelList::TypeInfo::DecodableType decodablelist; ReturnErrorOnFailure(aDecoder.Decode(decodablelist)); - ReturnErrorCodeIf(!IsValidLabelEntryList(decodablelist), CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!IsValidLabelEntryList(decodablelist), CHIP_IM_GLOBAL_STATUS(ConstraintError)); auto iter = decodablelist.begin(); while (iter.Next()) @@ -146,7 +146,7 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath & Structs::LabelStruct::DecodableType entry; ReturnErrorOnFailure(aDecoder.Decode(entry)); - ReturnErrorCodeIf(!IsValidLabelEntry(entry), CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!IsValidLabelEntry(entry), CHIP_IM_GLOBAL_STATUS(ConstraintError)); return provider->AppendUserLabel(endpoint, entry); } From 0b00641277800973d39e53c08b6fa0a2702d7247 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 11 Jul 2022 15:10:30 -0400 Subject: [PATCH 4/5] Update TC-ULABEL-2.3 for using constraint_error --- src/app/tests/suites/certification/Test_TC_ULABEL_2_3.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_ULABEL_2_3.yaml b/src/app/tests/suites/certification/Test_TC_ULABEL_2_3.yaml index e2b32bad360cab..9321a7d0116a27 100644 --- a/src/app/tests/suites/certification/Test_TC_ULABEL_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_ULABEL_2_3.yaml @@ -44,7 +44,7 @@ tests: }, ] response: - error: FAILURE + error: CONSTRAINT_ERROR - label: "TH reads LabelList attribute of the DUT" PICS: ULABEL.S.A0000 @@ -59,4 +59,4 @@ tests: }, ] response: - error: FAILURE + error: CONSTRAINT_ERROR From 5d11ec041188b44127e88dae74c1eb271b09313a Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 11 Jul 2022 15:15:06 -0400 Subject: [PATCH 5/5] Zap regen --- zzz_generated/chip-tool/zap-generated/test/Commands.h | 4 ++-- .../darwin-framework-tool/zap-generated/test/Commands.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 8e87b96624d452..33be6bf3a2982b 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -32397,10 +32397,10 @@ class Test_TC_ULABEL_2_3Suite : public TestCommand shouldContinue = true; break; case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 8e3cf96a4f7734..f2d9432b3d215c 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -51268,10 +51268,10 @@ class Test_TC_ULABEL_2_3 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; } @@ -51319,7 +51319,7 @@ class Test_TC_ULABEL_2_3 : public TestCommandBridge { completionHandler:^(NSError * _Nullable err) { NSLog(@"TH writes LabelList attribute of the DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); NextTest(); }]; @@ -51345,7 +51345,7 @@ class Test_TC_ULABEL_2_3 : public TestCommandBridge { completionHandler:^(NSError * _Nullable err) { NSLog(@"TH reads LabelList attribute of the DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); NextTest(); }];