|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 | 4 | using Microsoft.DotNet.XUnitExtensions;
|
| 5 | +using System.Diagnostics; |
5 | 6 | using System.Linq;
|
6 | 7 | using System.Net.Sockets;
|
7 | 8 | using System.Net.Test.Common;
|
@@ -915,5 +916,73 @@ public void SendPingWithIPAddressAndTimeoutAndBufferAndPingOptions_ElevatedUnix(
|
915 | 916 | });
|
916 | 917 | }, localIpAddress.ToString(), new RemoteInvokeOptions { RunAsSudo = true }).Dispose();
|
917 | 918 | }
|
| 919 | + |
| 920 | + [PlatformSpecific(TestPlatforms.AnyUnix)] |
| 921 | + [ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] |
| 922 | + [InlineData(AddressFamily.InterNetwork, "ja_JP.UTF8", null, null)] |
| 923 | + [InlineData(AddressFamily.InterNetwork, "en_US.UTF8", "ja_JP.UTF8", null)] |
| 924 | + [InlineData(AddressFamily.InterNetwork, "en_US.UTF8", null, "ja_JP.UTF8")] |
| 925 | + [InlineData(AddressFamily.InterNetworkV6, "ja_JP.UTF8", null, null)] |
| 926 | + [InlineData(AddressFamily.InterNetworkV6, "en_US.UTF8", "ja_JP.UTF8", null)] |
| 927 | + [InlineData(AddressFamily.InterNetworkV6, "en_US.UTF8", null, "ja_JP.UTF8")] |
| 928 | + public void SendPing_LocaleEnvVarsMustBeIgnored(AddressFamily addressFamily, string envVar_LANG, string envVar_LC_MESSAGES, string envVar_LC_ALL) |
| 929 | + { |
| 930 | + IPAddress localIpAddress = TestSettings.GetLocalIPAddress(addressFamily); |
| 931 | + if (localIpAddress == null) |
| 932 | + { |
| 933 | + // No local address for given address family. |
| 934 | + return; |
| 935 | + } |
| 936 | + |
| 937 | + var remoteInvokeStartInfo = new ProcessStartInfo(); |
| 938 | + |
| 939 | + remoteInvokeStartInfo.EnvironmentVariables["LANG"] = envVar_LANG; |
| 940 | + remoteInvokeStartInfo.EnvironmentVariables["LC_MESSAGES"] = envVar_LC_MESSAGES; |
| 941 | + remoteInvokeStartInfo.EnvironmentVariables["LC_ALL"] = envVar_LC_ALL; |
| 942 | + |
| 943 | + RemoteExecutor.Invoke(address => |
| 944 | + { |
| 945 | + SendBatchPing( |
| 946 | + (ping) => ping.Send(address, TestSettings.PingTimeout), |
| 947 | + (pingReply) => |
| 948 | + { |
| 949 | + PingResultValidator(pingReply, new IPAddress[] { IPAddress.Parse(address) }, null); |
| 950 | + }); |
| 951 | + }, localIpAddress.ToString(), new RemoteInvokeOptions { StartInfo = remoteInvokeStartInfo }).Dispose(); |
| 952 | + } |
| 953 | + |
| 954 | + [PlatformSpecific(TestPlatforms.AnyUnix)] |
| 955 | + [ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] |
| 956 | + [InlineData(AddressFamily.InterNetwork, "ja_JP.UTF8", null, null)] |
| 957 | + [InlineData(AddressFamily.InterNetwork, "en_US.UTF8", "ja_JP.UTF8", null)] |
| 958 | + [InlineData(AddressFamily.InterNetwork, "en_US.UTF8", null, "ja_JP.UTF8")] |
| 959 | + [InlineData(AddressFamily.InterNetworkV6, "ja_JP.UTF8", null, null)] |
| 960 | + [InlineData(AddressFamily.InterNetworkV6, "en_US.UTF8", "ja_JP.UTF8", null)] |
| 961 | + [InlineData(AddressFamily.InterNetworkV6, "en_US.UTF8", null, "ja_JP.UTF8")] |
| 962 | + public void SendPingAsync_LocaleEnvVarsMustBeIgnored(AddressFamily addressFamily, string envVar_LANG, string envVar_LC_MESSAGES, string envVar_LC_ALL) |
| 963 | + { |
| 964 | + IPAddress localIpAddress = TestSettings.GetLocalIPAddress(addressFamily); |
| 965 | + if (localIpAddress == null) |
| 966 | + { |
| 967 | + // No local address for given address family. |
| 968 | + return; |
| 969 | + } |
| 970 | + |
| 971 | + var remoteInvokeStartInfo = new ProcessStartInfo(); |
| 972 | + |
| 973 | + remoteInvokeStartInfo.EnvironmentVariables["LANG"] = envVar_LANG; |
| 974 | + remoteInvokeStartInfo.EnvironmentVariables["LC_MESSAGES"] = envVar_LC_MESSAGES; |
| 975 | + remoteInvokeStartInfo.EnvironmentVariables["LC_ALL"] = envVar_LC_ALL; |
| 976 | + |
| 977 | + RemoteExecutor.Invoke(async address => |
| 978 | + { |
| 979 | + await SendBatchPingAsync( |
| 980 | + (ping) => ping.SendPingAsync(address), |
| 981 | + (pingReply) => |
| 982 | + { |
| 983 | + PingResultValidator(pingReply, new IPAddress[] { IPAddress.Parse(address) }, null); |
| 984 | + }); |
| 985 | + }, localIpAddress.ToString(), new RemoteInvokeOptions { StartInfo = remoteInvokeStartInfo }).Dispose(); |
| 986 | + } |
918 | 987 | }
|
919 | 988 | }
|
0 commit comments