diff options
author | Egor Bogatov <egorbo@gmail.com> | 2017-12-19 13:37:51 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-12-19 13:37:51 +0300 |
commit | e9e17e069e6949600a382341e8888d7486553f21 (patch) | |
tree | 45b84d30524f4bec173c367c2236e8212b134ec2 /mcs/class/test-helpers | |
parent | 84c9542f15b90e7ce458bd39d267593082eaf508 (diff) |
[System] System.Net.* tests from corefx (+RemoteExecutorTestBase) (#6136)
Diffstat (limited to 'mcs/class/test-helpers')
-rw-r--r-- | mcs/class/test-helpers/AdminHelper.cs | 17 | ||||
-rw-r--r-- | mcs/class/test-helpers/PlatformDetection.cs | 7 | ||||
-rw-r--r-- | mcs/class/test-helpers/RemoteExecutorConsoleApp.cs | 49 | ||||
-rw-r--r-- | mcs/class/test-helpers/RemoteExecutorTestBase.Mobile.cs | 24 | ||||
-rw-r--r-- | mcs/class/test-helpers/RemoteExecutorTestBase.Mono.cs | 16 |
5 files changed, 112 insertions, 1 deletions
diff --git a/mcs/class/test-helpers/AdminHelper.cs b/mcs/class/test-helpers/AdminHelper.cs new file mode 100644 index 00000000000..c6c32033817 --- /dev/null +++ b/mcs/class/test-helpers/AdminHelper.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace System +{ + public static partial class AdminHelpers + { + public unsafe static bool IsProcessElevated() => true; + } +}
\ No newline at end of file diff --git a/mcs/class/test-helpers/PlatformDetection.cs b/mcs/class/test-helpers/PlatformDetection.cs index a265cc51113..d9d24695667 100644 --- a/mcs/class/test-helpers/PlatformDetection.cs +++ b/mcs/class/test-helpers/PlatformDetection.cs @@ -5,9 +5,14 @@ namespace System public static readonly bool IsNetNative = false; public static readonly bool IsNotWinRT = true; public static readonly bool IsWinRT = false; - public static readonly bool IsFullFramework = true; public static readonly bool IsWindowsNanoServer = false; + public static bool IsFullFramework => true; public static bool IsNonZeroLowerBoundArraySupported => true; public static bool IsUap => false; + + //TODO: check? + public static bool IsNotWindowsSubsystemForLinux => true; + public static bool IsWindowsSubsystemForLinux => false; + public static bool IsFedora => false; } }
\ No newline at end of file diff --git a/mcs/class/test-helpers/RemoteExecutorConsoleApp.cs b/mcs/class/test-helpers/RemoteExecutorConsoleApp.cs new file mode 100644 index 00000000000..93977430a5a --- /dev/null +++ b/mcs/class/test-helpers/RemoteExecutorConsoleApp.cs @@ -0,0 +1,49 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +class Program +{ + static int Main (string[] args) + { + if (args == null || args.Length < 3) + { + Console.WriteLine ("Invalid argumenets.\n Usage: RemoteTestExecuter.exe {assembly_name} {type_name} {method_name} {exception_file} {method_args}"); + return -1; + } + + string assemblyName = args[0]; + string typeName = args[1]; + string methodName = args[2]; + + var type = Type.GetType ($"{typeName}, {assemblyName}"); + if (type == null) + throw new Exception ($"Type {typeName} was not found in {assemblyName}"); + + var method = type.GetMethod (methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (method == null) + throw new Exception ($"Method {methodName} was not found in {typeName}, {assemblyName}"); + + var methodArgs = args.Length == 4 ? null : args.Skip(4).Cast<object>().ToArray(); + var instance = Activator.CreateInstance (type); + int result = 0; + + if (method.ReturnType == typeof (int)) + { + result = (int)method.Invoke (instance, methodArgs); + } + else if (method.ReturnType == typeof (Task<int>)) + { + var task = (Task<int>)method.Invoke (instance, methodArgs); + task.Wait(); //use C# 7.1 async Main? + result = task.Result; + } + else + { + throw new Exception($"ReturnType should be int or Task<int>. But was: {method.ReturnType.Name}"); + } + + return result; + } +}
\ No newline at end of file diff --git a/mcs/class/test-helpers/RemoteExecutorTestBase.Mobile.cs b/mcs/class/test-helpers/RemoteExecutorTestBase.Mobile.cs new file mode 100644 index 00000000000..ba6172d43b0 --- /dev/null +++ b/mcs/class/test-helpers/RemoteExecutorTestBase.Mobile.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Reflection; +using System.Text; +using Xunit; + +namespace System.Diagnostics +{ + // this file can be used in order to ignore all RemoteInvoke-tests + // should be used instead of /corefx/.../RemoteExecutorTestBase.Process.cs + public abstract partial class RemoteExecutorTestBase : FileCleanupTestBase + { + static RemoteInvokeHandle RemoteInvoke (MethodInfo method, string[] args, + RemoteInvokeOptions options, bool pasteArguments = true) + { + options = options ?? new RemoteInvokeOptions (); + //do nothing. Or we can invoke the method in the same process instead: + //method.Invoke(Activator.CreateInstance(method.DeclaringType), args.OfType<object>().ToArray()); + return new RemoteInvokeHandle (null, null); + } + } +}
\ No newline at end of file diff --git a/mcs/class/test-helpers/RemoteExecutorTestBase.Mono.cs b/mcs/class/test-helpers/RemoteExecutorTestBase.Mono.cs new file mode 100644 index 00000000000..33b04fdb5f8 --- /dev/null +++ b/mcs/class/test-helpers/RemoteExecutorTestBase.Mono.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.IO; +using System.Runtime.InteropServices; + +namespace System.Diagnostics +{ + /// <summary>Base class used for all tests that need to spawn a remote process.</summary> + public abstract partial class RemoteExecutorTestBase : FileCleanupTestBase + { + protected static readonly string HostRunner = Process.GetCurrentProcess().MainModule.FileName; + static readonly string ExtraParameter = "RemoteExecutorConsoleApp.exe"; + } +} |