2 Test some lldb command abbreviations.
10 from lldbsuite
.test
.decorators
import *
11 from lldbsuite
.test
.lldbtest
import *
12 from lldbsuite
.test
import lldbutil
13 from lldbsuite
.test
import lldbplatformutil
16 class TestPaths(TestBase
):
19 """Test to make sure no file names are set in the lldb.SBFileSpec objects returned by lldb.SBHostOS.GetLLDBPath() for paths that are directories"""
21 lldb
.ePathTypeLLDBShlibDir
,
22 lldb
.ePathTypeSupportExecutableDir
,
23 lldb
.ePathTypeHeaderDir
,
24 lldb
.ePathTypePythonDir
,
25 lldb
.ePathTypeLLDBSystemPlugins
,
26 lldb
.ePathTypeLLDBUserPlugins
,
27 lldb
.ePathTypeLLDBTempSystemDir
,
28 lldb
.ePathTypeClangDir
,
31 for path_type
in dir_path_types
:
32 f
= lldb
.SBHostOS
.GetLLDBPath(path_type
)
33 # No directory path types should have the filename set
34 self
.assertIsNone(f
.GetFilename())
36 shlib_dir
= lldb
.SBHostOS
.GetLLDBPath(lldb
.ePathTypeLLDBShlibDir
).GetDirectory()
37 if lldbplatformutil
.getHostPlatform() == "windows":
38 filenames
= ["liblldb.dll"]
39 elif lldbplatformutil
.getHostPlatform() == "macosx":
40 filenames
= ["LLDB", "liblldb.dylib"]
42 filenames
= ["liblldb.so"]
44 any([os
.path
.exists(os
.path
.join(shlib_dir
, f
)) for f
in filenames
]),
45 "shlib_dir = " + shlib_dir
,
49 def test_interpreter_info(self
):
50 info_sd
= self
.dbg
.GetScriptInterpreterInfo(
51 self
.dbg
.GetScriptingLanguage("python")
53 self
.assertTrue(info_sd
.IsValid())
54 stream
= lldb
.SBStream()
55 self
.assertSuccess(info_sd
.GetAsJSON(stream
))
56 info
= json
.loads(stream
.GetData())
57 prefix
= info
["prefix"]
58 self
.assertEqual(os
.path
.realpath(sys
.prefix
), os
.path
.realpath(prefix
))
60 os
.path
.realpath(os
.path
.join(info
["lldb-pythonpath"], "lldb")),
61 os
.path
.realpath(os
.path
.dirname(lldb
.__file
__)),
63 self
.assertTrue(os
.path
.exists(info
["executable"]))
64 self
.assertEqual(info
["language"], "python")
67 def test_directory_doesnt_end_with_slash(self
):
68 current_directory_spec
= lldb
.SBFileSpec(os
.path
.curdir
)
69 current_directory_string
= current_directory_spec
.GetDirectory()
70 self
.assertNotEqual(current_directory_string
[-1:], "/")
72 @skipUnlessPlatform(["windows"])
74 def test_windows_double_slash(self
):
75 """Test to check the path with double slash is handled correctly"""
76 # Create a path and see if lldb gets the directory and file right
77 fspec
= lldb
.SBFileSpec("C:\\dummy1\\dummy2//unknown_file", True)
79 os
.path
.normpath(fspec
.GetDirectory()), os
.path
.normpath("C:/dummy1/dummy2")
81 self
.assertEqual(fspec
.GetFilename(), "unknown_file")