示例#1
0
        public void GetAndApplyPlaceholderProperties(ulong fileBaseAddress)
        {
            long slide = (long)BASE_LOAD_ADDRESS - (long)fileBaseAddress;

            SbModule placeholderModule = CreatePlaceholderModule();

            var headerAddress = Substitute.For <SbAddress>();

            headerAddress.GetFileAddress().Returns(fileBaseAddress);

            var containerSection = Substitute.For <SbSection>();

            containerSection.GetSectionType().Returns(SectionType.Container);

            var otherModule = Substitute.For <SbModule>();

            otherModule.GetObjectFileHeaderAddress().Returns(headerAddress);
            otherModule.SetPlatformFileSpec(Arg.Any <SbFileSpec>()).Returns(true);

            PlaceholderModuleProperties properties =
                moduleUtil.GetPlaceholderProperties(placeholderModule, mockTarget);

            Assert.IsNotNull(properties);
            Assert.AreEqual(slide + (long)fileBaseAddress, properties.Slide);
            Assert.AreEqual(mockPlatformFileSpec, properties.PlatformFileSpec);

            Assert.True(
                moduleUtil.ApplyPlaceholderProperties(otherModule, properties, mockTarget));

            otherModule.Received().SetPlatformFileSpec(mockPlatformFileSpec);
            mockTarget.Received().SetModuleLoadAddress(otherModule, slide);
        }
        public void SetUp()
        {
            searchLog = new StringWriter();

            mockTarget            = Substitute.For <RemoteTarget>();
            moduleReplacedHandler = Substitute.For <EventHandler <LldbModuleReplacedEventArgs> >();

            mockModuleFileFinder = Substitute.For <IModuleFileFinder>();
            mockModuleFileFinder.FindFileAsync(BINARY_FILENAME, UUID, false, searchLog)
            .Returns(Task.FromResult(PATH_IN_STORE));

            placeholderModule = Substitute.For <SbModule>();
            placeholderModule.GetPlatformFileSpec().GetFilename().Returns(BINARY_FILENAME);
            placeholderModule.GetUUIDString().Returns(UUID.ToString());

            placeholderProperties =
                new PlaceholderModuleProperties(MODULE_SLIDE, Substitute.For <SbFileSpec>());

            mockModuleUtil = Substitute.For <ILldbModuleUtil>();
            mockModuleUtil.IsPlaceholderModule(placeholderModule).Returns(true);
            mockModuleUtil.GetPlaceholderProperties(Arg.Any <SbModule>(), Arg.Any <RemoteTarget>())
            .ReturnsForAnyArgs(placeholderProperties);
            mockModuleUtil.ApplyPlaceholderProperties(
                Arg.Any <SbModule>(), Arg.Any <PlaceholderModuleProperties>(),
                Arg.Any <RemoteTarget>())
            .ReturnsForAnyArgs(true);


            binaryLoader = new BinaryLoader(mockModuleUtil, mockModuleFileFinder,
                                            mockTarget);
            binaryLoader.LldbModuleReplaced += moduleReplacedHandler;
        }
示例#3
0
        public void ApplyPlaceholderProperties_SetPlatformFileSpecFails()
        {
            var otherModule = Substitute.For <SbModule>();

            otherModule.SetPlatformFileSpec(Arg.Any <SbFileSpec>()).Returns(false);

            var placeholderProperties =
                new PlaceholderModuleProperties(MODULE_SLIDE, Substitute.For <SbFileSpec>());

            Assert.IsFalse(moduleUtil.ApplyPlaceholderProperties(
                               otherModule, placeholderProperties, mockTarget));

            var output = logSpy.GetOutput();

            Assert.That(output, Does.Contain("Failed to set file spec"));
        }
示例#4
0
        public void ApplyPlaceholderProperties_SetModuleLoadAddressFails()
        {
            var error = new SbErrorStub(false, "failorama");

            mockTarget.SetModuleLoadAddress(Arg.Any <SbModule>(), Arg.Any <long>()).Returns(error);

            var placeholderProperties =
                new PlaceholderModuleProperties(MODULE_SLIDE, Substitute.For <SbFileSpec>());

            Assert.IsFalse(moduleUtil.ApplyPlaceholderProperties(
                               Substitute.For <SbModule>(), placeholderProperties, mockTarget));

            var output = logSpy.GetOutput();

            Assert.That(output, Does.Contain("Failed to set load address"));
            Assert.That(output, Does.Contain(error.GetCString()));
        }