Skip to content

Commit

Permalink
add a pinvoke test with many small stack arguments.
Browse files Browse the repository at this point in the history
It will fail on arm64 apple.
  • Loading branch information
Sergey Andreenko committed Sep 24, 2020
1 parent d888195 commit 5f5e631
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/tests/Interop/PInvoke/Primitives/Int/PInvokeIntTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 5f5e631

Please sign in to comment.