@@ -75,12 +75,19 @@ async def test_TC_RR_1_1(self):
75
75
skip_user_label_cluster_steps = self .user_params .get ("skip_user_label_cluster_steps" , False )
76
76
# Whether to do the local session ID comparison checks to prove new sessions have not been established.
77
77
check_local_session_id_unchanged = self .user_params .get ("check_local_session_id_unchanged" , False )
78
+ # Whether to check heap statistics. Add `--bool-arg check_heap_watermarks:true` to command line to enable
79
+ check_heap_watermarks = self .user_params .get ("check_heap_watermarks" , False )
78
80
79
81
BEFORE_LABEL = "Before Subscriptions 12345678912"
80
82
AFTER_LABEL = "After Subscriptions 123456789123"
81
83
82
84
# Pre-conditions
83
85
86
+ # Do a read-out of heap statistics before the test begins
87
+ if check_heap_watermarks :
88
+ logging .info ("Read Heap info before stress test" )
89
+ high_watermark_before , current_usage_before = await self .read_heap_statistics (dev_ctrl )
90
+
84
91
# Make sure all certificates are installed with maximal size
85
92
dev_ctrl .fabricAdmin .certificateAuthority .maximizeCertChains = True
86
93
@@ -406,6 +413,14 @@ async def test_TC_RR_1_1(self):
406
413
num_fabrics_to_commission , fabric_unique_clients , group_key_map , groups_cluster_endpoints , indicated_max_groups_per_fabric )
407
414
await self .validate_group_table (num_fabrics_to_commission , fabric_unique_clients , group_table_written )
408
415
416
+ # Read heap watermarks after the test
417
+ if check_heap_watermarks :
418
+ logging .info ("Read Heap info after stress test" )
419
+ high_watermark_after , current_usage_after = await self .read_heap_statistics (dev_ctrl )
420
+ logging .info ("=== Heap Usage Diagnostics ===\n High watermark: {} (before) / {} (after)\n "
421
+ "Current usage: {} (before) / {} (after)" .format (high_watermark_before , high_watermark_after ,
422
+ current_usage_before , current_usage_after ))
423
+
409
424
def random_string (self , length ) -> str :
410
425
rnd = self ._pseudo_random_generator
411
426
return "" .join ([rnd .choice ("abcdef0123456789" ) for _ in range (length )])[:length ]
@@ -619,7 +634,7 @@ def build_acl(self, fabric_number, client_by_name, num_controllers_per_fabric):
619
634
# - Subjects field: [0x3000_0000_0000_0001, 0x3000_0000_0000_0002, 0x3000_0000_0000_0003, 0x3000_0000_0000_0004]
620
635
# - Targets field: [{Cluster: 0xFFF1_FC40, DeviceType: 0xFFF1_FC20}, {Cluster: 0xFFF1_FC41, DeviceType: 0xFFF1_FC21}, {Cluster: 0xFFF1_FC02, DeviceType: 0xFFF1_FC42}]
621
636
# . struct
622
- # - Privilege field: View (3 )
637
+ # - Privilege field: View (1 )
623
638
# - AuthMode field: CASE (2)
624
639
# - Subjects field: [0x4000_0000_0000_0001, 0x4000_0000_0000_0002, 0x4000_0000_0000_0003, 0x4000_0000_0000_0004]
625
640
# - Targets field: [{Cluster: 0xFFF1_FC80, DeviceType: 0xFFF1_FC20}, {Cluster: 0xFFF1_FC81, DeviceType: 0xFFF1_FC21}, {Cluster: 0xFFF1_FC82, DeviceType: 0xFFF1_FC22}]
@@ -666,7 +681,7 @@ def build_acl(self, fabric_number, client_by_name, num_controllers_per_fabric):
666
681
targets = operate_targets )
667
682
acl .append (operate_acl_entry )
668
683
669
- # Operate ACL entry
684
+ # View ACL entry
670
685
view_subjects = [0x4000_0000_0000_0001 , 0x4000_0000_0000_0002 , 0x4000_0000_0000_0003 , 0x4000_0000_0000_0004 ]
671
686
view_targets = [
672
687
Clusters .AccessControl .Structs .Target (cluster = 0xFFF1_FC80 , deviceType = 0xFFF1_BC20 ),
@@ -701,6 +716,25 @@ def build_group_key(self, fabric_index: int, group_key_index: int, keys_per_fabr
701
716
epochKey2 = self .random_string (16 ).encode (),
702
717
epochStartTime2 = (set_id * 4 + 2 ))
703
718
719
+ async def read_heap_statistics (self , dev_ctrl ):
720
+ diagnostics_contents = [
721
+ Clusters .SoftwareDiagnostics .Attributes .CurrentHeapHighWatermark ,
722
+ Clusters .SoftwareDiagnostics .Attributes .CurrentHeapUsed ,
723
+ ]
724
+ diagnostics_paths = [(0 , attrib ) for attrib in diagnostics_contents ]
725
+ swdiag_info = await dev_ctrl .ReadAttribute (self .dut_node_id , diagnostics_paths )
726
+
727
+ # Make sure everything came back from the read that we expected
728
+ asserts .assert_true (0 in swdiag_info .keys (), "Must have read endpoint 0 data" )
729
+ asserts .assert_true (Clusters .SoftwareDiagnostics in swdiag_info [0 ].keys (
730
+ ), "Must have read Software Diagnostics cluster data" )
731
+ for attribute in diagnostics_contents :
732
+ asserts .assert_true (attribute in swdiag_info [0 ][Clusters .SoftwareDiagnostics ],
733
+ "Must have read back attribute %s" % (attribute .__name__ ))
734
+ high_watermark = swdiag_info [0 ][Clusters .SoftwareDiagnostics ][Clusters .SoftwareDiagnostics .Attributes .CurrentHeapHighWatermark ]
735
+ current_usage = swdiag_info [0 ][Clusters .SoftwareDiagnostics ][Clusters .SoftwareDiagnostics .Attributes .CurrentHeapUsed ]
736
+ return high_watermark , current_usage
737
+
704
738
705
739
if __name__ == "__main__" :
706
740
default_matter_test_main (maximize_cert_chains = True , controller_cat_tags = [0x0001_0001 ])
0 commit comments