From 5f5e631fdae0eae4b55db4e9e6e349bfedfc1d72 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Wed, 26 Aug 2020 16:32:52 -0700 Subject: [PATCH] add a pinvoke test with many small stack arguments. It will fail on arm64 apple. --- .../Primitives/Int/PInvokeIntNative.cpp | 20 +++++++++++++++++++ .../PInvoke/Primitives/Int/PInvokeIntTest.cs | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp b/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp index 0ea023f5cc8ad..34bef70d1914f 100644 --- a/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp +++ b/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp @@ -30,6 +30,26 @@ extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_In(/*[in]*/int intValue) return intReturn; } +extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_InMany(/*[in]*/short i1, short i2, short i3, short i4, short i5, short i6, short i7, short i8, short i9, short i10, short i11, unsigned char i12, unsigned char i13, int i14, short i15) +{ + //Check the input + if(i1 != 1 || i2 != 2 || i3 != 3 || i4 != 4 || i5 != 5 || i6 != 6 || i7 != 7 || i8 != 8 || i9 != 9 || i10 != 10 || i11 != 11 || i12 != 12 || i13 != 13 || i14 != 14 || i15 != 15) + { + printf("Error in Function Marshal_InMany(Native Client)\n"); + + //Expected + printf("Expected: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\n"); + + //Actual + printf("Actual: %hi, %hi, %hi, %hi, %hi, %hi, %hi, %hi, %hi, %hi, %hi, %i, %i, %i, %hi\n", i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, (int)i12, (int)i13, i14, i15); + + //Return the error value instead if verification failed + return intErrReturn; + } + + return i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + i13 + i14 + i15; +} + extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_InOut(/*[In,Out]*/int intValue) { //Check the input diff --git a/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntTest.cs b/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntTest.cs index 249a142e38a86..62a1d42277964 100644 --- a/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntTest.cs +++ b/src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntTest.cs @@ -24,6 +24,9 @@ class ClientPInvokeIntNativeTest [DllImport("PInvokeIntNative")] private static extern int MarshalPointer_Out(out int pintValue); + [DllImport("PInvokeIntNative")] + private static extern int Marshal_InMany([In]short i1, [In]short i2, [In]short i3, [In]short i4, [In]short i5, [In]short i6, [In]short i7, [In]short i8, [In]short i9, [In]short i10, [In]short i11, [In]byte i12, [In]byte i13, [In]int i14, [In]short i15); + public static int Main(string[] args) { @@ -99,6 +102,12 @@ public static int Main(string[] args) Console.WriteLine("Out byref value is wrong."); } + if(120 != Marshal_InMany(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) + { + failures++; + Console.WriteLine("InMany return value is wrong"); + } + return 100 + failures; } }