mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-21 20:45:53 -04:00

For convenience, we had added the folder that dotest.py was in to sys.path, so that we could easily write things like `import lldbutil` from anywhere and any test. This introduces a subtle problem when using Python's package system, because when unittest2 imports a particular test suite, the test suite is detached from the package. Thus, writing "import lldbutil" from dotest imports it as part of the package, and writing the same line from a test does a fresh import since the importing module was not part of the same package. The real way to fix this is to use absolute imports everywhere. Instead of writing "import lldbutil", we need to write "import lldbsuite.test.util". This patch fixes up that and all other similar cases, and additionally removes the script directory from sys.path to ensure that this can't happen again. llvm-svn: 251886
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
"""
|
|
Test that plugins that load commands work correctly.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
|
|
import use_lldb_suite
|
|
|
|
import os, time
|
|
import re
|
|
import lldb
|
|
from lldbsuite.test.lldbtest import *
|
|
import lldbsuite.test.lldbutil as lldbutil
|
|
|
|
class PluginCommandTestCase(TestBase):
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
@skipIfNoSBHeaders
|
|
@skipIfHostIncompatibleWithRemote # Requires a compatible arch and platform to link against the host's built lldb lib.
|
|
@expectedFailureWindows("llvm.org/pr24778")
|
|
@no_debug_info_test
|
|
def test_load_plugin(self):
|
|
"""Test that plugins that load commands work correctly."""
|
|
|
|
plugin_name = "plugin"
|
|
if sys.platform.startswith("darwin"):
|
|
plugin_lib_name = "lib%s.dylib" % plugin_name
|
|
else:
|
|
plugin_lib_name = "lib%s.so" % plugin_name
|
|
|
|
# Invoke the library build rule.
|
|
self.buildLibrary("plugin.cpp", plugin_name)
|
|
|
|
debugger = lldb.SBDebugger.Create()
|
|
|
|
retobj = lldb.SBCommandReturnObject()
|
|
|
|
retval = debugger.GetCommandInterpreter().HandleCommand("plugin load %s" % plugin_lib_name, retobj)
|
|
|
|
retobj.Clear()
|
|
|
|
retval = debugger.GetCommandInterpreter().HandleCommand("plugin_loaded_command child abc def ghi",retobj)
|
|
|
|
if self.TraceOn():
|
|
print(retobj.GetOutput())
|
|
|
|
self.expect(retobj,substrs = ['abc def ghi'], exe=False)
|
|
|
|
retobj.Clear()
|
|
|
|
# check that abbreviations work correctly in plugin commands.
|
|
retval = debugger.GetCommandInterpreter().HandleCommand("plugin_loaded_ ch abc def ghi",retobj)
|
|
|
|
if self.TraceOn():
|
|
print(retobj.GetOutput())
|
|
|
|
self.expect(retobj,substrs = ['abc def ghi'], exe=False)
|