Skip to content

Commit 6255dd7

Browse files
committed
Fixed: Hooked failsafe_expiration_seconds to user parameter PIXIT.CGEN.FailsafeExpiryLengthSeconds for CI or Cert flow flexibility.
1 parent 0534ca1 commit 6255dd7

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

src/python_testing/TC_CGEN_2_2.py

+21-24
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# --discriminator 1234
3030
# --passcode 20202021
3131
# --PICS src/app/tests/suites/certification/ci-pics-values
32+
# --int-arg PIXIT.CGEN.FailsafeExpiryLengthSeconds:20
3233
# --trace-to json:${TRACE_TEST_JSON}.json
3334
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
3435
# factory-reset: true
@@ -292,7 +293,8 @@ async def test_TC_CGEN_2_2(self):
292293

293294
# PIXIT.CGEN.FailsafeExpiryLengthSeconds:
294295
# Timeout used in test steps to verify failsafe. Must be less than DUT MaxCumulativeFailsafeSeconds
295-
failsafe_expiration_seconds = 20
296+
failsafe_expiration_seconds = self.matter_test_config.global_test_params['PIXIT.CGEN.FailsafeExpiryLengthSeconds']
297+
logger.info(f'Value of PIXIT.CGEN.FailsafeExpiryLengthSeconds: {failsafe_expiration_seconds}')
296298

297299
self.step(0)
298300

@@ -346,16 +348,13 @@ async def test_TC_CGEN_2_2(self):
346348
logger.info(
347349
f'Step 7: {run_type} - Bypassing failsafe expiration to avoid unnecessary delays in CI environment.')
348350

349-
# Expiration time set to 1 second to immediately expire the failsafe timer
350-
expiration_time_seconds = 1
351-
352351
# Force the failsafe timer to expire immediately for TH1, avoiding unnecessary delays in CI environments
353352
resp = await self.set_failsafe_timer(
354353
dev_ctrl=self.default_controller,
355354
node_id=self.dut_node_id,
356-
expiration_time_seconds=expiration_time_seconds)
355+
expiration_time_seconds=failsafe_expiration_seconds)
357356
logger.info(
358-
f'Step #7 {run_type} - Failsafe timer expiration bypassed for TH1 by setting expiration time to {expiration_time_seconds} seconds. '
357+
f'Step #7 {run_type} - Failsafe timer expiration bypassed for TH1 by setting expiration time to {failsafe_expiration_seconds} seconds. '
359358
f'Test continues without the original wait.'
360359
)
361360
else:
@@ -647,6 +646,12 @@ async def test_TC_CGEN_2_2(self):
647646
logger.info(f'Step #32: ArmFailSafeResponse with ErrorCode as OK({resp.errorCode})')
648647

649648
self.step(33)
649+
650+
# Set the failsafe expiration timeout to PIXIT.CGEN.FailsafeExpiryLengthSeconds seconds, must be less than maxFailsafe (max_fail_safe).
651+
failsafe_timeout_less_than_max = failsafe_expiration_seconds
652+
# Verify that failsafe_timeout_less_than_max is less than max_fail_safe
653+
asserts.assert_less(failsafe_timeout_less_than_max, maxFailsafe)
654+
650655
if self.is_pics_sdk_ci_only:
651656
# Step 33 - In CI environments avoiding the original wait time defined in PIXIT.CGEN.FailsafeExpiryLengthSeconds
652657
# and speeding up test execution by setting the expiration time to 2 seconds.
@@ -655,24 +660,18 @@ async def test_TC_CGEN_2_2(self):
655660
logger.info(
656661
f'Step 33: {run_type} - Bypassing failsafe expiration to avoid unnecessary delays in CI environment.')
657662

658-
# Set the failsafe expiration timeout to 2 seconds, must be less than maxFailsafe (max_fail_safe).
659-
failsafe_timeout_less_than_max = 2
660663
logger.info(
661664
f'Step #33: {run_type} - Waiting for the failsafe timer '
662665
f'(PIXIT.CGEN.FailsafeExpiryLengthSeconds --adjusted time for CI) to approach expiration, '
663666
f'but not allowing it to fully expire. Waiting for: {failsafe_timeout_less_than_max} seconds.')
664-
665667
# Wait PIXIT.CGEN.FailsafeExpiryLengthSeconds time with an additional 0.5-second buffer, not allowing the fully exire (max_fail_safe).
666668
await asyncio.sleep(failsafe_timeout_less_than_max + .5)
667669
else:
668670
run_type = "Cert Test"
669671

670-
# Set the failsafe expiration timeout to PIXIT.CGEN.FailsafeExpiryLengthSecondsseconds, must be less than maxFailsafe (max_fail_safe).
671-
failsafe_timeout_less_than_max = failsafe_expiration_seconds
672-
673672
logger.info(
674673
f'Step #33: {run_type} - Waiting for the failsafe timer '
675-
f'(PIXIT.CGEN.FailsafeExpiryLengthSeconds --adjusted time for CI) to approach expiration, '
674+
f'(PIXIT.CGEN.FailsafeExpiryLengthSeconds) to approach expiration, '
676675
f'but not allowing it to fully expire. Waiting for: {failsafe_timeout_less_than_max} seconds.')
677676
# Wait PIXIT.CGEN.FailsafeExpiryLengthSeconds time with an additional 0.5-second buffer, not allowing the fully exire (max_fail_safe).
678677
await asyncio.sleep(failsafe_timeout_less_than_max + .5)
@@ -727,7 +726,7 @@ async def test_TC_CGEN_2_2(self):
727726
# In CI environment, bypass the wait for the failsafe expiration to avoid unnecessary delays.
728727
run_type = "CI Test"
729728
logger.info(
730-
f'Step 38: {run_type} - Bypassing due to failsafe expiration workaround to avoid unnecessary delays in CI environment.')
729+
f'Step #38: {run_type} - Bypassing due to failsafe expiration workaround to avoid unnecessary delays in CI environment.')
731730
else:
732731
run_type = "Cert Test"
733732
t_start = time.time()
@@ -754,13 +753,14 @@ async def test_TC_CGEN_2_2(self):
754753
"Unexpected number of entries in the TrustedRootCertificates table after update")
755754

756755
self.step(41)
757-
# Limit maxFailsafe to 20 seconds to prevent excessively long waits in tests (due maxFailsafe = 900 seconds).
756+
# Limit maxFailsafe to PIXIT.CGEN.FailsafeExpiryLengthSeconds seconds to prevent excessively long waits in tests (due maxFailsafe = 900 seconds).
757+
maxFailsafe_original = maxFailsafe
758758
maxFailsafe = failsafe_expiration_seconds
759759
if self.is_pics_sdk_ci_only:
760760
# In CI environment, bypass the wait for the failsafe expiration to avoid unnecessary delays.
761761
run_type = "CI Test"
762762
logger.info(
763-
f'Step 41: {run_type} - Bypassing due to failsafe expiration workaround to avoid unnecessary delays in CI environment.')
763+
f'Step #41: {run_type} - Bypassing due to failsafe expiration workaround to avoid unnecessary delays in CI environment.')
764764
else:
765765
run_type = "Cert Test"
766766

@@ -780,7 +780,7 @@ async def test_TC_CGEN_2_2(self):
780780
)
781781

782782
self.step(42)
783-
cmd = Clusters.GeneralCommissioning.Commands.ArmFailSafe(expiryLengthSeconds=maxFailsafe)
783+
cmd = Clusters.GeneralCommissioning.Commands.ArmFailSafe(expiryLengthSeconds=maxFailsafe_original)
784784
resp = await self.send_single_cmd(
785785
dev_ctrl=self.default_controller,
786786
node_id=self.dut_node_id,
@@ -798,18 +798,15 @@ async def test_TC_CGEN_2_2(self):
798798

799799
run_type = "CI Test"
800800
logger.info(
801-
f'Step 43: {run_type} - Bypassing due to failsafe expiration workaround to avoid unnecessary delays in CI environment.')
802-
803-
# Expiration time set to 1 second to immediately expire the failsafe timer
804-
expiration_time_seconds = 1
801+
f'Step #43: {run_type} - Bypassing due to failsafe expiration workaround to avoid unnecessary delays in CI environment.')
805802

806803
# Force the failsafe timer to expire immediately for TH1, avoiding unnecessary delays in CI environments
807804
resp = await self.set_failsafe_timer(
808805
dev_ctrl=self.default_controller,
809806
node_id=self.dut_node_id,
810-
expiration_time_seconds=expiration_time_seconds)
807+
expiration_time_seconds=failsafe_expiration_seconds)
811808
logger.info(
812-
f'Step #43 {run_type} - Failsafe timer expiration bypassed for TH1 by setting expiration time to {expiration_time_seconds} seconds. '
809+
f'Step #43 {run_type} - Failsafe timer expiration bypassed for TH1 by setting expiration time to {failsafe_expiration_seconds} seconds. '
813810
f'Test continues without the original wait.'
814811
)
815812
else:
@@ -827,7 +824,7 @@ async def test_TC_CGEN_2_2(self):
827824
# Checks if the elapsed time from start_time has met or exceeded maxFailsafe
828825
# TH1 process can proceed
829826
logger.info(
830-
f'Step #43: {run_type} - - MaxFailsafe is {maxFailsafe}. '
827+
f'Step #43: {run_type} - MaxFailsafe is {maxFailsafe}. '
831828
f'TH1 can proceed. Elapsed time: {elapsed_time:.2f} ms. '
832829
f'The target time ({maxFailsafe} seconds) has passed '
833830
f'Confirmation that ArmFailSafe has not expired yet.'

0 commit comments

Comments
 (0)