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 with open(logfile, 'w') as f: 34 sbf = lldb.SBFile(f.fileno(), 'w', False) 35 status = self.dbg.SetErrorFile(sbf) 36 self.assertSuccess(status) 37 38 target, _, _, _ = lldbutil.run_to_source_breakpoint( 39 self, "break here", lldb.SBFileSpec("main.m")) 40 target.GetModuleAtIndex(0).FindTypes('my_int') 41 42 with open(logfile, 'r') as f: 43 for line in f: 44 if "hash mismatch" in line and "Foo" in line: 45 found = True 46 self.assertTrue(found) 47