mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 15:18:53 +08:00
[source maps] Fix remove, insert-after and replace
Summary: In this diff of mine D77186 I introduce a bug in the replace operation, where I was failing fast by mistake. Besides, a similar problem existed in the insert-after operation, where it was failing fast. Finally, the remove operation was wrong, as it was not using the indices provided by the users. I fixed those issues and added some tests account for cases with multiple elements in these requests. Reviewers: labath, clayborg Reviewed By: labath Subscribers: mgrang, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D77324
This commit is contained in:
committed by
Walter Erquinigo
parent
79afdfab9a
commit
ca47ac3d5f
@@ -42,67 +42,93 @@ class TestTargetSourceMap(TestBase):
|
||||
self.assertEquals(bp.GetNumLocations(), 0,
|
||||
"make sure no breakpoints were resolved without map")
|
||||
|
||||
valid_path = os.path.dirname(src_dir)
|
||||
valid_path2 = os.path.dirname(valid_path)
|
||||
invalid_path = src_dir + "invalid_path"
|
||||
invalid_path2 = src_dir + "invalid_path2"
|
||||
|
||||
# We make sure the error message contains all the invalid paths
|
||||
self.expect(
|
||||
'settings set target.source-map . "%s" . "%s" . "%s"' % (invalid_path, src_dir, invalid_path2),
|
||||
'settings set target.source-map . "%s" . "%s" . "%s" . "%s' \
|
||||
% (invalid_path, src_dir, invalid_path2, valid_path),
|
||||
substrs=[
|
||||
'the replacement path doesn\'t exist: "%s"' % (invalid_path),
|
||||
'error: the replacement path doesn\'t exist: "%s"' % (invalid_path),
|
||||
'the replacement path doesn\'t exist: "%s"' % (invalid_path2),
|
||||
],
|
||||
error=True,
|
||||
)
|
||||
self.expect(
|
||||
'settings show target.source-map',
|
||||
substrs=['[0] "." -> "%s"' % (src_dir)],
|
||||
substrs=[
|
||||
'[0] "." -> "%s"' % (src_dir),
|
||||
'[1] "." -> "%s"' % (valid_path),
|
||||
],
|
||||
)
|
||||
assertBreakpointWithSourceMap(src_path)
|
||||
|
||||
# Index 0 is the valid mapping, and modifying it to an invalid one should have no effect
|
||||
# Attempts to replace an index to an invalid mapping should have no effect.
|
||||
# Modifications to valid mappings should work.
|
||||
self.expect(
|
||||
'settings replace target.source-map 0 . "%s"' % (invalid_path),
|
||||
substrs=['error: the replacement path doesn\'t exist: "%s"' % (invalid_path)],
|
||||
'settings replace target.source-map 0 . "%s" . "%s"' % (invalid_path, valid_path2),
|
||||
substrs=[
|
||||
'error: the replacement path doesn\'t exist: "%s"' % (invalid_path),
|
||||
],
|
||||
error=True,
|
||||
)
|
||||
self.expect(
|
||||
'settings show target.source-map',
|
||||
substrs=['[0] "." -> "%s"' % (src_dir)]
|
||||
substrs=[
|
||||
'[0] "." -> "%s"' % (src_dir),
|
||||
'[1] "." -> "%s"' % (valid_path2),
|
||||
]
|
||||
)
|
||||
assertBreakpointWithSourceMap(src_path)
|
||||
|
||||
# Let's clear and add the mapping in with insert-after
|
||||
# Let's clear and add the mapping back with insert-after
|
||||
self.runCmd('settings remove target.source-map 0')
|
||||
self.expect(
|
||||
'settings show target.source-map',
|
||||
endstr="target.source-map (path-map) =\n",
|
||||
substrs=['[0] "." -> "%s"' % (valid_path2)],
|
||||
)
|
||||
|
||||
# We add a valid but useless mapping so that we can use insert-after
|
||||
another_valid_path = os.path.dirname(src_dir)
|
||||
self.runCmd('settings set target.source-map . "%s"' % (another_valid_path))
|
||||
|
||||
self.expect(
|
||||
'settings replace target.source-map 0 . "%s"' % (invalid_path),
|
||||
substrs=['error: the replacement path doesn\'t exist: "%s"' % (invalid_path)],
|
||||
'settings insert-after target.source-map 0 . "%s" . "%s" . "%s"' \
|
||||
% (invalid_path, invalid_path2, src_dir),
|
||||
substrs=[
|
||||
'error: the replacement path doesn\'t exist: "%s"' % (invalid_path),
|
||||
'the replacement path doesn\'t exist: "%s"' % (invalid_path2),
|
||||
],
|
||||
error=True,
|
||||
)
|
||||
self.expect(
|
||||
'settings show target.source-map',
|
||||
substrs=['[0] "." -> "%s"' % (another_valid_path)]
|
||||
substrs=[
|
||||
'[0] "." -> "%s"' % (valid_path2),
|
||||
'[1] "." -> "%s"' % (src_dir),
|
||||
]
|
||||
)
|
||||
|
||||
# Let's clear and add the mapping in with append
|
||||
self.expect('settings remove target.source-map 0')
|
||||
# Let's clear using remove and add the mapping in with append
|
||||
self.runCmd('settings remove target.source-map 1')
|
||||
self.expect(
|
||||
'settings show target.source-map',
|
||||
endstr="target.source-map (path-map) =\n",
|
||||
substrs=[
|
||||
'[0] "." -> "%s"' % (valid_path2),
|
||||
]
|
||||
)
|
||||
|
||||
self.runCmd('settings clear target.source-map')
|
||||
self.expect(
|
||||
'settings append target.source-map . "%s" . "%s"' % (invalid_path, src_dir),
|
||||
substrs=['error: the replacement path doesn\'t exist: "%s"' % (invalid_path)],
|
||||
'settings append target.source-map . "%s" . "%s" . "%s"' % (invalid_path, src_dir, invalid_path2),
|
||||
substrs=[
|
||||
'error: the replacement path doesn\'t exist: "%s"' % (invalid_path),
|
||||
'the replacement path doesn\'t exist: "%s"' % (invalid_path2),
|
||||
],
|
||||
error=True,
|
||||
)
|
||||
self.expect(
|
||||
'settings show target.source-map',
|
||||
substrs=[
|
||||
'[0] "." -> "%s"' % (src_dir),
|
||||
]
|
||||
)
|
||||
assertBreakpointWithSourceMap(src_path)
|
||||
|
||||
Reference in New Issue
Block a user