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