brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 56e9868 Raw
60 lines · python
1"""Test the LLDB module cache funcionality for universal mach-o files."""2 3import glob4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8import os9import time10 11 12class ModuleCacheTestcaseUniversal(TestBase):13    def setUp(self):14        # Call super's setUp().15        TestBase.setUp(self)16        # Find the line number in a(int) to break at.17        self.cache_dir = os.path.join(self.getBuildDir(), "lldb-module-cache")18        # Set the lldb module cache directory to a directory inside the build19        # artifacts directory so no other tests are interfered with.20        self.runCmd(21            'settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)22        )23        self.runCmd("settings set symbols.enable-lldb-index-cache true")24 25    def get_module_cache_files(self, basename):26        module_file_glob = os.path.join(self.cache_dir, "llvmcache-*%s*" % (basename))27        return glob.glob(module_file_glob)28 29    # Doesn't depend on any specific debug information.30    @no_debug_info_test31    def test(self):32        """33        Test module cache functionality for a universal mach-o files.34 35        This will test that if we enable the module cache, we can create36        lldb module caches for each slice of a universal mach-o file and37        they will each have a unique directory.38        """39        exe_basename = "testit"40        src_dir = self.getSourceDir()41        yaml_path = os.path.join(src_dir, "universal.yaml")42        yaml_base, ext = os.path.splitext(yaml_path)43        exe = self.getBuildArtifact(exe_basename)44        self.yaml2obj(yaml_path, exe)45        self.assertTrue(os.path.exists(exe))46        # Create a module with no dependencies.47        self.runCmd("target create -d --arch x86_64 %s" % (exe))48        self.runCmd("image dump symtab %s" % (exe_basename))49        self.runCmd("target create -d --arch arm64 %s" % (exe))50        self.runCmd("image dump symtab %s" % (exe_basename))51 52        cache_files = self.get_module_cache_files(exe_basename)53 54        self.assertEqual(55            len(cache_files),56            2,57            "make sure there are two files in the module cache directory (%s) for %s"58            % (self.cache_dir, exe_basename),59        )60