diff --git a/tests/common/TestRuntime.cs b/tests/common/TestRuntime.cs index 61dfda58c8..6d916ddd9a 100644 --- a/tests/common/TestRuntime.cs +++ b/tests/common/TestRuntime.cs @@ -154,6 +154,16 @@ partial class TestRuntime #endif } + public static void AssertIfSimulatorThenARM64 () + { +#if !__MACOS__ + if (ObjCRuntime.Runtime.Arch != Arch.SIMULATOR) + return; + if (!IsARM64) + NUnit.Framework.Assert.Ignore ("This test does not run simulators that aren't ARM64 simulators."); +#endif + } + public static void AssertNotSimulator () { #if !__MACOS__ @@ -1248,6 +1258,37 @@ partial class TestRuntime return !(Type.GetType ("System.__Canon") is null); } } + + + enum NXByteOrder /* unspecified in header, means most likely int */ { + Unknown, + LittleEndian, + BigEndian, + } + + [StructLayout (LayoutKind.Sequential)] + struct NXArchInfo { + IntPtr name; // const char * + public int CpuType; // cpu_type_t -> integer_t -> int + public int CpuSubType; // cpu_subtype_t -> integer_t -> int + public NXByteOrder ByteOrder; + IntPtr description; // const char * + + public string Name { + get { return Marshal.PtrToStringUTF8 (name)!; } + } + + public string Description { + get { return Marshal.PtrToStringUTF8 (description)!; } + } + } + + [DllImport (Constants.libSystemLibrary)] + static unsafe extern NXArchInfo* NXGetLocalArchInfo (); + + public unsafe static bool IsARM64 { + get { return NXGetLocalArchInfo ()->Name.StartsWith ("arm64"); } + } } #if NET diff --git a/tests/introspection/Mac/introspection-mac.csproj b/tests/introspection/Mac/introspection-mac.csproj index 36bcb422e9..95e7913491 100644 --- a/tests/introspection/Mac/introspection-mac.csproj +++ b/tests/introspection/Mac/introspection-mac.csproj @@ -16,6 +16,7 @@ PackageReference latest + true true diff --git a/tests/introspection/iOS/introspection-ios.csproj b/tests/introspection/iOS/introspection-ios.csproj index 6e7fecf539..360c8d658b 100644 --- a/tests/introspection/iOS/introspection-ios.csproj +++ b/tests/introspection/iOS/introspection-ios.csproj @@ -16,6 +16,7 @@ latest PackageReference ..\.. + true True diff --git a/tests/linker/ios/dont link/dont link.csproj b/tests/linker/ios/dont link/dont link.csproj index c2462610ed..5fbdbe3c4a 100644 --- a/tests/linker/ios/dont link/dont link.csproj +++ b/tests/linker/ios/dont link/dont link.csproj @@ -13,8 +13,10 @@ Xamarin.iOS obj\$(Platform)\$(Configuration)-unified + latest PackageReference ..\..\.. + true True diff --git a/tests/linker/ios/link all/link all.csproj b/tests/linker/ios/link all/link all.csproj index dc23f7e331..6769f7a12b 100644 --- a/tests/linker/ios/link all/link all.csproj +++ b/tests/linker/ios/link all/link all.csproj @@ -16,6 +16,7 @@ latest PackageReference ..\..\.. + true True diff --git a/tests/linker/ios/link sdk/link sdk.csproj b/tests/linker/ios/link sdk/link sdk.csproj index 66cdbde986..2f9d9ae2b4 100644 --- a/tests/linker/ios/link sdk/link sdk.csproj +++ b/tests/linker/ios/link sdk/link sdk.csproj @@ -13,8 +13,10 @@ Xamarin.iOS obj\$(Platform)\$(Configuration)-unified + latest PackageReference ..\..\.. + true True diff --git a/tests/linker/mac/dont link/dont link-mac.csproj b/tests/linker/mac/dont link/dont link-mac.csproj index 22056cad17..40c2d716b7 100644 --- a/tests/linker/mac/dont link/dont link-mac.csproj +++ b/tests/linker/mac/dont link/dont link-mac.csproj @@ -16,6 +16,7 @@ latest PackageReference + true true diff --git a/tests/linker/mac/link all/link all-mac.csproj b/tests/linker/mac/link all/link all-mac.csproj index bba11eb78b..9814ac65e0 100644 --- a/tests/linker/mac/link all/link all-mac.csproj +++ b/tests/linker/mac/link all/link all-mac.csproj @@ -13,6 +13,7 @@ Resources latest PackageReference + true true diff --git a/tests/linker/mac/link sdk/link sdk-mac.csproj b/tests/linker/mac/link sdk/link sdk-mac.csproj index 955f2929a5..95e2157fff 100644 --- a/tests/linker/mac/link sdk/link sdk-mac.csproj +++ b/tests/linker/mac/link sdk/link sdk-mac.csproj @@ -13,6 +13,7 @@ Resources latest PackageReference + true true diff --git a/tests/monotouch-test/Foundation/BundleTest.cs b/tests/monotouch-test/Foundation/BundleTest.cs index 82abb18ae0..2a9dc06be3 100644 --- a/tests/monotouch-test/Foundation/BundleTest.cs +++ b/tests/monotouch-test/Foundation/BundleTest.cs @@ -136,6 +136,9 @@ namespace MonoTouchFixtures.Foundation { if (!TestRuntime.CheckXcodeVersion (5, 0)) Assert.Inconclusive ("Requires iOS7 or later"); + // The AppStoreReceiptUrl property may or may not return anything useful on the simulator, so run this only on device. + TestRuntime.AssertDevice (); + // on iOS8 device this now ends with "/StoreKit/sandboxReceipt" // instead of "/StokeKit/receipt" Assert.That (main.AppStoreReceiptUrl.AbsoluteString, Does.EndWith ("eceipt"), "AppStoreReceiptUrl"); diff --git a/tests/monotouch-test/MobileCoreServices/UTTypeTest.cs b/tests/monotouch-test/MobileCoreServices/UTTypeTest.cs index 6108e6f22b..a7a3efd271 100644 --- a/tests/monotouch-test/MobileCoreServices/UTTypeTest.cs +++ b/tests/monotouch-test/MobileCoreServices/UTTypeTest.cs @@ -120,24 +120,40 @@ namespace MonoTouchFixtures.MobileCoreServices { [Test] public void GetPreferredTag () { + // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), + // so just skip this test for the simulator. + TestRuntime.AssertIfSimulatorThenARM64 (); + Assert.NotNull (UTType.GetPreferredTag (UTType.PDF, UTType.TagClassFilenameExtension), "GetPreferredTag"); } [Test] public void GetDeclaration () { + // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), + // so just skip this test for the simulator. + TestRuntime.AssertIfSimulatorThenARM64 (); + Assert.NotNull (UTType.GetDeclaration (UTType.PDF)); } [Test] public void GetDeclaringBundleURL () { + // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), + // so just skip this test for the simulator. + TestRuntime.AssertIfSimulatorThenARM64 (); + Assert.NotNull (UTType.GetDeclaringBundleURL (UTType.PDF)); } [Test] public void CreatePreferredIdentifier () { + // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), + // so just skip this test for the simulator. + TestRuntime.AssertIfSimulatorThenARM64 (); + string[] extensions = new [] { ".html", ".css", ".jpg", ".js", ".otf" }; // random failure reported in #36708 (on some iPad2 only) for (int i=0; i < 100; i++) { diff --git a/tests/monotouch-test/UIKit/UIDocumentTest.cs b/tests/monotouch-test/UIKit/UIDocumentTest.cs index 1b2b8c7a22..9c4c466d4e 100644 --- a/tests/monotouch-test/UIKit/UIDocumentTest.cs +++ b/tests/monotouch-test/UIKit/UIDocumentTest.cs @@ -99,6 +99,10 @@ namespace MonoTouchFixtures.UIKit { [Test] public void Save () { + // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), + // so just skip this test for the simulator. + TestRuntime.AssertIfSimulatorThenARM64 (); + using (NSUrl url = NSUrl.FromFilename (GetFileName ())) { doc = new MyDocument (url); doc.Save (url, UIDocumentSaveOperation.ForCreating, OperationHandler); diff --git a/tests/monotouch-test/UniformTypeIdentifiers/TypeTest.cs b/tests/monotouch-test/UniformTypeIdentifiers/TypeTest.cs index 6b9d72cccc..ab33820fad 100644 --- a/tests/monotouch-test/UniformTypeIdentifiers/TypeTest.cs +++ b/tests/monotouch-test/UniformTypeIdentifiers/TypeTest.cs @@ -19,6 +19,10 @@ namespace MonoTouchFixtures.UniformTypeIdentifiers { [Test] public void Archive () { + // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), + // so just skip this test for the simulator. + TestRuntime.AssertIfSimulatorThenARM64 (); + var a = UTTypes.Archive; Assert.False (a.Dynamic, "Dynamic"); var z = UTTypes.Zip;