@@ -255,8 +255,8 @@ def execute_str(self, path: str):
255
255
return f"valgrind { path } "
256
256
elif self == BinaryRunner .COVERAGE :
257
257
# Expected path is like "out/<target>/<binary>"
258
- rawname = path [: path .rindex ("/" )] + ".profraw"
259
- return f'LLVM_PROFILE_FILE="{ rawname } " { path } '
258
+ rawname = os . path . basename ( path [: path .rindex ("/" )] + ".profraw" )
259
+ return f'LLVM_PROFILE_FILE="out/profiling/ { rawname } " { path } '
260
260
261
261
262
262
__RUNNERS__ = {
@@ -552,13 +552,13 @@ def gen_coverage():
552
552
553
553
trace_files = []
554
554
for t in _get_targets (coverage = True ):
555
- path = os .path .join ("./out" , f"{ t .target } .profraw" )
555
+ path = os .path .join ("./out" , "profiling" , f"{ t .target } .profraw" )
556
556
557
557
if not os .path .exists (path ):
558
558
logging .warning ("No profile file '%s'. Skipping." , path )
559
559
continue
560
560
561
- data_path = os .path .join ("./out" , f"{ t .target } .profdata" )
561
+ data_path = os .path .join ("./out" , "profiling" , f"{ t .target } .profdata" )
562
562
cmd = [
563
563
"llvm-profdata" ,
564
564
"merge" ,
@@ -581,11 +581,34 @@ def gen_coverage():
581
581
cmd .append ("-ignore-filename-regex" )
582
582
cmd .append (p )
583
583
584
- info_path = os .path .join ("./out" , f"{ t .target } .info" )
584
+ info_path = os .path .join ("./out" , "profiling" , f"{ t .target } .info" )
585
585
subprocess .run (_with_activate (cmd , output_path = info_path ), check = True )
586
586
trace_files .append (info_path )
587
587
logging .info ("Generated %s" , info_path )
588
588
589
+ # !!!!! HACK ALERT !!!!!
590
+ #
591
+ # The paths for our examples are generally including CHIP as
592
+ # examples/<name>/third_party/connectedhomeip/....
593
+ # So we will replace every occurence of these to remove the extra indirection into third_party
594
+ #
595
+ # Generally we will replace every path (Shown as SF:...) with the corresponding item
596
+ #
597
+ # We assume that the info lines fit in RAM
598
+ lines = []
599
+ with open (info_path , 'rt' ) as f :
600
+ for line in f .readlines ():
601
+ if line .startswith ("SF:" ):
602
+ # This is a source file line: "SF:..."
603
+ path = line [3 :]
604
+ lines .append (f"SF:{ os .path .realpath (path )} " )
605
+ lines .append (line )
606
+
607
+ # re-write it.
608
+ with open (info_path , 'wt' ) as f :
609
+ f .write ("\n " .join (lines ))
610
+
611
+
589
612
if not trace_files :
590
613
logging .error (
591
614
"Could not find any trace files. Did you run tests with coverage enabled?"
@@ -602,13 +625,13 @@ def gen_coverage():
602
625
]
603
626
604
627
cmd .append ("--output-file" )
605
- cmd .append ("out/merged.info" )
628
+ cmd .append ("out/profiling/ merged.info" )
606
629
for e in errors_to_ignore :
607
630
cmd .append ("--ignore-errors" )
608
631
cmd .append (e )
609
632
610
- if os .path .exists ("out/merged.info" ):
611
- os .unlink ("out/merged.info" )
633
+ if os .path .exists ("out/profiling/ merged.info" ):
634
+ os .unlink ("out/profiling/ merged.info" )
612
635
613
636
subprocess .run (cmd , check = True )
614
637
@@ -620,7 +643,7 @@ def gen_coverage():
620
643
621
644
cmd .append ("--output-directory" )
622
645
cmd .append ("out/coverage" )
623
- cmd .append ("out/merged.info" )
646
+ cmd .append ("out/profiling/ merged.info" )
624
647
625
648
subprocess .run (cmd , check = True )
626
649
logging .info ("Coverage HTML should be available in out/coverage/index.html" )
@@ -673,7 +696,7 @@ def gen_coverage():
673
696
"--fail-log-dir" ,
674
697
default = None ,
675
698
help = "Save failure logs into the specified directory instead of logging (as logging can be noisy/slow)" ,
676
- type = click .Path (exists = True , file_okay = False , dir_okay = True ),
699
+ type = click .Path (file_okay = False , dir_okay = True ),
677
700
)
678
701
@click .option ("--coverage/--no-coverage" , default = None )
679
702
@click .option (
@@ -749,6 +772,9 @@ def as_runner(path):
749
772
if not os .path .exists ("out/trace_data" ):
750
773
os .mkdir ("out/trace_data" )
751
774
775
+ if not os .path .exists (fail_log_dir ):
776
+ os .mkdir (fail_log_dir )
777
+
752
778
metadata = yaml .full_load (open ("src/python_testing/test_metadata.yaml" ))
753
779
excluded_patterns = set ([item ["name" ] for item in metadata ["not_automated" ]])
754
780
0 commit comments