mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-17 19:06:05 +00: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
34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
"""
|
|
Test lldb-mi =library-loaded notifications.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
|
|
import use_lldb_suite
|
|
|
|
import lldbmi_testcase
|
|
from lldbsuite.test.lldbtest import *
|
|
|
|
class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
@skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
|
|
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
|
|
def test_lldbmi_library_loaded(self):
|
|
"""Test that 'lldb-mi --interpreter' shows the =library-loaded notifications."""
|
|
|
|
self.spawnLldbMi(args = None)
|
|
|
|
# Load executable
|
|
self.runCmd("-file-exec-and-symbols %s" % self.myexe)
|
|
self.expect("\^done")
|
|
|
|
# Test =library-loaded
|
|
import os
|
|
path = os.path.join(os.getcwd(), self.myexe)
|
|
symbols_path = os.path.join(path + ".dSYM", "Contents", "Resources", "DWARF", self.myexe)
|
|
def add_slashes(x): return x.replace("\\", "\\\\").replace("\"", "\\\"").replace("\'", "\\\'").replace("\0", "\\\0")
|
|
self.expect([ "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"1\",symbols-path=\"%s\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path), add_slashes(symbols_path)),
|
|
"=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"0\",loaded_addr=\"-\",size=\"[0-9]+\"" % (add_slashes(path), add_slashes(path), add_slashes(path)) ])
|