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 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 if configuration.is_reproducer_replay(): 36 logfile = self.getReproducerRemappedPath(logfile) 37 self.runCmd("log enable -v -f %s lldb host" % logfile) 38 target, _, _, _ = lldbutil.run_to_source_breakpoint( 39 self, "break here", lldb.SBFileSpec("main.m")) 40 target.GetModuleAtIndex(0).FindTypes('my_int') 41 42 found = False 43 with open(logfile, 'r') as f: 44 for line in f: 45 if "hash mismatch" in line and "Foo" in line: 46 found = True 47 self.assertTrue(found) 48