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 @skipIf(debug_info=no_match(["gmodules"])) 16 def test_expr(self): 17 with open(self.getBuildArtifact("module.modulemap"), "w") as f: 18 f.write(""" 19 module Foo { header "f.h" } 20 """) 21 with open(self.getBuildArtifact("f.h"), "w") as f: 22 f.write(""" 23 typedef int my_int; 24 void f() {} 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 if configuration.is_reproducer_replay(): 35 logfile = self.getReproducerRemappedPath(logfile) 36 self.runCmd("log enable -v -f %s lldb host" % logfile) 37 target, _, _, _ = lldbutil.run_to_source_breakpoint( 38 self, "break here", lldb.SBFileSpec("main.m")) 39 target.GetModuleAtIndex(0).FindTypes('my_int') 40 41 found = False 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