Skip to content

Commit e9f1f1e

Browse files
Fix BRBINFO_4_1 to run further (#35026)
* Fix BRBINFO_4_1 to run further * Restyled by autopep8 --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 7ae5199 commit e9f1f1e

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

src/python_testing/TC_BRBINFO_4_1.py

+38-33
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ async def _send_keep_active_command(self, duration, endpoint_id) -> int:
8181
keep_active = await self.default_controller.SendCommand(nodeid=self.dut_node_id, endpoint=endpoint_id, payload=Clusters.Objects.BridgedDeviceBasicInformation.Commands.KeepActive(stayActiveDuration=duration))
8282
return keep_active
8383

84-
async def _wait_for_active_changed_event(self, timeout) -> int:
84+
async def _wait_for_active_changed_event(self, timeout_s) -> int:
8585
try:
86-
promised_active_duration = self.q.get(block=True, timeout=timeout)
87-
logging.info(f"PromisedActiveDuration: {promised_active_duration}")
88-
return promised_active_duration
86+
promised_active_duration_event = self.q.get(block=True, timeout=timeout_s)
87+
logging.info(f"PromisedActiveDurationEvent: {promised_active_duration_event}")
88+
promised_active_duration_ms = promised_active_duration_event.Data.promisedActiveDuration
89+
return promised_active_duration_ms
8990
except queue.Empty:
9091
asserts.fail("Timeout on event ActiveChanged")
9192

@@ -192,21 +193,21 @@ async def test_TC_BRBINFO_4_1(self):
192193

193194
self.step("1a")
194195

195-
idle_mode_duration = await self._read_attribute_expect_success(
196+
idle_mode_duration_s = await self._read_attribute_expect_success(
196197
_ROOT_ENDPOINT_ID,
197198
icdm_cluster,
198199
icdm_attributes.IdleModeDuration,
199200
self.icd_nodeid
200201
)
201-
logging.info(f"IdleModeDuration: {idle_mode_duration}")
202+
logging.info(f"IdleModeDurationS: {idle_mode_duration_s}")
202203

203-
active_mode_duration = await self._read_attribute_expect_success(
204+
active_mode_duration_ms = await self._read_attribute_expect_success(
204205
_ROOT_ENDPOINT_ID,
205206
icdm_cluster,
206207
icdm_attributes.ActiveModeDuration,
207208
self.icd_nodeid
208209
)
209-
logging.info(f"ActiveModeDuration: {active_mode_duration}")
210+
logging.info(f"ActiveModeDurationMs: {active_mode_duration_ms}")
210211

211212
self.step("1b")
212213

@@ -218,49 +219,53 @@ async def test_TC_BRBINFO_4_1(self):
218219
subscription = await self.default_controller.ReadEvent(nodeid=self.dut_node_id, events=[(dynamic_endpoint_id, event, urgent)], reportInterval=[1, 3])
219220
subscription.SetEventUpdateCallback(callback=cb)
220221

221-
stay_active_duration = 1000
222-
logging.info(f"Sending KeepActiveCommand({stay_active_duration}ms)")
223-
self._send_keep_active_command(stay_active_duration, dynamic_endpoint_id)
222+
stay_active_duration_ms = 1000
223+
logging.info(f"Sending KeepActiveCommand({stay_active_duration_ms}ms)")
224+
await self._send_keep_active_command(stay_active_duration_ms, dynamic_endpoint_id)
224225

225226
logging.info("Waiting for ActiveChanged from DUT...")
226-
promised_active_duration = await self._wait_for_active_changed_event((idle_mode_duration + max(active_mode_duration, stay_active_duration))/1000)
227+
timeout_s = idle_mode_duration_s + max(active_mode_duration_ms, stay_active_duration_ms)/1000
228+
promised_active_duration_ms = await self._wait_for_active_changed_event(timeout_s)
227229

228-
asserts.assert_greater_equal(promised_active_duration, stay_active_duration, "PromisedActiveDuration < StayActiveDuration")
230+
asserts.assert_greater_equal(promised_active_duration_ms, stay_active_duration_ms,
231+
"PromisedActiveDuration < StayActiveDuration")
229232

230233
self.step("2")
231234

232-
stay_active_duration = 1500
233-
logging.info(f"Sending KeepActiveCommand({stay_active_duration}ms)")
234-
self._send_keep_active_command(stay_active_duration)
235+
stay_active_duration_ms = 1500
236+
logging.info(f"Sending KeepActiveCommand({stay_active_duration_ms}ms)")
237+
await self._send_keep_active_command(stay_active_duration_ms, dynamic_endpoint_id)
235238

236239
logging.info("Waiting for ActiveChanged from DUT...")
237-
promised_active_duration = await self._wait_for_active_changed_event((idle_mode_duration + max(active_mode_duration, stay_active_duration))/1000)
240+
timeout_s = idle_mode_duration_s + max(active_mode_duration_ms, stay_active_duration_ms)/1000
241+
promised_active_duration_ms = await self._wait_for_active_changed_event(timeout_s)
238242

239243
# wait for active time duration
240-
time.sleep(max(stay_active_duration/1000, promised_active_duration))
244+
sleep_time_s = max(stay_active_duration_ms, promised_active_duration_ms)/1000
245+
time.sleep(sleep_time_s)
241246
# ICD now should be in idle mode
242247

243248
# sends 3x keep active commands
244-
logging.info(f"Sending KeepActiveCommand({stay_active_duration})")
245-
self._send_keep_active_command(stay_active_duration, dynamic_endpoint_id)
246-
time.sleep(100)
247-
logging.info(f"Sending KeepActiveCommand({stay_active_duration})")
248-
self._send_keep_active_command(stay_active_duration, dynamic_endpoint_id)
249-
time.sleep(100)
250-
logging.info(f"Sending KeepActiveCommand({stay_active_duration})")
251-
self._send_keep_active_command(stay_active_duration, dynamic_endpoint_id)
252-
time.sleep(100)
249+
logging.info(f"Step3 Sending first KeepActiveCommand({stay_active_duration_ms})")
250+
await self._send_keep_active_command(stay_active_duration_ms, dynamic_endpoint_id)
251+
time.sleep(0.1)
252+
logging.info(f"Step3 Sending second KeepActiveCommand({stay_active_duration_ms})")
253+
await self._send_keep_active_command(stay_active_duration_ms, dynamic_endpoint_id)
254+
time.sleep(0.1)
255+
logging.info(f"Step3 Sending third KeepActiveCommand({stay_active_duration_ms})")
256+
await self._send_keep_active_command(stay_active_duration_ms, dynamic_endpoint_id)
257+
time.sleep(0.1)
253258

254259
logging.info("Waiting for ActiveChanged from DUT...")
255-
promised_active_duration = await self._wait_for_active_changed_event((idle_mode_duration + max(active_mode_duration, stay_active_duration))/1000)
260+
promised_active_duration_ms = await self._wait_for_active_changed_event((idle_mode_duration_s + max(active_mode_duration_ms, stay_active_duration_ms))/1000)
256261

257262
asserts.assert_equal(self.q.qSize(), 0, "More than one event received from DUT")
258263

259264
self.step("3")
260265

261-
stay_active_duration = 10000
262-
logging.info(f"Sending KeepActiveCommand({stay_active_duration})")
263-
self._send_keep_active_command(stay_active_duration, dynamic_endpoint_id)
266+
stay_active_duration_ms = 10000
267+
logging.info(f"Sending KeepActiveCommand({stay_active_duration_ms})")
268+
await self._send_keep_active_command(stay_active_duration_ms, dynamic_endpoint_id)
264269

265270
# stops (halts) the ICD server process by sending a SIGTOP signal
266271
self.app_process.send_signal(signal.SIGSTOP.value)
@@ -274,9 +279,9 @@ async def test_TC_BRBINFO_4_1(self):
274279
self.app_process.send_signal(signal.SIGCONT.value)
275280

276281
# wait for active changed event, expect no event will be sent
277-
event_timeout = (idle_mode_duration + max(active_mode_duration, stay_active_duration))/1000
282+
event_timeout = (idle_mode_duration_s + max(active_mode_duration_ms, stay_active_duration_ms))/1000
278283
try:
279-
promised_active_duration = self.q.get(block=True, timeout=event_timeout)
284+
promised_active_duration_ms = self.q.get(block=True, timeout=event_timeout)
280285
finally:
281286
asserts.assert_true(queue.Empty(), "ActiveChanged event received when not expected")
282287

0 commit comments

Comments
 (0)