コード例 #1
0
ファイル: PEReaderTests.cs プロジェクト: pgovind/runtime
        [PlatformSpecific(TestPlatforms.Windows)]  // Uses P/Invokes to get module handles
        public void GetMethodBody_Loaded()
        {
            LoaderUtilities.LoadPEAndValidate(Misc.Members, reader =>
            {
                var md = reader.GetMetadataReader();
                var il = reader.GetMethodBody(md.GetMethodDefinition(MetadataTokens.MethodDefinitionHandle(1)).RelativeVirtualAddress);

                Assert.Equal(new byte[] { 0, 42 }, il.GetILBytes());
                Assert.Equal(8, il.MaxStack);
            });
        }
コード例 #2
0
        public void TestRoboRioMapsToNativeAssemblySymbols()
        {
            OsType type = LoaderUtilities.GetOsType();

            //Only run the roboRIO symbol test on windows.
            if (type != OsType.Windows32 && type != OsType.Windows64)
            {
                Assert.Pass();
            }

            var roboRIOSymbols = GetRequestedNativeSymbols();

            var pathToSolution = FindRootSolutionDirectory();
            var ps             = Path.DirectorySeparatorChar;

            Assert.That(pathToSolution, Is.Not.Null);
            var dirToNetworkTablesLib = $"{pathToSolution}{ps}src{ps}FRC.NetworkTables.Core";

            // Start the child process.
            Process p = new Process();

            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.CreateNoWindow         = true;
            p.StartInfo.FileName = $"{dirToNetworkTablesLib}\\NativeLibraries\\roborio\\frcnm.exe";
            Console.WriteLine(p.StartInfo.FileName);
            p.StartInfo.Arguments = $"{dirToNetworkTablesLib}\\NativeLibraries\\roborio\\libntcore.so";
            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            p.WaitForExit();

            bool found = true;


            string[] nativeSymbols = output.Split('\r');

            foreach (var halSymbol in roboRIOSymbols)
            {
                bool foundSymbol = nativeSymbols.Any(nativeSymbol => nativeSymbol.EndsWith(halSymbol));
                if (!foundSymbol)
                {
                    found = false;
                    Console.WriteLine(halSymbol);
                }
            }

            Assert.That(found);
        }
コード例 #3
0
        public void TestRoboRioMapsToNativeAssemblySymbols()
        {
            OsType type = LoaderUtilities.GetOsType();

            //Only run the roboRIO symbol test on windows.
            if (type != OsType.Windows32 || type != OsType.Windows64)
            {
                Assert.Pass();
            }

            var roboRIOSymbols = GetRequestedNativeSymbols();

            // Start the child process.
            Process p = new Process();

            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = "..\\..\\NetworkTablesCore\\NativeLibraries\\roborio\\frcnm.exe";
            Console.WriteLine(p.StartInfo.FileName);
            p.StartInfo.Arguments = "..\\..\\NetworkTablesCore\\NativeLibraries\\roborio\\libHALAthena.so";
            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            p.WaitForExit();

            bool found = true;


            string[] nativeSymbols = output.Split('\r');

            foreach (var halSymbol in roboRIOSymbols)
            {
                bool foundSymbol = nativeSymbols.Any(nativeSymbol => nativeSymbol.EndsWith(halSymbol));
                if (!foundSymbol)
                {
                    found = false;
                    Console.WriteLine(halSymbol);
                }
            }

            Assert.That(found);
        }
コード例 #4
0
        public void TestNtConnectionInfo()
        {
            int numberNonChangingBytes = 16;
            int numberPointers         = 0;
            //Check for mac changes
            OsType type = LoaderUtilities.GetOsType();

            if (type == OsType.MacOs32 || type == OsType.MacOs64)
            {
                //No padding byte added on Mac OS X.
                numberPointers = 3;
            }
            else
            {
                //Padding pointer added on all other OS's
                numberPointers = 3 + 1;
            }
            int pointerSize = Marshal.SizeOf(typeof(IntPtr));

            int pointerTotal = numberPointers * pointerSize;

            Assert.That(Marshal.SizeOf(typeof(NtConnectionInfo)), Is.EqualTo(pointerTotal + numberNonChangingBytes));
            Assert.That(IsBlittable(typeof(NtConnectionInfo)));
        }
コード例 #5
0
ファイル: PEReaderTests.cs プロジェクト: pgovind/runtime
 [PlatformSpecific(TestPlatforms.Windows)]  // Uses P/Invokes to get module handles
 public void GetSectionData_Loaded()
 {
     LoaderUtilities.LoadPEAndValidate(Misc.Members, ValidateSectionData);
 }
コード例 #6
0
 public void Deterministic_Loaded()
 {
     LoaderUtilities.LoadPEAndValidate(Misc.Deterministic, ValidateDeterministic);
 }
コード例 #7
0
 public void CodeView_Loaded_FromStream()
 {
     LoaderUtilities.LoadPEAndValidate(Misc.Debug, ValidateCodeView, useStream: true);
 }
コード例 #8
0
 public void CodeView_Loaded()
 {
     LoaderUtilities.LoadPEAndValidate(Misc.Debug, ValidateCodeView);
 }
コード例 #9
0
 public void EmbeddedPortablePdb_Loaded_FromStream()
 {
     LoaderUtilities.LoadPEAndValidate(PortablePdbs.DocumentsEmbeddedDll, ValidateEmbeddedPortablePdb, useStream: true);
 }
コード例 #10
0
 public void EmbeddedPortablePdb_Loaded()
 {
     LoaderUtilities.LoadPEAndValidate(PortablePdbs.DocumentsEmbeddedDll, ValidateEmbeddedPortablePdb);
 }
コード例 #11
0
        public void TestNativeIntefaceBlittable()
        {
            OsType type = LoaderUtilities.GetOsType();

            //Only run the blittable test on windows. Pathing on linux is being an issue
            if (type != OsType.Windows32 && type != OsType.Windows64)
            {
                Assert.Pass();
            }

            List <string> allowedTypes = new List <string>()
            {
                // Allowed types with arrays are also allowed
                "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "IntPtr", "UIntPtr", "float", "void", "double",

                // For now force our enum types to be OK
                "NtType",
                //"CTR_Code", "HALAccelerometerRange", "HALAllianceStationID", "AnalogTriggerType", "Mode",

                //Allow delegates to be blittable
                "WarmFunction", "NT_LogFunc", "NT_ConnectionListenerCallback", "NT_EntryListenerCallback", "NT_RPCCallback",

                //Also allow any structs known to be blittable
                "NtStringRead", "NtStringWrite", "NtConnectionInfo", "NtRpcCallInfo",

                //For now allow bool, since it marshalls easily
                //This will change if the native windows HAL is not 1 byte bools
                "bool",
            };

            List <string> notBlittableMethods = new List <string>();


            var halBaseDelegates = GetDelegates();

            foreach (var halDelegate in halBaseDelegates)
            {
                foreach (var methodSyntax in halDelegate.Methods)
                {
                    List <TypeSyntax> types = new List <TypeSyntax>();

                    if (methodSyntax.AttributeLists.Count != 0)
                    {
                        types.Add(methodSyntax.ReturnType);
                    }
                    else
                    {
                        types.Add(methodSyntax.ReturnType);
                    }

                    List <string> param = new List <string>();

                    StringBuilder builder = new StringBuilder();
                    builder.Append($"\t {methodSyntax.ReturnType} {methodSyntax.Identifier} (");
                    bool first = true;
                    foreach (var parameter in methodSyntax.ParameterList.Parameters)
                    {
                        if (parameter.AttributeLists.Count != 0)
                        {
                            types.Add(parameter.Type);
                        }
                        else
                        {
                            types.Add(parameter.Type);
                        }


                        param.Add(parameter.Type.ToString());
                        if (first)
                        {
                            first = false;
                            builder.Append($"{parameter.Type} {parameter.Identifier}");
                        }
                        else
                        {
                            builder.Append($", {parameter.Type} {parameter.Identifier}");
                        }
                    }
                    builder.Append(")");

                    CheckForBlittable(types, allowedTypes, notBlittableMethods, builder.ToString());
                }
            }

            foreach (string s in notBlittableMethods)
            {
                Console.WriteLine(s);
            }

            if (notBlittableMethods.Count != 0)
            {
                Assert.Fail();
            }
            else
            {
                Assert.Pass();
            }
        }