diff --git a/tests/Makefile b/tests/Makefile index b242791bc3ff..917286623b74 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -352,8 +352,6 @@ package-test-libraries.zip: $(Q) $(MAKE) all -C test-libraries/custom-type-assembly build-assembly $(Q_GEN) rm -f "$@" "$@.tmp" $(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tests/test-libraries - $(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tests/mono-native/macOS/unified ./tests/mono-native/macOS/compat - $(Q_GEN) cd $(TOP) && zip -9r --symlinks $(abspath $@).tmp ./tests/mono-native/iOS/unified ./tests/mono-native/iOS/compat $(Q_GEN) cd $(TOP) && find tests -regex '.*/generated-projects/.*[c|f]sproj' -exec zip -9r --symlinks $(abspath $@).tmp {} + $(Q_GEN) cd $(TOP) && find tests -regex '.*/generated-projects/.*sln' -exec zip -9r --symlinks $(abspath $@).tmp {} + $(Q_GEN) cd $(TOP) && find tests -regex 'tests/test-libraries/custom-type-assembly/.libs/.*dll' -exec zip -9r --symlinks $(abspath $@).tmp {} + diff --git a/tests/common/MonoNativeConfig.cs b/tests/common/MonoNativeConfig.cs deleted file mode 100644 index 770ea99552ca..000000000000 --- a/tests/common/MonoNativeConfig.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using NUnit.Framework; - -namespace Xamarin.Tests { - public enum MonoNativeLinkMode { - None, - Static, - Dynamic, - Framework, - Symlink, - } - - public enum MonoNativeFlavor { - None, - Unified, - } - - public static class MonoNativeConfig { - public static MonoNativeLinkMode LinkMode { - get { -#if MONO_NATIVE_STATIC - return MonoNativeLinkMode.Static; -#elif MONO_NATIVE_DYNAMIC - return MonoNativeLinkMode.Dynamic; -#elif MONO_NATIVE_SYMLINK - return MonoNativeLinkMode.Symlink; -#else - return MonoNativeLinkMode.None; -#endif - } - } - - public static MonoNativeFlavor Flavor { - get { -#if MONO_NATIVE_UNIFIED - return MonoNativeFlavor.Unified; -#else - return MonoNativeFlavor.None; -#endif - } - } - - public static bool UsingCompat { - get { -#if MONO_NATIVE_UNIFIED - return false; -#else - Assert.Fail ("Missing `MONO_NATIVE_UNIFIED`"); - throw new NotImplementedException (); -#endif - } - } - - public static string GetDynamicLibraryName () - { - return GetDynamicLibraryName (MonoNativeFlavor.Unified); - } - - public static string GetDynamicLibraryName (MonoNativeFlavor flavor) - { - switch (flavor) { - case MonoNativeFlavor.Unified: - return "libmono-native-unified.dylib"; - default: - Assert.Fail ($"Invalid MonoNativeFlavor: {flavor}"); - throw new NotImplementedException (); - } - } - - public static string GetPInvokeLibraryName (MonoNativeFlavor flavor, MonoNativeLinkMode link) - { - switch (link) { - case MonoNativeLinkMode.Static: - return null; - case MonoNativeLinkMode.Dynamic: - return GetDynamicLibraryName (flavor); - case MonoNativeLinkMode.Symlink: - return "libmono-native.dylib"; - default: - Assert.Fail ($"Invalid link mode: {MonoNativeConfig.LinkMode}"); - throw new NotImplementedException (); - } - } - - public static string DynamicLibraryName => GetDynamicLibraryName (); - } -} diff --git a/tests/introspection/ApiPInvokeTest.cs b/tests/introspection/ApiPInvokeTest.cs index 043ef299944a..e75f72d0e01e 100644 --- a/tests/introspection/ApiPInvokeTest.cs +++ b/tests/introspection/ApiPInvokeTest.cs @@ -158,13 +158,7 @@ public void SymbolExists () case "System.Native": case "System.Security.Cryptography.Native.Apple": case "System.Net.Security.Native": - if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None) - continue; -#if __IOS__ - libname = MonoNativeConfig.GetPInvokeLibraryName (MonoNativeFlavor.Unified, MonoNativeConfig.LinkMode); -#else libname = null; -#endif break; } @@ -248,13 +242,7 @@ protected void Check (Assembly a) case "System.Native": case "System.Security.Cryptography.Native.Apple": case "System.Net.Security.Native": - if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None) - continue; -#if __IOS__ - path = MonoNativeConfig.GetPInvokeLibraryName (MonoNativeFlavor.Unified, MonoNativeConfig.LinkMode); -#else path = null; -#endif break; } diff --git a/tests/introspection/Mac/introspection-mac.csproj b/tests/introspection/Mac/introspection-mac.csproj index 7119a988ade4..1909259c4a0e 100644 --- a/tests/introspection/Mac/introspection-mac.csproj +++ b/tests/introspection/Mac/introspection-mac.csproj @@ -122,9 +122,6 @@ TestRuntime.cs - - MonoNativeConfig.cs - ApiAvailabilityTest.cs diff --git a/tests/introspection/dotnet/shared.csproj b/tests/introspection/dotnet/shared.csproj index c787b358fcf5..a20624fe5b36 100644 --- a/tests/introspection/dotnet/shared.csproj +++ b/tests/introspection/dotnet/shared.csproj @@ -111,9 +111,6 @@ EnvironmentVariable.cs - - MonoNativeConfig.cs - PlatformInfo.cs diff --git a/tests/introspection/iOS/introspection-ios.csproj b/tests/introspection/iOS/introspection-ios.csproj index 56901f7b3870..8e2601f88ae0 100644 --- a/tests/introspection/iOS/introspection-ios.csproj +++ b/tests/introspection/iOS/introspection-ios.csproj @@ -148,9 +148,6 @@ EnvironmentVariable.cs - - MonoNativeConfig.cs - PlatformInfo.cs diff --git a/tests/mmptest/src/CodeStrippingTests.cs b/tests/mmptest/src/CodeStrippingTests.cs index 5fb469da1b54..45ec14d41849 100644 --- a/tests/mmptest/src/CodeStrippingTests.cs +++ b/tests/mmptest/src/CodeStrippingTests.cs @@ -9,11 +9,11 @@ namespace Xamarin.MMP.Tests { public class CodeStrippingTests { static Func LipoStripConditional = s => s.Contains ("lipo") && s.Contains ("-extract_family"); - static Func LipoStripSkipPosixAndMonoNativeConditional = s => LipoStripConditional (s) && !s.Contains ("libMonoPosixHelper.dylib") && !s.Contains ("libmono-native.dylib"); + static Func LipoStripSkipPosixConditional = s => LipoStripConditional (s) && !s.Contains ("libMonoPosixHelper.dylib"); - static bool DidAnyLipoStripSkipPosixAndMonoNative (BuildResult buildResult) + static bool DidAnyLipoStripSkipPosix (BuildResult buildResult) { - return buildResult.BuildOutputLines.Any (LipoStripSkipPosixAndMonoNativeConditional); + return buildResult.BuildOutputLines.Any (LipoStripSkipPosixConditional); } static bool DidAnyLipoStrip (BuildResult buildResult) @@ -129,9 +129,9 @@ void AssertNoLipoOrWarning (BuildResult buildOutput, string context) Assert.False (buildOutput.HasMessage (2108), "MM2108 incorrectly given in in context: " + context); } - void AssertLipoOnlyMonoPosixAndMonoNative (BuildResult buildOutput, string context) + void AssertLipoOnlyMonoPosix (BuildResult buildOutput, string context) { - Assert.False (DidAnyLipoStripSkipPosixAndMonoNative (buildOutput), "lipo incorrectly run in context outside of libMonoPosixHelper/libmono-native: " + context); + Assert.False (DidAnyLipoStripSkipPosix (buildOutput), "lipo incorrectly run in context outside of libMonoPosixHelper/libmono-native: " + context); Assert.False (buildOutput.HasMessage (2108), "MM2108 incorrectly given in in context: " + context); } @@ -173,7 +173,7 @@ public void ThirdPartyLibrary_WithCorrectBitness_ShouldNotStripOrWarn () test.Release = true; testResult = TI.TestUnifiedExecutable (test); - AssertLipoOnlyMonoPosixAndMonoNative (testResult.BuildResult, "Release"); // libMonoPosixHelper.dylib and libmono-native.dylib will lipo in Release + AssertLipoOnlyMonoPosix (testResult.BuildResult, "Release"); // libMonoPosixHelper.dylib and libmono-native.dylib will lipo in Release }); } } diff --git a/tests/mono-native/.gitignore b/tests/mono-native/.gitignore deleted file mode 100644 index 7f0c25398785..000000000000 --- a/tests/mono-native/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.csproj diff --git a/tests/mono-native/AppDelegate.cs b/tests/mono-native/AppDelegate.cs deleted file mode 100644 index e08e3de2785a..000000000000 --- a/tests/mono-native/AppDelegate.cs +++ /dev/null @@ -1,117 +0,0 @@ -#if !__WATCHOS__ && !MONOMAC -using System; -using System.Collections.Generic; -using System.Reflection; -using Foundation; -using UIKit; -using MonoTouch.NUnit.UI; -using NUnit.Framework.Internal; - -namespace Mono.Native.Tests { - // The UIApplicationDelegate for the application. This class is responsible for launching the - // User Interface of the application, as well as listening (and optionally responding) to - // application events from iOS. - [Register ("AppDelegate")] - public partial class AppDelegate : UIApplicationDelegate { - // class-level declarations - static UIWindow window; - TouchRunner runner; - -#if !__TVOS__ - public override bool AccessibilityPerformMagicTap () - { - try { - runner.OpenWriter ("Magic Tap"); - runner.Run (runner.LoadedTest as TestSuite); - } finally { - runner.CloseWriter (); - } - return true; - } -#endif - // - // This method is invoked when the application has loaded and is ready to run. In this - // method you should instantiate the window, load the UI into it and then make the window - // visible. - // - // You have 17 seconds to return from this method, or iOS will terminate your application. - // - public override bool FinishedLaunching (UIApplication app, NSDictionary options) - { - // create a new window instance based on the screen size - window = new UIWindow (UIScreen.MainScreen.Bounds); - runner = new TouchRunner (window); - - // tests can be inside the main assembly - runner.Add (Assembly.GetExecutingAssembly ()); - - window.RootViewController = new UINavigationController (runner.GetViewController ()); - // make the window visible - window.MakeKeyAndVisible (); - - return true; - } - - public static void PresentModalViewController (UIViewController vc, double duration) - { - var bckp = window.RootViewController; - window.RootViewController = vc; - try { - NSRunLoop.Main.RunUntil (NSDate.Now.AddSeconds (duration)); - } finally { - window.RootViewController = bckp; - } - } - - public static bool RunAsync (DateTime timeout, Action action, Func check_completed) - { - var vc = new AsyncController (action); - var bckp = window.RootViewController; - window.RootViewController = vc; - try { - do { - if (timeout < DateTime.Now) - return false; - NSRunLoop.Main.RunUntil (NSDate.Now.AddSeconds (0.1)); - } while (!check_completed ()); - } finally { - window.RootViewController = bckp; - } - - return true; - } - - static void Main (string [] args) - { - UIApplication.Main (args, null, typeof (AppDelegate)); - } - } - - class AsyncController : UIViewController { - Action action; - static int counter; - - public AsyncController (Action action) - { - this.action = action; - counter++; - } - - public override void ViewDidLoad () - { - base.ViewDidLoad (); - - switch (counter % 2) { - case 0: - View.BackgroundColor = UIColor.Yellow; - break; - default: - View.BackgroundColor = UIColor.LightGray; - break; - } - NSTimer.CreateScheduledTimer (0.01, (v) => action ()); - } - } -} - -#endif // !__WATCHOS__ diff --git a/tests/mono-native/Introspection.cs b/tests/mono-native/Introspection.cs deleted file mode 100644 index 6343229c77ca..000000000000 --- a/tests/mono-native/Introspection.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Reflection; -using System.Runtime.InteropServices; -using NUnit.Framework; -using ObjCRuntime; - -namespace Xamarin.Tests { - [TestFixture] - public class Introspection { - public static string RootDirectory => Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location); - - void AssertShouldExist (string name) - { - var pathName = Path.Combine (RootDirectory, name); - Assert.That (File.Exists (pathName), $"Found {name}."); - } - - void AssertShouldNotExist (string name) - { - var pathName = Path.Combine (RootDirectory, name); - Assert.That (File.Exists (pathName), Is.False, $"Should not have {name}."); - } - - int CountFiles (string pattern) - { - // Don't use Linq as it'd use too much memory. - return Directory.GetFiles (RootDirectory, pattern, SearchOption.AllDirectories).Length; - } - - void CheckDynamicLibrary () - { - AssertShouldExist (MonoNativeConfig.DynamicLibraryName); - AssertShouldNotExist ("libmono-native.dylib"); - - var count = CountFiles ("libmono-native*"); - Assert.That (count, Is.EqualTo (1), "exactly one mono-native library."); - } - - void CheckStaticLibrary () - { - AssertShouldNotExist ("libmono-native.dylib"); - AssertShouldNotExist ("libmono-native-compat.dylib"); - AssertShouldNotExist ("libmono-native-unified.dylib"); - - var count = CountFiles ("libmono-native*"); - Assert.That (count, Is.EqualTo (0), "zero mono-native libraries."); - } - - void CheckSymlinkedLibrary () - { - AssertShouldExist ("libmono-native.dylib"); - AssertShouldNotExist ("libmono-native-compat.dylib"); - AssertShouldNotExist ("libmono-native-unified.dylib"); - - var count = CountFiles ("libmono-native*"); - Assert.That (count, Is.EqualTo (1), "exactly one mono-native library."); - } - - [Test] - public void CheckLibrary () - { - switch (MonoNativeConfig.LinkMode) { - case MonoNativeLinkMode.Dynamic: - CheckDynamicLibrary (); - break; - case MonoNativeLinkMode.Static: - CheckStaticLibrary (); - break; - case MonoNativeLinkMode.Symlink: - CheckSymlinkedLibrary (); - break; - default: - Assert.Fail ($"Unknown link mode: {MonoNativeConfig.LinkMode}"); - break; - } - } - - [DllImport ("System.Native")] - extern static void mono_native_initialize (); - - [Test] - public void TestInvoke () - { - mono_native_initialize (); - } - } -} diff --git a/tests/mono-native/MacAppDelegate.cs b/tests/mono-native/MacAppDelegate.cs deleted file mode 100644 index b8b1ef0127ae..000000000000 --- a/tests/mono-native/MacAppDelegate.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using NUnitLite; -using AppKit; -using Foundation; - -namespace Mono.Native.Tests { - [Register ("AppDelegate")] - public class MacAppDelegate : NSApplicationDelegate { - public override void DidFinishLaunching (NSNotification notification) - { - } - - public override void WillTerminate (NSNotification notification) - { - // Insert code here to tear down your application - } - } -} diff --git a/tests/mono-native/MacMain.cs b/tests/mono-native/MacMain.cs deleted file mode 100644 index b2e379ef7de7..000000000000 --- a/tests/mono-native/MacMain.cs +++ /dev/null @@ -1,10 +0,0 @@ -using NUnitLite; - -namespace mononativetests { - public class Application { - static int Main (string [] args) - { - return new AutoRun ().Execute (args); - } - } -} diff --git a/tests/mono-native/Main.cs b/tests/mono-native/Main.cs deleted file mode 100644 index aaa9fe15eeb7..000000000000 --- a/tests/mono-native/Main.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -#if __WATCHOS__ -using Foundation; -#endif -using UIKit; - -partial class TestRuntime { - public static bool RunAsync (DateTime timeout, Action action, Func check_completed) - { -#if __WATCHOS__ - NSTimer.CreateScheduledTimer (0.01, (v) => action ()); - do { - if (timeout < DateTime.Now) - return false; - NSRunLoop.Main.RunUntil (NSDate.Now.AddSeconds (0.1)); - } while (!check_completed ()); - - return true; -#else - return Mono.Native.Tests.AppDelegate.RunAsync (timeout, action, check_completed); -#endif - } -} diff --git a/tests/mono-native/NativePlatformConfig.cs b/tests/mono-native/NativePlatformConfig.cs deleted file mode 100644 index 08f3a9056122..000000000000 --- a/tests/mono-native/NativePlatformConfig.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using NUnit.Framework; -using Mono; - -namespace Xamarin.Tests { - [TestFixture] - public class NativePlatformConfig { - [Test] - public void PlatformType () - { - var type = MonoNativePlatform.GetPlatformType (); - Assert.That ((int) type, Is.GreaterThan (0), "platform type"); - - var usingCompat = (type & MonoNativePlatformType.MONO_NATIVE_PLATFORM_TYPE_COMPAT) != 0; - Assert.AreEqual (MonoNativeConfig.UsingCompat, usingCompat, "using compatibility layer"); - } - } -} diff --git a/tests/mono-native/iOS/Info.plist b/tests/mono-native/iOS/Info.plist deleted file mode 100644 index 6415bfd4d6f2..000000000000 --- a/tests/mono-native/iOS/Info.plist +++ /dev/null @@ -1,44 +0,0 @@ - - - - - CFBundleDisplayName - MonoNativeTest - CFBundleIdentifier - com.xamarin.mono-native-test - CFBundleName - MonoNativeTest - MinimumOSVersion - 11.0 - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - UIDeviceFamily - - 1 - 2 - - UILaunchStoryboardName - LaunchScreen - UIRequiresFullScreen - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - XSAppIconAssets - Assets.xcassets/AppIcons.appiconset - - diff --git a/tests/mono-native/iOS/mono-native.csproj.template b/tests/mono-native/iOS/mono-native.csproj.template deleted file mode 100644 index 18c13ef180c5..000000000000 --- a/tests/mono-native/iOS/mono-native.csproj.template +++ /dev/null @@ -1,125 +0,0 @@ - - - - Debug - iPhoneSimulator - 10.0.0 - 2.0 - {26125265-2204-4514-A572-36079CA4F925} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - Mono.Native.Tests - Resources - mononativetests - 168,169,219,414,612,618,649,672 - Xamarin.iOS - obj\$(Platform)\$(Configuration)-unified - PackageReference - ..\.. - latest - true - - - MONO_NATIVE_SYMLINK - MONO_NATIVE_STATIC - $(MonoNativeMode);$(DefineConstants) - - - True - full - False - bin\iPhoneSimulator\$(Configuration)-unified - DEBUG;$(DefineConstants) - prompt - 4 - True - None - True - -v -v - x86_64 - iPhone Developer - HttpClientHandler - - - none - True - bin\iPhoneSimulator\$(Configuration)-unified - $(DefineConstants) - prompt - 4 - None - True - -v -v - x86_64 - HttpClientHandler - - - True - full - False - bin\iPhone\$(Configuration)-unified - DEBUG;$(DefineConstants) - prompt - 4 - iPhone Developer - True - True - -v -v - ARM64 - SdkOnly - HttpClientHandler - - - none - True - bin\iPhone\$(Configuration)-unified - $(DefineConstants) - prompt - 4 - iPhone Developer - True - -v -v - ARM64 - true - SdkOnly - HttpClientHandler - - - - - - - - {F611ED96-54B5-4975-99BB-12F50AF95936} - Touch.Client-iOS - - - - - - - - Info.plist - - - - - - - - MonoNativePlatform.cs - - - MonoNativePlatformType.cs - - - NativePlatformTest.cs - - - MonoNativeConfig.cs - - - - - - diff --git a/tests/mono-native/macOS/Entitlements.plist b/tests/mono-native/macOS/Entitlements.plist deleted file mode 100644 index 9ae599370b42..000000000000 --- a/tests/mono-native/macOS/Entitlements.plist +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/tests/mono-native/macOS/Info.plist b/tests/mono-native/macOS/Info.plist deleted file mode 100644 index ff6ae70a155b..000000000000 --- a/tests/mono-native/macOS/Info.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleName - mononativetests - CFBundleIdentifier - com.xamarin.mononativetests - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSMinimumSystemVersion - 10.15 - CFBundleDevelopmentRegion - en - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - APPL - CFBundleSignature - ???? - NSHumanReadableCopyright - Xamarin Inc. (http://www.xamarin.com) - NSPrincipalClass - NSApplication - NSMainStoryboardFile - Main - - diff --git a/tests/mono-native/macOS/mono-native.csproj.template b/tests/mono-native/macOS/mono-native.csproj.template deleted file mode 100644 index 82a7761c8c04..000000000000 --- a/tests/mono-native/macOS/mono-native.csproj.template +++ /dev/null @@ -1,85 +0,0 @@ - - - - ..\.. - Debug - AnyCPU - {2B174B45-CC6B-443D-870F-6B5394FDE3FD} - {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - Mono.Native.Tests - mononativetests - Resources - 67,168,169,219,414,612,618,649,672 - Xamarin.Mac - v2.0 - $(DefineConstants);MOBILE;XAMMAC - PackageReference - latest - true - - - false - bin\Mac - 4 - false - false - false - false - HttpClientHandler - None - $(DefineConstants); - - - - - - - - - - Info.plist - - - - - - MacMain.cs - - - Assert.cs - - - MonoNativeConfig.cs - - - TestAssemblyLoader.cs - - - - MonoNativePlatform.cs - - - MonoNativePlatformType.cs - - - NativePlatformTest.cs - - - TestRuntime.cs - - - ApplePlatform.cs - - - SdkVersions.cs - - - - - {88A8A1AC-0829-4C98-8F4A-9FC23DC42A06} - Touch.Client-macOS-mobile - - - - \ No newline at end of file diff --git a/tests/mtouch/MonoNativeTests.cs b/tests/mtouch/MonoNativeTests.cs deleted file mode 100644 index f132c64667b3..000000000000 --- a/tests/mtouch/MonoNativeTests.cs +++ /dev/null @@ -1,271 +0,0 @@ -// -// MonoNativeTests.cs -// -// Author: -// Martin Baulig -// -// Copyright (c) 2018 Xamarin Inc. (http://www.xamarin.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using System.IO; -using System.Linq; -using NUnit.Framework; - -// using MTouchLinker = Xamarin.Tests.LinkerOption; -// using ExecutionHelper = Xamarin.Tests.ExecutionHelper; -// using MTouchRegistrar = Xamarin.Tests.RegistrarOption; - -namespace Xamarin { - using Tests; - using Utils; - - [TestFixture] - public class MonoNativeTests { - [Test] - public void TestDebugSymlink () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (); - mtouch.Debug = true; - mtouch.Linker = LinkerOption.DontLink; - mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - - AssertSymlinked (mtouch.AppPath); - } - } - - [Test] - public void TestDebugLinkOut () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (); - mtouch.Debug = true; - mtouch.Linker = LinkerOption.LinkAll; - mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - - AssertStaticLinked (mtouch); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Not.Contain ("_mono_native_initialize")); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Not.Contain ("_NetSecurityNative_ImportUserName")); - } - } - - [Test] - public void TestDeviceLinkOut () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (); - mtouch.Linker = LinkerOption.LinkSdk; - mtouch.AssertExecute (MTouchAction.BuildDev, "build"); - - AssertStaticLinked (mtouch); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Not.Contain ("_mono_native_initialize")); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Not.Contain ("_NetSecurityNative_ImportUserName")); - } - } - - [Test] - public void TestDebugLinkAll () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (code: MonoNativeInitialize); - mtouch.Debug = true; - mtouch.Linker = LinkerOption.LinkAll; - mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - - AssertStaticLinked (mtouch); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Contain ("_mono_native_initialize")); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Not.Contain ("_NetSecurityNative_ImportUserName")); - } - } - - [Test] - public void TestDeviceLinkAll () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (code: MonoNativeInitialize); - mtouch.Linker = LinkerOption.LinkAll; - mtouch.AssertExecute (MTouchAction.BuildDev, "build"); - - AssertStaticLinked (mtouch); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Contain ("_mono_native_initialize")); - Assert.That (mtouch.NativeSymbolsInExecutable, Does.Not.Contain ("_NetSecurityNative_ImportUserName")); - } - } - - [Test] - [TestCase (Profile.iOS, "9.3", "libmono-native-compat.dylib", SdkVersions.MiniOS)] - [TestCase (Profile.iOS, "10.0", "libmono-native-unified.dylib", SdkVersions.MiniOS)] - [TestCase (Profile.tvOS, "9.0", "libmono-native-compat.dylib", SdkVersions.MinTVOS)] - [TestCase (Profile.tvOS, "10.0", "libmono-native-unified.dylib", SdkVersions.MinTVOS)] - [TestCase (Profile.watchOS, "2.0", "libmono-native-compat.dylib", SdkVersions.MinWatchOS)] - [TestCase (Profile.watchOS, "5.0", "libmono-native-unified.dylib", SdkVersions.MinWatchOS)] - public void TestDeviceDylib (Profile profile, string version, string mono_native_dylib, string min_version) - { - if (mono_native_dylib.Contains ("compat") && Version.Parse (min_version) > Version.Parse (version)) - Assert.Ignore ("No OS versions that require compat libmono-unified are supported anymore"); - if (Version.Parse (min_version) > Version.Parse (version)) - version = min_version; - - using (var mtouch = new MTouchTool ()) { - mtouch.Profile = profile; - if (profile == Profile.watchOS) { - mtouch.CreateTemporaryWatchKitExtension (code: MonoNativeWatchInitialize, extraCode: MonoNativeInitialize); - } else { - mtouch.CreateTemporaryApp (code: MonoNativeInitialize); - } - mtouch.Linker = LinkerOption.LinkAll; - mtouch.AssemblyBuildTargets.Add ("@all=dynamiclibrary"); - mtouch.TargetVer = version; - - mtouch.AssertExecute (MTouchAction.BuildDev, "build"); - - var files = Directory.EnumerateFiles (mtouch.AppPath, "libmono-native*", SearchOption.AllDirectories).Select (Path.GetFileName); - Assert.That (files.Count, Is.EqualTo (1), "One single libmono-native* library"); - Assert.That (files.First (), Is.EqualTo (mono_native_dylib)); - - var mono_native_path = Path.Combine (mtouch.AppPath, mono_native_dylib); - - var symbols = MTouch.GetNativeSymbols (mono_native_path); - var otool_dylib = ExecutionHelper.Execute ("otool", new [] { "-L", mono_native_path }, hide_output: true); - - Assert.That (symbols, Does.Contain ("_mono_native_initialize")); - Assert.That (otool_dylib, Does.Contain ($"@rpath/{mono_native_dylib}")); - Assert.That (otool_dylib.Replace (mono_native_path, ""), Does.Not.Contain ("/Users/")); - - if (profile == Profile.iOS) { - Assert.That (symbols, Does.Contain ("_NetSecurityNative_ImportUserName")); - Assert.That (otool_dylib, Does.Contain ("/System/Library/Frameworks/GSS.framework/GSS")); - } else { - Assert.That (symbols, Does.Not.Contain ("_NetSecurityNative_ImportUserName")); - Assert.That (otool_dylib, Does.Not.Contain ("/System/Library/Frameworks/GSS.framework/GSS")); - } - - var otool_exe = ExecutionHelper.Execute ("otool", new [] { "-L", mtouch.NativeExecutablePath }, hide_output: true); - Assert.That (otool_exe, Does.Not.Contain ("GSS")); - Assert.That (otool_exe, Does.Contain ($"@rpath/{mono_native_dylib}")); - } - } - - [Test] - public void TestDeviceFrameworkLinkOut () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (); - mtouch.Linker = LinkerOption.LinkAll; - mtouch.AssemblyBuildTargets.Add ("@all=framework"); - mtouch.TargetVer = SdkVersions.MiniOSVersion.Major >= 10 ? SdkVersions.MiniOS : "10.0"; - - mtouch.AssertExecute (MTouchAction.BuildDev, "build"); - - var files = Directory.EnumerateFiles (mtouch.AppPath, "libmono-native*", SearchOption.AllDirectories).Select (Path.GetFileName); - Assert.That (files.Count, Is.EqualTo (0), "No libmono-native* library"); - } - } - - [Test] - public void TestGss () - { - using (var mtouch = new MTouchTool ()) { - mtouch.CreateTemporaryApp (code: MonoNativeGss); - mtouch.Linker = LinkerOption.LinkAll; - mtouch.AssertExecute (MTouchAction.BuildSim, "build"); - - AssertStaticLinked (mtouch); - var symbols = mtouch.NativeSymbolsInExecutable; - Assert.That (symbols, Does.Contain ("_mono_native_initialize")); - Assert.That (symbols, Does.Contain ("_NetSecurityNative_ImportUserName")); - - var otool_exe = ExecutionHelper.Execute ("otool", new [] { "-L", mtouch.NativeExecutablePath }, hide_output: true); - Assert.That (otool_exe, Does.Contain ("/System/Library/Frameworks/GSS.framework/GSS")); - } - } - - [Test] - public void TestGssTv () - { - using (var mtouch = new MTouchTool ()) { - mtouch.Profile = Profile.tvOS; - mtouch.CreateTemporaryApp (code: MonoNativeGss); - mtouch.Linker = LinkerOption.LinkAll; - - mtouch.AssertExecuteFailure (MTouchAction.BuildSim, "build"); - mtouch.AssertError (5214, "Native linking failed, undefined symbol: _NetSecurityNative_ImportUserName. This symbol was referenced by the managed member X.NetSecurityNative_ImportUserName. Please verify that all the necessary frameworks have been referenced and native libraries linked."); - } - } - - void AssertSymlinked (string path) - { - var files = Directory.EnumerateFiles (path, "libmono-native*", SearchOption.AllDirectories).Select (Path.GetFileName); - Assert.That (files.Count, Is.EqualTo (1), "One single libmono-native* library"); - Assert.That (files.First (), Is.EqualTo ("libmono-native.dylib"), "Found libmono-native.dylib"); - } - - void AssertStaticLinked (MTouchTool app) - { - var files = Directory.EnumerateFiles (app.AppPath, "libmono-native*", SearchOption.AllDirectories).Select (Path.GetFileName); - Assert.That (files.Count, Is.EqualTo (0), "No libmono-native* libraries"); - } - - string MonoNativeWatchInitialize => @" -using WatchKit; -public partial class NotificationController : WKUserNotificationInterfaceController -{ - protected NotificationController (System.IntPtr handle) : base (handle) { X.Main(); } -} -"; - - string MonoNativeInitialize => @" -class X { - [System.Runtime.InteropServices.DllImport (""System.Native"")] - extern static void mono_native_initialize (); - - public static void Main () - { - System.Console.WriteLine (typeof (ObjCRuntime.Runtime).ToString ()); - mono_native_initialize (); - } -} -"; - - string MonoNativeGss => @" -using System; - -class X { - [System.Runtime.InteropServices.DllImport (""System.Native"")] - extern static void mono_native_initialize (); - - [System.Runtime.InteropServices.DllImport (""System.Net.Security.Native"")] - extern static void NetSecurityNative_ImportUserName (IntPtr a, IntPtr b, int c, IntPtr d); - - static void Main () - { - // Reference Xamarin.iOS - var runtime = typeof (ObjCRuntime.Runtime).ToString (); - // Always false, but the linker does not know that, so the following code won't be linked out. - if (runtime.Equals (""XXX"")) { - mono_native_initialize (); - NetSecurityNative_ImportUserName (IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero); - } - } -} -"; - - } -} diff --git a/tests/mtouch/mtouchtests.csproj b/tests/mtouch/mtouchtests.csproj index feec07e1769c..c207827fbe0b 100644 --- a/tests/mtouch/mtouchtests.csproj +++ b/tests/mtouch/mtouchtests.csproj @@ -74,7 +74,6 @@ BundlerTool.cs - SdkVersions.cs diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 2d6f5b1bc2d0..7fb3f9118dc8 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -493,22 +493,6 @@ int AutoConfigureMac (bool generate_projects) }); } - var monoNativeInfo = new MonoNativeInfo (DevicePlatform.macOS, RootDirectory, Log); - var macTestProject = new MacTestProject (TestLabel.Mononative, monoNativeInfo.ProjectPath, targetFrameworkFlavor: MacFlavors.Modern | MacFlavors.Full) { - MonoNativeInfo = monoNativeInfo, - Name = monoNativeInfo.ProjectName, - Platform = "AnyCPU", - Ignore = !INCLUDE_XAMARIN_LEGACY, - - }; - MacTestProjects.Add (macTestProject); - - - // Generate test projects from templates (mono-native templates) - if (generate_projects) { - foreach (var mtp in MacTestProjects.Where (x => x.MonoNativeInfo is not null).Select (x => x.MonoNativeInfo)) - mtp.Convert (); - } // All test projects should be either Modern projects or NUnit/console executables at this point. // If we need to generate Full/System variations, we do that here. @@ -611,13 +595,6 @@ void AutoConfigureIOS () Configurations = new string [] { "Debug", "Release" }, }); - var monoNativeInfo = new MonoNativeInfo (DevicePlatform.iOS, RootDirectory, Log); - var iosTestProject = new iOSTestProject (TestLabel.Mononative, monoNativeInfo.ProjectPath) { - MonoNativeInfo = monoNativeInfo, - Name = monoNativeInfo.ProjectName, - }; - IOSTestProjects.Add (iosTestProject); - // add all the tests that are using the precompiled mono assemblies WatchOSContainerTemplate = Path.GetFullPath (Path.Combine (RootDirectory, "templates/WatchContainer")); WatchOSAppTemplate = Path.GetFullPath (Path.Combine (RootDirectory, "templates/WatchApp")); @@ -688,8 +665,6 @@ int Configure () // * dont link, link all, link sdk // * Each of these test projects can used to generate other platform variations (tvOS, watchOS, macOS full, etc), // if the the TestProject.GenerateVariations property is true. - // * For the mono-native template project, we generate a compat+unified version of the mono-native template project (in MonoNativeInfo.Convert). - // GenerateVariations is true for mono-native projects, which means we'll generate platform variations. int ConfigureIOS () { @@ -702,9 +677,6 @@ int ConfigureIOS () if (autoConf) AutoConfigureIOS (); - foreach (var monoNativeInfo in IOSTestProjects.Where (x => x.MonoNativeInfo is not null).Select (x => x.MonoNativeInfo)) - monoNativeInfo.Convert (); - foreach (var proj in IOSTestProjects.Where ((v) => v.GenerateVariations)) { var file = proj.Path; diff --git a/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs b/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs index ca268427dfb7..b0821bfb9aa2 100644 --- a/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs +++ b/tests/xharness/Jenkins/RunSimulatorTasksFactory.cs @@ -30,8 +30,6 @@ public async Task> CreateAsync (Jenkins jenkins, IMlaunch } else { if (!project.SkipiOSVariation) ps.Add (new Tuple (project, TestPlatform.iOS_Unified, ignored)); - if (project.MonoNativeInfo is not null) - ps.Add (new Tuple (project, TestPlatform.iOS_TodayExtension64, ignored)); if (!project.SkiptvOSVariation) ps.Add (new Tuple (project.AsTvOSProject (), TestPlatform.tvOS, ignored)); if (!project.SkipwatchOSVariation) diff --git a/tests/xharness/Jenkins/TestData.cs b/tests/xharness/Jenkins/TestData.cs index 411f64cdac9f..423702dc0150 100644 --- a/tests/xharness/Jenkins/TestData.cs +++ b/tests/xharness/Jenkins/TestData.cs @@ -18,7 +18,6 @@ class TestData { public bool UseThumb; public bool UseLlvm; public bool? UseMonoRuntime; - public MonoNativeLinkMode MonoNativeLinkMode; public IEnumerable Candidates; public string XamMacArch; public string RuntimeIdentifier; diff --git a/tests/xharness/Jenkins/TestSelector.cs b/tests/xharness/Jenkins/TestSelector.cs index 3751141bc004..632734ef94cf 100644 --- a/tests/xharness/Jenkins/TestSelector.cs +++ b/tests/xharness/Jenkins/TestSelector.cs @@ -278,7 +278,6 @@ public void SelectTests (TestSelection selection) selection.SetEnabled (PlatformLabel.LegacyXamarin, false); selection.SetEnabled (PlatformLabel.watchOS, false); selection.SetEnabled (TestLabel.Mmp, false); - selection.SetEnabled (TestLabel.Mononative, false); selection.SetEnabled (TestLabel.Mtouch, false); selection.SetEnabled (TestLabel.Xammac, false); } diff --git a/tests/xharness/Jenkins/TestVariationsFactory.cs b/tests/xharness/Jenkins/TestVariationsFactory.cs index 970dc0131624..5c3b87f9cf32 100644 --- a/tests/xharness/Jenkins/TestVariationsFactory.cs +++ b/tests/xharness/Jenkins/TestVariationsFactory.cs @@ -68,22 +68,22 @@ IEnumerable GetTestData (RunTestTask test) /* we don't add --assembly-build-target=@all=staticobject because that's the default in all our test projects */ if (supports_debug && !test.TestProject.IsDotNetProject) { - yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug)", AppBundleExtraOptions = $"--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, Ignored = ignore }; - yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug)", AppBundleExtraOptions = $"--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, Ignored = ignore }; - yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug, profiling)", AppBundleExtraOptions = $"--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, Ignored = ignore }; - yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug, profiling)", AppBundleExtraOptions = $"--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Static, Ignored = ignore }; + yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug)", AppBundleExtraOptions = $"--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = false, Ignored = ignore }; + yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug)", AppBundleExtraOptions = $"--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = false, Ignored = ignore }; + yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug, profiling)", AppBundleExtraOptions = $"--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = true, Ignored = ignore }; + yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug, profiling)", AppBundleExtraOptions = $"--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = true, Ignored = ignore }; } if (test.ProjectConfiguration.Contains ("Debug")) - yield return new TestData { Variation = "Release", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static }; + yield return new TestData { Variation = "Release", Debug = false, Profiling = false }; if (test.Platform == TestPlatform.iOS_Unified32 && !test.TestProject.IsDotNetProject) - yield return new TestData { Variation = "Release: UseThumb", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, UseThumb = true }; + yield return new TestData { Variation = "Release: UseThumb", Debug = false, Profiling = false, UseThumb = true }; // Disable this by default for tvOS/Release because the app ends up being too big (https://github.com/xamarin/maccore/issues/2282) var sdk_release_skip = test.Platform == TestPlatform.tvOS && test.TestName == "dont link"; sdk_release_skip = sdk_release_skip || test.TestProject.IsDotNetProject; if (!sdk_release_skip) - yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (release)", AppBundleExtraOptions = $"--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, }; + yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (release)", AppBundleExtraOptions = $"--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = false, Profiling = false, }; switch (test.TestName) { case "monotouch-test": @@ -94,7 +94,7 @@ IEnumerable GetTestData (RunTestTask test) yield return new TestData { Variation = "Release (all optimizations)", AppBundleExtraOptions = "--optimize:all", Registrar = "static", Debug = false, Profiling = false, Defines = "OPTIMIZEALL", Ignored = ignore }; if (supports_debug) { yield return new TestData { Variation = "Debug (all optimizations)", AppBundleExtraOptions = "--optimize:all", Registrar = "static", Debug = true, Profiling = false, Defines = "OPTIMIZEALL", Ignored = ignore }; - yield return new TestData { Variation = "Debug: SGenConc", AppBundleExtraOptions = "", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, EnableSGenConc = true, Ignored = ignore }; + yield return new TestData { Variation = "Debug: SGenConc", AppBundleExtraOptions = "", Debug = true, Profiling = false, EnableSGenConc = true, Ignored = ignore }; } if (supports_interpreter) { if (supports_debug) { @@ -113,7 +113,7 @@ IEnumerable GetTestData (RunTestTask test) break; case string name when name.StartsWith ("mscorlib", StringComparison.Ordinal): if (supports_debug) - yield return new TestData { Variation = "Debug: SGenConc", AppBundleExtraOptions = "", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, EnableSGenConc = true }; + yield return new TestData { Variation = "Debug: SGenConc", AppBundleExtraOptions = "", Debug = true, Profiling = false, EnableSGenConc = true }; if (supports_interpreter) { if (supports_debug) { yield return new TestData { Variation = "Debug (interpreter)", AppBundleExtraOptions = "--interpreter", Debug = true, Profiling = false, Undefines = "FULL_AOT_RUNTIME", KnownFailure = new KnownIssue ("#1683", issueLink: "https://github.com/xamarin/maccore/issues/1683") }; @@ -280,12 +280,6 @@ public IEnumerable CreateTestVariations (IEnumerable tests, Func -// -// Copyright (c) 2018 Xamarin Inc. (http://www.xamarin.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using System.IO; -using System.Xml; - -using Microsoft.DotNet.XHarness.iOS.Shared.Utilities; -using Microsoft.DotNet.XHarness.iOS.Shared.Hardware; - -namespace Xharness { - public enum MonoNativeLinkMode { - None, - Static, - Dynamic, - Symlink, - } - - public static class MonoNativeHelper { - public static void AddProjectDefines (XmlDocument project, MonoNativeLinkMode link) - { - switch (link) { - case MonoNativeLinkMode.Static: - project.AddTopLevelProperty ("MonoNativeMode", "MONO_NATIVE_STATIC"); - break; - case MonoNativeLinkMode.Dynamic: - project.AddTopLevelProperty ("MonoNativeMode", "MONO_NATIVE_DYNAMIC"); - break; - case MonoNativeLinkMode.Symlink: - project.AddTopLevelProperty ("MonoNativeMode", "MONO_NATIVE_SYMLINK"); - break; - default: - throw new Exception ($"Unknown MonoNativeLinkMode: {link}"); - } - } - - public static string GetMinimumOSVersion (DevicePlatform platform) - { - switch (platform) { - case DevicePlatform.iOS: - return Xamarin.SdkVersions.MiniOS; - case DevicePlatform.tvOS: - return Xamarin.SdkVersions.MinTVOS; - case DevicePlatform.watchOS: - return Xamarin.SdkVersions.LegacyMinWatchOS; - case DevicePlatform.macOS: - return Xamarin.SdkVersions.MinOSX; - default: - throw new Exception ($"Unknown DevicePlatform: {platform}"); - } - } - } - - public class MonoNativeInfo { - Action log; - public DevicePlatform DevicePlatform { get; set; } - string rootDirectory; - - public MonoNativeInfo (DevicePlatform platform, string rootDirectory, Action logAction = null) - { - DevicePlatform = platform; - this.log = logAction; - this.rootDirectory = rootDirectory ?? throw new ArgumentNullException (nameof (rootDirectory)); - } - - public string FlavorSuffix => "-unified"; - public string ProjectName => "mono-native" + FlavorSuffix; - public string ProjectPath => Path.Combine (rootDirectory, "mono-native", DevicePlatform.ToString (), FlavorSuffix.TrimStart ('-'), TemplateName + FlavorSuffix + ".csproj"); - string TemplateName => "mono-native"; - public string TemplatePath => Path.Combine (rootDirectory, "mono-native", DevicePlatform.ToString (), TemplateName + ".csproj.template"); - - public void Convert () - { - var inputProject = new XmlDocument (); - - var xml = File.ReadAllText (TemplatePath); - inputProject.LoadXmlWithoutNetworkAccess (xml); - inputProject.SetAssemblyName (inputProject.GetAssemblyName () + FlavorSuffix); - inputProject.AddAdditionalDefines ("MONO_NATIVE_UNIFIED"); - inputProject.ResolveAllPaths (TemplatePath); - - var template_info_plist = HarnessConfiguration.EvaluateRootTestsDirectory (inputProject.GetInfoPListInclude ().Replace ('\\', '/')); - var target_info_plist = Path.Combine (Path.GetDirectoryName (ProjectPath), "Info" + FlavorSuffix + ".plist"); - SetInfoPListMinimumOSVersion (template_info_plist, target_info_plist); - target_info_plist = HarnessConfiguration.InjectRootTestsDirectory (target_info_plist); - inputProject.FixInfoPListInclude (FlavorSuffix, newName: target_info_plist); - - inputProject.Save (ProjectPath, log); - } - - public XmlDocument SetInfoPListMinimumOSVersion (string template_plist, string target_plist) - { - var template_info_plist = template_plist; - var info_plist = new XmlDocument (); - info_plist.LoadWithoutNetworkAccess (template_info_plist); - SetInfoPListMinimumOSVersion (info_plist, MonoNativeHelper.GetMinimumOSVersion (DevicePlatform)); - info_plist.Save (target_plist, log); - return info_plist; - } - - public virtual void SetInfoPListMinimumOSVersion (XmlDocument info_plist, string version) - { - if (DevicePlatform == DevicePlatform.macOS) { - info_plist.SetMinimummacOSVersion (version); - } else { - info_plist.SetMinimumOSVersion (version); - } - } - } -} diff --git a/tests/xharness/Targets/TVOSTarget.cs b/tests/xharness/Targets/TVOSTarget.cs index c026021ad1d0..b3bf5c5de289 100644 --- a/tests/xharness/Targets/TVOSTarget.cs +++ b/tests/xharness/Targets/TVOSTarget.cs @@ -63,9 +63,7 @@ public override string DeviceArchitectures { protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { - if (MonoNativeInfo is null) - return Xamarin.SdkVersions.MinTVOS; - return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.tvOS); + return Xamarin.SdkVersions.MinTVOS; } protected override int [] UIDeviceFamily { diff --git a/tests/xharness/Targets/Target.cs b/tests/xharness/Targets/Target.cs index 47b845f9857c..3d62d717fcc1 100644 --- a/tests/xharness/Targets/Target.cs +++ b/tests/xharness/Targets/Target.cs @@ -235,9 +235,6 @@ public void Execute () templateName = Path.GetFileNameWithoutExtension (templateName); templateName = Path.GetFileNameWithoutExtension (templateName); - if (templateName.Equals ("mono-native-mac", StringComparison.Ordinal)) - templateName = "mono-native"; - if (!ShouldSkipProjectGeneration) { inputProject = new XmlDocument (); inputProject.LoadWithoutNetworkAccess (TemplateProjectPath); diff --git a/tests/xharness/Targets/TodayExtensionTarget.cs b/tests/xharness/Targets/TodayExtensionTarget.cs index ae4e6867c7a5..262f053b466f 100644 --- a/tests/xharness/Targets/TodayExtensionTarget.cs +++ b/tests/xharness/Targets/TodayExtensionTarget.cs @@ -129,9 +129,7 @@ protected override void ExecuteInternal () protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { - if (MonoNativeInfo is null) - return templateMinimumOSVersion; - return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.iOS); + return templateMinimumOSVersion; } public override IEnumerable GetRelatedProjects () diff --git a/tests/xharness/Targets/UnifiedTarget.cs b/tests/xharness/Targets/UnifiedTarget.cs index a782a2063f53..e5d6c138abda 100644 --- a/tests/xharness/Targets/UnifiedTarget.cs +++ b/tests/xharness/Targets/UnifiedTarget.cs @@ -63,9 +63,7 @@ public override string DeviceArchitectures { protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { - if (MonoNativeInfo is null) - return templateMinimumOSVersion; - return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.iOS); + return templateMinimumOSVersion; } protected override int [] UIDeviceFamily { diff --git a/tests/xharness/Targets/WatchOSTarget.cs b/tests/xharness/Targets/WatchOSTarget.cs index 19d9df59a371..b1490c0df9da 100644 --- a/tests/xharness/Targets/WatchOSTarget.cs +++ b/tests/xharness/Targets/WatchOSTarget.cs @@ -217,9 +217,7 @@ protected override void ExecuteInternal () protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { - if (MonoNativeInfo is null) - return templateMinimumOSVersion; - return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.watchOS); + return templateMinimumOSVersion; } public override string Suffix { diff --git a/tests/xharness/Targets/iOSTarget.cs b/tests/xharness/Targets/iOSTarget.cs index a06b3242996d..208c88a815d3 100644 --- a/tests/xharness/Targets/iOSTarget.cs +++ b/tests/xharness/Targets/iOSTarget.cs @@ -8,8 +8,6 @@ namespace Xharness.Targets { public abstract class iOSTarget : Target { public iOSTestProject TestProject; - public MonoNativeInfo MonoNativeInfo => TestProject.MonoNativeInfo; - protected override void PostProcessExecutableProject () { base.PostProcessExecutableProject (); diff --git a/tests/xharness/TestLabel.cs b/tests/xharness/TestLabel.cs index 61e73d0e976c..de55a4774f0f 100644 --- a/tests/xharness/TestLabel.cs +++ b/tests/xharness/TestLabel.cs @@ -55,8 +55,7 @@ public enum TestLabel : Int64 { MacBindingProject = 1 << 17, [Label ("mmp")] Mmp = 1 << 18, - [Label ("mononative")] - Mononative = 1 << 19, + // 1 << 19 is unused [Label ("monotouch")] Monotouch = 1 << 20, [Label ("msbuild")] diff --git a/tests/xharness/TestProject.cs b/tests/xharness/TestProject.cs index caceaa93c253..a645531746c4 100644 --- a/tests/xharness/TestProject.cs +++ b/tests/xharness/TestProject.cs @@ -37,9 +37,6 @@ public class TestProject { public IEnumerable? ProjectReferences; - // Optional - public MonoNativeInfo? MonoNativeInfo { get; set; } - public TestProject (TestLabel label, string path, bool isExecutableProject = true) { Label = label; diff --git a/tests/xharness/iOSTestProject.cs b/tests/xharness/iOSTestProject.cs index 85ad3e3526f7..6d8a9cf2c214 100644 --- a/tests/xharness/iOSTestProject.cs +++ b/tests/xharness/iOSTestProject.cs @@ -19,10 +19,7 @@ public iOSTestProject (TestLabel label, string path, bool isExecutableProject = public bool IsSupported (DevicePlatform devicePlatform, string productVersion) { - if (MonoNativeInfo is null) - return true; - var min_version = MonoNativeHelper.GetMinimumOSVersion (devicePlatform); - return Version.Parse (productVersion) >= Version.Parse (min_version); + return true; } public override TestProject Clone () diff --git a/tests/xharness/xharness.csproj b/tests/xharness/xharness.csproj index 27ef8e5ea82a..1fb000b19799 100644 --- a/tests/xharness/xharness.csproj +++ b/tests/xharness/xharness.csproj @@ -105,7 +105,6 @@ -