From 1f270e95a903b78c16f1781915a05af1847247d8 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com> Date: Fri, 3 Sep 2021 13:22:20 -0400 Subject: [PATCH 1/9] [libraries] Skip test suites crashing on CI for iOS/tvOS/MacCatalyst --- .../tests/PhysicalFileProviderTests.cs | 3 +- .../tests/FileSystemWatcher.WaitForChanged.cs | 1 + .../tests/MemoryMappedViewAccessor.Tests.cs | 4 +- .../tests/MemoryMappedViewStream.Tests.cs | 4 +- .../tests/System/EnvironmentTests.cs | 7 +- .../tests/System/TimeZoneInfoTests.cs | 2 +- src/libraries/tests.proj | 74 ++++--------------- .../AotCompilerTask/MonoAOTCompiler.props | 3 +- 8 files changed, 28 insertions(+), 70 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs index 8f2b5691fa9f80..4aa57114fcdc69 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs @@ -137,7 +137,7 @@ public void PollingFileProviderShouldntConsumeINotifyInstances() } } } - + private void GetFileInfoReturnsNotFoundFileInfoForIllegalPathWithLeadingSlashes(string path) { using (var provider = new PhysicalFileProvider(Path.GetTempPath())) @@ -936,6 +936,7 @@ public void NoopChangeTokenForFilterThatNavigatesAboveRoot() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/58584", TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] public void TokenForEmptyFilter() { using (var root = new DisposableFileSystem()) diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.WaitForChanged.cs b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.WaitForChanged.cs index aec8019cdceb9d..cce5f54469f2dd 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.WaitForChanged.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.WaitForChanged.cs @@ -111,6 +111,7 @@ public void NonZeroTimeout_NoEvents_TimesOut(bool enabledBeforeWait) [InlineData(WatcherChangeTypes.Changed, false)] [InlineData(WatcherChangeTypes.Renamed, true)] [InlineData(WatcherChangeTypes.All, true)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/58418", typeof(PlatformDetection), nameof(PlatformDetection.IsMacCatalyst), nameof(PlatformDetection.IsArm64Process))] public void NonZeroTimeout_NoActivity_TimesOut(WatcherChangeTypes changeType, bool enabledBeforeWait) { using (var testDirectory = new TempDirectory(GetTestFilePath())) diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs index 8f7e2fae576eb0..0c8517ca4affe8 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs @@ -91,10 +91,10 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor } catch (UnauthorizedAccessException) { - if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || PlatformDetection.IsInContainer) && + if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || PlatformDetection.IsInContainer) && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute)) { - // Containers and OSX with SIP enabled do not have execute permissions by default. + // Containers and OSXlike platforms with SIP enabled do not have execute permissions by default. throw new SkipTestException("Insufficient execute permission."); } diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs index d77a24ae0ddfa6..a5340527df9011 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs @@ -91,10 +91,10 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor } catch (UnauthorizedAccessException) { - if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || PlatformDetection.IsInContainer) && + if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || PlatformDetection.IsInContainer) && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute)) { - // Containers and OSX with SIP enabled do not have execute permissions by default. + // Containers and OSXlike platforms with SIP enabled do not have execute permissions by default. throw new SkipTestException("Insufficient execute permission."); } diff --git a/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs b/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs index f2b35eb6c2cdf7..63723f0117a099 100644 --- a/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs +++ b/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs @@ -346,11 +346,8 @@ public void GetFolderPath_Unix_PersonalIsHomeAndUserProfile() Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.Personal)); Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); } - // tvOS effectively doesn't have a HOME - if (!PlatformDetection.IstvOS) - { - Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)); - } + + Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)); } [Theory] diff --git a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs index e9f08a9b389dbb..e9a187e0e6b1ae 100644 --- a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs @@ -2662,7 +2662,7 @@ public static void IsIanaIdWithNotCacheTest() } [ConditionalFact(nameof(SupportIanaNamesConversion))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/52072", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/58440", TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] public static void IsIanaIdTest() { bool expected = !s_isWindows; diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 79e47df5100e6d..d7380dafa130b9 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -120,6 +120,7 @@ + @@ -145,71 +146,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - + - - - - - - - - - - - - - - + + + @@ -313,8 +270,9 @@ - + + - + + From 675d34088a6741d4a0ab49a34957c9f02d9ca34f Mon Sep 17 00:00:00 2001 From: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com> Date: Mon, 6 Sep 2021 05:04:22 -0400 Subject: [PATCH 2/9] [libraries] Restrict ILLink Suppression xml to mobile platforms (#58519) Co-authored-by: Mitchell Hwang --- ...raryBuild.xml => ILLink.Suppressions.Mobile.LibraryBuild.xml} | 0 src/libraries/System.Net.Http/src/System.Net.Http.csproj | 1 + 2 files changed, 1 insertion(+) rename src/libraries/System.Net.Http/src/ILLink/{ILLink.Suppressions.LibraryBuild.xml => ILLink.Suppressions.Mobile.LibraryBuild.xml} (100%) diff --git a/src/libraries/System.Net.Http/src/ILLink/ILLink.Suppressions.LibraryBuild.xml b/src/libraries/System.Net.Http/src/ILLink/ILLink.Suppressions.Mobile.LibraryBuild.xml similarity index 100% rename from src/libraries/System.Net.Http/src/ILLink/ILLink.Suppressions.LibraryBuild.xml rename to src/libraries/System.Net.Http/src/ILLink/ILLink.Suppressions.Mobile.LibraryBuild.xml diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index f6bcf3faacba20..2897f5fb1505fc 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -35,6 +35,7 @@ + From 4e2986d0ae44295739c747e6ae83087314e2ec81 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com> Date: Mon, 6 Sep 2021 05:06:38 -0400 Subject: [PATCH 3/9] [Libraries] Fix TimeZoneInfoTests IsIanaIdTest for iOS/MacCatalyst/tvOS (#58562) * [Libraries] Fix TimeZoneInfoTests IsIanaIdTest for iOS/MacCatalyst/tvOS * [Libraries] Fix IsIanaIdTest to assert throw for iOS/MacCatalyst/tvOS * Readd new line * [Mobile][Libraries] System.Runtime.Tests TimeZoneInfoTests remove mobile from iana conversion support * [libraries] System.Runtime.Tests revert IsIanaIdTest iOS tvOS special casing * Remove active issue added in recently merged PR Co-authored-by: Mitchell Hwang --- .../System.Runtime/tests/System/TimeZoneInfoTests.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs index e9a187e0e6b1ae..c5258a6252fec2 100644 --- a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs @@ -2641,7 +2641,7 @@ public static void UsingAlternativeTimeZoneIdsTest(string windowsId, string iana } } - public static bool SupportIanaNamesConversion => PlatformDetection.IsNotBrowser && PlatformDetection.ICUVersion.Major >= 52; + public static bool SupportIanaNamesConversion => PlatformDetection.IsNotMobile && PlatformDetection.ICUVersion.Major >= 52; public static bool SupportIanaNamesConversionAndRemoteExecution => SupportIanaNamesConversion && RemoteExecutor.IsSupported; // This test is executed using the remote execution because it needs to run before creating the time zone cache to ensure testing with that state. @@ -2662,7 +2662,6 @@ public static void IsIanaIdWithNotCacheTest() } [ConditionalFact(nameof(SupportIanaNamesConversion))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/58440", TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] public static void IsIanaIdTest() { bool expected = !s_isWindows; @@ -2694,7 +2693,6 @@ public static void IsIanaIdTest() [InlineData("Argentina Standard Time", "America/Buenos_Aires")] [InlineData("Newfoundland Standard Time", "America/St_Johns")] [InlineData("Iran Standard Time", "Asia/Tehran")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/52072", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public static void IdsConversionsTest(string windowsId, string ianaId) { Assert.True(TimeZoneInfo.TryConvertIanaIdToWindowsId(ianaId, out string winId)); @@ -2729,7 +2727,6 @@ public static void IdsConversionsTest(string windowsId, string ianaId) [InlineData("GMT Standard Time", "Europe/Dublin", "ie")] [InlineData("W. Europe Standard Time", "Europe/Rome", "it")] [InlineData("New Zealand Standard Time", "Pacific/Auckland", "nz")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/52072", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public static void IdsConversionsWithRegionTest(string windowsId, string ianaId, string region) { Assert.True(TimeZoneInfo.TryConvertWindowsIdToIanaId(windowsId, region, out string ianaConvertedId)); From 65350e42e4e90e8d5e144a5fe5a509e934ea9ca3 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com> Date: Fri, 27 Aug 2021 07:42:01 -0400 Subject: [PATCH 4/9] [iOS/tvOS] Skip System.Security.Cryptography.Pkcs PNSE, System.Diagnostics.Tracing and System.Runtime.Extensions test (#58210) --- .../TestsWriteEventToListener.cs | 1 + .../SignedCms/SignedCmsTests.netcoreapp.cs | 2 ++ .../tests/CollectionTests.cs | 1 + .../tests/ExportTests.cs | 2 ++ .../PfxFormatTests.SingleCertGenerator.cs | 1 + .../tests/PfxFormatTests.cs | 19 +++++++++++++++++++ .../tests/PfxTests.cs | 1 + 7 files changed, 27 insertions(+) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs index d7c7046ab693ed..97470a2ff4450e 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs @@ -452,6 +452,7 @@ public void Test_EventSourceCreatedEvents_AfterListener() [Theory] [InlineData(true)] [InlineData(false)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/51382", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public void Test_EventListenerThrows_ExceptionIsNotRethrownToCaller(bool setThrowOnEventWriteErrorsFlag) { TestUtilities.CheckNoEventSourcesRunning("Start"); diff --git a/src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs b/src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs index 9d90fe7905550f..cfa17458204e57 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs @@ -377,6 +377,7 @@ public static void AddAttributeToIndefiniteLengthContent() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public static void AddSigner_RSA_EphemeralKey() { using (RSA rsa = RSA.Create()) @@ -435,6 +436,7 @@ public static void AddSigner_DSA_EphemeralKey() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public static void AddSigner_ECDSA_EphemeralKey() { using (ECDsa ecdsa = ECDsa.Create()) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/CollectionTests.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/CollectionTests.cs index a519f7a7ccb69b..0392b093e87d7c 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/CollectionTests.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/CollectionTests.cs @@ -833,6 +833,7 @@ public static void ExportMultiplePrivateKeys() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public static void CanAddMultipleCertsWithSinglePrivateKey() { using (var oneWithKey = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword, X509KeyStorageFlags.Exportable | Cert.EphemeralIfPossible)) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/ExportTests.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/ExportTests.cs index 0051bc4da70e67..951a1329b77244 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/ExportTests.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/ExportTests.cs @@ -104,6 +104,7 @@ public static void ExportAsPfxVerifyPassword() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public static void ExportAsPfxWithPrivateKeyVerifyPassword() { using (var cert = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword, X509KeyStorageFlags.Exportable)) @@ -124,6 +125,7 @@ public static void ExportAsPfxWithPrivateKeyVerifyPassword() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public static void ExportAsPfxWithPrivateKey() { using (X509Certificate2 cert = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword, X509KeyStorageFlags.Exportable)) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.SingleCertGenerator.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.SingleCertGenerator.cs index de3a5f18004e4e..3fad2b9d3beb08 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.SingleCertGenerator.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.SingleCertGenerator.cs @@ -62,6 +62,7 @@ public static IEnumerable AllSingleCertVariations [Theory] [MemberData(nameof(AllSingleCertVariations))] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCertWithOneKey(SingleCertOptions options) { bool sameContainer = (options & SingleCertOptions.KeyAndCertInSameContents) != 0; diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.cs index 3b83ac201e5097..c73af1ac3173a7 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxFormatTests.cs @@ -158,6 +158,7 @@ public void EmptyPfx_BadPassword() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_NoKeys_EncryptedNullPassword_NoMac() { using (X509Certificate2 cert = new X509Certificate2(TestData.MsCertificate)) @@ -175,6 +176,7 @@ public void OneCert_NoKeys_EncryptedNullPassword_NoMac() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_NoKeys_EncryptedEmptyPassword_NoMac() { using (X509Certificate2 cert = new X509Certificate2(TestData.MsCertificate)) @@ -196,6 +198,7 @@ public void OneCert_NoKeys_EncryptedEmptyPassword_NoMac() [InlineData(false, true)] [InlineData(true, false)] [InlineData(true, true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_EncryptedEmptyPassword_OneKey_EncryptedNullPassword_NoMac(bool encryptKeySafe, bool associateKey) { // This test shows that while a null or empty password will result in both @@ -237,6 +240,7 @@ public void OneCert_EncryptedEmptyPassword_OneKey_EncryptedNullPassword_NoMac(bo } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_MismatchedKey() { string pw = nameof(OneCert_MismatchedKey); @@ -285,6 +289,7 @@ public void OneCert_MismatchedKey() [Theory] [InlineData(false)] [InlineData(true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_TwoKeys_FirstWins(bool correctKeyFirst) { string pw = nameof(OneCert_TwoKeys_FirstWins); @@ -356,6 +361,7 @@ public void OneCert_TwoKeys_FirstWins(bool correctKeyFirst) [Theory] [InlineData(false)] [InlineData(true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void TwoCerts_OneKey(bool certWithKeyFirst) { string pw = nameof(TwoCerts_OneKey); @@ -400,6 +406,7 @@ public void TwoCerts_OneKey(bool certWithKeyFirst) } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_ExtraKeyWithUnknownAlgorithm() { string pw = nameof(OneCert_ExtraKeyWithUnknownAlgorithm); @@ -445,6 +452,7 @@ public void OneCert_ExtraKeyWithUnknownAlgorithm() [Theory] [InlineData(true)] [InlineData(false)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_ExtraKeyBadEncoding(bool badTag) { string pw = nameof(OneCert_ExtraKeyBadEncoding); @@ -503,6 +511,7 @@ public void OneCert_ExtraKeyBadEncoding(bool badTag) } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_NoKey_WithLocalKeyId() { string pw = nameof(OneCert_NoKey_WithLocalKeyId); @@ -524,6 +533,7 @@ public void OneCert_NoKey_WithLocalKeyId() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void OneCert_TwentyKeys_NoMatches() { string pw = nameof(OneCert_NoKey_WithLocalKeyId); @@ -562,6 +572,7 @@ public void OneCert_TwentyKeys_NoMatches() [Theory] [InlineData(true)] [InlineData(false)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void TwoCerts_TwentyKeys_NoMatches(bool msCertFirst) { string pw = nameof(OneCert_NoKey_WithLocalKeyId); @@ -635,6 +646,7 @@ public void OneCorruptCert() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void CertAndKey_NoLocalKeyId() { string pw = nameof(CertAndKey_NoLocalKeyId); @@ -661,6 +673,7 @@ public void CertAndKey_NoLocalKeyId() [Theory] [InlineData(false)] [InlineData(true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void SameCertTwice_NoKeys(bool addLocalKeyId) { string pw = nameof(SameCertTwice_NoKeys); @@ -692,6 +705,7 @@ public void SameCertTwice_NoKeys(bool addLocalKeyId) } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void TwoCerts_CrossedKeys() { string pw = nameof(TwoCerts_CrossedKeys); @@ -766,6 +780,7 @@ public void TwoCerts_CrossedKeys() [InlineData(false, false)] [InlineData(true, false)] [InlineData(true, true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void CertAndKeyTwice(bool addLocalKeyId, bool crossIdentifiers) { string pw = nameof(CertAndKeyTwice); @@ -821,6 +836,7 @@ public void CertAndKeyTwice(bool addLocalKeyId, bool crossIdentifiers) } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void CertAndKeyTwice_KeysUntagged() { string pw = nameof(CertAndKeyTwice); @@ -873,6 +889,7 @@ public void CertAndKeyTwice_KeysUntagged() [Theory] [InlineData(false)] [InlineData(true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void CertTwice_KeyOnce(bool addLocalKeyId) { string pw = nameof(CertTwice_KeyOnce); @@ -930,6 +947,7 @@ public void CertTwice_KeyOnce(bool addLocalKeyId) [Theory] [InlineData(false)] [InlineData(true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void CertTwice_KeyOnce_OtherCertBetter(bool addLocalKeyId) { string pw = nameof(CertTwice_KeyOnce); @@ -990,6 +1008,7 @@ public void CertTwice_KeyOnce_OtherCertBetter(bool addLocalKeyId) [InlineData(false, true)] [InlineData(true, false)] [InlineData(true, true)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public void TwoCerts_TwoKeys_ManySafeContentsValues(bool invertCertOrder, bool invertKeyOrder) { string pw = nameof(TwoCerts_TwoKeys_ManySafeContentsValues); diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs index bd853f1e098be6..1132d8d85a406b 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs @@ -141,6 +141,7 @@ private static void VerifyPrivateKey(RSA rsa) [Theory] [MemberData(nameof(StorageFlags))] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "The PKCS#12 Exportable flag is not supported on iOS/MacCatalyst/tvOS")] public static void ExportWithPrivateKey(X509KeyStorageFlags keyStorageFlags) { using (var cert = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword, X509KeyStorageFlags.Exportable | keyStorageFlags)) From 68b6c0a962456296f769bfc2a5c96f61db782f5a Mon Sep 17 00:00:00 2001 From: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com> Date: Thu, 19 Aug 2021 18:12:53 -0400 Subject: [PATCH 5/9] [libraries] Fix System.Runtime.Tests TimeZoneInfoTests for iOS/MacCatalyst/tvOS (#57732) * [libraries] Fix System.Runtime.Tests TimeZoneInfoTests for iOS/MacCatalyst/tvOS * Remove redundant PlatformDetection.IsMacCatalyst as IsiOS covers it Co-authored-by: Mitchell Hwang --- .../System.Runtime/tests/System/TimeZoneInfoTests.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs index c5258a6252fec2..6ce8bef598c2bf 100644 --- a/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs @@ -87,7 +87,7 @@ public static void Names() // Name abbreviations, if available, are used instead public static IEnumerable Platform_TimeZoneNamesTestData() { - if (PlatformDetection.IsBrowser) + if (PlatformDetection.IsBrowser || PlatformDetection.IsiOS || PlatformDetection.IstvOS) return new TheoryData { { TimeZoneInfo.FindSystemTimeZoneById(s_strPacific), "(UTC-08:00) America/Los_Angeles", "PST", "PDT" }, @@ -125,7 +125,6 @@ public static IEnumerable Platform_TimeZoneNamesTestData() // We test the existence of a specific English time zone name to avoid failures on non-English platforms. [ConditionalTheory(nameof(IsEnglishUILanguage))] [MemberData(nameof(Platform_TimeZoneNamesTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/52072", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public static void Platform_TimeZoneNames(TimeZoneInfo tzi, string displayName, string standardName, string daylightName) { // Edge case - Optionally allow some characters to be absent in the display name. @@ -2623,10 +2622,9 @@ public static void EnsureUtcObjectSingleton() [InlineData("Argentina Standard Time", "America/Argentina/Catamarca")] [InlineData("Newfoundland Standard Time", "America/St_Johns")] [InlineData("Iran Standard Time", "Asia/Tehran")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/52072", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)] public static void UsingAlternativeTimeZoneIdsTest(string windowsId, string ianaId) { - if (PlatformDetection.ICUVersion.Major >= 52) + if (PlatformDetection.ICUVersion.Major >= 52 && !PlatformDetection.IsiOS && !PlatformDetection.IstvOS) { TimeZoneInfo tzi1 = TimeZoneInfo.FindSystemTimeZoneById(ianaId); TimeZoneInfo tzi2 = TimeZoneInfo.FindSystemTimeZoneById(windowsId); From 2bb7a34f9783ddaa13b4666afa634f36d5713b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 2 Sep 2021 18:18:44 +0200 Subject: [PATCH 6/9] Reenable a few OperatingSystem tests on MacCatalyst (#58428) https://github.com/dotnet/runtime/issues/56084 was fixed. (cherry picked from commit 2d3ad726ac2f82f16ebddf9e1e45cf5a3d34064c) --- .../tests/System/OperatingSystemTests.cs | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs b/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs index 40fea32233194e..3a7e5aaa60f25e 100644 --- a/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs +++ b/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs @@ -102,11 +102,9 @@ public static void IsOSPlatformVersionAtLeast_InvalidArgs_Throws() public static void TestIsOSVersionAtLeast_Android_21() => Assert.True(OperatingSystem.IsAndroidVersionAtLeast(21)); // 21 is our min supported version [Fact, PlatformSpecific(TestPlatforms.iOS)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)] public static void TestIsOSPlatform_IOS() => TestIsOSPlatform("iOS", OperatingSystem.IsIOS); [Fact, PlatformSpecific(TestPlatforms.iOS)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)] public static void TestIsOSVersionAtLeast_IOS() => TestIsOSVersionAtLeast("iOS"); [Fact, PlatformSpecific(TestPlatforms.OSX)] @@ -129,11 +127,9 @@ public static void OSX_Is_Treated_as_macOS() } [Fact, PlatformSpecific(TestPlatforms.MacCatalyst)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)] public static void TestIsOSPlatform_MacCatalyst() => TestIsOSPlatform("MacCatalyst", OperatingSystem.IsMacCatalyst); [Fact, PlatformSpecific(TestPlatforms.MacCatalyst)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)] public static void TestIsOSVersionAtLeast_MacCatalyst() => TestIsOSVersionAtLeast("MacCatalyst"); [Fact, PlatformSpecific(TestPlatforms.MacCatalyst)] @@ -147,7 +143,6 @@ public static void MacCatalyst_Is_Also_iOS() } [Fact, PlatformSpecific(TestPlatforms.iOS)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)] public static void IOS_Is_Not_Also_MacCatalyst() { Assert.False(OperatingSystem.IsOSPlatform("MacCatalyst")); @@ -172,6 +167,12 @@ private static void TestIsOSPlatform(string currentOSName, Func currentOSC { bool expected = currentOSName.Equals(platformName, StringComparison.OrdinalIgnoreCase); + // MacCatalyst is a special case since it also returns true for iOS + if (currentOSName == "MacCatalyst" && platformName == "iOS") + { + expected = true; + } + Assert.Equal(expected, OperatingSystem.IsOSPlatform(platformName)); Assert.Equal(expected, OperatingSystem.IsOSPlatform(platformName.ToUpper())); Assert.Equal(expected, OperatingSystem.IsOSPlatform(platformName.ToLower())); @@ -186,14 +187,32 @@ private static void TestIsOSPlatform(string currentOSName, Func currentOSC OperatingSystem.IsFreeBSD(), OperatingSystem.IsAndroid(), OperatingSystem.IsIOS(), - OperatingSystem.IsMacOS(), OperatingSystem.IsMacCatalyst(), + OperatingSystem.IsMacOS(), OperatingSystem.IsTvOS(), OperatingSystem.IsWatchOS(), OperatingSystem.IsWindows() }; - Assert.Single(allResults, true); + // MacCatalyst is a special case since it also returns true for iOS + if (currentOSName == "MacCatalyst") + { + Assert.Equal(10, allResults.Length); + Assert.False(allResults[0]); // IsBrowser() + Assert.False(allResults[1]); // IsLinux() + Assert.False(allResults[2]); // IsFreeBSD() + Assert.False(allResults[3]); // IsAndroid() + Assert.True(allResults[4]); // IsIOS() + Assert.True(allResults[5]); // IsMacCatalyst() + Assert.False(allResults[6]); // IsMacOS() + Assert.False(allResults[7]); // IsTvOS() + Assert.False(allResults[8]); // IsWatchOS() + Assert.False(allResults[9]); // IsWindows() + } + else + { + Assert.Single(allResults, true); + } } private static void TestIsOSVersionAtLeast(string currentOSName) @@ -202,13 +221,19 @@ private static void TestIsOSVersionAtLeast(string currentOSName) { bool isCurrentOS = currentOSName.Equals(platformName, StringComparison.OrdinalIgnoreCase); + // MacCatalyst is a special case since it also returns true for iOS + if (currentOSName == "MacCatalyst" && platformName == "iOS") + { + isCurrentOS = true; + } + AssertVersionChecks(isCurrentOS, (major, minor, build, revision) => OperatingSystem.IsOSPlatformVersionAtLeast(platformName, major, minor, build, revision)); AssertVersionChecks(isCurrentOS, (major, minor, build, revision) => OperatingSystem.IsOSPlatformVersionAtLeast(platformName.ToLower(), major, minor, build, revision)); AssertVersionChecks(isCurrentOS, (major, minor, build, revision) => OperatingSystem.IsOSPlatformVersionAtLeast(platformName.ToUpper(), major, minor, build, revision)); } AssertVersionChecks(currentOSName.Equals("Android", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsAndroidVersionAtLeast); - AssertVersionChecks(currentOSName.Equals("iOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsIOSVersionAtLeast); + AssertVersionChecks(currentOSName == "MacCatalyst" || currentOSName.Equals("iOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsIOSVersionAtLeast); AssertVersionChecks(currentOSName.Equals("macOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsMacOSVersionAtLeast); AssertVersionChecks(currentOSName.Equals("MacCatalyst", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsMacCatalystVersionAtLeast); AssertVersionChecks(currentOSName.Equals("tvOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsTvOSVersionAtLeast); From 6ecf2baff6aab724e7770535aff9d043d023e30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 3 Sep 2021 16:07:55 +0200 Subject: [PATCH 7/9] Fix Android device issues related to filesystem/IO (#58586) - Use F_SETLK64 for fcntl to fix an issue where 32bit arm Android apps would get the wrong flag - Add numerical magic numbers for missing file systems to Interop.UnixFileSystemTypes so they are correctly recognized - Make ping test a bit more forgiving if the process returns a few milliseconds _before_ the timeout (cherry picked from commit 462ab6e7a65dec97944e408b1959e71276f83988) --- .../System.Native/Interop.MountPoints.FormatInfo.cs | 1 + .../System.Native/Interop.UnixFileSystemTypes.cs | 3 +++ src/libraries/Native/Unix/System.Native/pal_io.c | 13 ++++++++++++- .../tests/FunctionalTests/UnixPingUtilityTests.cs | 4 ++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs index 15d6aa3c2f147a..fbd95d485e8415 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs @@ -80,6 +80,7 @@ private static DriveType GetDriveType(string fileSystemName) // This list is based primarily on "man fs", "man mount", "mntent.h", "/proc/filesystems", coreutils "stat.c", // and "wiki.debian.org/FileSystem". It can be extended over time as we find additional file systems that should // be recognized as a particular drive type. + // Keep this in sync with the UnixFileSystemTypes enum in Interop.UnixFileSystemTypes.cs switch (fileSystemName) { case "cddafs": diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs index 892e5ccaaed336..d86dcfbe4e59ae 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs @@ -28,6 +28,7 @@ internal enum UnixFileSystemTypes : long befs = 0x42465331, bdevfs = 0x62646576, bfs = 0x1BADFACE, + bpf_fs = 0xCAFE4A11, binfmt_misc = 0x42494E4D, bootfs = 0xA56D3FF9, btrfs = 0x9123683E, @@ -53,6 +54,7 @@ internal enum UnixFileSystemTypes : long ext2 = 0xEF53, ext3 = 0xEF53, ext4 = 0xEF53, + f2fs = 0xF2F52010, fat = 0x4006, fd = 0xF00D1E, fhgfs = 0x19830326, @@ -122,6 +124,7 @@ internal enum UnixFileSystemTypes : long sysv2 = 0x012FF7B6, sysv4 = 0x012FF7B5, tmpfs = 0x01021994, + tracefs = 0x74726163, ubifs = 0x24051905, udf = 0x15013346, ufs = 0x00011954, diff --git a/src/libraries/Native/Unix/System.Native/pal_io.c b/src/libraries/Native/Unix/System.Native/pal_io.c index 51d841ffc55bdb..d86e8feb93584e 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.c +++ b/src/libraries/Native/Unix/System.Native/pal_io.c @@ -1427,6 +1427,7 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd) else if (strcmp(statfsArgs.f_basetype, "befs") == 0) result = 0x42465331; else if (strcmp(statfsArgs.f_basetype, "bdevfs") == 0) result = 0x62646576; else if (strcmp(statfsArgs.f_basetype, "bfs") == 0) result = 0x1BADFACE; + else if (strcmp(statfsArgs.f_basetype, "bpf_fs") == 0) result = 0xCAFE4A11; else if (strcmp(statfsArgs.f_basetype, "binfmt_misc") == 0) result = 0x42494E4D; else if (strcmp(statfsArgs.f_basetype, "bootfs") == 0) result = 0xA56D3FF9; else if (strcmp(statfsArgs.f_basetype, "btrfs") == 0) result = 0x9123683E; @@ -1452,6 +1453,7 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd) else if (strcmp(statfsArgs.f_basetype, "ext2") == 0) result = 0xEF53; else if (strcmp(statfsArgs.f_basetype, "ext3") == 0) result = 0xEF53; else if (strcmp(statfsArgs.f_basetype, "ext4") == 0) result = 0xEF53; + else if (strcmp(statfsArgs.f_basetype, "f2fs") == 0) result = 0xF2F52010; else if (strcmp(statfsArgs.f_basetype, "fat") == 0) result = 0x4006; else if (strcmp(statfsArgs.f_basetype, "fd") == 0) result = 0xF00D1E; else if (strcmp(statfsArgs.f_basetype, "fhgfs") == 0) result = 0x19830326; @@ -1519,6 +1521,7 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd) else if (strcmp(statfsArgs.f_basetype, "sysv2") == 0) result = 0x012FF7B6; else if (strcmp(statfsArgs.f_basetype, "sysv4") == 0) result = 0x012FF7B5; else if (strcmp(statfsArgs.f_basetype, "tmpfs") == 0) result = 0x01021994; + else if (strcmp(statfsArgs.f_basetype, "tracefs") == 0) result = 0x74726163; else if (strcmp(statfsArgs.f_basetype, "ubifs") == 0) result = 0x24051905; else if (strcmp(statfsArgs.f_basetype, "udf") == 0) result = 0x15013346; else if (strcmp(statfsArgs.f_basetype, "ufs") == 0) result = 0x00011954; @@ -1560,13 +1563,21 @@ int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, struct flock lockArgs; #endif +#if defined(TARGET_ANDROID) && defined(HAVE_FLOCK64) + // On Android, fcntl is always implemented by fcntl64 but before https://github.com/aosp-mirror/platform_bionic/commit/09e77f35ab8d291bf88302bb9673aaa518c6bcb0 + // there was no remapping of F_SETLK to F_SETLK64 when _FILE_OFFSET_BITS=64 (which we set in eng/native/configurecompiler.cmake) so we need to always pass F_SETLK64 + int command = F_SETLK64; +#else + int command = F_SETLK; +#endif + lockArgs.l_type = unixLockType; lockArgs.l_whence = SEEK_SET; lockArgs.l_start = (off_t)offset; lockArgs.l_len = (off_t)length; int32_t ret; - while ((ret = fcntl (ToFileDescriptor(fd), F_SETLK, &lockArgs)) < 0 && errno == EINTR); + while ((ret = fcntl (ToFileDescriptor(fd), command, &lockArgs)) < 0 && errno == EINTR); return ret; } diff --git a/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs b/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs index 0d686f9a8ee4ad..cafc675f807228 100644 --- a/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs +++ b/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs @@ -37,8 +37,8 @@ public static void TimeoutIsRespected(int timeout) p.Start(); p.WaitForExit(); - //ensure that the process takes longer than or equal to 'timeout' - Assert.True(stopWatch.ElapsedMilliseconds >= timeout); + //ensure that the process takes longer than or within 10ms of 'timeout', with a 5s maximum + Assert.InRange(stopWatch.ElapsedMilliseconds, timeout - 10, 5000); } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] From b138558a47881552ad08cab3bb2c4de35e74a09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 9 Sep 2021 13:40:05 +0200 Subject: [PATCH 8/9] System.Net.Ping: Skip TimeoutIsRespected test if network is unreachable (#58745) The TestSettings.UnreachableAddress is using 192.0.2.0 which is documented in RFC5735 as a network to be used in docs/example code. On the Android devices in Helix the upstream network is configured to not route this address which results in a "Destination Net Unreachable" response which causes the timeout argument to ping to be ignored and ping returns immediately. Skip the test in these cases. Example output from ping on the device: ``` 1|sunfish:/ $ time ping -c 1 -W 2 -s 50 192.0.2.0 PING 192.0.2.0 (192.0.2.0) 50(78) bytes of data. From 131.107.5.118: icmp_seq=1 Destination Net Unreachable --- 192.0.2.0 ping statistics --- 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time Oms 0m00.03s real 0m00.00s user 0m00.00s system ``` (cherry picked from commit 84fb871ff1da5aca65c0508520bde9162ce6f514) --- .../FunctionalTests/UnixPingUtilityTests.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs b/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs index cafc675f807228..b34f45bdd881f7 100644 --- a/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs +++ b/src/libraries/System.Net.Ping/tests/FunctionalTests/UnixPingUtilityTests.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Xunit; +using Microsoft.DotNet.XUnitExtensions; namespace System.Net.NetworkInformation.Tests { @@ -19,7 +20,7 @@ public class UnixPingUtilityTests { private const int IcmpHeaderLengthInBytes = 8; - [Theory] + [ConditionalTheory] [InlineData(0)] [InlineData(100)] [InlineData(1000)] @@ -32,11 +33,24 @@ public static void TimeoutIsRespected(int timeout) p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; + bool destinationNetUnreachable = false; + p.OutputDataReceived += delegate (object sendingProcess, DataReceivedEventArgs outputLine) + { + if (outputLine.Data?.Contains("Destination Net Unreachable", StringComparison.OrdinalIgnoreCase) == true) + destinationNetUnreachable = true; + }; + Stopwatch stopWatch = Stopwatch.StartNew(); p.Start(); + p.BeginOutputReadLine(); p.WaitForExit(); + if (destinationNetUnreachable) + { + throw new SkipTestException($"Network doesn't route {TestSettings.UnreachableAddress}, skipping test."); + } + //ensure that the process takes longer than or within 10ms of 'timeout', with a 5s maximum Assert.InRange(stopWatch.ElapsedMilliseconds, timeout - 10, 5000); } From f3ec696f9142e5be94b752bad56246223bc491f3 Mon Sep 17 00:00:00 2001 From: Jo Shields Date: Thu, 19 Aug 2021 06:40:25 -0400 Subject: [PATCH 9/9] Add special Mac Catalyst values for mtriple to MonoAOTCompiler.props (#57687) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Effectively, we are correctly saying "build a Mac Catalyst app from runtime and these `-llvm.o` files, but the `-llvm.o` files are not correctly being built in a Mac Catalyst compatible way, resulting in the error ``` ld: building for Mac Catalyst, but linking in object file built for , file '/Users/filipnavara/Projects/llvmbug/obj/Debug/net6.0-maccatalyst/maccatalyst-arm64/nativelibraries/aot-output/arm64/llvmbug.dll.llvm.o' ``` The target platform parameter gets passed around a LOT - `src/tasks/AotCompilerTask/MonoAOTCompiler.props` specifies `` which passes through to MonoAOTCompiler.cs task which passes through to the `mono --aot=llvmopts=mtriple=arm64-ios` flag, which is processed by `src/mono/mono/mini/aot-compiler.c` and eventually regurgitated as `llc -mtriple=arm64-ios -march=aarch64`, which results in .o files which lack the required annotations to be considered Catalyst compatible. Thankfully, it seems that `llc` accepts `clang`'s `-target` triplet values as valid for `-mtriple`, so passing through Catalyst specific values for `mtriple` in `MonoAOTCompiler.props` results in .o files which are correctly linked later by `clang` during the AppleAppBuilder task. It's slow though! 🙀 Fixes https://github.com/dotnet/runtime/issues/57589 --- src/tasks/AotCompilerTask/MonoAOTCompiler.props | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.props b/src/tasks/AotCompilerTask/MonoAOTCompiler.props index 93bd704de3b89f..6ef2f973eb8140 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.props +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.props @@ -1,8 +1,10 @@ - + + - + +