Skip to content

Commit 3045920

Browse files
authored
Merge dd886c7 into 422b423
2 parents 422b423 + dd886c7 commit 3045920

4 files changed

Lines changed: 30 additions & 16 deletions

File tree

‎src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static partial class PlatformDetection
3030

3131
public static bool IsMonoLinuxArm64 => IsMonoRuntime && IsLinux && IsArm64Process;
3232
public static bool IsNotMonoLinuxArm64 => !IsMonoLinuxArm64;
33+
public static bool IsNotRiscV64Ubuntu => !IsUbuntu || !IsRiscV64Process;
3334

3435
// OSX family
3536
public static bool IsApplePlatform => IsOSX || IsiOS || IstvOS || IsMacCatalyst;

‎src/libraries/System.Net.Sockets/tests/FunctionalTests/ArgumentValidationTests.cs‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -794,18 +794,20 @@ await Task.WhenAll(
794794

795795
[Theory]
796796
[PlatformSpecific(TestPlatforms.AnyUnix)] // API throws PNSE on Unix
797-
[InlineData(0)]
798-
[InlineData(1)]
799-
public void Connect_ConnectTwice_NotSupported(int invalidatingAction)
797+
[InlineData(false)]
798+
[InlineData(true)]
799+
public void Connect_ConnectTwice_NotSupported(bool invalidatingAction)
800800
{
801801
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
802802
{
803-
switch (invalidatingAction)
803+
// On RISC-V Qemu we omit one test case due to: https://gitlab.com/qemu-project/qemu/-/issues/2410
804+
bool invalidatingActionOnPlatform = invalidatingAction && PlatformDetection.IsNotRiscV64Ubuntu;
805+
switch (invalidatingActionOnPlatform)
804806
{
805-
case 0:
807+
case false:
806808
IntPtr handle = client.Handle; // exposing the underlying handle
807809
break;
808-
case 1:
810+
case true:
809811
client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.Debug, 1); // untracked socket option
810812
break;
811813
}
@@ -825,20 +827,22 @@ public void Connect_ConnectTwice_NotSupported(int invalidatingAction)
825827

826828
[Theory]
827829
[PlatformSpecific(TestPlatforms.AnyUnix)] // API throws PNSE on Unix
828-
[InlineData(0)]
829-
[InlineData(1)]
830-
public void ConnectAsync_ConnectTwice_NotSupported(int invalidatingAction)
830+
[InlineData(false)]
831+
[InlineData(true)]
832+
public void ConnectAsync_ConnectTwice_NotSupported(bool invalidatingAction)
831833
{
832834
AutoResetEvent completed = new AutoResetEvent(false);
833835

834836
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
835837
{
836-
switch (invalidatingAction)
838+
// On RISC-V Qemu we omit one test case due to: https://gitlab.com/qemu-project/qemu/-/issues/2410
839+
bool invalidatingActionOnPlatform = invalidatingAction && PlatformDetection.IsNotRiscV64Ubuntu;
840+
switch (invalidatingActionOnPlatform)
837841
{
838-
case 0:
842+
case false:
839843
IntPtr handle = client.Handle; // exposing the underlying handle
840844
break;
841-
case 1:
845+
case true:
842846
client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.Debug, 1); // untracked socket option
843847
break;
844848
}

‎src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace System.Net.Sockets.Tests
1515
public partial class SocketOptionNameTest
1616
{
1717
private static bool SocketsReuseUnicastPortSupport => Capability.SocketsReuseUnicastPortSupport().HasValue;
18+
private static bool SupportedOnPlatform = PlatformDetection.IsNotWindowsNanoNorServerCore && PlatformDetection.IsNotRiscV64Ubuntu;
1819

1920
[ConditionalFact(nameof(SocketsReuseUnicastPortSupport))]
2021
public void ReuseUnicastPort_CreateSocketGetOption()
@@ -50,7 +51,7 @@ public void ReuseUnicastPort_CreateSocketSetOption()
5051
}
5152
}
5253

53-
[Fact]
54+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotRiscV64Ubuntu))]
5455
public void MulticastOption_CreateSocketSetGetOption_GroupAndInterfaceIndex_SetSucceeds_GetThrows()
5556
{
5657
int interfaceIndex = 0;
@@ -64,7 +65,7 @@ public void MulticastOption_CreateSocketSetGetOption_GroupAndInterfaceIndex_SetS
6465
}
6566
}
6667

67-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] // Skip on Nano: https://github.com/dotnet/runtime/issues/26286
68+
[ConditionalFact(nameof(SupportedOnPlatform))] // Skip on Nano: https://github.com/dotnet/runtime/issues/26286 and RISC-V Qemu
6869
public async Task MulticastInterface_Set_AnyInterface_Succeeds()
6970
{
7071
// On all platforms, index 0 means "any interface"
@@ -120,7 +121,7 @@ public void MulticastInterface_Set_InvalidIndex_Throws()
120121
}
121122
}
122123

123-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoNorServerCore))] // Skip on Nano: https://github.com/dotnet/runtime/issues/26286
124+
[ConditionalFact(nameof(SupportedOnPlatform))] // Skip on Nano: https://github.com/dotnet/runtime/issues/26286 and RISC-V Qemu
124125
[SkipOnPlatform(TestPlatforms.OSX | TestPlatforms.FreeBSD, "Expected behavior is different on OSX or FreeBSD")]
125126
[ActiveIssue("https://github.com/dotnet/runtime/issues/52124", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
126127
public async Task MulticastInterface_Set_IPv6_AnyInterface_Succeeds()

‎src/native/libs/System.Native/pal_networking.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,15 @@ int32_t SystemNative_GetSockOpt(
20882088
{
20892089
return Error_EFAULT;
20902090
}
2091-
2091+
#if defined(TARGET_RISCV64)
2092+
uint8_t nonEmptyOptionValueBuffer;
2093+
if (socketOptionLevel == SocketOptionLevel_SOL_TCP && socketOptionName == SocketOptionName_SO_TCP_KEEPALIVE_TIME && optionValue == NULL
2094+
&& *optionLen == 0)
2095+
{
2096+
// It's workaround for Qemu bug: https://gitlab.com/qemu-project/qemu/-/issues/2390.
2097+
optionValue = &nonEmptyOptionValueBuffer;
2098+
}
2099+
#endif
20922100
int fd = ToFileDescriptor(socket);
20932101

20942102
//

0 commit comments

Comments
 (0)