Skip to content

Commit 78567b7

Browse files
pidarpedgemini-code-assist[bot]Copilot
authored
Update/Fix AVSM test scripts (#40706)
* Update/Fix AVSM test scripts based on Test plan changes in CHIP-Specifications/chip-test-plans#5453 - This does not include the new test case 2.16 which shall be a separate PR. * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]>
1 parent f1631b6 commit 78567b7

File tree

5 files changed

+184
-24
lines changed

5 files changed

+184
-24
lines changed

src/python_testing/TC_AVSM_2_11.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,16 @@ def steps_TC_AVSM_2_11(self) -> list[TestStep]:
9595
),
9696
TestStep(
9797
8,
98+
"TH reads StreamUsagePriorities attribute from CameraAVStreamManagement Cluster on DUT.",
99+
"Verify the list is the same as set in StreamPriorities in step 7.",
100+
),
101+
TestStep(
102+
9,
98103
"TH sends the SetStreamPriorities command with StreamPriorities containing a StreamUsage not in aSupportedStreamUsages.",
99104
"DUT responds with a DYNAMIC_CONSTRAINT_ERROR status code.",
100105
),
101106
TestStep(
102-
9,
107+
10,
103108
"TH sends the SetStreamPriorities command with StreamPriorities containing duplicate StreamUsage values from aSupportedStreamUsages.",
104109
"DUT responds with a ALREADY_EXISTS status code.",
105110
),
@@ -169,14 +174,23 @@ async def test_TC_AVSM_2_11(self):
169174

170175
self.step(7)
171176
try:
177+
aStreamUsagePriorities = aSupportedStreamUsages[0:1]
172178
await self.send_single_cmd(
173-
endpoint=endpoint, cmd=commands.SetStreamPriorities(streamPriorities=(aSupportedStreamUsages))
179+
endpoint=endpoint, cmd=commands.SetStreamPriorities(streamPriorities=(aStreamUsagePriorities))
174180
)
175181
except InteractionModelError as e:
176182
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
177183
pass
178184

179185
self.step(8)
186+
readStreamUsagePriorities = await self.read_single_attribute_check_success(
187+
endpoint=endpoint, cluster=cluster, attribute=attr.StreamUsagePriorities
188+
)
189+
logger.info(f"Rx'd StreamUsagePriorities: {readStreamUsagePriorities}")
190+
asserts.assert_equal(readStreamUsagePriorities, aStreamUsagePriorities,
191+
"The read StreamUsagePriorities is different from the one set in SetStreamPriorities")
192+
193+
self.step(9)
180194
try:
181195
notSupportedStreamUsage = next(
182196
(e for e in Globals.Enums.StreamUsageEnum if e not in aSupportedStreamUsages and e != Globals.Enums.StreamUsageEnum.kInternal), None)
@@ -194,7 +208,7 @@ async def test_TC_AVSM_2_11(self):
194208
)
195209
pass
196210

197-
self.step(9)
211+
self.step(10)
198212
try:
199213
await self.send_single_cmd(
200214
endpoint=endpoint,

src/python_testing/TC_AVSM_2_3.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ def steps_TC_AVSM_2_3(self) -> list[TestStep]:
7474
),
7575
TestStep(
7676
4,
77+
"TH sends the SnapshotStreamModify command with SnapshotStreamID set to aStreamID + 1.",
78+
"DUT responds with an NOT_FOUND status code.",
79+
),
80+
TestStep(
81+
5,
7782
"TH sends the SnapshotStreamModify command with SnapshotStreamID set to aStreamID. If WMARK is supported, set WaterMarkEnabled to !aWmark`and if OSD is supported, set OSDEnabled to `!aOSD in the command.",
7883
"DUT responds with a SUCCESS status code.",
7984
),
8085
TestStep(
81-
5,
86+
6,
8287
"TH reads AllocatedSnapshotStreams attribute from CameraAVStreamManagement Cluster on DUT",
8388
"Verify the following: If WMARK is supported, verify WaterMarkEnabled == !aWmark. If OSD is supported, verify OSDEnabled == !aOSD.",
8489
),
@@ -137,6 +142,19 @@ async def test_TC_AVSM_2_3(self):
137142
pass
138143

139144
self.step(4)
145+
try:
146+
cmd = commands.SnapshotStreamModify(
147+
snapshotStreamID=aStreamID + 1,
148+
watermarkEnabled=None if aWmark is None else not aWmark,
149+
OSDEnabled=None if aOSD is None else not aOSD,
150+
)
151+
await self.send_single_cmd(endpoint=endpoint, cmd=cmd)
152+
asserts.fail("Unexpected success when expecting NOT_FOUND due to wrong streamID")
153+
except InteractionModelError as e:
154+
asserts.assert_equal(e.status, Status.NotFound, "Unexpected error when expecting NOT_FOUND")
155+
pass
156+
157+
self.step(5)
140158
try:
141159
cmd = commands.SnapshotStreamModify(
142160
snapshotStreamID=aStreamID,
@@ -148,7 +166,7 @@ async def test_TC_AVSM_2_3(self):
148166
asserts.assert_equal(e.status, Status.Success, "Unexpected error returned")
149167
pass
150168

151-
self.step(5)
169+
self.step(6)
152170
aAllocatedSnapshotStreams = await self.read_single_attribute_check_success(
153171
endpoint=endpoint, cluster=cluster, attribute=attr.AllocatedSnapshotStreams
154172
)

src/python_testing/TC_AVSM_2_5.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ def steps_TC_AVSM_2_5(self) -> list[TestStep]:
123123
"TH sends the AudioStreamAllocate command with values from step 6 except with AudioCodec set to 10(outside of valid range)",
124124
"DUT responds with a CONSTRAINT_ERROR status code.",
125125
),
126+
TestStep(
127+
15,
128+
"TH sends the AudioStreamAllocate command with values from step 6 except with SampleRate set to a value not in aMicrophoneCapabilities",
129+
"DUT responds with a DYNAMIC_CONSTRAINT_ERROR status code.",
130+
),
126131
]
127132

128133
@run_if_endpoint_matches(
@@ -219,12 +224,12 @@ async def test_TC_AVSM_2_5(self):
219224
)
220225
pass
221226

227+
self.step(9)
222228
notSupportedStreamUsage = next(
223229
(e for e in Globals.Enums.StreamUsageEnum if e not in aStreamUsagePriorities and e != Globals.Enums.StreamUsageEnum.kInternal),
224230
Globals.Enums.StreamUsageEnum.kUnknownEnumValue,
225231
)
226232

227-
self.step(9)
228233
try:
229234
adoStreamAllocateCmd = commands.AudioStreamAllocate(
230235
streamUsage=notSupportedStreamUsage,
@@ -344,6 +349,26 @@ async def test_TC_AVSM_2_5(self):
344349
)
345350
pass
346351

352+
self.step(15)
353+
try:
354+
adoStreamAllocateCmd = commands.AudioStreamAllocate(
355+
streamUsage=aStreamUsagePriorities[0],
356+
audioCodec=aMicrophoneCapabilities.supportedCodecs[0],
357+
channelCount=aMicrophoneCapabilities.maxNumberOfChannels,
358+
sampleRate=aMicrophoneCapabilities.supportedSampleRates[0] + 10,
359+
bitRate=aBitRate,
360+
bitDepth=aMicrophoneCapabilities.supportedBitDepths[0],
361+
)
362+
await self.send_single_cmd(endpoint=endpoint, cmd=adoStreamAllocateCmd)
363+
asserts.fail("Unexpected success when expecting DYNAMIC_CONSTRAINT_ERROR due to unsupported sample rate")
364+
except InteractionModelError as e:
365+
asserts.assert_equal(
366+
e.status,
367+
Status.DynamicConstraintError,
368+
"Unexpected status returned when expecting DYNAMIC_CONSTRAINT_ERROR due to unsupported sample rate",
369+
)
370+
pass
371+
347372

348373
if __name__ == "__main__":
349374
default_matter_test_main()

src/python_testing/TC_AVSM_2_7.py

Lines changed: 83 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,39 +132,49 @@ def steps_TC_AVSM_2_7(self) -> list[TestStep]:
132132
),
133133
TestStep(
134134
17,
135+
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except with StreamUsage set to Internal",
136+
"DUT responds with a CONSTRAINT_ERROR status code.",
137+
),
138+
TestStep(
139+
18,
135140
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except StreamUsage set to a value not in aStreamUsagePriorities.",
136141
"DUT responds with a INVALID IN STATE status code.",
137142
),
138143
TestStep(
139-
18,
144+
19,
140145
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except MinFrameRate set to 0(outside of valid range).",
141146
"DUT responds with a CONSTRAINT_ERROR status code.",
142147
),
143148
TestStep(
144-
19,
149+
20,
145150
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except MinFrameRate > MaxFrameRate.",
146151
"DUT responds with a CONSTRAINT_ERROR status code.",
147152
),
148153
TestStep(
149-
20,
154+
21,
150155
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except MinBitRate set to 0(outside of valid range).",
151156
"DUT responds with a CONSTRAINT_ERROR status code.",
152157
),
153158
TestStep(
154-
21,
159+
22,
155160
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except MinBitRate > MaxBitRate.",
156161
"DUT responds with a CONSTRAINT_ERROR status code.",
157162
),
158163
TestStep(
159-
22,
160-
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except MinKeyFrameInterval > MaxKeyFrameInterval.",
164+
23,
165+
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except KeyFrameInterval > Max value",
161166
"DUT responds with a CONSTRAINT_ERROR status code.",
162167
),
163168
TestStep(
164-
23,
169+
24,
165170
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except VideoCodec is set to 10 (out of range).",
166171
"DUT responds with a CONSTRAINT_ERROR status code.",
167172
),
173+
TestStep(
174+
25,
175+
"TH sends the VideoStreamAllocate command with the same arguments from step 10 except MaxFrameRate set to a value not in aVideoSensorParams.",
176+
"DUT responds with a DYNAMIC_CONSTRAINT_ERROR status code.",
177+
),
168178
]
169179

170180
@run_if_endpoint_matches(
@@ -343,6 +353,36 @@ async def test_TC_AVSM_2_7(self):
343353
self.skip_step(16)
344354

345355
self.step(17)
356+
try:
357+
outOfConstraintStreamUsage = Globals.Enums.StreamUsageEnum.kInternal
358+
videoStreamAllocateCmd = commands.VideoStreamAllocate(
359+
streamUsage=outOfConstraintStreamUsage,
360+
videoCodec=aRateDistortionTradeOffPoints[0].codec,
361+
minFrameRate=30, # An acceptable value for min frame rate
362+
maxFrameRate=aVideoSensorParams.maxFPS,
363+
minResolution=aMinViewport,
364+
maxResolution=cluster.Structs.VideoResolutionStruct(
365+
width=aVideoSensorParams.sensorWidth, height=aVideoSensorParams.sensorHeight
366+
),
367+
minBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
368+
maxBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
369+
keyFrameInterval=4000,
370+
watermarkEnabled=watermark,
371+
OSDEnabled=osd,
372+
)
373+
await self.send_single_cmd(endpoint=endpoint, cmd=videoStreamAllocateCmd)
374+
asserts.fail(
375+
"Unexpected success when expecting CONSTRAINT_ERROR due to StreamUsage set to Internal",
376+
)
377+
except InteractionModelError as e:
378+
asserts.assert_equal(
379+
e.status,
380+
Status.ConstraintError,
381+
"Unexpected error returned when expecting CONSTRAINT_ERROR due to StreamUsage set to Internal",
382+
)
383+
pass
384+
385+
self.step(18)
346386
try:
347387
notSupportedStreamUsage = next(
348388
(e for e in Globals.Enums.StreamUsageEnum if e not in aStreamUsagePriorities and e != Globals.Enums.StreamUsageEnum.kInternal),
@@ -375,7 +415,7 @@ async def test_TC_AVSM_2_7(self):
375415
)
376416
pass
377417

378-
self.step(18)
418+
self.step(19)
379419
try:
380420
videoStreamAllocateCmd = commands.VideoStreamAllocate(
381421
streamUsage=aStreamUsagePriorities[0],
@@ -402,7 +442,7 @@ async def test_TC_AVSM_2_7(self):
402442
)
403443
pass
404444

405-
self.step(19)
445+
self.step(20)
406446
try:
407447
videoStreamAllocateCmd = commands.VideoStreamAllocate(
408448
streamUsage=aStreamUsagePriorities[0],
@@ -429,7 +469,7 @@ async def test_TC_AVSM_2_7(self):
429469
)
430470
pass
431471

432-
self.step(20)
472+
self.step(21)
433473
try:
434474
videoStreamAllocateCmd = commands.VideoStreamAllocate(
435475
streamUsage=aStreamUsagePriorities[0],
@@ -456,7 +496,7 @@ async def test_TC_AVSM_2_7(self):
456496
)
457497
pass
458498

459-
self.step(21)
499+
self.step(22)
460500
try:
461501
videoStreamAllocateCmd = commands.VideoStreamAllocate(
462502
streamUsage=aStreamUsagePriorities[0],
@@ -483,7 +523,7 @@ async def test_TC_AVSM_2_7(self):
483523
)
484524
pass
485525

486-
self.step(22)
526+
self.step(23)
487527
try:
488528
videoStreamAllocateCmd = commands.VideoStreamAllocate(
489529
streamUsage=aStreamUsagePriorities[0],
@@ -494,9 +534,9 @@ async def test_TC_AVSM_2_7(self):
494534
maxResolution=cluster.Structs.VideoResolutionStruct(
495535
width=aVideoSensorParams.sensorWidth, height=aVideoSensorParams.sensorHeight
496536
),
497-
minBitRate=aRateDistortionTradeOffPoints[0].minBitRate + 1,
537+
minBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
498538
maxBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
499-
keyFrameInterval=4000 + 1,
539+
keyFrameInterval=65500 + 1,
500540
watermarkEnabled=watermark,
501541
OSDEnabled=osd,
502542
)
@@ -510,7 +550,7 @@ async def test_TC_AVSM_2_7(self):
510550
)
511551
pass
512552

513-
self.step(23)
553+
self.step(24)
514554
try:
515555
videoStreamAllocateCmd = commands.VideoStreamAllocate(
516556
streamUsage=aStreamUsagePriorities[0],
@@ -521,7 +561,7 @@ async def test_TC_AVSM_2_7(self):
521561
maxResolution=cluster.Structs.VideoResolutionStruct(
522562
width=aVideoSensorParams.sensorWidth, height=aVideoSensorParams.sensorHeight
523563
),
524-
minBitRate=aRateDistortionTradeOffPoints[0].minBitRate + 1,
564+
minBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
525565
maxBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
526566
keyFrameInterval=4000,
527567
watermarkEnabled=watermark,
@@ -537,6 +577,33 @@ async def test_TC_AVSM_2_7(self):
537577
)
538578
pass
539579

580+
self.step(25)
581+
try:
582+
videoStreamAllocateCmd = commands.VideoStreamAllocate(
583+
streamUsage=aStreamUsagePriorities[0],
584+
videoCodec=aRateDistortionTradeOffPoints[0].codec,
585+
minFrameRate=30, # An acceptable value for min frame rate
586+
maxFrameRate=aVideoSensorParams.maxFPS + 10,
587+
minResolution=aMinViewport,
588+
maxResolution=cluster.Structs.VideoResolutionStruct(
589+
width=aVideoSensorParams.sensorWidth, height=aVideoSensorParams.sensorHeight
590+
),
591+
minBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
592+
maxBitRate=aRateDistortionTradeOffPoints[0].minBitRate,
593+
keyFrameInterval=4000,
594+
watermarkEnabled=watermark,
595+
OSDEnabled=osd,
596+
)
597+
await self.send_single_cmd(endpoint=endpoint, cmd=videoStreamAllocateCmd)
598+
asserts.fail("Unexpected success when expecting DYNAMIC_CONSTRAINT_ERROR due to unsupported MaxFrameRate")
599+
except InteractionModelError as e:
600+
asserts.assert_equal(
601+
e.status,
602+
Status.DynamicConstraintError,
603+
"Unexpected error returned when expecting DYNAMIC_CONSTRAINT_ERROR due to unsupported MaxFrameRate",
604+
)
605+
pass
606+
540607

541608
if __name__ == "__main__":
542609
default_matter_test_main()

0 commit comments

Comments
 (0)