From f91e8fb811f695b419689870b3d3fefbba3482cd Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 20 Nov 2018 12:14:16 -0500 Subject: [PATCH 01/15] Use a full path to xibuild. (#5140) * Use a full path to xibuild. Use a full path to xibuild everywhere, since it's easier than making sure PATH is correct every time we want to invoke xibuild. Also remove the xbuild-in-place script, it's not used anymore. * Fix xibuild path lookup. * [xammac_tests] Remove unneeded csproj changes. --- .../ProjectsTests/ProjectReference.cs | 2 +- msbuild/xbuild-in-place | 19 ------------------- tests/Makefile | 2 -- tests/common/Configuration.cs | 6 ++++++ tests/common/ExecutionHelper.cs | 4 ++-- tests/common/mac/ProjectTestHelpers.cs | 6 +++--- tests/xammac_tests/xammac_tests.csproj | 8 ++++++-- tests/xharness/Harness.cs | 4 ++++ tests/xharness/Jenkins.cs | 6 +++--- 9 files changed, 25 insertions(+), 32 deletions(-) delete mode 100755 msbuild/xbuild-in-place diff --git a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectReference.cs b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectReference.cs index e6a3af90b5f2..90435c54e458 100644 --- a/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectReference.cs +++ b/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/ProjectReference.cs @@ -32,7 +32,7 @@ public void BasicTest () NugetRestore ("../MyExtensionWithPackageReference/MyExtensionWithPackageReference.csproj"); // Can't use the in-process MSBuild engine, because it complains that the project file is invalid (the attribute 'Version' in the element '' is unrecognized) - var rv = ExecutionHelper.Execute ("xibuild", $"-- ../MyAppWithPackageReference/MyAppWithPackageReference.csproj /p:Platform={Platform} /p:Configuration=Debug", out var output); + var rv = ExecutionHelper.Execute (Configuration.XIBuildPath, $"-- ../MyAppWithPackageReference/MyAppWithPackageReference.csproj /p:Platform={Platform} /p:Configuration=Debug", out var output); if (rv != 0) { Console.WriteLine ("Build failed:"); Console.WriteLine (output); diff --git a/msbuild/xbuild-in-place b/msbuild/xbuild-in-place deleted file mode 100755 index 9836ca0cee9e..000000000000 --- a/msbuild/xbuild-in-place +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -self="$(dirname "$0")" -build_in_place_dir="$(python -c "import os; print os.path.realpath('$self/../_mac-build')")" -xammac_framework_dir="$build_in_place_dir/Library/Frameworks/Xamarin.Mac.framework/Versions/Current" -xbuild_external_dir="$build_in_place_dir/Library/Frameworks/Mono.framework/External" - -export TargetFrameworkFallbackSearchPaths="$xbuild_external_dir/xbuild-frameworks" -export MSBuildExtensionsPathFallbackPathsOverride="$xbuild_external_dir/xbuild" - -XamarinMacFrameworkRoot="$xammac_framework_dir" -TargetFrameworkIdentifier=Xamarin.Mac -TargetFrameworkVersion=v2.0 - -$(self)/../tools/xibuild/bin/Debug/xibuild.exe -- \ - /property:XamarinMacFrameworkRoot="$XamarinMacFrameworkRoot" \ - /property:TargetFrameworkIdentifier="$TargetFrameworkIdentifier" \ - /property:TargetFrameworkVersion="$TargetFrameworkVersion" \ - "$@" diff --git a/tests/Makefile b/tests/Makefile index 1be1d6a7e120..5901c99e97ce 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -47,8 +47,6 @@ export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Framewo export XAMMAC_FRAMEWORK_PATH=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current export XamarinMacFrameworkRoot=$(MAC_DESTDIR)/Library/Frameworks/Xamarin.Mac.framework/Versions/Current -export PATH := $(abspath $(TOP)/tools/xibuild:$(PATH)) - ifneq ($(RELEASE),) ifneq ($(BITCODE),) CONFIG=Release-bitcode diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs index 41c3b4a8ff96..4eb03eea243f 100644 --- a/tests/common/Configuration.cs +++ b/tests/common/Configuration.cs @@ -417,6 +417,7 @@ public static string MlaunchPath { } } +#if !XAMMAC_TESTS public static string GetBaseLibrary (Profile profile) { switch (profile) { @@ -482,6 +483,7 @@ public static string GetCompiler (Profile profile, StringBuilder args, bool use_ return "/Library/Frameworks/Mono.framework/Commands/mcs"; } } +#endif // !XAMMAC_TESTS public static void AssertXcodeSupports32Bit () { @@ -501,5 +503,9 @@ public static string NuGetPackagesDirectory { return Path.Combine (RootPath, "packages"); } } + + public static string XIBuildPath { + get { return Path.GetFullPath (Path.Combine (RootPath, "tools", "xibuild", "xibuild")); } + } } } diff --git a/tests/common/ExecutionHelper.cs b/tests/common/ExecutionHelper.cs index 998855e66ebd..fb2629fd668d 100644 --- a/tests/common/ExecutionHelper.cs +++ b/tests/common/ExecutionHelper.cs @@ -84,7 +84,7 @@ public int Execute (string toolPath, string arguments, bool always_show_output, output.Clear (); output_lines = null; - var rv = ExecutionHelper.Execute ("xibuild", $"-t -- {toolPath} " + string.Format (arguments, args), EnvironmentVariables, output, output, workingDirectory: WorkingDirectory); + var rv = ExecutionHelper.Execute (Configuration.XIBuildPath, $"-t -- {toolPath} " + string.Format (arguments, args), EnvironmentVariables, output, output, workingDirectory: WorkingDirectory); if ((rv != 0 || always_show_output) && output.Length > 0) Console.WriteLine ("\t" + output.ToString ().Replace ("\n", "\n\t")); @@ -375,7 +375,7 @@ class XBuild public static string ToolPath { get { - return "xibuild"; + return Configuration.XIBuildPath; } } diff --git a/tests/common/mac/ProjectTestHelpers.cs b/tests/common/mac/ProjectTestHelpers.cs index 122905331e04..6148c8e5fe54 100644 --- a/tests/common/mac/ProjectTestHelpers.cs +++ b/tests/common/mac/ProjectTestHelpers.cs @@ -227,7 +227,7 @@ public static string RunAndAssert (string exe, StringBuilder args, string stepNa // In most cases we generate projects in tmp and this is not needed. But nuget and test projects can make that hard public static void CleanUnifiedProject (string csprojTarget) { - RunAndAssert ("xibuild", new StringBuilder ("-- " + csprojTarget + " /t:clean"), "Clean"); + RunAndAssert (Configuration.XIBuildPath, new StringBuilder ("-- " + csprojTarget + " /t:clean"), "Clean"); } public static string BuildProject (string csprojTarget, bool isUnified, bool shouldFail = false, bool release = false, string[] environment = null) @@ -267,7 +267,7 @@ public static string BuildProject (string csprojTarget, bool isUnified, bool sho if (isUnified) { buildArgs.Insert (0, " -- "); - return RunAndAssert ("xibuild", buildArgs, "Compile", shouldFail, getBuildProjectErrorInfo, environment); + return RunAndAssert (Configuration.XIBuildPath, buildArgs, "Compile", shouldFail, getBuildProjectErrorInfo, environment); } else return RunAndAssert ("/Applications/Visual Studio.app/Contents/MacOS/vstool", buildArgs, "Compile", shouldFail, getBuildProjectErrorInfo, environment); } @@ -581,7 +581,7 @@ public static void NugetRestore (string project) Environment.SetEnvironmentVariable ("XAMMAC_FRAMEWORK_PATH", rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current"); Environment.SetEnvironmentVariable ("XamarinMacFrameworkRoot", rootDirectory + "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current"); - var rv = ExecutionHelper.Execute ("xibuild", $"-- /restore {StringUtils.Quote (project)}", out var output); + var rv = ExecutionHelper.Execute (Configuration.XIBuildPath, $"-- /restore {StringUtils.Quote (project)}", out var output); if (rv != 0) { Console.WriteLine ("nuget restore failed:"); Console.WriteLine (output); diff --git a/tests/xammac_tests/xammac_tests.csproj b/tests/xammac_tests/xammac_tests.csproj index 319ca51d3274..e8ce769f5672 100644 --- a/tests/xammac_tests/xammac_tests.csproj +++ b/tests/xammac_tests/xammac_tests.csproj @@ -17,7 +17,7 @@ full false bin\x86\Debug - __UNIFIED__;DEBUG;MONOMAC;XAMCORE_2_0 + __UNIFIED__;DEBUG;MONOMAC;XAMCORE_2_0;XAMMAC_TESTS prompt 4 false @@ -38,7 +38,7 @@ true bin\x86\Release - __UNIFIED__;MONOMAC;XAMCORE_2_0 + __UNIFIED__;MONOMAC;XAMCORE_2_0;XAMMAC_TESTS prompt 4 false @@ -60,8 +60,12 @@ + + + Configuration.cs + TestRuntime.cs diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index d7ec7f442abd..590dbc38066e 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -30,6 +30,10 @@ public class Harness public bool UseSystem { get; set; } // if the system XI/XM should be used, or the locally build XI/XM. public HashSet Labels { get; } = new HashSet (); + public string XIBuildPath { + get { return Path.GetFullPath (Path.Combine (RootDirectory, "..", "tools", "xibuild", "xibuild")); } + } + public static string Timestamp { get { return $"{DateTime.Now:yyyyMMdd_HHmmss}"; diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index aafd17f5ec1a..99236e8cf3d5 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -2760,7 +2760,7 @@ protected override async Task ExecuteAsync () await RestoreNugetsAsync (log, resource); using (var xbuild = new Process ()) { - xbuild.StartInfo.FileName = "xibuild"; + xbuild.StartInfo.FileName = Harness.XIBuildPath; var args = new StringBuilder (); args.Append ("-- "); args.Append ("/verbosity:diagnostic "); @@ -2797,7 +2797,7 @@ async Task CleanProjectAsync (Log log, string project_file, string project_platf { // Don't require the desktop resource here, this shouldn't be that resource sensitive using (var xbuild = new Process ()) { - xbuild.StartInfo.FileName = "xibuild"; + xbuild.StartInfo.FileName = Harness.XIBuildPath; var args = new StringBuilder (); args.Append ("-- "); args.Append ("/verbosity:diagnostic "); @@ -2874,7 +2874,7 @@ protected override async Task RunTestAsync () using (var proc = new Process ()) { proc.StartInfo.WorkingDirectory = WorkingDirectory; - proc.StartInfo.FileName = "xibuild"; + proc.StartInfo.FileName = Harness.XIBuildPath; var args = new StringBuilder (); args.Append ("-t -- "); args.Append (StringUtils.Quote (Path.GetFullPath (TestExecutable))).Append (' '); From 6289d941d2840975b2ded9e425c705b8009bc3eb Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 21 Nov 2018 01:09:18 -0500 Subject: [PATCH 02/15] Bump maccore to get provisioning profile fix. (#5160) Commit diff for xamarin/maccore: Diff: https://github.com/xamarin/maccore/compare/278d0e0c98c1718acd30aebba3f3c8a5cdc68805...7ba9c5a962c1fcdeb651488e7459e89f3c9932fd --- mk/xamarin.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/xamarin.mk b/mk/xamarin.mk index dff6acb82dcc..a263dbe1e909 100644 --- a/mk/xamarin.mk +++ b/mk/xamarin.mk @@ -1,5 +1,5 @@ ifdef ENABLE_XAMARIN -NEEDED_MACCORE_VERSION := 278d0e0c98c1718acd30aebba3f3c8a5cdc68805 +NEEDED_MACCORE_VERSION := 7ba9c5a962c1fcdeb651488e7459e89f3c9932fd NEEDED_MACCORE_BRANCH := master MACCORE_DIRECTORY := maccore From abbc4698d61fde78ca6b4134012a63ead4cae27e Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 21 Nov 2018 01:45:39 -0500 Subject: [PATCH 03/15] [jenkins] Improve failure reporting slightly by listing 'Test docs' and 'Test run' as failing stages in the commit comment. (#5150) --- jenkins/Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 7c877c38a961..45b7324ef2b4 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -718,6 +718,7 @@ timestamps { if (runTestResult != 0) { echoError ("Test run failed") currentBuild.result = 'FAILURE' + failedStages.add (currentStage) } } } @@ -733,6 +734,7 @@ timestamps { if (testDocsResult != 0) { echoError ("Test docs failed") currentBuild.result = 'FAILURE' + failedStages.add (currentStage) } } } From 3618cefc5ab0cf939b7d15bd8a731c3904f88d00 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 21 Nov 2018 13:28:06 +0100 Subject: [PATCH 04/15] [Harness] Reduce the noise in the make files. Fixes xamarin/maccore#1156 (#5154) * [Harness] Reduce the noise in the make files. The Makefile.cs code generates a lot of noise becuase it tries to build a make rule for the new BCL tests, these rules do not work and can be ignored. Fixes issue: https://github.com/xamarin/maccore/issues/1156 --- tests/xharness/MakefileGenerator.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/xharness/MakefileGenerator.cs b/tests/xharness/MakefileGenerator.cs index 8709aef36a17..3e696083a40c 100644 --- a/tests/xharness/MakefileGenerator.cs +++ b/tests/xharness/MakefileGenerator.cs @@ -297,7 +297,7 @@ public static void CreateMakefile (Harness harness, IEnumerable u // build/[install/]run targets for specific test projects. foreach (var target in allTargets) { - if (!target.IsExe) + if (!target.IsExe || target.Name.IndexOf ("BCLTests", 0, StringComparison.Ordinal) != -1) continue; var make_escaped_suffix = target.GetMakeSuffix (); @@ -591,7 +591,7 @@ public static void CreateMakefile (Harness harness, IEnumerable u writer.WriteLine ("run-local:"); // run every single test we have everywhere writer.WriteLine ("\t$(Q) rm -rf \".$@-failure.stamp\""); foreach (var target in allTargets) { - if (!target.IsExe) + if (!target.IsExe || target.Name.IndexOf ("BCLTests", 0, StringComparison.Ordinal) != -1) continue; writer.WriteLine ("\t$(Q) $(MAKE) \"run{0}-sim-{1}\" || echo \"run{0}-sim-{1} failed\" >> \".$@-failure.stamp\"", target.GetMakeSuffix (false), target.GetMakeName (false)); @@ -603,7 +603,7 @@ public static void CreateMakefile (Harness harness, IEnumerable u writer.WriteLine ("run-sim run-all-sim:"); // run every single test we have in the simulator writer.WriteLine ("\t$(Q) rm -rf \".$@-failure.stamp\""); foreach (var target in allTargets) { - if (!target.IsExe) + if (!target.IsExe || target.Name.IndexOf ("BCLTests", 0, StringComparison.Ordinal) != -1) continue; writer.WriteLine ("\t$(Q) $(MAKE) \"run{0}-sim-{1}\" || echo \"run{0}-sim-{1} failed\" >> \".$@-failure.stamp\"", target.GetMakeSuffix (false), target.GetMakeName (false)); @@ -614,7 +614,7 @@ public static void CreateMakefile (Harness harness, IEnumerable u writer.WriteLine ("run-dev run-all-dev:"); // run every single test we have on device writer.WriteLine ("\t$(Q) rm -rf \".$@-failure.stamp\""); foreach (var target in allTargets) { - if (!target.IsExe) + if (!target.IsExe || target.Name.IndexOf ("BCLTests", 0, StringComparison.Ordinal) != -1) continue; writer.WriteLine ("\t$(Q) $(MAKE) \"run{0}-dev-{1}\" || echo \"run{0}-dev-{1} failed\" >> \".$@-failure.stamp\"", target.GetMakeSuffix (false), target.GetMakeName (false)); @@ -631,7 +631,7 @@ public static void CreateMakefile (Harness harness, IEnumerable u writer.WriteLine ("build build-all:"); // build everything writer.WriteLine ("\t$(Q) rm -rf \".$@-failure.stamp\""); foreach (var target in unified_targets) { - if (!target.IsExe) + if (!target.IsExe || target.Name.IndexOf ("BCLTests", 0, StringComparison.Ordinal) != -1) continue; writer.WriteLine ("\t$(Q) $(MAKE) \"build-sim-{0}\" \"build-dev-{0}\" || echo \"build-{0} failed\" >> \".$@-failure.stamp\"", target.GetMakeName (false)); @@ -641,7 +641,7 @@ public static void CreateMakefile (Harness harness, IEnumerable u // targets that run all platforms writer.WriteLine (); foreach (var target in unified_targets) { - if (!target.IsExe) + if (!target.IsExe || target.Name.IndexOf ("BCLTests", 0, StringComparison.Ordinal) != -1) continue; var make_escaped_name = target.GetMakeName (); From 37cd57219c4fe542489832a34774b298feaed282 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 21 Nov 2018 09:59:10 -0500 Subject: [PATCH 05/15] [tests] Use xibuild when building packaged XM tests. Fixes maccore#1169. (#5164) Fixes https://github.com/xamarin/maccore/issues/1169. --- tests/package-mac-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/package-mac-tests.sh b/tests/package-mac-tests.sh index 5b15d62ba4ce..e42f45985c23 100755 --- a/tests/package-mac-tests.sh +++ b/tests/package-mac-tests.sh @@ -25,7 +25,7 @@ export MSBuildExtensionsPathFallbackPathsOverride=$MAC_DESTDIR/Library/Framework make make .stamp-configure-projects-mac -msbuild bindings-test/bindings-test-mac.csproj +../tools/xibuild/xibuild -- bindings-test/bindings-test-mac.csproj make build-mac-dontlink build-mac-apitest build-mac-introspection build-mac-linksdk build-mac-linkall build-mac-xammac_tests build-mac-system-dontlink -j8 for app in */bin/x86/*/*.app linker/mac/*/bin/x86/*/*.app introspection/Mac/bin/x86/*/*.app; do From 6f54cb7c28a578b69c932d41efcd2179c5c1c6ed Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 21 Nov 2018 10:11:55 -0500 Subject: [PATCH 06/15] Bump maccore to get fix for test-docs. (#5163) * Bump maccore to get fix for test-docs. Commit list for xamarin/maccore: * xamarin/maccore@6e9b63e537 Merge pull request #1162 from rolfbjarne/docfixer-fixes * xamarin/maccore@4cf1d63b7b [docfixer] Create project files and fix a few issues. Fixes #1118. * xamarin/maccore@714bd73a55 [docfixer] Avoid declaring the same target twice. * xamarin/maccore@34f4bfa339 [populate] Directories need to call Directory.Exists for existence checks. * xamarin/maccore@341333db88 [docs] Remove truly ancient and outdated targets to publish updated docs. Diff: https://github.com/xamarin/maccore/compare/7ba9c5a962c1fcdeb651488e7459e89f3c9932fd...6e9b63e53755a74138b78dafd098836a79660edd * [jenkins] Make it possible to force docs testing by applying a label to pull requests. --- jenkins/Jenkinsfile | 3 ++- mk/xamarin.mk | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 45b7324ef2b4..2d39d8e01aab 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -726,7 +726,8 @@ timestamps { currentStage = "${STAGE_NAME}" echo ("Building on ${env.NODE_NAME}") def targetBranch = isPr ? githubGetPullRequestInfo () ["base"] ["ref"] : "${BRANCH_NAME}" - def testDocs = targetBranch == "master" + def hasRunDocsTestsLabel = isPr ? githubGetPullRequestLabels ().contains ("run-docs-tests") : false + def testDocs = targetBranch == "master" || hasRunDocsTestsLabel if (!testDocs) { echo ("Skipping docs testing, it's only done on master (current (target) branch is ${targetBranch})") } else { diff --git a/mk/xamarin.mk b/mk/xamarin.mk index a263dbe1e909..1daa91b3cb28 100644 --- a/mk/xamarin.mk +++ b/mk/xamarin.mk @@ -1,5 +1,5 @@ ifdef ENABLE_XAMARIN -NEEDED_MACCORE_VERSION := 7ba9c5a962c1fcdeb651488e7459e89f3c9932fd +NEEDED_MACCORE_VERSION := 6e9b63e53755a74138b78dafd098836a79660edd NEEDED_MACCORE_BRANCH := master MACCORE_DIRECTORY := maccore From 02fe5339a40a9e9cf042b7be87e066f3903249f4 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 21 Nov 2018 11:48:15 -0500 Subject: [PATCH 07/15] [runtime] Clean up public symbols. Fixes #5124. (#5155) * [runtime] Clean up public symbols. Fixes #5124. Clean up public symbols, by: * Symbols that don't need to be public (most of them), can be private. * Prefix all public symbols with `xamarin_`. * Add a test to ensure we don't introduce new public symbols. * Use C symbols instead of mangled C++ symbols, since those are easier to handle in the test. This minimizes the chance of getting into a symbol clash with another native library. Fixes https://github.com/xamarin/xamarin-macios/issues/5124. * Some test fixes. --- runtime/extension-main.m | 6 ++ runtime/launcher.m | 2 +- runtime/mono-runtime.m.t4 | 2 +- runtime/monotouch-debug.m | 37 ++++++------ runtime/monotouch-main.m | 4 +- runtime/runtime.m | 4 +- runtime/shared.h | 4 +- runtime/shared.m | 10 ++-- runtime/trampolines-x86_64.m | 4 +- runtime/xamarin/main.h | 12 ++-- runtime/xamarin/runtime.h | 1 + runtime/xamarin/trampolines.h | 7 ++- tests/common/Configuration.cs | 18 ++++++ tests/mtouch/MTouch.cs | 4 +- tests/mtouch/MTouchTool.cs | 19 +++++- tests/mtouch/MiscTests.cs | 103 +++++++++++++++++++++++++++++++++ tools/mtouch/monotouch-fixes.c | 9 ++- 17 files changed, 197 insertions(+), 49 deletions(-) diff --git a/runtime/extension-main.m b/runtime/extension-main.m index 45cec989ffe8..af6443c7457b 100644 --- a/runtime/extension-main.m +++ b/runtime/extension-main.m @@ -2,8 +2,14 @@ #include "xamarin/main.h" #include "main-internal.h" +#ifdef __cplusplus +extern "C" { +#endif void xamarin_initialize_extension_main () __attribute__ ((constructor)); +#ifdef __cplusplus +} +#endif void xamarin_initialize_extension_main () diff --git a/runtime/launcher.m b/runtime/launcher.m index ba4b098b0c15..521d96961915 100644 --- a/runtime/launcher.m +++ b/runtime/launcher.m @@ -526,7 +526,7 @@ /* other non-documented stuff... */ - initialize_cocoa_threads (NULL); + xamarin_initialize_cocoa_threads (NULL); init_logdir (); mono_set_signal_chaining (TRUE); mono_set_crash_chaining (TRUE); diff --git a/runtime/mono-runtime.m.t4 b/runtime/mono-runtime.m.t4 index e49dbedde8ef..1cf4e7dcace7 100644 --- a/runtime/mono-runtime.m.t4 +++ b/runtime/mono-runtime.m.t4 @@ -147,5 +147,5 @@ bool <# } #> #else -int fix_ranlib_warning_about_no_symbols; +int xamarin_fix_ranlib_warning_about_no_symbols; #endif /* DYNAMIC_MONO_RUNTIME */ diff --git a/runtime/monotouch-debug.m b/runtime/monotouch-debug.m index 3fd96ab09e8e..f7db2348bb0e 100644 --- a/runtime/monotouch-debug.m +++ b/runtime/monotouch-debug.m @@ -43,16 +43,13 @@ #include "product.h" // permanent connection variables -int monodevelop_port = -1; -int sdb_fd = -1; -int profiler_fd = -1; -int heapshot_fd = -1; // this is the socket to write 'heapshot' to to requests heapshots from the profiler -int heapshot_port = -1; -char *profiler_description = NULL; +static int monodevelop_port = -1; +static int sdb_fd = -1; +static int heapshot_fd = -1; // this is the socket to write 'heapshot' to to requests heapshots from the profiler +static int heapshot_port = -1; +static char *profiler_description = NULL; // old variables -int output_port; -int debug_port; -char *debug_host = NULL; +static char *debug_host = NULL; enum DebuggingMode { @@ -71,6 +68,7 @@ static DebuggingMode debugging_mode = DebuggingModeWifi; static const char *connection_mode = "default"; // this is set from the cmd line, can be either 'usb', 'wifi', 'http' or 'none' +extern "C" { void monotouch_connect_usb (); void monotouch_connect_wifi (NSMutableArray *hosts); void xamarin_connect_http (NSMutableArray *hosts); @@ -80,6 +78,8 @@ void monotouch_load_profiler (); void monotouch_load_debugger (); bool monotouch_process_connection (int fd); +void monotouch_dump_objc_api (Class klass); +} static struct timeval wait_tv; static struct timespec wait_ts; @@ -705,7 +705,7 @@ void monotouch_configure_debugging () pthread_mutex_unlock (&mutex); } -void sdb_connect (const char *address) +static void sdb_connect (const char *address) { gboolean shaked; @@ -719,17 +719,17 @@ void sdb_connect (const char *address) return; } -void sdb_close1 (void) +static void sdb_close1 (void) { shutdown (sdb_fd, SHUT_RD); } -void sdb_close2 (void) +static void sdb_close2 (void) { shutdown (sdb_fd, SHUT_RDWR); } -gboolean send_uninterrupted (int fd, const void *buf, int len) +static gboolean send_uninterrupted (int fd, const void *buf, int len) { int res; @@ -740,7 +740,7 @@ gboolean send_uninterrupted (int fd, const void *buf, int len) return res == len; } -int recv_uninterrupted (int fd, void *buf, int len) +static int recv_uninterrupted (int fd, void *buf, int len) { int res; int total = 0; @@ -755,7 +755,7 @@ int recv_uninterrupted (int fd, void *buf, int len) return total; } -gboolean sdb_send (void *buf, int len) +static gboolean sdb_send (void *buf, int len) { gboolean rv; @@ -771,7 +771,7 @@ gboolean sdb_send (void *buf, int len) } -int sdb_recv (void *buf, int len) +static int sdb_recv (void *buf, int len) { int rv; @@ -1323,8 +1323,7 @@ int sdb_recv (void *buf, int len) profiler_description = strdup (prof); #else use_fd = true; - profiler_fd = fd; - profiler_description = xamarin_strdup_printf ("%s,output=#%i", prof, profiler_fd); + profiler_description = xamarin_strdup_printf ("%s,output=#%i", prof, fd); #endif xamarin_set_gc_pump_enabled (false); } else { @@ -1709,6 +1708,6 @@ int monotouch_debug_connect (NSMutableArray *ips, int debug_port, int output_por #endif /* TARGET_OS_WATCH && !TARGET_OS_SIMULATOR */ #else -int fix_ranlib_warning_about_no_symbols_v2; +int xamarin_fix_ranlib_warning_about_no_symbols_v2; #endif /* DEBUG */ diff --git a/runtime/monotouch-main.m b/runtime/monotouch-main.m index 76c068529ac2..9b63621c2254 100644 --- a/runtime/monotouch-main.m +++ b/runtime/monotouch-main.m @@ -386,9 +386,9 @@ - (void) memoryWarning: (NSNotification *) sender } #ifdef DEBUG - initialize_cocoa_threads (monotouch_configure_debugging); + xamarin_initialize_cocoa_threads (monotouch_configure_debugging); #else - initialize_cocoa_threads (NULL); + xamarin_initialize_cocoa_threads (NULL); #endif #if defined (__arm__) || defined(__aarch64__) diff --git a/runtime/runtime.m b/runtime/runtime.m index 8e829b39a987..86c9adda6382 100644 --- a/runtime/runtime.m +++ b/runtime/runtime.m @@ -185,7 +185,7 @@ (void *) &xamarin_set_gchandle_trampoline, }; -struct InitializationOptions options = { 0 }; +static struct InitializationOptions options = { 0 }; struct Managed_NSObject { MonoObject obj; @@ -1388,7 +1388,7 @@ -(void) xamarinSetGCHandle: (int) gc_handle; if (!register_assembly (assembly, &exception_gchandle)) xamarin_process_managed_exception_gchandle (exception_gchandle); - install_nsautoreleasepool_hooks (); + xamarin_install_nsautoreleasepool_hooks (); #if defined (DEBUG) if (xamarin_gc_pump) { diff --git a/runtime/shared.h b/runtime/shared.h index 3d6d7d4026ca..991ec821621f 100644 --- a/runtime/shared.h +++ b/runtime/shared.h @@ -18,9 +18,9 @@ extern "C" { #endif typedef void (init_cocoa_func) (void); -void initialize_cocoa_threads (init_cocoa_func *func); +void xamarin_initialize_cocoa_threads (init_cocoa_func *func); -void install_nsautoreleasepool_hooks (); +void xamarin_install_nsautoreleasepool_hooks (); id xamarin_init_nsthread (id obj, bool is_direct, id target, SEL sel, id arg); void xamarin_insert_dllmap (); diff --git a/runtime/shared.m b/runtime/shared.m index 8b7e05b6f41e..3931d7e2ecca 100644 --- a/runtime/shared.m +++ b/runtime/shared.m @@ -112,7 +112,7 @@ -(void) dealloc; * Ref: https://bugzilla.xamarin.com/show_bug.cgi?id=798 */ -@interface CocoaThreadInitializer : NSObject +@interface XamarinCocoaThreadInitializer : NSObject { init_cocoa_func *the_func; } @@ -120,7 +120,7 @@ -(void) entryPoint: (NSObject *) obj; -(id) initWithFunc: (init_cocoa_func *) func; @end -@implementation CocoaThreadInitializer +@implementation XamarinCocoaThreadInitializer { } -(void) entryPoint: (NSObject *) obj @@ -144,10 +144,10 @@ -(id) initWithFunc: (init_cocoa_func *) func; @end void -initialize_cocoa_threads (init_cocoa_func *func) +xamarin_initialize_cocoa_threads (init_cocoa_func *func) { // COOP: no managed memory access: any mode. - [[[CocoaThreadInitializer alloc] initWithFunc: func] autorelease]; + [[[XamarinCocoaThreadInitializer alloc] initWithFunc: func] autorelease]; } /* Wrapping threads with NSAutoreleasePool @@ -233,7 +233,7 @@ -(id) initWithFunc: (init_cocoa_func *) func; } void -install_nsautoreleasepool_hooks () +xamarin_install_nsautoreleasepool_hooks () { // COOP: executed at startup (and no managed memory access): any mode. xamarin_thread_hash = CFDictionaryCreateMutable (kCFAllocatorDefault, 0, NULL, NULL); diff --git a/runtime/trampolines-x86_64.m b/runtime/trampolines-x86_64.m index 02aa72f94154..390beea60152 100644 --- a/runtime/trampolines-x86_64.m +++ b/runtime/trampolines-x86_64.m @@ -87,7 +87,9 @@ #define dump_state(...) #endif -const char* registers[] = { "rdi", "rsi", "rdx", "rcx", "r8", "r9", "err" }; +#ifdef TRACE +static const char* registers[] = { "rdi", "rsi", "rdx", "rcx", "r8", "r9", "err" }; +#endif static const char * skip_type_name (const char *ptr) diff --git a/runtime/xamarin/main.h b/runtime/xamarin/main.h index cdd2845c7fe8..c5b58acbea13 100644 --- a/runtime/xamarin/main.h +++ b/runtime/xamarin/main.h @@ -87,12 +87,6 @@ int xamarin_get_launch_mode (); int xamarin_watchextension_main (int argc, char **argv); -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* __XAMARIN_MAIN_H__ */ - #ifndef MONOTOUCH void xamarin_set_is_mkbundle (bool value); /* Not Public API, exact semantics is not defined yet */ bool xamarin_get_is_mkbundle (); /* Not Public API, exact semantics is not defined yet */ @@ -100,3 +94,9 @@ bool xamarin_get_is_mkbundle (); /* Not Public API, exact semantics is not defin void xamarin_set_is_debug (bool value); /* Public API */ bool xamarin_get_is_debug (); /* Public API */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __XAMARIN_MAIN_H__ */ diff --git a/runtime/xamarin/runtime.h b/runtime/xamarin/runtime.h index bfb443fd4d5b..caed811062d3 100644 --- a/runtime/xamarin/runtime.h +++ b/runtime/xamarin/runtime.h @@ -216,6 +216,7 @@ void xamarin_free_gchandle (id self, int gchandle); void xamarin_clear_gchandle (id self); int xamarin_get_gchandle_with_flags (id self); void xamarin_set_gchandle (id self, int gchandle); +void xamarin_create_gchandle (id self, void *managed_object, int flags, bool force_weak); void xamarin_create_managed_ref (id self, void * managed_object, bool retain); void xamarin_release_managed_ref (id self, MonoObject *managed_obj); void xamarin_notify_dealloc (id self, int gchandle); diff --git a/runtime/xamarin/trampolines.h b/runtime/xamarin/trampolines.h index fa53d912e4af..c5fbd755cb81 100644 --- a/runtime/xamarin/trampolines.h +++ b/runtime/xamarin/trampolines.h @@ -84,8 +84,8 @@ typedef id (*xamarin_managed_to_id_func) (MonoObject *value, guint32 context, g id xamarin_generate_conversion_to_native (MonoObject *value, MonoType *inputType, MonoType *outputType, MonoMethod *method, guint32 context, guint32 *exception_gchandle); void * xamarin_generate_conversion_to_managed (id value, MonoType *inputType, MonoType *outputType, MonoMethod *method, guint32 *exception_gchandle, guint32 context, /*SList*/ void **free_list); -NSNumber * xamarin_convert_managed_to_nsnumber (MonoObject *value, MonoType *managedType, MonoType *nativeType, MonoMethod *method, guint32 *exception_gchandle); -NSValue * xamarin_convert_managed_to_nsvalue (MonoObject *value, MonoType *managedType, MonoType *nativeType, MonoMethod *method, guint32 *exception_gchandle); +NSNumber * xamarin_convert_managed_to_nsnumber (MonoObject *value, MonoClass *managedType, MonoMethod *method, guint32 context, guint32 *exception_gchandle); +NSValue * xamarin_convert_managed_to_nsvalue (MonoObject *value, MonoClass *managedType, MonoMethod *method, guint32 context, guint32 *exception_gchandle); NSString * xamarin_convert_managed_to_nsstring (MonoObject *value, MonoType *managedType, MonoType *nativeType, MonoMethod *method, guint32 *exception_gchandle); MonoObject * xamarin_convert_nsnumber_to_managed (NSNumber *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle); MonoObject * xamarin_convert_nsvalue_to_managed (NSValue *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle); @@ -104,6 +104,9 @@ xamarin_managed_to_id_func xamarin_get_smart_enum_to_nsstring_func (MonoClass *m NSArray * xamarin_convert_managed_to_nsarray_with_func (MonoArray *array, xamarin_managed_to_id_func convert, guint32 context, guint32 *exception_gchandle); MonoArray * xamarin_convert_nsarray_to_managed_with_func (NSArray *array, MonoClass *managedElementType, xamarin_id_to_managed_func convert, guint32 context, guint32 *exception_gchandle); +void * xamarin_nsstring_to_smart_enum (id value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle); +void * xamarin_smart_enum_to_nsstring (MonoObject *value, guint32 context /* token ref */, guint32 *exception_gchandle); + // Returns a pointer to the value type, which must be freed using xamarin_free. void *xamarin_nsnumber_to_bool (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle); void *xamarin_nsnumber_to_sbyte (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle); diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs index 4eb03eea243f..a44865eddc89 100644 --- a/tests/common/Configuration.cs +++ b/tests/common/Configuration.cs @@ -474,6 +474,24 @@ public static string GetSdkVersion (Profile profile) } } + public static string GetSdkPath (Profile profile, bool is_device) + { + switch (profile) { + case Profile.iOS: + return Path.Combine (MonoTouchRootDirectory, "SDKs", "MonoTouch." + (is_device ? "iphoneos" : "iphonesimulator") + ".sdk"); + case Profile.tvOS: + return Path.Combine (MonoTouchRootDirectory, "SDKs", "Xamarin.AppleTV" + (is_device ? "OS" : "Simulator") + ".sdk"); + case Profile.watchOS: + return Path.Combine (MonoTouchRootDirectory, "SDKs", "Xamarin.Watch" + (is_device ? "OS" : "Simulator") + ".sdk"); + case Profile.macOSFull: + case Profile.macOSMobile: + case Profile.macOSSystem: + return Path.Combine (SdkRootXM, "lib"); + default: + throw new NotImplementedException (profile.ToString ()); + } + } + public static string GetCompiler (Profile profile, StringBuilder args, bool use_csc = false) { args.Append (" -lib:").Append (Path.GetDirectoryName (GetBaseLibrary (profile))).Append (' '); diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 1421d526c503..57755d751769 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -3856,8 +3856,8 @@ public void SimlauncherSymbols (string arch, string simlauncher_suffix) var missingSimlauncherSymbols = new List (); foreach (var symbol in only_libxamarin) { switch (symbol) { - case "_fix_ranlib_warning_about_no_symbols": // Dummy symbol to fix linker warning - case "_fix_ranlib_warning_about_no_symbols_v2": // Dummy symbol to fix linker warning + case "_xamarin_fix_ranlib_warning_about_no_symbols": // Dummy symbol to fix linker warning + case "_xamarin_fix_ranlib_warning_about_no_symbols_v2": // Dummy symbol to fix linker warning case "_monotouch_IntPtr_objc_msgSendSuper_IntPtr": // Classic only, this function can probably be removed when we switch to binary copy of a Classic version of libxamarin.a case "_monotouch_IntPtr_objc_msgSend_IntPtr": // Classic only, this function can probably be removed when we switch to binary copy of a Classic version of libxamarin.a case "_xamarin_float_objc_msgSend": // Classic only, this function can probably be removed when we switch to binary copy of a Classic version of libxamarin.a diff --git a/tests/mtouch/MTouchTool.cs b/tests/mtouch/MTouchTool.cs index 2153a0d2335c..610f536ec32d 100644 --- a/tests/mtouch/MTouchTool.cs +++ b/tests/mtouch/MTouchTool.cs @@ -796,10 +796,27 @@ void IDisposable.Dispose () public IEnumerable NativeSymbolsInExecutable { get { - return ExecutionHelper.Execute ("nm", $"-gUj {StringUtils.Quote (NativeExecutablePath)}", hide_output: true).Split ('\n'); + return GetNativeSymbolsInExecutable (NativeExecutablePath); } } + public static IEnumerable GetNativeSymbolsInExecutable (string executable) + { + IEnumerable rv = ExecutionHelper.Execute ("nm", $"-gUj {StringUtils.Quote (executable)}", hide_output: true).Split ('\n'); + + rv = rv.Where ((v) => { + if (string.IsNullOrEmpty (v)) + return false; + + if (v.StartsWith (executable, StringComparison.Ordinal) && v.EndsWith (":", StringComparison.Ordinal)) + return false; + + return true; + }); + + return rv; + } + protected override string ToolPath { get { return Configuration.MtouchPath; } } diff --git a/tests/mtouch/MiscTests.cs b/tests/mtouch/MiscTests.cs index cda26dc0cd8d..0e730325dc62 100644 --- a/tests/mtouch/MiscTests.cs +++ b/tests/mtouch/MiscTests.cs @@ -75,6 +75,109 @@ public void VerifySymbols () } } } + + [Test] + [TestCase (Profile.iOS)] + [TestCase (Profile.tvOS)] + [TestCase (Profile.watchOS)] + [TestCase (Profile.macOSMobile)] + public void PublicSymbols (Profile profile) + { + var paths = new HashSet (); + 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"); + } } } diff --git a/tools/mtouch/monotouch-fixes.c b/tools/mtouch/monotouch-fixes.c index b3a558b87861..db1790f0c8c6 100644 --- a/tools/mtouch/monotouch-fixes.c +++ b/tools/mtouch/monotouch-fixes.c @@ -31,12 +31,10 @@ // we patch the system sigaction instead. // -int my_sigaction (int signo, const struct sigaction *__restrict act, struct sigaction *__restrict oact); - typedef int (*SigAction) (int sig, const struct sigaction *__restrict act, struct sigaction *__restrict oact); -SigAction system_sigaction = sigaction; +static SigAction system_sigaction = sigaction; -int +static int my_sigaction (int sig, const struct sigaction *__restrict act, struct sigaction *__restrict oact) { //fprintf (stderr, "my_sigaction (%i, %p: handler = %p mask = %i flags = %i, %p)\n", sig, act, act ? act->sa_handler : NULL, act ? act->sa_mask : -1, act ? act->sa_flags : -1, oact); @@ -69,7 +67,8 @@ static const interpose_t interposers[] __attribute__ ((unused)) \ #elif defined(__x86_64__) -void patch_sigaction () +static void +patch_sigaction () { // Sanity check. uint64_t * func = (uint64_t *) &sigaction; From 94d87ddba6c1d820a94723d28444ffa865bf21d1 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 21 Nov 2018 12:21:57 -0500 Subject: [PATCH 08/15] [jenkins] Don't execute the packaged XM tests on the main macOS version. (#5165) * [jenkins] Don't execute the packaged XM tests on the main macOS version. Don't execute the packaged XM tests on the main macOS version, since it's redundant. It also prevents a potential test deadlock if all main bots are busy. * Rework to make it show better in the Jenkins UI. --- jenkins/Jenkinsfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 2d39d8e01aab..3876f62797f4 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -383,7 +383,8 @@ def abortExecutingBuilds () } timestamps { - node ('xamarin-macios && macos-10.13') { + def mainMacOSVersion = 13 + node ("xamarin-macios && macos-10.${mainMacOSVersion}") { try { timeout (time: 9, unit: 'HOURS') { // Hard-code a workspace, since branch-based and PR-based @@ -673,13 +674,21 @@ timestamps { for (os = firstOS; os <= lastOS; os++) macOSes.add (os) // If any macOS version needs to be excluded manually, it can be done like this (in this case to remove macOS 10.14): + // Any macOS versions excluded like this still get a entry in the Jenkins UI, making it explicit that the OS version was skipped. // excludedOSes.add (14) // Have in mind that the value in the list is only the minor part of the macOS version number. for (i = 0; i < macOSes.size (); i++) { def os = macOSes [i]; def macOS = "${os}" // Need to bind the label variable before the closure - def excluded = indexOfElement (excludedOSes, os) >= 0 - def nodeText = excluded ? "ℹ️ XM tests not executed on 10.${macOS} ℹ️" : "XM tests on 10.${macOS}" + def excluded = false + def nodeText = "XM tests on 10.${macOS}" + if (indexOfElement (excludedOSes, os) >= 0) { + excluded = true + nodeText = "ℹ️ XM tests not executed on 10.${macOS} ℹ️" + } else if (os == mainMacOSVersion) { + excluded = true + nodeText = "ℹ️ XM tests not executed on a separate 10.${macOS} bot because they're already executed as a part of the main test run ℹ️" + } builders [nodeText] = { try { if (excluded) { From b059252473ad0d2fcfcdd4dc1a47c3b507d36d45 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 22 Nov 2018 10:42:24 -0500 Subject: [PATCH 09/15] [jenkins] If provisioning fails with error 56, try again a few more times. Fixes maccore#1098. (#5168) It seems curl can randomly fail with error 56, so if that happens, try again a few more times before giving up. Fixes https://github.com/xamarin/maccore/issues/1098. --- jenkins/prepare-packaged-macos-tests.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) mode change 100644 => 100755 jenkins/prepare-packaged-macos-tests.sh diff --git a/jenkins/prepare-packaged-macos-tests.sh b/jenkins/prepare-packaged-macos-tests.sh old mode 100644 new mode 100755 index 056727de9149..575263b102cd --- a/jenkins/prepare-packaged-macos-tests.sh +++ b/jenkins/prepare-packaged-macos-tests.sh @@ -26,7 +26,25 @@ rm -f -- ./*.zip curl -fL "$URL" --output mac-test-package.zip rm -rf mac-test-package unzip -o mac-test-package.zip -cd mac-test-package && ./system-dependencies.sh --provision-mono --ignore-autotools --ignore-xamarin-studio --ignore-xcode --ignore-osx --ignore-cmake +cd mac-test-package + +COUNTER=0 +EC=0 +while [[ $COUNTER -lt 5 ]]; do + ./system-dependencies.sh --provision-mono --ignore-autotools --ignore-xamarin-studio --ignore-xcode --ignore-osx --ignore-cmake || EC=$? + if [[ $EC -eq 56 ]]; then + # Sometimes we get spurious "curl: (56) SSLRead() return error -9806" errors. Trying again usually works, so lets try again a few more times. + # https://github.com/xamarin/maccore/issues/1098 + let COUNTER++ || true + continue + fi + break +done + +if [[ "x$EC" != "x0" ]]; then + echo "Failed to provision dependencies (exit code: $EC)" + exit $EC +fi # fetch script to install provisioning profiles and run it if test -d maccore; then From 4f1c39a00fda2d7bbbe0fb6ed3b39261005f33f1 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 22 Nov 2018 13:24:55 -0500 Subject: [PATCH 10/15] [tests] Add introspection tests for Constants.*.cs.in. Fixes #5047 (#5159) * Fix mac classic build * Fix mac 32 bits (can't load 64bits only libraries) * Check paths too leading to fixes to old (now incorrect) paths and typo * apitest (Mac) has a similar test - but assumed that a file that did not exists was fine (missing typos and changes); * tvOS simulator does not (unlike iOS) support loading the MetalPerformanceShaders.framework reference: https://github.com/xamarin/xamarin-macios/issues/5047 --- src/Compression/CompressionStreamStruct.cs | 6 +- src/Constants.iOS.cs.in | 12 ++-- src/Constants.mac.cs.in | 16 +++-- src/Constants.tvos.cs.in | 10 ++- src/Constants.watch.cs.in | 8 ++- tests/apitest/src/EveryFrameworkSmokeTest.cs | 1 + tests/introspection/ApiTypoTest.cs | 69 +++++++++++++++++++- tests/introspection/iOS/iOSApiTypoTest.cs | 15 +++-- 8 files changed, 114 insertions(+), 23 deletions(-) diff --git a/src/Compression/CompressionStreamStruct.cs b/src/Compression/CompressionStreamStruct.cs index 857ae3b15cde..551bf986e23e 100644 --- a/src/Compression/CompressionStreamStruct.cs +++ b/src/Compression/CompressionStreamStruct.cs @@ -17,13 +17,13 @@ struct CompressionStreamStruct { public IntPtr State; // void * __nullable state; - [DllImport (Constants.libcompression)] + [DllImport (Constants.libcompressionLibrary)] public static extern CompressionStatus compression_stream_init (ref CompressionStreamStruct stream, StreamOperation operation, CompressionAlgorithm algorithm); - [DllImport (Constants.libcompression)] + [DllImport (Constants.libcompressionLibrary)] public static extern CompressionStatus compression_stream_process (ref CompressionStreamStruct stream, StreamFlag flags); - [DllImport (Constants.libcompression)] + [DllImport (Constants.libcompressionLibrary)] public static extern CompressionStatus compression_stream_destroy (ref CompressionStreamStruct stream); } } diff --git a/src/Constants.iOS.cs.in b/src/Constants.iOS.cs.in index d760ea4e8828..03f99d400645 100644 --- a/src/Constants.iOS.cs.in +++ b/src/Constants.iOS.cs.in @@ -12,7 +12,9 @@ namespace MonoTouch { public const string libSystemLibrary = "/usr/lib/libSystem.dylib"; public const string libcLibrary = "/usr/lib/libc.dylib"; +#if !XAMCORE_4_0 public const string libdispatchLibrary = "/usr/lib/system/libdispatch.dylib"; +#endif public const string AddressBookLibrary = "/System/Library/Frameworks/AddressBook.framework/AddressBook"; public const string AddressBookUILibrary = "/System/Library/Frameworks/AddressBookUI.framework/AddressBookUI"; public const string AudioToolboxLibrary = "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"; @@ -98,14 +100,16 @@ namespace MonoTouch { public const string MetalKitLibrary = "/System/Library/Frameworks/MetalKit.framework/MetalKit"; public const string ModelIOLibrary = "/System/Library/Frameworks/ModelIO.framework/ModelIO"; public const string GameplayKitLibrary = "/System/Library/Frameworks/GameplayKit.framework/GameplayKit"; + public const string libcompressionLibrary = "/usr/lib/libcompression.dylib"; +#if !XAMCORE_4_0 public const string libcompression = "/usr/lib/libcompression.dylib"; - +#endif // iOS 9.3 - public const string HealthKitUILibrary = "/System/Library/Frameworks/HealthKitUI.framework/HealthKit"; + public const string HealthKitUILibrary = "/System/Library/Frameworks/HealthKitUI.framework/HealthKitUI"; // iOS 10.0 public const string CallKitLibrary = "/System/Library/Frameworks/CallKit.framework/CallKit"; public const string MessagesLibrary = "/System/Library/Frameworks/Messages.framework/Messages"; - public const string SpeechLibrary = "/System/Library/Frameworks/Speech.framework/"; + public const string SpeechLibrary = "/System/Library/Frameworks/Speech.framework/Speech"; public const string VideoSubscriberAccountLibrary = "/System/Library/Frameworks/VideoSubscriberAccount.framework/VideoSubscriberAccount"; public const string UserNotificationsLibrary = "/System/Library/Frameworks/UserNotifications.framework/UserNotifications"; public const string UserNotificationsUILibrary = "/System/Library/Frameworks/UserNotificationsUI.framework/UserNotificationsUI"; @@ -130,6 +134,6 @@ namespace MonoTouch { public const string AuthenticationServicesLibrary = "/System/Library/Frameworks/AuthenticationServices.framework/AuthenticationServices"; public const string CarPlayLibrary = "/System/Library/Frameworks/CarPlay.framework/CarPlay"; public const string IdentityLookupUILibrary = "/System/Library/Frameworks/IdentityLookupUI.framework/IdentityLookupUI"; - public const string NaturalLanguageLibrary = "/System/Library/Frameworks/Frameworks/NaturalLanguage.framework/NaturalLanguage"; + public const string NaturalLanguageLibrary = "/System/Library/Frameworks/NaturalLanguage.framework/NaturalLanguage"; } } diff --git a/src/Constants.mac.cs.in b/src/Constants.mac.cs.in index 0998741b16f8..536c16f109ae 100644 --- a/src/Constants.mac.cs.in +++ b/src/Constants.mac.cs.in @@ -59,17 +59,17 @@ namespace MonoMac { public const string ImageKitLibrary = "/System/Library/Frameworks/Quartz.framework/Frameworks/ImageKit.framework/ImageKit"; public const string OpenGLLibrary = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; public const string OpenALLibrary = "/System/Library/Frameworks/OpenAL.framework/OpenAL"; - public const string CoreMediaLibrary = "/System/Library/PrivateFrameworks/CoreMedia.framework/Versions/A/CoreMedia"; + public const string CoreMediaLibrary = "/System/Library/Frameworks/CoreMedia.framework/CoreMedia"; public const string ScriptingBridgeLibrary = "/System/Library/Frameworks/ScriptingBridge.framework/ScriptingBridge"; public const string CoreDataLibrary = "/System/Library/Frameworks/CoreData.framework/CoreData"; - public const string CoreImageLibrary = "/System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/CoreImage"; - public const string CFNetworkLibrary = "/System/Library/Frameworks/CoreServices.framework/Frameworks/CFNetwork.framework/CFNetwork"; + public const string CoreImageLibrary = "/System/Library/Frameworks/CoreImage.framework/Versions/Current/CoreImage"; + public const string CFNetworkLibrary = "/System/Library/Frameworks//CFNetwork.framework/CFNetwork"; public const string CoreMidiLibrary = "/System/Library/Frameworks/CoreMIDI.framework/CoreMIDI"; public const string QuickLookLibrary = "/System/Library/Frameworks/QuickLook.framework/QuickLook"; public const string AVFoundationLibrary = "/System/Library/Frameworks/AVFoundation.framework/AVFoundation"; public const string AccelerateImageLibrary = "/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/vImage"; - public const string CoreBluetoothLibrary = "/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework/CoreBluetooth"; + public const string CoreBluetoothLibrary = "/System/Library/Frameworks//CoreBluetooth.framework/CoreBluetooth"; public const string GameKitLibrary = "/System/Library/Frameworks/GameKit.framework/GameKit"; public const string SceneKitLibrary = "/System/Library/Frameworks/SceneKit.framework/SceneKit"; public const string StoreKitLibrary = "/System/Library/Frameworks/StoreKit.framework/StoreKit"; @@ -107,7 +107,9 @@ namespace MonoMac { public const string SearchKitLibrary = "/System/Library/Frameworks/CoreServices.framework/Frameworks/SearchKit.framework/SearchKit"; public const string libSystemLibrary = "/usr/lib/libSystem.dylib"; public const string libcLibrary = "/usr/lib/libc.dylib"; +#if !XAMCORE_4_0 public const string libdispatchLibrary = "/usr/lib/system/libdispatch.dylib"; +#endif public const string ContactsLibrary = "/System/Library/Frameworks/Contacts.framework/Contacts"; public const string ContactsUILibrary = "/System/Library/Frameworks/ContactsUI.framework/ContactsUI"; @@ -123,8 +125,10 @@ namespace MonoMac { public const string SafariServicesLibrary = "/System/Library/Frameworks/SafariServices.framework/SafariServices"; public const string PrintCoreLibrary = "/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/PrintCore"; - + public const string libcompressionLibrary = "/usr/lib/libcompression.dylib"; +#if !XAMCORE_4_0 public const string libcompression = "/usr/lib/libcompression.dylib"; +#endif // macOS 10.12 public const string PhotosLibrary = "/System/Library/Frameworks/Photos.framework/Photos"; @@ -144,7 +148,7 @@ namespace MonoMac { // macOS 10.14 public const string AdSupportLibrary = "/System/Library/Frameworks/AdSupport.framework/AdSupport"; - public const string NaturalLanguageLibrary = "/System/Library/Frameworks/Frameworks/NaturalLanguage.framework/NaturalLanguage"; + public const string NaturalLanguageLibrary = "/System/Library/Frameworks/NaturalLanguage.framework/NaturalLanguage"; public const string VideoSubscriberAccountLibrary = "/System/Library/Frameworks/VideoSubscriberAccount.framework/VideoSubscriberAccount"; public const string UserNotificationsLibrary = "/System/Library/Frameworks/UserNotifications.framework/UserNotifications"; public const string iTunesLibraryLibrary = "/System/Library/Frameworks/iTunesLibrary.framework/iTunesLibrary"; diff --git a/src/Constants.tvos.cs.in b/src/Constants.tvos.cs.in index cd2a5d6cf483..ea902d9a1d76 100644 --- a/src/Constants.tvos.cs.in +++ b/src/Constants.tvos.cs.in @@ -7,7 +7,9 @@ namespace ObjCRuntime { public const string libSystemLibrary = "/usr/lib/libSystem.dylib"; public const string libcLibrary = "/usr/lib/libc.dylib"; public const string ObjectiveCLibrary = "/usr/lib/libobjc.dylib"; +#if !XAMCORE_4_0 public const string libdispatchLibrary = "/usr/lib/system/libdispatch.dylib"; +#endif // TVOS 9.0 internal const string CoreServicesLibrary = "/System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices"; @@ -47,7 +49,9 @@ namespace ObjCRuntime { public const string ModelIOLibrary = "/System/Library/Frameworks/ModelIO.framework/ModelIO"; public const string NetworkLibrary = "/System/Library/Frameworks/Network.framework/Network"; public const string OpenGLESLibrary = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"; +#if !XAMCORE_4_0 public const string PassKitLibrary = "/System/Library/Frameworks/PassKit.framework/PassKit"; +#endif public const string QuartzLibrary = "/System/Library/Frameworks/QuartzCore.framework/QuartzCore"; public const string SceneKitLibrary = "/System/Library/Frameworks/SceneKit.framework/SceneKit"; public const string SecurityLibrary = "/System/Library/Frameworks/Security.framework/Security"; @@ -57,8 +61,10 @@ namespace ObjCRuntime { public const string TVMLKitLibrary = "/System/Library/Frameworks/TVMLKit.framework/TVMLKit"; public const string TVServicesLibrary = "/System/Library/Frameworks/TVServices.framework/TVServices"; public const string UIKitLibrary = "/System/Library/Frameworks/UIKit.framework/UIKit"; - + public const string libcompressionLibrary = "/usr/lib/libcompression.dylib"; +#if !XAMCORE_4_0 public const string libcompression = "/usr/lib/libcompression.dylib"; +#endif // TVOS 9.2 public const string MapKitLibrary = "/System/Library/Frameworks/MapKit.framework/MapKit"; @@ -80,6 +86,6 @@ namespace ObjCRuntime { public const string IOSurfaceLibrary = "/System/Library/Frameworks/IOSurface.framework/IOSurface"; // tvOS 12.0 - public const string NaturalLanguageLibrary = "/System/Library/Frameworks/Frameworks/NaturalLanguage.framework/NaturalLanguage"; + public const string NaturalLanguageLibrary = "/System/Library/Frameworks/NaturalLanguage.framework/NaturalLanguage"; } } diff --git a/src/Constants.watch.cs.in b/src/Constants.watch.cs.in index abd8aa1cbd02..d18754eff837 100644 --- a/src/Constants.watch.cs.in +++ b/src/Constants.watch.cs.in @@ -7,7 +7,9 @@ namespace ObjCRuntime { public const string libSystemLibrary = "/usr/lib/libSystem.dylib"; public const string libcLibrary = "/usr/lib/libc.dylib"; public const string ObjectiveCLibrary = "/usr/lib/libobjc.dylib"; +#if !XAMCORE_4_0 public const string libdispatchLibrary = "/usr/lib/system/libdispatch.dylib"; +#endif // WatchOS 2.0 public const string CFNetworkLibrary = "/System/Library/Frameworks/CFNetwork.framework/CFNetwork"; @@ -32,8 +34,10 @@ namespace ObjCRuntime { public const string UIKitLibrary = "/System/Library/Frameworks/UIKit.framework/UIKit"; public const string WatchConnectivityLibrary = "/System/Library/Frameworks/WatchConnectivity.framework/WatchConnectivity"; public const string WatchKitLibrary = "/System/Library/Frameworks/WatchKit.framework/WatchKit"; - + public const string libcompressionLibrary = "/usr/lib/libcompression.dylib"; +#if !XAMCORE_4_0 public const string libcompression = "/usr/lib/libcompression.dylib"; +#endif // WatchOS 3.0 public const string AVFoundationLibrary = "/System/Library/Frameworks/AVFoundation.framework/AVFoundation"; @@ -54,7 +58,7 @@ namespace ObjCRuntime { public const string VisionLibrary = "/System/Library/Frameworks/Vision.framework/Vision"; // WatchOS 5 - public const string NaturalLanguageLibrary = "/System/Library/Frameworks/Frameworks/NaturalLanguage.framework/NaturalLanguage"; + public const string NaturalLanguageLibrary = "/System/Library/Frameworks/NaturalLanguage.framework/NaturalLanguage"; public const string MediaPlayerLibrary = "/System/Library/Frameworks/MediaPlayer.framework/MediaPlayer"; } } diff --git a/tests/apitest/src/EveryFrameworkSmokeTest.cs b/tests/apitest/src/EveryFrameworkSmokeTest.cs index 6d7c4e0d00f1..27fc0deee506 100644 --- a/tests/apitest/src/EveryFrameworkSmokeTest.cs +++ b/tests/apitest/src/EveryFrameworkSmokeTest.cs @@ -79,6 +79,7 @@ LoadStatus CheckLoadFailure (string libraryName, string path) // macOS 10.14 case "AdSupportLibrary": case "iTunesLibraryLibrary": + case "NaturalLanguageLibrary": case "NetworkLibrary": case "UserNotificationsLibrary": case "VideoSubscriberAccountLibrary": diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index 26dc12d56ab6..d35dcf6134f2 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -36,6 +37,7 @@ using Foundation; #else #if MONOMAC +using MonoMac; using MonoMac.AppKit; using MonoMac.ObjCRuntime; using MonoMac.Foundation; @@ -847,7 +849,7 @@ bool IsObsolete (MemberInfo mi) } [Test] - public void TypoTest () + public virtual void TypoTest () { var types = Assembly.GetTypes (); int totalErrors = 0; @@ -1034,5 +1036,70 @@ static string NameCleaner (string name) } return clean.ToString (); } + + bool CheckLibrary (string lib) + { +#if MONOMAC + // on macOS the file should exist on the specified path + // for iOS the simulator paths do not match the strings + if (!File.Exists (lib)) + return false; +#endif + var h = IntPtr.Zero; + try { + h = Dlfcn.dlopen (lib, 0); + if (h != IntPtr.Zero) + return true; +#if MONOMAC + // on macOS it might be wrong architecture + // i.e. 64 bits only (thin) libraries running on 32 bits process + if (IntPtr.Size == 4) + return true; +#endif + } finally { + Dlfcn.dlclose (h); + } + return false; + } + + [Test] + public void ConstantsCheck () + { + var c = typeof (Constants); + foreach (var fi in c.GetFields ()) { + if (!fi.IsPublic) + continue; + var s = fi.GetValue (null) as string; + switch (fi.Name) { + case "Version": + case "SdkVersion": + Assert.True (Version.TryParse (s, out _), fi.Name); + break; +#if !XAMCORE_4_0 +#if __TVOS__ + case "PassKitLibrary": // not part of tvOS + break; +#endif + case "libcompression": // bad (missing) suffix + Assert.True (CheckLibrary (s), fi.Name); + break; +#endif +#if __TVOS__ + case "MetalPerformanceShadersLibrary": + // not supported in tvOS (12.1) simulator so load fails + if (Runtime.Arch == Arch.SIMULATOR) + break; + goto default; +#endif + default: + if (fi.Name.EndsWith ("Library", StringComparison.Ordinal)) { + Assert.True (CheckLibrary (s), fi.Name); + } else { + Assert.Fail ($"Unknown '{fi.Name}' field cannot be verified - please fix me!"); + } + break; + } + } + } } } diff --git a/tests/introspection/iOS/iOSApiTypoTest.cs b/tests/introspection/iOS/iOSApiTypoTest.cs index 4fa3a1ba6f1c..b9dcc13d315e 100644 --- a/tests/introspection/iOS/iOSApiTypoTest.cs +++ b/tests/introspection/iOS/iOSApiTypoTest.cs @@ -26,11 +26,6 @@ public void SetUp () #if __WATCHOS__ Assert.Ignore ("Need to find alternative for UITextChecker on WatchOS."); #else - // that's slow and there's no value to run it on devices as the API names - // being verified won't change from the simulator - if (Runtime.Arch == Arch.DEVICE) - Assert.Ignore ("Typos only detected on simulator"); - // the dictionary used by iOS varies with versions and // we don't want to maintain special cases for each version var sdk = new Version (Constants.SdkVersion); @@ -51,5 +46,15 @@ public override string GetTypo (string txt) return txt.Substring ((int) typoRange.Location, (int) typoRange.Length); #endif } + + public override void TypoTest () + { + // that's slow and there's no value to run it on devices as the API names + // being verified won't change from the simulator + if (Runtime.Arch == Arch.DEVICE) + Assert.Ignore ("Typos only detected on simulator"); + + base.TypoTest (); + } } } From 61b2038b3d85d22b58e60640a8ef40b69f1e73d5 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 23 Nov 2018 16:02:15 +0100 Subject: [PATCH 11/15] [Xharness] Add a workaround to not build the xunit tests when not needed. (#5156) * [Xharness] Add a workaround to not build the xunit tests when not needed. This is a workaround that does not use reflection to build the bcl test projects. We need this until we have complete support of using mono as an SDK. --- tests/Makefile | 7 +- .../BCLTestImportTargetFactory.cs | 11 +- tests/xharness/Harness.cs | 9 + tests/xharness/Jenkins.cs | 6 + tests/xharness/TestProject.cs | 1 + tests/xharness/xharness.csproj | 3 + .../BCLTestImporter/BCLTestImporter.csproj | 1 + .../BCLTestImporterTests.csproj | 3 + .../BCLTestProjectDefinition.cs | 2 +- .../BCLTestProjectDefinitionWorkaround.cs | 156 ++++++++++++++++++ .../BCLTestProjectGenerator.cs | 14 +- .../BCLTestImporter/RegisterTypeGenerator.cs | 41 ++++- 12 files changed, 239 insertions(+), 15 deletions(-) create mode 100644 tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs diff --git a/tests/Makefile b/tests/Makefile index 5901c99e97ce..947881940e9a 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -193,11 +193,14 @@ $(TOP)/tools/mtouch/SdkVersions.cs: $(TOP)/tools/common/SdkVersions.cs.in @$(MAKE) -C $(TOP)/src project-files @touch $@ -xharness/xharness.exe: $(wildcard xharness/*.cs) xharness/xharness.csproj $(TOP)/tools/mtouch/SdkVersions.cs test.config test-system.config .stamp-src-project-files +.stamp-build-mono-unit-tests: $(TOP)/.git/modules/external/mono/HEAD make -j8 -C $(TOP)/external/mono/mcs/class -i do-test PROFILE=MONOTOUCH # TODO: This should not be needed and we should get the dlls from the SDK. make -j8 -C $(TOP)/external/mono/mcs/class -i do-xunit-test PROFILE=MONOTOUCH # TODO: This should not be needed and we should get the dlls from the SDK. - nuget restore xharness/xharness.csproj nuget restore bcl-test/BCLTests/BCLTests.csproj + $(Q) touch $@ + +xharness/xharness.exe: $(wildcard xharness/*.cs) xharness/xharness.csproj $(TOP)/tools/mtouch/SdkVersions.cs test.config test-system.config .stamp-src-project-files + nuget restore xharness/xharness.csproj $(Q_GEN) $(SYSTEM_XIBUILD) -- $(MSBUILD_VERBOSITY_QUIET) xharness/xharness.csproj killall: diff --git a/tests/xharness/BCLTestImporter/BCLTestImportTargetFactory.cs b/tests/xharness/BCLTestImporter/BCLTestImportTargetFactory.cs index 114719d3f8ee..85dbcd885ae2 100644 --- a/tests/xharness/BCLTestImporter/BCLTestImportTargetFactory.cs +++ b/tests/xharness/BCLTestImporter/BCLTestImportTargetFactory.cs @@ -33,10 +33,15 @@ public List GetBclTargets () // generate all projects, then create a new iOSTarget per project foreach (var (name, path, xunit, platforms) in projectGenerator.GenerateAllTestProjects ()) { var prefix = xunit ? "xUnit" : "NUnit"; - result.Add (new iOSTestProject (path) { + result.Add (new iOSTestProject (path) { Name = $"[{prefix}] Mono {name}", - SkiptvOSVariation=!platforms.Contains (Platform.TvOS), - SkipwatchOSVariation=!platforms.Contains (Platform.WatchOS) + SkiptvOSVariation = !platforms.Contains (Platform.TvOS), + SkipwatchOSVariation = !platforms.Contains (Platform.WatchOS), + Dependency = async () => { + var rv = await Harness.BuildBclTests (); + if (!rv.Succeeded) + throw new Exception ($"Failed to build BCL tests, exit code: {rv.ExitCode}. Check the harness log for more details."); + } }); } return result; diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 590dbc38066e..5cee1114cf01 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -833,6 +833,15 @@ public async Task> CreateCrashReportsSnapshotAsync (Log log, boo return rv; } + + Task build_bcl_tests; + public Task BuildBclTests () + { + if (build_bcl_tests == null) + build_bcl_tests = ProcessHelper.ExecuteCommandAsync ("make", $".stamp-build-mono-unit-tests -C {StringUtils.Quote (Path.GetFullPath (RootDirectory))}", HarnessLog, TimeSpan.FromMinutes (30)); + return build_bcl_tests; + } + } public class CrashReportSnapshot diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index 99236e8cf3d5..dbb6da7981b8 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -57,6 +57,7 @@ public Logs Logs { public Devices Devices = new Devices (); List Tasks = new List (); + Dictionary DependencyTasks = new Dictionary (); internal static Resource DesktopResource = new Resource ("Desktop", Environment.ProcessorCount); @@ -348,6 +349,7 @@ IEnumerable CreateRunSimulatorTasks () Platform = pair.Item2, Ignored = pair.Item3, TestName = project.Name, + Dependency = project.Dependency, }; derived.CloneTestProject (pair.Item1); var simTasks = CreateRunSimulatorTaskAsync (derived); @@ -2206,6 +2208,7 @@ abstract class TestTask public string ProjectPlatform; public Dictionary Environment = new Dictionary (); + public Func Dependency; // a task that's feteched and awaited before this task's ExecuteAsync method public Task InitialTask; // a task that's executed before this task's ExecuteAsync method. public Task CompletedTask; // a task that's executed after this task's ExecuteAsync method. @@ -2402,6 +2405,9 @@ async Task RunInternalAsync () ExecutionResult = (ExecutionResult & ~TestExecutingResult.StateMask) | TestExecutingResult.InProgress; try { + if (Dependency != null) + await Dependency (); + if (InitialTask != null) await InitialTask; diff --git a/tests/xharness/TestProject.cs b/tests/xharness/TestProject.cs index 67a5d5010250..b9bdc123fa1d 100644 --- a/tests/xharness/TestProject.cs +++ b/tests/xharness/TestProject.cs @@ -18,6 +18,7 @@ public class TestProject public bool IsNUnitProject; public bool GenerateVariations = true; public string [] Configurations; + public Func Dependency; public IEnumerable ProjectReferences; diff --git a/tests/xharness/xharness.csproj b/tests/xharness/xharness.csproj index 85d1cd359f9f..9efb5edb668a 100644 --- a/tests/xharness/xharness.csproj +++ b/tests/xharness/xharness.csproj @@ -130,6 +130,9 @@ BCLTestImporter\BCLTestInfoPlistGenerator.cs + + BCLTestImporter\BCLTestProjectDefinitionWorkaround.cs + diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestImporter.csproj b/tools/bcl-test-importer/BCLTestImporter/BCLTestImporter.csproj index 19818b26339b..4c6fca064ed1 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestImporter.csproj +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestImporter.csproj @@ -40,6 +40,7 @@ + diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestImporterTests/BCLTestImporterTests.csproj b/tools/bcl-test-importer/BCLTestImporter/BCLTestImporterTests/BCLTestImporterTests.csproj index 42ca4ab27db9..0dcdc9f9002d 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestImporterTests/BCLTestImporterTests.csproj +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestImporterTests/BCLTestImporterTests.csproj @@ -21,6 +21,9 @@ BCLTestInfoPlistGenerator.cs + + BCLTestProjectDefinitionWorkaround.cs + BCLTestProjectGenerator.cs diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs index ba34a00d5011..bb8e0879c96a 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinition.cs @@ -9,7 +9,7 @@ namespace BCLTestImporter { /// Class that defines a bcl test project. A bcl test project by definition is the combination of the name /// of the project and a set on assemblies to be tested. /// - public struct BCLTestProjectDefinition { + public partial struct BCLTestProjectDefinition { public string Name { get; set; } public List TestAssemblies {get; private set;} public bool IsXUnit { diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs new file mode 100644 index 000000000000..5e7d5d00aa87 --- /dev/null +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectDefinitionWorkaround.cs @@ -0,0 +1,156 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; + +namespace BCLTestImporter +{ + // Added for the workaround so that it does not make the code uglier + public partial struct BCLTestProjectDefinition + { + static Dictionary> cachedAssemblyInfo = + new Dictionary> + { + {"SystemNumericsTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System.Numerics", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Numerics.dll"), + (assembly:"MONOTOUCH_System.Numerics_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Numerics_test.dll"), + }}, + {"SystemRuntimeSerializationTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"System.Runtime.Serialization", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Runtime.Serialization.dll"), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"System", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.dll"), + (assembly:"System.ServiceModel", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.ServiceModel.dll"), + (assembly:"System.Xml", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Xml.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"MONOTOUCH_System.Runtime.Serialization_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Runtime.Serialization_test.dll"), + }}, + {"SystemXmlLinqTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System.Xml", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Xml.dll"), + (assembly:"System.Xml.Linq", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Xml.Linq.dll"), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"MONOTOUCH_System.Xml.Linq_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Xml.Linq_test.dll"), + }}, + {"MonoSecurityTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"Mono.Security", hint:"{MONO_ROOT}mcs/class/lib/monotouch/Mono.Security.dll"), + (assembly:"MONOTOUCH_Mono.Security_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_Mono.Security_test.dll"), + }}, + {"SystemComponentModelDataAnnotationTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System.ComponentModel.DataAnnotations", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.ComponentModel.DataAnnotations.dll"), + (assembly:"System", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.dll"), + (assembly:"MONOTOUCH_System.ComponentModel.DataAnnotations_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.ComponentModel.DataAnnotations_test.dll"), + }}, + {"SystemJsonTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System.Json", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Json.dll"), + (assembly:"MONOTOUCH_System.Json_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Json_test.dll"), + }}, + {"MonoDataTdsTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.dll"), + (assembly:"Mono.Data.Tds", hint:"{MONO_ROOT}mcs/class/lib/monotouch/Mono.Data.Tds.dll"), + (assembly:"MONOTOUCH_Mono.Data.Tds_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_Mono.Data.Tds_test.dll"), + }}, + {"MonoCSharpTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"Mono.CSharp", hint:"{MONO_ROOT}mcs/class/lib/monotouch/Mono.CSharp.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"MONOTOUCH_Mono.CSharp_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_Mono.CSharp_test.dll"), + }}, + {"SystemJsonMicrosoftTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System.Json.Microsoft", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Json.Microsoft.dll"), + (assembly:"MONOTOUCH_System.Json.Microsoft_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Json.Microsoft_test.dll"), + }}, + {"MonoParallelTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"Mono.Parallel", hint:"{MONO_ROOT}mcs/class/lib/monotouch/Mono.Parallel.dll"), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"MONOTOUCH_Mono.Parallel_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_Mono.Parallel_test.dll"), + }}, + {"MonoTaskletsTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"Mono.Tasklets", hint:"{MONO_ROOT}mcs/class/lib/monotouch/Mono.Tasklets.dll"), + (assembly:"MONOTOUCH_Mono.Tasklets_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_Mono.Tasklets_test.dll"), + }}, + {"SystemThreadingTasksDataflowTests", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"System.Threading.Tasks.Dataflow", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Threading.Tasks.Dataflow.dll"), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"nunitlite", hint:"{MONO_ROOT}mcs/class/lib/monotouch/nunitlite.dll"), + (assembly:"System", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.dll"), + (assembly:"MONOTOUCH_System.Threading.Tasks.Dataflow_test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Threading.Tasks.Dataflow_test.dll"), + }}, + {"SystemJsonXunit", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"xunit.core", hint:""), + (assembly:"xunit.abstractions", hint:""), + (assembly:"xunit.assert", hint:""), + (assembly:"System.Json", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Json.dll"), + (assembly:"System", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.dll"), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"MONOTOUCH_System.Json_xunit-test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Json_xunit-test.dll"), + }}, + {"SystemNumericsXunit", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"xunit.core", hint:""), + (assembly:"xunit.abstractions", hint:""), + (assembly:"xunit.assert", hint:""), + (assembly:"System.Numerics", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Numerics.dll"), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"Xunit.NetCore.Extensions", hint:""), + (assembly:"Microsoft.CSharp", hint:"{MONO_ROOT}mcs/class/lib/monotouch/Microsoft.CSharp.dll"), + (assembly:"MONOTOUCH_System.Numerics_xunit-test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Numerics_xunit-test.dll"), + }}, + {"SystemLinqXunit", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"System.Xml", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Xml.dll"), + (assembly:"xunit.core", hint:""), + (assembly:"xunit.abstractions", hint:""), + (assembly:"System.Xml.Linq", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Xml.Linq.dll"), + (assembly:"Xunit.NetCore.Extensions", hint:""), + (assembly:"System", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.dll"), + (assembly:"xunit.assert", hint:""), + (assembly:"System.Core", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Core.dll"), + (assembly:"MONOTOUCH_System.Xml.Linq_xunit-test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Xml.Linq_xunit-test.dll"), + }}, + {"SystemRuntimeCompilerServicesUnsafeXunit", new List<(string assembly, string hint)> { + (assembly:"mscorlib", hint:"{MONO_ROOT}mcs/class/lib/monotouch/mscorlib.dll"), + (assembly:"xunit.core", hint:""), + (assembly:"xunit.abstractions", hint:""), + (assembly:"System.Runtime.CompilerServices.Unsafe", hint:"{MONO_ROOT}mcs/class/lib/monotouch/System.Runtime.CompilerServices.Unsafe.dll"), + (assembly:"xunit.assert", hint:""), + (assembly:"MONOTOUCH_System.Runtime.CompilerServices.Unsafe_xunit-test.dll", hint:"{MONO_ROOT}mcs/class/lib/monotouch/tests/MONOTOUCH_System.Runtime.CompilerServices.Unsafe_xunit-test.dll"), + }}, + }; + + public List<(string assembly, string hintPath)> GetCachedAssemblyInclusionInformation (string monoRootPath, + Platform platform) + { + if (!monoRootPath.EndsWith ("/")) + monoRootPath += "/"; + var info = cachedAssemblyInfo[Name]; + // lets fix the path + var fixedResult = new List<(string assembly, string hintPath)> (); + foreach (var (assembly, hin) in info){ + fixedResult.Add ((assembly, hin.Replace ("{MONO_ROOT}", monoRootPath))); + } + + return fixedResult; + } + } +} diff --git a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs index fce1b580bd8b..b78c65a125c8 100644 --- a/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/BCLTestProjectGenerator.cs @@ -313,9 +313,8 @@ bool IsIgnored(BCLTestProjectDefinition project, Platform platform) Directory.CreateDirectory (generatedCodeDir); } var registerTypePath = Path.Combine (generatedCodeDir, "RegisterType.cs"); - var typesPerAssembly = projectDefinition.GetTypeForAssemblies (MonoRootPath, Platform.WatchOS); - var registerCode = await RegisterTypeGenerator.GenerateCodeAsync (typesPerAssembly, - projectDefinition.IsXUnit, RegisterTypesTemplatePath); + var registerCode = await RegisterTypeGenerator.GenerateCodeAsync (def.name, projectDefinition.IsXUnit, + RegisterTypesTemplatePath); using (var file = new StreamWriter (registerTypePath, false)) { // false is do not append await file.WriteAsync (registerCode); } @@ -337,7 +336,7 @@ bool IsIgnored(BCLTestProjectDefinition project, Platform platform) generatedProject = await GenerateWatchAppAsync (projectDefinition.Name, projetTemplate, data.plist); break; default: - generatedProject = await GenerateWatchExtensionAsync (projectDefinition.Name, projetTemplate, data.plist, registerTypePath, projectDefinition.GetAssemblyInclusionInformation (MonoRootPath, Platform.WatchOS)); + generatedProject = await GenerateWatchExtensionAsync (projectDefinition.Name, projetTemplate, data.plist, registerTypePath, projectDefinition.GetCachedAssemblyInclusionInformation (MonoRootPath, Platform.WatchOS)); break; } data.project = GetProjectPath (projectDefinition.Name, appType); @@ -391,9 +390,8 @@ bool IsIgnored(BCLTestProjectDefinition project, Platform platform) } var registerTypePath = Path.Combine (generatedCodeDir, "RegisterType.cs"); - var typesPerAssembly = projectDefinition.GetTypeForAssemblies (MonoRootPath, platform); - var registerCode = await RegisterTypeGenerator.GenerateCodeAsync (typesPerAssembly, - projectDefinition.IsXUnit, RegisterTypesTemplatePath); + var registerCode = await RegisterTypeGenerator.GenerateCodeAsync (def.name, projectDefinition.IsXUnit, + RegisterTypesTemplatePath); using (var file = new StreamWriter (registerTypePath, false)) { // false is do not append await file.WriteAsync (registerCode); @@ -408,7 +406,7 @@ bool IsIgnored(BCLTestProjectDefinition project, Platform platform) var projectTemplatePath = Path.Combine (ProjectTemplateRootPath, projectTemplateMatches[platform]); var generatedProject = await GenerateAsync (projectDefinition.Name, registerTypePath, - projectDefinition.GetAssemblyInclusionInformation (MonoRootPath, platform), projectTemplatePath, infoPlistPath); + projectDefinition.GetCachedAssemblyInclusionInformation (MonoRootPath, platform), projectTemplatePath, infoPlistPath); var projectPath = GetProjectPath (projectDefinition.Name, platform); projectPaths.Add ((name: projectDefinition.Name, path: projectPath, xunit: projectDefinition.IsXUnit)); using (var file = new StreamWriter (projectPath, false)) { // false is do not append diff --git a/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs b/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs index 65fd81afccbb..f8aacebd825e 100644 --- a/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs +++ b/tools/bcl-test-importer/BCLTestImporter/RegisterTypeGenerator.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.IO; using System.Text; using System.Threading.Tasks; using System.Reflection; using System.Collections.Generic; +using System.Linq; namespace BCLTestImporter { public static class RegisterTypeGenerator { @@ -11,6 +12,44 @@ public static class RegisterTypeGenerator { static string UsingReplacement = "%USING%"; static string KeysReplacement = "%KEY VALUES%"; static string IsxUnitReplacement = "%IS XUNIT%"; + + // the following cache is a workaround until mono does provide the required binaries precompiled, at that point + // we will remove the dict and we will use the refection based method. + static Dictionary cache = new Dictionary { + {"SystemNumericsTests", ("MonoTests.System.Numerics", "MONOTOUCH_System.Numerics_test.dll", "MonoTests.System.Numerics.BigIntegerTest")}, + {"SystemRuntimeSerializationTests", ("MonoTests", "MONOTOUCH_System.Runtime.Serialization_test.dll", "MonoTests.XmlComparer")}, + {"SystemXmlLinqTests", ("MonoTests.System.Xml", "MONOTOUCH_System.Xml.Linq_test.dll", "MonoTests.System.Xml.ExtensionsTest")}, + {"MonoSecurityTests", ("MonoTests.System.Security.Cryptography", "MONOTOUCH_Mono.Security_test.dll", "MonoTests.System.Security.Cryptography.SHA224ManagedTest")}, + {"SystemComponentModelDataAnnotationTests", ("MonoTests.System.ComponentModel.DataAnnotations", "MONOTOUCH_System.ComponentModel.DataAnnotations_test.dll", "MonoTests.System.ComponentModel.DataAnnotations.AssociationAttributeTest")}, + {"SystemJsonTests", ("MonoTests.System", "MONOTOUCH_System.Json_test.dll", "MonoTests.System.JsonValueTests")}, + {"MonoDataTdsTests", ("MonoTests.Mono.Data.Tds", "MONOTOUCH_Mono.Data.Tds_test.dll", "MonoTests.Mono.Data.Tds.TdsConnectionPoolTest")}, + {"MonoCSharpTests", ("MonoTests.Visit", "MONOTOUCH_Mono.CSharp_test.dll", "MonoTests.Visit.ASTVisitorTest")}, + {"SystemJsonMicrosoftTests", ("MonoTests.System", "MONOTOUCH_System.Json.Microsoft_test.dll", "MonoTests.System.JsonValueTests")}, + {"MonoParallelTests", ("MonoTests.Mono.Threading", "MONOTOUCH_Mono.Parallel_test.dll", "MonoTests.Mono.Threading.SnziTests")}, + {"MonoTaskletsTests", ("MonoTests.System", "MONOTOUCH_Mono.Tasklets_test.dll", "MonoTests.System.ContinuationsTest")}, + {"SystemThreadingTasksDataflowTests", ("MonoTests", "MONOTOUCH_System.Threading.Tasks.Dataflow_test.dll", "MonoTests.TestScheduler")}, + {"SystemJsonXunit", ("System.Json.Tests", "MONOTOUCH_System.Json_xunit-test.dll", "System.Json.Tests.JsonArrayTests")}, + {"SystemNumericsXunit", ("System.Numerics.Tests", "MONOTOUCH_System.Numerics_xunit-test.dll", "System.Numerics.Tests.GenericVectorTests")}, + {"SystemLinqXunit", ("Microsoft.Test.ModuleCore", "MONOTOUCH_System.Xml.Linq_xunit-test.dll", "Microsoft.Test.ModuleCore.LtmContext")}, + {"SystemRuntimeCompilerServicesUnsafeXunit", ("System.Runtime.CompilerServices", "MONOTOUCH_System.Runtime.CompilerServices.Unsafe_xunit-test.dll", "System.Runtime.CompilerServices.UnsafeTests")}, + }; + + public static async Task GenerateCodeAsync (string projectName, bool isXunit, string templatePath) + { + var cachedData = cache[projectName]; + var importStringBuilder = new StringBuilder (); + var keyValuesStringBuilder = new StringBuilder (); + importStringBuilder.AppendLine ($"using {cachedData.testNamespace};"); + keyValuesStringBuilder.AppendLine ($"\t\t\t{{ \"{cachedData.testAssembly}\", typeof ({cachedData.testType})}}, "); + // got the lines we want to add, read the template and substitute + using (var reader = new StreamReader(templatePath)) { + var result = await reader.ReadToEndAsync (); + result = result.Replace (UsingReplacement, importStringBuilder.ToString ()); + result = result.Replace (KeysReplacement, keyValuesStringBuilder.ToString ()); + result = result.Replace (IsxUnitReplacement, (isXunit)? "true" : "false"); + return result; + } + } public static async Task GenerateCodeAsync (Dictionary typeRegistration, bool isXunit, string templatePath) From 2e754a2f7073d3a06d13a78c5b03f22fd38feff7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 23 Nov 2018 16:22:14 +0100 Subject: [PATCH 12/15] [xibuild] Build the expected configuration. (#5172) --- tools/xibuild/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/xibuild/Makefile b/tools/xibuild/Makefile index e2c25409b713..b1627b49b469 100644 --- a/tools/xibuild/Makefile +++ b/tools/xibuild/Makefile @@ -2,14 +2,14 @@ TOP = ../.. include $(TOP)/Make.config -CONFIGURATION=Release +CONFIGURATION=Debug SRC_FILES=Main.cs \ ../../external/mono/mcs/class/Mono.Options/Mono.Options/Options.cs all: bin/$(CONFIGURATION)/xibuild.exe bin/$(CONFIGURATION)/xibuild.exe: xibuild.csproj $(SRC_FILES) - $(SYSTEM_MSBUILD) xibuild.csproj + $(SYSTEM_MSBUILD) xibuild.csproj /p:Configuration=$(CONFIGURATION) clean-local:: $(SYSTEM_MSBUILD) /t:Clean xibuild.csproj From ecb1081e23b7c6f4a6c89608f8250f3917ce4023 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 23 Nov 2018 16:23:03 +0100 Subject: [PATCH 13/15] [jenkins] Fix path to api diff in commit comment. (#5173) --- jenkins/compare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/compare.sh b/jenkins/compare.sh index a87fdee66689..09e1c35d39db 100755 --- a/jenkins/compare.sh +++ b/jenkins/compare.sh @@ -65,7 +65,7 @@ cp -R tools/comparison/generator-diff jenkins-results/generator-diff if [[ "x$1" == "x--publish" ]]; then URL_PREFIX=$(./jenkins/publish-results.sh | grep "^Url Prefix: " | sed 's/^Url Prefix: //') - URL_API="$URL_PREFIX/apicomparison/index.html" + URL_API="$URL_PREFIX/apicomparison/api-diff.html" URL_GENERATOR="$URL_PREFIX/generator-diff/index.html" else URL_API="$BUILD_URL/API_20diff_20_28PR_20only_29" From db4e24e99f3b699160ef7d87f69f61d5bd628039 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 23 Nov 2018 15:19:15 -0500 Subject: [PATCH 14/15] Revert "Mono 5.16.0.87+ breaks us, so make sure we don't use it for now. (#5088)" (#5175) This reverts commit 1ca7da537da1e81d56bcdeb215c63e16d2a08bdc. This is fixed so the restriction is not needed anymore. --- Make.config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Make.config b/Make.config index 8dc5e7151903..b988a7f0035f 100644 --- a/Make.config +++ b/Make.config @@ -48,8 +48,7 @@ XCODE94_DEVELOPER_ROOT=/Applications/Xcode94.app/Contents/Developer # Minimum Mono version for building XI/XM MIN_MONO_VERSION=5.16.0.5 -# https://github.com/mono/mono/issues/11564: 5.16.0.87+ breaks us, so make sure we don't use it. -MAX_MONO_VERSION=5.16.0.86 +MAX_MONO_VERSION=5.16.99 MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-06/7/7627a5f9eeba0fd846731ad0c498556f55be1a34/MonoFramework-MDK-5.16.0.5.macos10.xamarin.universal.pkg # Minimum Mono version for Xamarin.Mac apps using the system mono From 930e37232fe4c677e843baaadb81c32fad5413a7 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 23 Nov 2018 18:25:31 -0500 Subject: [PATCH 15/15] [tests][intro] Fix CoreImage location check for older macOS versions (#5176) addendum to https://github.com/xamarin/xamarin-macios/pull/5159 failure on internal bots https://github.com/xamarin/xamarin-macios/commit/4f1c39a00fda2d7bbbe0fb6ed3b39261005f33f1#commitcomment-31401007 --- src/Constants.mac.cs.in | 4 ++-- tests/introspection/ApiTypoTest.cs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Constants.mac.cs.in b/src/Constants.mac.cs.in index 536c16f109ae..96a727b41521 100644 --- a/src/Constants.mac.cs.in +++ b/src/Constants.mac.cs.in @@ -62,8 +62,8 @@ namespace MonoMac { public const string CoreMediaLibrary = "/System/Library/Frameworks/CoreMedia.framework/CoreMedia"; public const string ScriptingBridgeLibrary = "/System/Library/Frameworks/ScriptingBridge.framework/ScriptingBridge"; public const string CoreDataLibrary = "/System/Library/Frameworks/CoreData.framework/CoreData"; - public const string CoreImageLibrary = "/System/Library/Frameworks/CoreImage.framework/Versions/Current/CoreImage"; - public const string CFNetworkLibrary = "/System/Library/Frameworks//CFNetwork.framework/CFNetwork"; + public const string CoreImageLibrary = "/System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/CoreImage"; + public const string CFNetworkLibrary = "/System/Library/Frameworks/CFNetwork.framework/CFNetwork"; public const string CoreMidiLibrary = "/System/Library/Frameworks/CoreMIDI.framework/CoreMIDI"; public const string QuickLookLibrary = "/System/Library/Frameworks/QuickLook.framework/QuickLook"; public const string AVFoundationLibrary = "/System/Library/Frameworks/AVFoundation.framework/AVFoundation"; diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index d35dcf6134f2..db80c307de61 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -1042,8 +1042,11 @@ bool CheckLibrary (string lib) #if MONOMAC // on macOS the file should exist on the specified path // for iOS the simulator paths do not match the strings - if (!File.Exists (lib)) - return false; + if (!File.Exists (lib)) { + if (lib != Constants.CoreImageLibrary) + return false; + // location changed in 10.11 but it loads fine (and fixing it breaks on earlier macOS) + } #endif var h = IntPtr.Zero; try {