1da816ca0SGreg Clayton"""Test the LLDB module cache funcionality for universal mach-o files.""" 2da816ca0SGreg Clayton 3da816ca0SGreg Claytonimport glob 4da816ca0SGreg Claytonimport lldb 5da816ca0SGreg Claytonfrom lldbsuite.test.decorators import * 6da816ca0SGreg Claytonfrom lldbsuite.test.lldbtest import * 7da816ca0SGreg Claytonfrom lldbsuite.test import lldbutil 8da816ca0SGreg Claytonimport os 9da816ca0SGreg Claytonimport time 10da816ca0SGreg Clayton 11da816ca0SGreg Clayton 12da816ca0SGreg Claytonclass ModuleCacheTestcaseUniversal(TestBase): 13da816ca0SGreg Clayton 14da816ca0SGreg Clayton def setUp(self): 15da816ca0SGreg Clayton # Call super's setUp(). 16da816ca0SGreg Clayton TestBase.setUp(self) 17da816ca0SGreg Clayton # Find the line number in a(int) to break at. 18da816ca0SGreg Clayton self.cache_dir = os.path.join(self.getBuildDir(), 'lldb-module-cache') 19da816ca0SGreg Clayton # Set the lldb module cache directory to a directory inside the build 20da816ca0SGreg Clayton # artifacts directory so no other tests are interfered with. 21da816ca0SGreg Clayton self.runCmd('settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)) 22da816ca0SGreg Clayton self.runCmd('settings set symbols.enable-lldb-index-cache true') 23da816ca0SGreg Clayton 24da816ca0SGreg Clayton def get_module_cache_files(self, basename): 25da816ca0SGreg Clayton module_file_glob = os.path.join(self.cache_dir, "llvmcache-*%s*" % (basename)) 26da816ca0SGreg Clayton return glob.glob(module_file_glob) 27da816ca0SGreg Clayton 28da816ca0SGreg Clayton 29da816ca0SGreg Clayton # Doesn't depend on any specific debug information. 30da816ca0SGreg Clayton @no_debug_info_test 31da816ca0SGreg Clayton def test(self): 32da816ca0SGreg Clayton """ 33da816ca0SGreg Clayton Test module cache functionality for a universal mach-o files. 34da816ca0SGreg Clayton 35da816ca0SGreg Clayton This will test that if we enable the module cache, we can create 36da816ca0SGreg Clayton lldb module caches for each slice of a universal mach-o file and 37da816ca0SGreg Clayton they will each have a unique directory. 38da816ca0SGreg Clayton """ 39da816ca0SGreg Clayton exe_basename = "testit" 402a844c88SGreg Clayton src_dir = self.getSourceDir() 412a844c88SGreg Clayton yaml_path = os.path.join(src_dir, "universal.yaml") 422a844c88SGreg Clayton yaml_base, ext = os.path.splitext(yaml_path) 43da816ca0SGreg Clayton exe = self.getBuildArtifact(exe_basename) 442a844c88SGreg Clayton self.yaml2obj(yaml_path, exe) 452a844c88SGreg Clayton self.assertTrue(os.path.exists(exe)) 46*7240436cSGabriel Ravier # Create a module with no dependencies. 47da816ca0SGreg Clayton self.runCmd('target create -d --arch x86_64 %s' % (exe)) 48da816ca0SGreg Clayton self.runCmd('image dump symtab %s' % (exe_basename)) 49da816ca0SGreg Clayton self.runCmd('target create -d --arch arm64 %s' % (exe)) 50da816ca0SGreg Clayton self.runCmd('image dump symtab %s' % (exe_basename)) 51da816ca0SGreg Clayton 52da816ca0SGreg Clayton cache_files = self.get_module_cache_files(exe_basename) 53da816ca0SGreg Clayton 54da816ca0SGreg Clayton self.assertEqual(len(cache_files), 2, 55da816ca0SGreg Clayton "make sure there are two files in the module cache directory (%s) for %s" % (self.cache_dir, exe_basename)) 56