public void RegistrarTime(MTouchRegistrar registrarMode) { using (var buildTool = new MTouchTool()) { var registrarModeName = Enum.GetName(typeof(MTouchRegistrar), registrarMode); buildTool.Profile = profile; buildTool.Registrar = registrarMode; buildTool.NoFastSim = true; buildTool.CreateTemporaryApp(true, "RegistrarTime" + registrarModeName + profile); var sw = new Stopwatch(); sw.Start(); buildTool.Execute(MTouchAction.BuildSim); sw.Stop(); var buildTime = sw.Elapsed.TotalSeconds; var launchTool = new MLaunchTool(); launchTool.AppPath = buildTool.AppPath; launchTool.Profile = profile; sw.Reset(); sw.Start(); launchTool.Execute(); sw.Stop(); var launchTime = sw.Elapsed.TotalSeconds; var totalTime = buildTime + launchTime; sb.AppendLine(string.Format("RegistrarTime - {0}: {1} seconds [build time], {2} seconds [launch time], {3} seconds [total time]", registrarModeName, buildTime.ToString("#.000"), launchTime.ToString("#.000"), totalTime.ToString("#.000"))); } }
public TimingTests(MTouch.Profile profile) { this.profile = profile; // Create dummy app to initialize the simulator. using (var buildTool = new MTouchTool()) { buildTool.Profile = profile; buildTool.CreateTemporaryApp(true); buildTool.Execute(MTouchAction.BuildSim); var mlaunch = new MLaunchTool(); mlaunch.AppPath = buildTool.AppPath; mlaunch.Profile = profile; mlaunch.Execute(); } }
public void PreserveParameterInfoInXml() { using (var mtouch = new MTouchTool()) { var xml = Path.Combine(mtouch.CreateTemporaryDirectory(), "extra.xml"); File.WriteAllText(xml, @" <linker> <assembly fullname=""mscorlib""> <type fullname=""System.Reflection.ParameterInfo"" /> </assembly> </linker>"); mtouch.Linker = MTouchLinker.LinkAll; mtouch.XmlDefinitions = new string [] { xml }; mtouch.CreateTemporaryApp(); mtouch.AssertExecute(MTouchAction.BuildSim, "build"); } }
public void AppLaunchTime() { using (var buildTool = new MTouchTool()) { buildTool.Profile = profile; buildTool.CreateTemporaryApp(profile, true, "AppLaunchTime" + profile); buildTool.Execute(MTouchAction.BuildSim); var sw = new Stopwatch(); var launchTool = new MLaunchTool(); launchTool.AppPath = buildTool.AppPath; launchTool.Profile = profile; sw.Start(); launchTool.Execute(); sw.Stop(); Console.WriteLine("TimingTests - AppLaunchTime ({0}): {1} seconds", profile, sw.Elapsed.TotalSeconds.ToString("#.000")); } }
public void PublicSymbols(Profile profile) { var paths = new HashSet <string> (); if (Configuration.include_device) { paths.UnionWith(Directory.GetFileSystemEntries(Configuration.GetSdkPath(profile, true), "*.a", SearchOption.AllDirectories)); } paths.UnionWith(Directory.GetFileSystemEntries(Configuration.GetSdkPath(profile, false), "*.a", SearchOption.AllDirectories)); var failed = new StringBuilder(); var prefixes = new string [] { // xamarin-macios "_xamarin_", "_monotouch_", "_monomac_", "_OBJC_METACLASS_$_Xamarin", "_OBJC_CLASS_$_Xamarin", "_OBJC_IVAR_$_Xamarin", "__ZN13XamarinObject", "__ZN16XamarinCallState", ".objc_class_name_Xamarin", // 32-bit macOS naming scheme ".objc_category_name_NSObject_NonXamarinObject", // 32-bit macOS naming scheme "_main", // I think these are inline functions from a header "__Z7isasciii", "__Z7isblanki", "__Z7isdigiti", "__Z8__istypeim", "__Z9__isctypeim", // mono "_mono_", "_monoeg_", "_eg_", "_mini_", "_proflog_", "_ves_icall_", "___mono_jit_", "_sdb_options", "_SystemNative_", "_NetSecurityNative_", "_Brotli", "_kStaticDictionaryHash", "_MapHardwareType", "_gateway_from_rtm", "_sgen_", "_arm_patch", // These aren't public in a way we care about "l_OBJC_LABEL_PROTOCOL_$_", "__OBJC_LABEL_PROTOCOL_$_", // Xcode 11 b1 format "l_OBJC_PROTOCOL_$_", "__OBJC_PROTOCOL_$_", // Xcode 11 b1 format // block stuff, automatically exported by clang "___block_descriptor_", "___copy_helper_block_", "___destroy_helper_block_", // compiler-generated helper methods "___os_log_helper_", }; paths.RemoveWhere((v) => { var file = Path.GetFileName(v); switch (file) { case "libxammac-classic.a": case "libxammac-classic-debug.a": case "libxammac-system-classic.a": case "libxammac-system-classic-debug.a": return(true); } return(false); }); foreach (var path in paths) { var symbols = MTouchTool.GetNativeSymbolsInExecutable(path, arch: "all"); // Remove known public symbols symbols = symbols.Where((v) => { foreach (var prefix in prefixes) { if (v.StartsWith(prefix, StringComparison.Ordinal)) { return(false); } } // zlib-helper symbols switch (v) { case "_CloseZStream": case "_CreateZStream": case "_Flush": case "_ReadZStream": case "_WriteZStream": return(false); // Helper objc_msgSend functions for arm64 case "_objc_msgSend_stret": case "_objc_msgSendSuper_stret": return(false); } // Be a bit more lenient with symbols from the static registrar if (path.Contains(".registrar.")) { if (v.StartsWith("_OBJC_CLASS_$", StringComparison.Ordinal)) { return(false); } if (v.StartsWith("_OBJC_IVAR_$", StringComparison.Ordinal)) { return(false); } if (v.StartsWith("_OBJC_METACLASS_$", StringComparison.Ordinal)) { return(false); } // 32-bit macOS naming scheme: if (v.StartsWith(".objc_class_name_", StringComparison.Ordinal)) { return(false); } if (v.StartsWith(".objc_category_name_", StringComparison.Ordinal)) { return(false); } } return(true); }); // If there are any public symbols left, that's a problem so fail the test. if (symbols.Any()) { failed.AppendLine($"{path}:\n\t{string.Join ("\n\t", symbols.ToArray ())}"); } } Assert.IsEmpty(failed.ToString(), "Failed libraries"); }
public void PublicSymbols(Profile profile) { var paths = new HashSet <string> (); if (Configuration.include_device) { paths.UnionWith(Directory.GetFileSystemEntries(Configuration.GetSdkPath(profile, true), "*.a", SearchOption.AllDirectories)); } paths.UnionWith(Directory.GetFileSystemEntries(Configuration.GetSdkPath(profile, false), "*.a", SearchOption.AllDirectories)); var failed = new StringBuilder(); var prefixes = new string [] { // xamarin-macios "_xamarin_", "_monotouch_", "_monomac_", "_OBJC_METACLASS_$_Xamarin", "_OBJC_CLASS_$_Xamarin", "_OBJC_IVAR_$_Xamarin", "__ZN13XamarinObject", "_main", // I think these are inline functions from a header "__Z7isasciii", "__Z7isblanki", "__Z7isdigiti", "__Z8__istypeim", "__Z9__isctypeim", // mono "_mono_", "_monoeg_", "_eg_", "_mini_", "_proflog_", "_ves_icall_", "___mono_jit_", "_sdb_options", "_SystemNative_", "_MapHardwareType", "_gateway_from_rtm", "_sgen_", "_arm_patch", "_g_printv", // These two aren't public in a way we care about "l_OBJC_LABEL_PROTOCOL_$_", "l_OBJC_PROTOCOL_$_", }; paths.RemoveWhere((v) => { var file = Path.GetFileName(v); switch (file) { case "libxammac-classic.a": case "libxammac-classic-debug.a": case "libxammac-system-classic.a": case "libxammac-system-classic-debug.a": return(true); } return(false); }); foreach (var path in paths) { var symbols = MTouchTool.GetNativeSymbolsInExecutable(path); // Remove known public symbols symbols = symbols.Where((v) => { foreach (var prefix in prefixes) { if (v.StartsWith(prefix, StringComparison.Ordinal)) { return(false); } } // zlib-helper symbols switch (v) { case "_CloseZStream": case "_CreateZStream": case "_Flush": case "_ReadZStream": case "_WriteZStream": return(false); } // Be a bit more lenient with symbols from the static registrar if (path.Contains(".registrar.")) { if (v.StartsWith("_OBJC_CLASS_$", StringComparison.Ordinal)) { return(false); } if (v.StartsWith("_OBJC_IVAR_$", StringComparison.Ordinal)) { return(false); } if (v.StartsWith("_OBJC_METACLASS_$", StringComparison.Ordinal)) { return(false); } } return(true); }); // If there are any public symbols left, that's a problem so fail the test. if (symbols.Any()) { failed.AppendLine($"{path}:\n\t{string.Join ("\n\t", symbols.ToArray ())}"); } } Assert.IsEmpty(failed.ToString(), "Failed libraries"); }