Skip to content

Commit 9de5fe3

Browse files
committed
Fix the potential inconsisitency issue in test_dwo_id_mismatch_error_stats
1 parent b8d2944 commit 9de5fe3

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

lldb/test/API/commands/statistics/basic/TestStats.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import glob
21
import json
32
import os
43
import 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

Comments
 (0)