Jonas Devlieghere 2238dcc393
[NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python
code. Reformatting is done with `black` (23.1.0).

If you end up having problems merging this commit because you have made
changes to a python file, the best way to handle that is to run `git
checkout --ours <yourfile>` and then reformat it with black.

RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Differential revision: https://reviews.llvm.org/D151460
2023-05-25 12:54:09 -07:00

35 lines
1.1 KiB
Python

"""
Test that SBCompileUnit::FindLineEntryIndex works correctly.
"""
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
class FindLineEntry(TestBase):
def test_compile_unit_find_line_entry_index(self):
"""Test the CompileUnit LineEntryIndex lookup API"""
self.build()
exe = self.getBuildArtifact("a.out")
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target.IsValid(), "Target is not valid")
self.file = lldb.SBFileSpec("main.c")
sc_list = self.target.FindCompileUnits(self.file)
self.assertEqual(len(sc_list), 1)
cu = sc_list[0].GetCompileUnit()
self.assertTrue(cu.IsValid(), "CompileUnit is not valid")
# First look for valid line
self.line = line_number("main.c", "int change_me")
self.assertNotEqual(
cu.FindLineEntryIndex(0, self.line, self.file),
lldb.LLDB_INVALID_LINE_NUMBER,
)
# Then look for a line out of bound
self.assertEqual(
cu.FindLineEntryIndex(0, 42, self.file), lldb.LLDB_INVALID_LINE_NUMBER
)