1
2import unittest2
3import os
4import shutil
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class TestClangModuleHashMismatch(TestBase):
13
14    @skipIf(debug_info=no_match(["gmodules"]))
15    def test_expr(self):
16        with open(self.getBuildArtifact("module.modulemap"), "w") as f:
17            f.write("""
18                    module Foo { header "f.h" }
19                    """)
20        with open(self.getBuildArtifact("f.h"), "w") as f:
21            f.write("""
22                    typedef int my_int;
23                    void f() {}
24                    """)
25
26        mod_cache = self.getBuildArtifact("private-module-cache")
27        if os.path.isdir(mod_cache):
28          shutil.rmtree(mod_cache)
29        self.build()
30        self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
31
32        logfile = self.getBuildArtifact("host.log")
33        self.runCmd("log enable -v -f %s lldb host" % logfile)
34        target, _, _, _ = lldbutil.run_to_source_breakpoint(
35            self, "break here", lldb.SBFileSpec("main.m"))
36        target.GetModuleAtIndex(0).FindTypes('my_int')
37
38        found = False
39        with open(logfile, 'r') as f:
40            for line in f:
41                if "hash mismatch" in line and "Foo" in line:
42                    found = True
43        self.assertTrue(found)
44