Disable JIT/Directed/pinvoke/pinvoke-examples test. (dotnet/coreclr#27614)
authorAaron Robinson <arobins@microsoft.com>
Fri, 1 Nov 2019 23:18:08 +0000 (16:18 -0700)
committerGitHub <noreply@github.com>
Fri, 1 Nov 2019 23:18:08 +0000 (16:18 -0700)
* Test and fix pinvoke-examples test

Commit migrated from https://github.com/dotnet/coreclr/commit/cceb5c80f795f889eaa1ae4ac6e17cdff6acf305

src/coreclr/tests/src/JIT/Directed/pinvoke/CMakeLists.txt
src/coreclr/tests/src/JIT/Directed/pinvoke/pinvoke-examples.cs
src/coreclr/tests/src/JIT/Directed/pinvoke/pinvoke-examples.csproj
src/coreclr/tests/src/JIT/Directed/pinvoke/pinvokeexamplenative.cpp [moved from src/coreclr/tests/src/JIT/Directed/pinvoke/user32menu.cpp with 97% similarity]
src/coreclr/tests/src/JIT/Directed/pinvoke/tail.il

index 7fc8f06..9ed78ec 100644 (file)
@@ -1,13 +1,13 @@
 cmake_minimum_required(VERSION 2.6)
-project(pinvoke_user32menu)
+project(PInvokeExampleNative)
 
 set(CMAKE_SHARED_LIBRARY_PREFIX "")
 
-add_library(user32menu SHARED user32menu.cpp)
-SET_TARGET_PROPERTIES(user32menu PROPERTIES COMPILE_FLAGS "-c")
+add_library(PInvokeExampleNative SHARED pinvokeexamplenative.cpp)
+SET_TARGET_PROPERTIES(PInvokeExampleNative PROPERTIES COMPILE_FLAGS "-c")
 
 # add the install targets (this "installs" the native file on Windows systems)
-install(TARGETS user32menu DESTINATION bin)
+install(TARGETS PInvokeExampleNative DESTINATION bin)
 
 # This "installs" the native file on System V systems
-set_target_properties(user32menu PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/user32menu)
+set_target_properties(PInvokeExampleNative PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/PInvokeExampleNative)
index d25a24e..d043260 100644 (file)
@@ -8,27 +8,39 @@
 using System;
 using System.Threading;
 using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 
 
 namespace PInvokeTest
 {
+    static class PInvokeExampleNative
+    {
+        public static int GetConstant()
+        {
+            return GetConstantInternal();
+        }
+
+        [DllImport(nameof(PInvokeExampleNative))]
+        private extern static int GetConstantInternal();
+    }
+
     internal class Test
     {
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        static bool AsForceInline()
+        static int AsForceInline()
         {
-            return Thread.Yield();
+            return PInvokeExampleNative.GetConstant();
         }
 
-        static bool AsNormalInline()
+        static int AsNormalInline()
         {
-            return Thread.Yield();
+            return PInvokeExampleNative.GetConstant();
         }
 
         [MethodImpl(MethodImplOptions.NoInlining)]
-        static bool AsNoInline()
+        static int AsNoInline()
         {
-            return Thread.Yield();
+            return PInvokeExampleNative.GetConstant();
         }
 
         static bool FromTryCatch()
@@ -37,7 +49,7 @@ namespace PInvokeTest
             try 
             {
                 // All pinvokes should be inline, except on x64
-                result = (Thread.Yield() == AsNormalInline());
+                result = (PInvokeExampleNative.GetConstant() == AsNormalInline());
             }
             catch (Exception)
             {
@@ -54,8 +66,8 @@ namespace PInvokeTest
             try 
             {
                 // All pinvokes should be inline, except on x64
-                result1 = (Thread.Yield() == AsNormalInline());
-                result2 = (Thread.Yield() == AsNormalInline());
+                result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
+                result2 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
             }
             finally
             {
@@ -73,12 +85,12 @@ namespace PInvokeTest
             try 
             {
                 // These two pinvokes should be inline, except on x64
-                result1 = (Thread.Yield() == AsNormalInline());
+                result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
             }
             finally
             {
                 // These two pinvokes should *not* be inline (finally)
-                result2 = (Thread.Yield() == AsNormalInline());
+                result2 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
                 result = result1 && result2;
             }
 
@@ -94,14 +106,14 @@ namespace PInvokeTest
             try 
             {
                 // These two pinvokes should be inline, except on x64
-                result1 = (Thread.Yield() == AsNormalInline());
+                result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
             }
             finally
             {
                 try 
                 {
                     // These two pinvokes should *not* be inline (finally)
-                    result2 = (Thread.Yield() == AsNormalInline());
+                    result2 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
                 }
                 catch (Exception)
                 {
@@ -118,7 +130,7 @@ namespace PInvokeTest
         static bool FromInline()
         {
             // These two pinvokes should be inline
-            bool result = (Thread.Yield() == AsForceInline());
+            bool result = (PInvokeExampleNative.GetConstant() == AsForceInline());
             return result;
         }
 
@@ -126,8 +138,8 @@ namespace PInvokeTest
         static bool FromInline2()
         {
             // These four pinvokes should be inline
-            bool result1 = (Thread.Yield() == AsNormalInline());
-            bool result2 = (Thread.Yield() == AsForceInline());
+            bool result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
+            bool result2 = (PInvokeExampleNative.GetConstant() == AsForceInline());
             return result1 && result2;
         }
 
@@ -135,7 +147,7 @@ namespace PInvokeTest
         static bool FromNoInline()
         {
             // The only pinvoke should be inline
-            bool result = (Thread.Yield() == AsNoInline());
+            bool result = (PInvokeExampleNative.GetConstant() == AsNoInline());
             return result;
         }
 
@@ -143,8 +155,8 @@ namespace PInvokeTest
         static bool FromNoInline2()
         {
             // Three pinvokes should be inline
-            bool result1 = (Thread.Yield() == AsNormalInline());
-            bool result2 = (Thread.Yield() == AsNoInline());
+            bool result1 = (PInvokeExampleNative.GetConstant() == AsNormalInline());
+            bool result2 = (PInvokeExampleNative.GetConstant() == AsNoInline());
             return result1 && result2;
         }
 
@@ -159,13 +171,13 @@ namespace PInvokeTest
             // These two pinvokes should *not* be inline (filter)
             //
             // For the first call the jit won't inline the wrapper, so
-            // it just calls get_ProcessorCount.
+            // it just calls GetConstant().
             //
             // For the second call, the force inline works, and the
-            // subsequent inline of Thread.Yield exposes a call
-            // to the pinvoke YieldInternal.  This pinvoke will
+            // subsequent inline of GetConstant() exposes a call
+            // to the pinvoke GetConstantInternal().  This pinvoke will
             // not be inline.
-            catch (Exception) when (Thread.Yield() == AsForceInline())
+            catch (Exception) when (PInvokeExampleNative.GetConstant() == AsForceInline())
             {
                 result = true;
             }
@@ -175,14 +187,14 @@ namespace PInvokeTest
 
         static bool FromColdCode()
         {
-            bool yield = false;
+            int yield = -1;
             bool result1 = false;
             bool result2 = false;
 
             try
             {
                 // This pinvoke should not be inline (cold)
-                yield = Thread.Yield();
+                yield = PInvokeExampleNative.GetConstant();
                 throw new Exception("expected");
             }
             catch (Exception)
@@ -190,13 +202,13 @@ namespace PInvokeTest
                 // These two pinvokes should not be inline (catch)
                 //
                 // For the first call the jit won't inline the
-                // wrapper, so it just calls Thread.Yield.
+                // wrapper, so it just calls GetConstant().
                 //
                 // For the second call, the force inline works, and
-                // the subsequent inline of Thread.Yield exposes
-                // a call to the pinvoke YieldInternal.  This
+                // the subsequent inline of GetConstant() exposes
+                // a call to the pinvoke GetConstantInternal().  This
                 // pinvoke will not be inline.
-                result1 = (yield == Thread.Yield());
+                result1 = (yield == PInvokeExampleNative.GetConstant());
                 result2 = (yield == AsForceInline());
             }
 
index fa0aa1d..382d1ca 100644 (file)
@@ -12,4 +12,7 @@
   <ItemGroup>
     <Compile Include="pinvoke-examples.cs" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="CMakeLists.txt" />
+  </ItemGroup>
 </Project>
index 542bc34..6237a6a 100644 (file)
   .class private auto ansi beforefieldinit Test
          extends [mscorlib]System.Object
   {
-    .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
+    .method private hidebysig static pinvokeimpl("PInvokeExampleNative" ansi winapi)
             native uint CreatePopupMenu() cil managed preservesig
     {
     }
-    .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
+    .method private hidebysig static pinvokeimpl("PInvokeExampleNative" ansi winapi)
             bool  DestroyMenu(native uint hMenu) cil managed preservesig
     {
     }
-    .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
+    .method private hidebysig static pinvokeimpl("PInvokeExampleNative" ansi winapi)
             bool  AppendMenu(native uint hMenu,
                              unsigned int32 uFlags,
                              unsigned int32 uID,
                              string item) cil managed preservesig
     {
     }
-    .method private hidebysig static pinvokeimpl("user32menu" ansi winapi)
+    .method private hidebysig static pinvokeimpl("PInvokeExampleNative" ansi winapi)
             int32  GetMenuString(native uint  hMenu,
                                  unsigned int32 uIDItem,
                                  class [mscorlib]System.Text.StringBuilder data,