Skip to content

Commit 1089212

Browse files
cecillepull[bot]
authored andcommitted
TC-IDM-5.2: Fix status code in test and SDK (#33952)
* TC-IDM-5.2: Fix status code in test and SDK Please see: #33936 * Fix unit tests We have unit tests! They didn't match the spec, but they exist! One for two is still better than 0 for 2. * Fix unit test * Fix error on write request with incorrect timed request flag Please see #33952 (comment) This was changed in the spec, but not in the SDK or unit tests. The unit test here covers this, but we should consider adding it to the cert testing as well. Please see https://github.com/CHIP-Specifications/chip-test-plans/issues/4256 * fix write in test as well
1 parent 2ab5013 commit 1089212

6 files changed

+37
-48
lines changed

src/app/TimedHandler.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ CHIP_ERROR TimedHandler::OnMessageReceived(Messaging::ExchangeContext * aExchang
6666
ChipLogValueX64(now.count()), this, ChipLogValueExchange(aExchangeContext));
6767
if (now > mTimeLimit)
6868
{
69-
// Time is up. Spec says to send UNSUPPORTED_ACCESS.
7069
ChipLogError(DataManagement, "Timeout expired: handler %p exchange " ChipLogFormatExchange, this,
7170
ChipLogValueExchange(aExchangeContext));
72-
return StatusResponse::Send(Status::UnsupportedAccess, aExchangeContext, /* aExpectResponse = */ false);
71+
return StatusResponse::Send(Status::Timeout, aExchangeContext, /* aExpectResponse = */ false);
7372
}
7473

7574
if (aPayloadHeader.HasMessageType(MsgType::InvokeCommandRequest))

src/app/WriteHandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ Status WriteHandler::ProcessWriteRequest(System::PacketBufferHandle && aPayload,
587587
if (mIsTimedRequest != aIsTimedWrite)
588588
{
589589
// The message thinks it should be part of a timed interaction but it's
590-
// not, or vice versa. Spec says to Respond with UNSUPPORTED_ACCESS.
591-
status = Status::UnsupportedAccess;
590+
// not, or vice versa.
591+
status = Status::TimedRequestMismatch;
592592
goto exit;
593593
}
594594

src/app/tests/TestTimedHandler.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void TestTimedHandler::TestFollowingMessageFastEnough(MsgType aMsgType)
139139
EXPECT_EQ(delegate.mError, CHIP_NO_ERROR);
140140

141141
// Send an empty payload, which will error out but not with the
142-
// UNSUPPORTED_ACCESS status we expect if we miss our timeout.
142+
// TIMEOUT status we expect if we miss our timeout.
143143
payload = MessagePacketBuffer::New(0);
144144
ASSERT_FALSE(payload.IsNull());
145145

@@ -151,7 +151,7 @@ void TestTimedHandler::TestFollowingMessageFastEnough(MsgType aMsgType)
151151
mpTestContext->DrainAndServiceIO();
152152
EXPECT_TRUE(delegate.mNewMessageReceived);
153153
EXPECT_TRUE(delegate.mLastMessageWasStatus);
154-
EXPECT_NE(StatusIB(delegate.mError).mStatus, Status::UnsupportedAccess);
154+
EXPECT_NE(StatusIB(delegate.mError).mStatus, Status::Timeout);
155155
}
156156

157157
TEST_F(TestTimedHandler, TestInvokeFastEnough)
@@ -189,7 +189,7 @@ void TestTimedHandler::TestFollowingMessageTooSlow(MsgType aMsgType)
189189
chip::test_utils::SleepMillis(75);
190190

191191
// Send an empty payload, which will error out but not with the
192-
// UNSUPPORTED_ACCESS status we expect if we miss our timeout.
192+
// TIMEOUT status we expect if we miss our timeout.
193193
payload = MessagePacketBuffer::New(0);
194194
EXPECT_FALSE(payload.IsNull());
195195

@@ -201,7 +201,7 @@ void TestTimedHandler::TestFollowingMessageTooSlow(MsgType aMsgType)
201201
mpTestContext->DrainAndServiceIO();
202202
EXPECT_TRUE(delegate.mNewMessageReceived);
203203
EXPECT_TRUE(delegate.mLastMessageWasStatus);
204-
EXPECT_EQ(StatusIB(delegate.mError).mStatus, Status::UnsupportedAccess);
204+
EXPECT_EQ(StatusIB(delegate.mError).mStatus, Status::Timeout);
205205
}
206206

207207
TEST_F(TestTimedHandler, TestInvokeTooSlow)

src/app/tests/TestWriteInteraction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ TEST_F(TestWriteInteraction, TestWriteHandler)
328328
}
329329
else
330330
{
331-
EXPECT_EQ(status, Status::UnsupportedAccess);
331+
EXPECT_EQ(status, Status::TimedRequestMismatch);
332332
}
333333

334334
mpTestContext->DrainAndServiceIO();

src/app/tests/suites/TestClusterComplexTypes.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tests:
7070
# expires.
7171
busyWaitMs: 100
7272
response:
73-
error: UNSUPPORTED_ACCESS
73+
error: TIMEOUT
7474

7575
- label:
7676
"Send command that does not need timed invoke with a long timeout
@@ -88,7 +88,7 @@ tests:
8888
# expires.
8989
busyWaitMs: 100
9090
response:
91-
error: UNSUPPORTED_ACCESS
91+
error: TIMEOUT
9292

9393
# The timed write tests are not in TestCluster.yaml for now because Darwin
9494
# SDK APIs have not been updated to do timed invoke properly yet.
@@ -125,7 +125,7 @@ tests:
125125
# expires.
126126
busyWaitMs: 100
127127
response:
128-
error: UNSUPPORTED_ACCESS
128+
error: TIMEOUT
129129

130130
- label: "Read attribute that needs timed write state unchanged 2"
131131
command: "readAttribute"
@@ -173,7 +173,7 @@ tests:
173173
# expires.
174174
busyWaitMs: 100
175175
response:
176-
error: UNSUPPORTED_ACCESS
176+
error: TIMEOUT
177177

178178
- label: "Read attribute that does not need timed write unchanged value"
179179
command: "readAttribute"

src/app/tests/suites/certification/Test_TC_IDM_5_2.yaml

+25-35
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,19 @@ tests:
9494
verification: |
9595
./chip-tool onoff on 1 1 --repeat-delay-ms 5000 --timedInteractionTimeoutMs 200
9696
97-
On TH(chip-tool), Verify we are getting status response and UNSUPPORTED_ACCESS from DUT to TH for above command
98-
99-
[1649686333.696111][3252:3257] CHIP:DMG: StatusResponseMessage =
100-
[1649686333.696178][3252:3257] CHIP:DMG: {
101-
[1649686333.696236][3252:3257] CHIP:DMG: Status = 0x0,
102-
[1649686333.696311][3252:3257] CHIP:DMG: InteractionModelRevision = 1
103-
[1649686333.696375][3252:3257] CHIP:DMG: }
104-
[1649686333.696434][3252:3257] CHIP:IM: Received status response, status is 0x00 (SUCCESS)
105-
[1649686333.696513][3252:3257] CHIP:EM: Piggybacking Ack for MessageCounter:3570360 on exchange: 28108i
106-
[1649686333.696626][3252:3257] CHIP:IN: Prepared secure message 0xaaaae019e098 to 0x0000000000000001 (1) of type 0x8 and protocolId (0, 1) on exchange 28108i with MessageCounter:6840786.
107-
[1649686333.696711][3252:3257] CHIP:IN: Sending encrypted msg 0xaaaae019e098 with MessageCounter:6840786 to 0x0000000000000001 (1) at monotonic time: 0000000000CE3312 msec
108-
[1649686333.696989][3252:3257] CHIP:DMG: ICR moving to [CommandSen]
109-
[1649686333.698938][3252:3257] CHIP:EM: Received message of type 0x1 with protocolId (0, 1) and MessageCounter:3570361 on exchange 28108i
110-
[1649686333.699013][3252:3257] CHIP:EM: Found matching exchange: 28108i, Delegate: 0xffff68005c30
111-
[1649686333.699089][3252:3257] CHIP:EM: Rxd Ack; Removing MessageCounter:6840786 from Retrans Table on exchange 28108i
112-
[1649686333.699147][3252:3257] CHIP:EM: Removed CHIP MessageCounter:6840786 from RetransTable on exchange 28108i
113-
[1649686333.699215][3252:3257] CHIP:DMG: ICR moving to [ResponseRe]
114-
[1649686333.699294][3252:3257] CHIP:DMG: StatusResponseMessage =
115-
[1649686333.699354][3252:3257] CHIP:DMG: {
116-
[1649686333.699410][3252:3257] CHIP:DMG: Status = 0x7e,
117-
[1649686333.699471][3252:3257] CHIP:DMG: InteractionModelRevision = 1
118-
[1649686333.699528][3252:3257] CHIP:DMG: }
119-
[1649686333.699585][3252:3257] CHIP:IM: Received status response, status is 0x7e (UNSUPPORTED_ACCESS)
120-
[1649686333.699661][3252:3257] CHIP:TOO: Error: IM Error 0x0000057E: General error: 0x7e (UNSUPPORTED_ACCESS)
97+
If the device being certified is Matter release 1.4 or later, verify DUT sends back a Status response with the TIMEOUT status code.
98+
If the device being certified is Matter release 1.3 or earlier, verify the DUT sends back a Status response with either TIMEOUT or UNSUPPORTED_ACCESS status code.
99+
100+
[1718641649.158222][1587554:1587556] CHIP:EM: Rxd Ack; Removing MessageCounter:70404585 from Retrans Table on exchange 44026i
101+
[1718641649.158241][1587554:1587556] CHIP:DMG: ICR moving to [ResponseRe]
102+
[1718641649.158261][1587554:1587556] CHIP:DMG: StatusResponseMessage =
103+
[1718641649.158276][1587554:1587556] CHIP:DMG: {
104+
[1718641649.158290][1587554:1587556] CHIP:DMG: Status = 0x94 (TIMEOUT),
105+
[1718641649.158304][1587554:1587556] CHIP:DMG: InteractionModelRevision = 11
106+
[1718641649.158318][1587554:1587556] CHIP:DMG: }
107+
[1718641649.158332][1587554:1587556] CHIP:IM: Received status response, status is 0x94 (TIMEOUT)
108+
[1718641649.158355][1587554:1587556] CHIP:TOO: Error: IM Error 0x00000594: General error: 0x94 (TIMEOUT)
109+
121110
disabled: true
122111

123112
- label:
@@ -128,15 +117,16 @@ tests:
128117
verification: |
129118
./chip-tool modeselect write on-mode 0 1 1 --repeat-delay-ms 1000 --timedInteractionTimeoutMs 500
130119
131-
On TH(chip-tool), Verify we are getting status response and UNSUPPORTED_ACCESS from DUT to TH for above command
132-
133-
[1654771611.106067][28715:28720] CHIP:DMG: WriteClient moving to [ResponseRe]
134-
[1654771611.106112][28715:28720] CHIP:DMG: StatusResponseMessage =
135-
[1654771611.106140][28715:28720] CHIP:DMG: {
136-
[1654771611.106165][28715:28720] CHIP:DMG: Status = 0x7e (UNSUPPORTED_ACCESS),
137-
[1654771611.106192][28715:28720] CHIP:DMG: InteractionModelRevision = 1
138-
[1654771611.106216][28715:28720] CHIP:DMG: }
139-
[1654771611.106244][28715:28720] CHIP:IM: Received status response, status is 0x7e (UNSUPPORTED_ACCESS)
140-
[1654771611.106280][28715:28720] CHIP:TOO: Error: IM Error 0x0000057E: General error: 0x7e (UNSUPPORTED_ACCESS)
141-
[1654771611.106303][28715:28720] CHIP:DMG: WriteClient moving to [AwaitingDe]
120+
If the device being certified is Matter release 1.4 or later, verify DUT sends back a Status response with the TIMEOUT status code.
121+
If the device being certified is Matter release 1.3 or earlier, verify the DUT sends back a Status response with either TIMEOUT or UNSUPPORTED_ACCESS status code.
122+
123+
[1720104134.620521][3325282:3325284] CHIP:DMG: WriteClient moving to [ResponseRe]
124+
[1720104134.620540][3325282:3325284] CHIP:DMG: StatusResponseMessage =
125+
[1720104134.620555][3325282:3325284] CHIP:DMG: {
126+
[1720104134.620569][3325282:3325284] CHIP:DMG: Status = 0x94 (TIMEOUT),
127+
[1720104134.620583][3325282:3325284] CHIP:DMG: InteractionModelRevision = 11
128+
[1720104134.620596][3325282:3325284] CHIP:DMG: }
129+
[1720104134.620611][3325282:3325284] CHIP:IM: Received status response, status is 0x94 (TIMEOUT)
130+
[1720104134.620689][3325282:3325284] CHIP:TOO: Error: IM Error 0x00000594: General error: 0x94 (TIMEOUT)
131+
142132
disabled: true

0 commit comments

Comments
 (0)