1- import glob
21import json
32import os
43import re
@@ -682,9 +681,20 @@ def test_dwo_missing_error_stats(self):
682681 self .addTearDownCleanup (dictionary = da )
683682 exe = self .getBuildArtifact ("a.out" )
684683
685- # Remove the two .dwo files to trigger a DWO load error
686- dwo_files = glob .glob (self .getBuildArtifact ("*.dwo" ))
687- for dwo_file in dwo_files :
684+ expected_dwo_files = [
685+ self .getBuildArtifact ("dwo_error_main.dwo" ),
686+ self .getBuildArtifact ("dwo_error_foo.dwo" ),
687+ ]
688+
689+ # Verify expected files exist
690+ for dwo_file in expected_dwo_files :
691+ self .assertTrue (
692+ os .path .exists (dwo_file ),
693+ f"Expected .dwo file does not exist: { dwo_file } " ,
694+ )
695+
696+ # Remove the two .dwo files to trigger DWO load errors
697+ for dwo_file in expected_dwo_files :
688698 os .rename (dwo_file , dwo_file + ".bak" )
689699
690700 target = self .createTestTarget (file_path = exe )
@@ -699,7 +709,7 @@ def test_dwo_missing_error_stats(self):
699709 self .assertEqual (debug_stats ["modules" ][0 ]["dwoErrorCount" ], 2 )
700710
701711 # Restore the original .dwo file
702- for dwo_file in dwo_files :
712+ for dwo_file in expected_dwo_files :
703713 os .rename (dwo_file + ".bak" , dwo_file )
704714
705715 @add_test_categories (["dwo" ])
@@ -723,10 +733,20 @@ def test_dwo_id_mismatch_error_stats(self):
723733 self .addTearDownCleanup (dictionary = da )
724734 exe = self .getBuildArtifact ("a.out" )
725735
726- # Find and make a backup of the original .dwo file
727- dwo_files = glob .glob (self .getBuildArtifact ("*.dwo" ))
736+ expected_dwo_files = [
737+ self .getBuildArtifact ("dwo_error_main.dwo" ),
738+ self .getBuildArtifact ("dwo_error_foo.dwo" ),
739+ ]
740+
741+ # Verify expected files exist
742+ for dwo_file in expected_dwo_files :
743+ self .assertTrue (
744+ os .path .exists (dwo_file ),
745+ f"Expected .dwo file does not exist: { dwo_file } " ,
746+ )
728747
729- original_dwo_file = dwo_files [1 ]
748+ # Find and make a backup of the original .dwo file
749+ original_dwo_file = self .getBuildArtifact ("dwo_error_foo.dwo" )
730750 original_dwo_backup = original_dwo_file + ".bak"
731751 shutil .copy2 (original_dwo_file , original_dwo_backup )
732752
@@ -749,7 +769,7 @@ def test_dwo_id_mismatch_error_stats(self):
749769 self .build (dictionary = da , debug_info = "dwo" )
750770 shutil .copy2 (original_dwo_backup , original_dwo_file )
751771
752- # Create a new target and run to a breakpoint to force DWO file loading
772+ # Create a new target and get stats
753773 target = self .createTestTarget (file_path = exe )
754774 debug_stats = self .get_stats ()
755775
0 commit comments