1""" 2Test some lldb command abbreviations. 3""" 4 5 6import lldb 7import os 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class TestPaths(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 @no_debug_info_test 18 def test_paths(self): 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''' 20 dir_path_types = [lldb.ePathTypeLLDBShlibDir, 21 lldb.ePathTypeSupportExecutableDir, 22 lldb.ePathTypeHeaderDir, 23 lldb.ePathTypePythonDir, 24 lldb.ePathTypeLLDBSystemPlugins, 25 lldb.ePathTypeLLDBUserPlugins, 26 lldb.ePathTypeLLDBTempSystemDir, 27 lldb.ePathTypeClangDir] 28 29 for path_type in dir_path_types: 30 f = lldb.SBHostOS.GetLLDBPath(path_type) 31 # No directory path types should have the filename set 32 self.assertTrue(f.GetFilename() is None) 33 34 @no_debug_info_test 35 def test_directory_doesnt_end_with_slash(self): 36 current_directory_spec = lldb.SBFileSpec(os.path.curdir) 37 current_directory_string = current_directory_spec.GetDirectory() 38 self.assertNotEqual(current_directory_string[-1:], '/') 39 40 @skipUnlessPlatform(["windows"]) 41 @no_debug_info_test 42 def test_windows_double_slash(self): 43 '''Test to check the path with double slash is handled correctly ''' 44 # Create a path and see if lldb gets the directory and file right 45 fspec = lldb.SBFileSpec("C:\\dummy1\\dummy2//unknown_file", True) 46 self.assertEqual( 47 os.path.normpath( 48 fspec.GetDirectory()), 49 os.path.normpath("C:/dummy1/dummy2")) 50 self.assertEqual(fspec.GetFilename(), "unknown_file") 51