Пример #1
0
		List<string> GetFiledAOTed (AOTCompilerType compilerType = AOTCompilerType.Bundled64, AOTKind kind = AOTKind.Standard, bool isModern = false, bool expectStripping = false, bool expectSymbolDeletion = false)
		{
			List<string> filesAOTed = new List<string> (); 

			foreach (var command in commandsRun) {
				if (expectStripping && command.Item1 == AOTCompiler.StripCommand)
					continue;
				if (expectSymbolDeletion && command.Item1 == AOTCompiler.DeleteDebugSymbolCommand)
					continue;
				Assert.IsTrue (command.Item1.EndsWith (GetExpectedMonoCommand (compilerType)), "Unexpected command: " + command.Item1);
				var argParts = command.Item2;

				if (kind == AOTKind.Hybrid)
					Assert.AreEqual (argParts[0], "--aot=hybrid", "First arg should be --aot=hybrid");
				else
					Assert.AreEqual (argParts[0], "--aot", "First arg should be --aot");

				if (isModern)
					Assert.AreEqual (argParts[1], "--runtime=mobile", "Second arg should be --runtime=mobile");
				else
					Assert.AreNotEqual (argParts[1], "--runtime=mobile", "Second arg should not be --runtime=mobile");


				var fileName = command.Item2 [1];
				if (isModern)
					fileName = command.Item2 [2];

				filesAOTed.Add (fileName);
			}
			return filesAOTed;
		}
Пример #2
0
        public AOTOptions(string options)
        {
            // Syntax - all,core,sdk,none or "" if explicit then optional list of +/-'ed assemblies
            // Sections seperated by ,
            string [] optionParts = options.Split(',');
            for (int i = 0; i < optionParts.Length; ++i)
            {
                string option = optionParts [i];

                AOTKind kind = AOTKind.Default;
                // Technically '|' is valid in a file name, so |hybrid.dll would be as well.
                // So check the left hand side for a valid option and pass if not
                if (option.Contains("|"))
                {
                    string [] optionTypeParts = option.Split('|');
                    if (optionTypeParts.Length != 2)
                    {
                        throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
                    }
                    switch (optionTypeParts [0])
                    {
                    case "none":
                    case "core":
                    case "sdk":
                    case "all": {
                        option = optionTypeParts [0];
                        switch (optionTypeParts [1])
                        {
                        case "hybrid":
                            if (option != "all")
                            {
                                throw new MonoMacException(114, true, "Hybrid AOT compilation requires all assemblies to be AOT compiled");
                            }
                            kind = AOTKind.Hybrid;
                            break;

                        case "standard":
                            kind = AOTKind.Standard;
                            break;

                        default:
                            throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }

                switch (option)
                {
                case "none":
                    CompilationType = AOTCompilationType.None;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;

                case "all":
                    CompilationType = AOTCompilationType.All;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;

                case "sdk":
                    CompilationType = AOTCompilationType.SDK;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;

                case "core":
                    CompilationType = AOTCompilationType.Core;
                    if (kind != AOTKind.Default)
                    {
                        Kind = kind;
                    }
                    continue;
                }

                if (option.StartsWith("+", StringComparison.Ordinal))
                {
                    if (CompilationType == AOTCompilationType.Default)
                    {
                        CompilationType = AOTCompilationType.Explicit;
                    }
                    IncludedAssemblies.Add(option.Substring(1));
                    continue;
                }
                if (option.StartsWith("-", StringComparison.Ordinal))
                {
                    if (CompilationType == AOTCompilationType.Default)
                    {
                        CompilationType = AOTCompilationType.Explicit;
                    }
                    ExcludedAssemblies.Add(option.Substring(1));
                    continue;
                }
                throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
            }
            if (CompilationType == AOTCompilationType.Default)
            {
                throw new MonoMacException(20, true, "The valid options for '{0}' are '{1}'.", "--aot", "{none, all, core, sdk}{|hybrid}, then an optional explicit list of assemblies.");
            }
        }
Пример #3
0
		void AssertFilesAOTed (IEnumerable <string> expectedFiles, AOTCompilerType compilerType = AOTCompilerType.Bundled64, AOTKind kind = AOTKind.Standard, bool isModern = false, bool expectStripping = false, bool expectSymbolDeletion = false)
		{
			List<string> filesAOTed = GetFiledAOTed (compilerType, kind, isModern: isModern, expectStripping: expectStripping, expectSymbolDeletion : expectSymbolDeletion);

			Func<string> getErrorDetails = () => $"\n {FormatDebugList (filesAOTed)} \nvs\n {FormatDebugList (expectedFiles)}\n{AllCommandsRun}";

			Assert.AreEqual (filesAOTed.Count, expectedFiles.Count (), "Different number of files AOT than expected: " + getErrorDetails ());
			Assert.IsTrue (filesAOTed.All (x => expectedFiles.Contains (x)), "Different files AOT than expected: "  + getErrorDetails ());
		}
Пример #4
0
        List <string> GetFiledAOTed(AOTCompilerType compilerType = AOTCompilerType.Bundled64, AOTKind kind = AOTKind.Standard, bool isModern = false, bool expectStripping = false, bool expectSymbolDeletion = false)
        {
            List <string> filesAOTed = new List <string> ();

            foreach (var command in commandsRun)
            {
                if (expectStripping && command.Item1 == AOTCompiler.StripCommand)
                {
                    continue;
                }

                var          argParts  = command.Item2;
                const string aotArg    = "--aot=";
                const string tripleArg = "mtriple=";
                Assert.IsTrue(argParts [0].StartsWith(aotArg), $"First arg should be {aotArg}");
                var aotParts = argParts [0].Substring(aotArg.Length).Split(new char [] { ',' });
                Assert.IsTrue(aotParts [0].StartsWith(tripleArg), $"Aot first argument should be {tripleArg}triple");
                var triple = aotParts [0].Substring(tripleArg.Length);
                Assert.IsTrue(Enum.TryParse(triple, true, out Abi currAbi), "Triple does not represent a valid abi");

                Assert.IsTrue(command.Item1.EndsWith(GetExpectedMonoCommand(compilerType, currAbi)), "Unexpected command: " + command.Item1);
                if (kind == AOTKind.Hybrid)
                {
                    Assert.AreEqual(aotParts [1], "hybrid", "Aot arg should contain hybrid");
                }
                else if (aotParts.Length > 1)
                {
                    Assert.AreNotEqual(aotParts [1], "hybrid", "Aot arg should not contain hybrid");
                }

                if (isModern)
                {
                    Assert.AreEqual(argParts[1], "--runtime=mobile", "Second arg should be --runtime=mobile");
                }
                else
                {
                    Assert.AreNotEqual(argParts[1], "--runtime=mobile", "Second arg should not be --runtime=mobile");
                }


                var fileName = command.Item2 [1];
                if (isModern)
                {
                    fileName = command.Item2 [2];
                }

                filesAOTed.Add(fileName);
            }
            return(filesAOTed);
        }
Пример #5
0
        List <string> GetFiledAOTed(AOTCompilerType compilerType = AOTCompilerType.Bundled64, AOTKind kind = AOTKind.Standard, bool isModern = false, bool expectStripping = false, bool expectSymbolDeletion = false)
        {
            List <string> filesAOTed = new List <string> ();

            foreach (var command in commandsRun)
            {
                if (expectStripping && command.Item1 == AOTCompiler.StripCommand)
                {
                    continue;
                }
                if (expectSymbolDeletion && command.Item1 == AOTCompiler.DeleteDebugSymbolCommand)
                {
                    continue;
                }
                Assert.IsTrue(command.Item1.EndsWith(GetExpectedMonoCommand(compilerType)), "Unexpected command: " + command.Item1);
                string [] argParts = command.Item2.Split(' ');

                if (kind == AOTKind.Hybrid)
                {
                    Assert.AreEqual(argParts[0], "--aot=hybrid", "First arg should be --aot=hybrid");
                }
                else
                {
                    Assert.AreEqual(argParts[0], "--aot", "First arg should be --aot");
                }

                if (isModern)
                {
                    Assert.AreEqual(argParts[1], "--runtime=mobile", "Second arg should be --runtime=mobile");
                }
                else
                {
                    Assert.AreNotEqual(argParts[1], "--runtime=mobile", "Second arg should not be --runtime=mobile");
                }


                int fileNameBeginningIndex = command.Item2.IndexOf(' ') + 1;
                if (isModern)
                {
                    fileNameBeginningIndex = command.Item2.IndexOf(' ', fileNameBeginningIndex) + 1;
                }

                string fileName = command.Item2.Substring(fileNameBeginningIndex).Replace("\'", "");
                filesAOTed.Add(fileName);
            }
            return(filesAOTed);
        }
Пример #6
0
        List <string> GetFiledAOTed(AOTCompilerType compilerType = AOTCompilerType.Bundled64, AOTKind kind = AOTKind.Standard)
        {
            List <string> filesAOTed = new List <string> ();

            foreach (var command in commandsRun)
            {
                Assert.IsTrue(command.Item1.EndsWith(GetExpectedMonoCommand(compilerType)), "Unexpected command: " + command.Item1);
                if (kind == AOTKind.Hybrid)
                {
                    Assert.AreEqual(command.Item2.Split(' ')[0], "--aot=hybrid", "First arg should be --aot=hybrid");
                }
                else
                {
                    Assert.AreEqual(command.Item2.Split(' ')[0], "--aot", "First arg should be --aot");
                }

                string fileName = command.Item2.Substring(command.Item2.IndexOf(' ') + 1).Replace("\"", "");
                filesAOTed.Add(fileName);
            }
            return(filesAOTed);
        }
Пример #7
0
        void AssertFilesAOTed(IEnumerable <string> expectedFiles, AOTCompilerType compilerType = AOTCompilerType.Bundled64, AOTKind kind = AOTKind.Standard)
        {
            List <string> filesAOTed = GetFiledAOTed(compilerType, kind);

            Func <string> getErrorDetails = () => $"\n {String.Join (" ", filesAOTed)} \nvs\n {String.Join (" ", expectedFiles)}";

            Assert.AreEqual(filesAOTed.Count, expectedFiles.Count(), "Different number of files AOT than expected: " + getErrorDetails());
            Assert.IsTrue(filesAOTed.All(x => expectedFiles.Contains(x)), "Different files AOT than expected: " + getErrorDetails());
        }