Files
clang-p2996/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
Jordan Rupprecht 99451b4453 [lldb][test] Remove symlink for API tests.
Summary: Moves lldbsuite tests to lldb/test/API.

This is a largely mechanical change, moved with the following steps:

```
rm lldb/test/API/testcases
mkdir -p lldb/test/API/{test_runner/test,tools/lldb-{server,vscode}}
mv lldb/packages/Python/lldbsuite/test/test_runner/test lldb/test/API/test_runner
for d in $(find lldb/packages/Python/lldbsuite/test/* -maxdepth 0 -type d | egrep -v "make|plugins|test_runner|tools"); do mv $d lldb/test/API; done
for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-vscode -maxdepth 1 -mindepth 1 | grep -v ".py"); do mv $d lldb/test/API/tools/lldb-vscode; done
for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-server -maxdepth 1 -mindepth 1 | egrep -v "gdbremote_testcase.py|lldbgdbserverutils.py|socket_packet_pump.py"); do mv $d lldb/test/API/tools/lldb-server; done
```

lldb/packages/Python/lldbsuite/__init__.py and lldb/test/API/lit.cfg.py were also updated with the new directory structure.

Reviewers: labath, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71151
2020-02-11 10:03:53 -08:00

119 lines
4.1 KiB
Python

"""Test for the JITLoaderGDB interface"""
import unittest2
import os
import lldb
from lldbsuite.test import lldbutil
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
file_index = 0
class JITLoaderGDBTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipTestIfFn(
lambda: "Skipped because the test crashes the test runner",
bugnumber="llvm.org/pr24702")
@unittest2.expectedFailure("llvm.org/pr24702")
def test_bogus_values(self):
"""Test that we handle inferior misusing the GDB JIT interface"""
self.build()
exe = self.getBuildArtifact("a.out")
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
# launch the process, do not stop at entry point.
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# The inferior will now pass bogus values over the interface. Make sure
# we don't crash.
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), 0)
def gen_log_file(self):
global file_index
++file_index
logfile = os.path.join(
self.getBuildDir(),
"jitintgdb-" + self.getArchitecture() + "-" +
str(file_index) + ".txt")
def cleanup():
if os.path.exists(logfile):
os.unlink(logfile)
self.addTearDownHook(cleanup)
return logfile
def test_jit_int_default(self):
self.expect("settings show plugin.jit-loader.gdb.enable",
substrs=["plugin.jit-loader.gdb.enable (enum) = default"])
@skipIfWindows # This test fails on Windows during C code build
def test_jit_int_on(self):
"""Tests interface with 'enable' settings 'on'"""
self.build()
exe = self.getBuildArtifact("simple")
logfile = self.gen_log_file()
self.runCmd("log enable -f %s lldb jit" % (logfile))
self.runCmd("settings set plugin.jit-loader.gdb.enable on")
def cleanup():
self.runCmd("log disable lldb")
self.runCmd("settings set plugin.jit-loader.gdb.enable default")
self.addTearDownHook(cleanup)
# launch the process
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), 0)
logcontent = ""
if os.path.exists(logfile):
logcontent = open(logfile).read()
self.assertIn(
"SetJITBreakpoint setting JIT breakpoint", logcontent)
@skipIfWindows # This test fails on Windows during C code build
def test_jit_int_off(self):
"""Tests interface with 'enable' settings 'off'"""
self.build()
exe = self.getBuildArtifact("simple")
logfile = self.gen_log_file()
self.runCmd("log enable -f %s lldb jit" % (logfile))
self.runCmd("settings set plugin.jit-loader.gdb.enable off")
def cleanup():
self.runCmd("log disable lldb")
self.runCmd("settings set plugin.jit-loader.gdb.enable default")
self.addTearDownHook(cleanup)
# launch the process
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), 0)
if os.path.exists(logfile):
logcontent = open(logfile).read()
self.assertNotIn(
"SetJITBreakpoint setting JIT breakpoint", logcontent)
else:
self.assertTrue(false)