brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · afa97cf Raw
63 lines · python
1import lldb2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5 6import gc7import os8 9 10class ReplaceDllTestCase(TestBase):11    @skipUnlessWindows12    def test(self):13        """14        Test that LLDB unlocks module files once all references are released.15        """16 17        exe = self.getBuildArtifact("a.out")18        foo = self.getBuildArtifact("foo.dll")19        bar = self.getBuildArtifact("bar.dll")20 21        self.build(22            dictionary={23                "DYLIB_NAME": "foo",24                "DYLIB_C_SOURCES": "foo.c",25                "C_SOURCES": "test.c",26            }27        )28        self.build(29            dictionary={30                "DYLIB_ONLY": "YES",31                "DYLIB_NAME": "bar",32                "DYLIB_C_SOURCES": "bar.c",33            }34        )35 36        target = self.dbg.CreateTarget(exe)37        self.assertTrue(target, VALID_TARGET)38 39        shlib_names = ["foo"]40        environment = self.registerSharedLibrariesWithTarget(target, shlib_names)41        process = target.LaunchSimple(42            None, environment, self.get_process_working_directory()43        )44        self.assertEqual(process.GetExitStatus(), 42)45 46        module = next((m for m in target.modules if "foo" in m.file.basename), None)47        self.assertIsNotNone(module)48        self.assertEqual(module.file.fullpath, foo)49 50        target.RemoveModule(module)51        del module52        gc.collect()53 54        self.dbg.MemoryPressureDetected()55 56        os.remove(foo)57        os.rename(bar, foo)58 59        process = target.LaunchSimple(60            None, environment, self.get_process_working_directory()61        )62        self.assertEqual(process.GetExitStatus(), 43)63