-
Notifications
You must be signed in to change notification settings - Fork 3
/
pytest_with_llvm.py
41 lines (32 loc) · 1.28 KB
/
pytest_with_llvm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
import time
import lldb
def test(debugger, command, result, internal_dict):
debugger.HandleCommand("settings set target.process.follow-fork-mode child")
target = debugger.CreateTargetWithFileAndArch("uv", lldb.LLDB_ARCH_DEFAULT)
process = target.LaunchSimple(
["run", "pytest", "tests/test_sora_disconnect.py", "-s"], None, None
)
if not process:
print("Error: could not launch process")
return
while True:
time.sleep(1.0)
state = process.GetState()
if state == lldb.eStateExited:
exit_status = process.GetExitStatus()
# debugger.HandleCommand(f"exit {exit_status}")
# sys.exit(exit_status)
debugger.HandleCommand("exit 0")
sys.exit(0)
elif state == lldb.eStateStopped:
thread = process.GetSelectedThread()
if thread.GetStopReason() == lldb.eStopReasonExec:
process.Continue()
continue
debugger.HandleCommand("bt all")
debugger.HandleCommand("exit 1")
sys.exit(1)
# LLDBにスクリプトを初期化してコマンドを追加
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("command script add -f test_with_llvm.test test")