コード例 #1
0
ファイル: SysVPlatformTests.cs プロジェクト: xxtxiaofeng/reko
        public void SysV_TerminatingFunction()
        {
            cfgSvc.Setup(c => c.GetInstallationRelativePath("libc.xml"))
            .Returns("libc.xml");

            var env = new PlatformDefinition
            {
                TypeLibraries =
                {
                    new TypeLibraryDefinition
                    {
                        Name = "libc.xml"
                    }
                },
                CharacteristicsLibraries =
                {
                    new TypeLibraryDefinition
                    {
                        Name = "libcharacteristics.xml",
                    }
                }
            };

            Given_EnvironmentConfiguration(env);
            tlSvc.Setup(t => t.LoadCharacteristics(It.IsAny <string>()))
            .Returns(new CharacteristicsLibrary
            {
                Entries =
                {
                    {
                        "exit",
                        new ProcedureCharacteristics {
                            Terminates = true
                        }
                    }
                }
            });
            tlSvc.Setup(t => t.LoadMetadataIntoLibrary(
                            It.IsAny <IPlatform>(),
                            It.IsAny <TypeLibraryDefinition>(),
                            It.IsAny <TypeLibrary>()))
            .Returns(new TypeLibrary
            {
                Signatures =
                {
                    {
                        "exit",
                        new FunctionType()
                    }
                }
            });

            var sysv = new SysVPlatform(sc, arch.Object);
            var proc = sysv.LookupProcedureByName(null, "exit");

            Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating.");
        }
コード例 #2
0
        public void SysV_TerminatingFunction()
        {
            cfgSvc.Stub(c => c.GetInstallationRelativePath("libc.xml"))
            .Return("libc.xml");

            var env = new OperatingEnvironmentElement
            {
                TypeLibraries =
                {
                    new TypeLibraryElement
                    {
                        Name = "libc.xml"
                    }
                },
                CharacteristicsLibraries =
                {
                    new TypeLibraryElement
                    {
                        Name = "libcharacteristics.xml",
                    }
                }
            };

            Given_EnvironmentConfiguration(env);
            tlSvc.Stub(t => t.LoadCharacteristics(null))
            .IgnoreArguments()
            .Return(new CharacteristicsLibrary
            {
                Entries =
                {
                    {
                        "exit",
                        new ProcedureCharacteristics {
                            Terminates = true
                        }
                    }
                }
            });
            tlSvc.Stub(t => t.LoadMetadataIntoLibrary(null, null, null))
            .IgnoreArguments()
            .Return(new TypeLibrary
            {
                Signatures =
                {
                    {
                        "exit",
                        new FunctionType()
                    }
                }
            });
            mr.ReplayAll();

            var sysv = new SysVPlatform(sc, arch);
            var proc = sysv.LookupProcedureByName(null, "exit");

            Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating.");
        }
コード例 #3
0
        public void SysV_TerminatingFunction()
        {
            var mr     = new MockRepository();
            var sc     = new ServiceContainer();
            var arch   = mr.Stub <IProcessorArchitecture>();
            var tlSvc  = mr.Stub <ITypeLibraryLoaderService>();
            var cfgSvc = mr.Stub <IConfigurationService>();

            sc.AddService <IConfigurationService>(cfgSvc);
            sc.AddService <ITypeLibraryLoaderService>(tlSvc);
            cfgSvc.Stub(c => c.GetEnvironment(null))
            .IgnoreArguments()
            .Return(new OperatingEnvironmentElement
            {
                TypeLibraries =
                {
                    new TypeLibraryElement
                    {
                        Name = "libc.xml"
                    }
                },
                CharacteristicsLibraries =
                {
                    new TypeLibraryElement
                    {
                        Name = "libcharacteristics.xml",
                    }
                }
            });
            tlSvc.Stub(t => t.LoadCharacteristics(null))
            .IgnoreArguments()
            .Return(new CharacteristicsLibrary
            {
                Entries =
                {
                    {
                        "exit",
                        new ProcedureCharacteristics {
                            Terminates = true
                        }
                    }
                }
            });
            tlSvc.Stub(t => t.LoadLibrary(null, null))
            .IgnoreArguments()
            .Return(new TypeLibrary
            {
                Signatures =
                {
                    {
                        "exit",
                        new ProcedureSignature(null)
                    }
                }
            });
            mr.ReplayAll();

            var sysv = new SysVPlatform(sc, arch);
            var proc = sysv.LookupProcedureByName(null, "exit");

            Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating.");
        }