brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 1661294 Raw
49 lines · python
1import os2import shutil3 4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class TestClangModuleHashMismatch(TestBase):11    @add_test_categories(["gmodules"])12    def test_expr(self):13        with open(self.getBuildArtifact("module.modulemap"), "w") as f:14            f.write(15                """16                    module Foo { header "f.h" }17                    """18            )19        with open(self.getBuildArtifact("f.h"), "w") as f:20            f.write(21                """22                    typedef int my_int;23                    void f() {}24                    """25            )26 27        mod_cache = self.getBuildArtifact("private-module-cache")28        if os.path.isdir(mod_cache):29            shutil.rmtree(mod_cache)30        self.build()31        self.assertTrue(os.path.isdir(mod_cache), "module cache exists")32 33        logfile = self.getBuildArtifact("host.log")34        with open(logfile, "w") as f:35            sbf = lldb.SBFile(f.fileno(), "w", False)36            status = self.dbg.SetErrorFile(sbf)37            self.assertSuccess(status)38 39            target, _, _, _ = lldbutil.run_to_source_breakpoint(40                self, "break here", lldb.SBFileSpec("main.m")41            )42            target.GetModuleAtIndex(0).FindTypes("my_int")43 44        with open(logfile, "r") as f:45            for line in f:46                if "hash mismatch" in line and "Foo" in line:47                    found = True48        self.assertTrue(found)49