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

57 lines
1.6 KiB
Python

"""
Test that LLDB can emit JIT objects when the appropriate setting is enabled
"""
import os
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class SaveJITObjectsTestCase(TestBase):
def enumerateJITFiles(self):
return [f for f in os.listdir(self.getBuildDir()) if f.startswith("jit")]
def countJITFiles(self):
return len(self.enumerateJITFiles())
def cleanJITFiles(self):
for j in self.enumerateJITFiles():
os.remove(j)
return
def test_save_jit_objects(self):
self.build()
os.chdir(self.getBuildDir())
src_file = "main.c"
src_file_spec = lldb.SBFileSpec(src_file)
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "break", src_file_spec
)
frame = thread.frames[0]
self.cleanJITFiles()
frame.EvaluateExpression("(void*)malloc(0x1)")
self.assertEquals(
self.countJITFiles(), 0, "No files emitted with save-jit-objects-dir empty"
)
self.runCmd(
"settings set target.save-jit-objects-dir {0}".format(self.getBuildDir())
)
frame.EvaluateExpression("(void*)malloc(0x1)")
jit_files_count = self.countJITFiles()
self.cleanJITFiles()
self.assertNotEqual(
jit_files_count,
0,
"At least one file emitted with save-jit-objects-dir set to the build dir",
)
process.Kill()
os.chdir(self.getSourceDir())