From 7ba27cd6134a0d2f63a179ce9abb0f1b1055e159 Mon Sep 17 00:00:00 2001 From: Eugene Rozenfeld Date: Tue, 22 Jan 2019 16:47:33 -0800 Subject: Fix for JIT\Directed\arglist\vararg test case. TestEchoShortNoVararg was failing and disabled. The reason it was failing was a mismatch between DllImport declaration for echo_short and the native function: the former specified 2-byte arg and return while the latter specified 1-byte arg and return. I fixed that and also added a couple of test cases with 1-byte arg and 2-byte return and vice versa. Fixes #19704. --- tests/src/JIT/Directed/arglist/vararg.cs | 28 +++++++++++++++++++++++++-- tests/src/JIT/Directed/arglist/varargnative.c | 12 +++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tests/src/JIT/Directed/arglist/vararg.cs b/tests/src/JIT/Directed/arglist/vararg.cs index 56146163da..cf05aeb123 100644 --- a/tests/src/JIT/Directed/arglist/vararg.cs +++ b/tests/src/JIT/Directed/arglist/vararg.cs @@ -134,6 +134,12 @@ namespace NativeVarargTest [DllImport("varargnative", CallingConvention = CallingConvention.Cdecl)] extern static FourDoubleStruct echo_four_double_struct(FourDoubleStruct arg, __arglist); + [DllImport("varargnative", CallingConvention = CallingConvention.Cdecl)] + extern static byte short_in_byte_out(short arg, __arglist); + + [DllImport("varargnative", CallingConvention = CallingConvention.Cdecl)] + extern static short byte_in_short_out(byte arg, __arglist); + //////////////////////////////////////////////////////////////////////////// // Test PInvoke, native vararg calls. //////////////////////////////////////////////////////////////////////////// @@ -4410,6 +4416,22 @@ namespace NativeVarargTest return equal; } + [MethodImpl(MethodImplOptions.NoInlining)] + static bool TestShortInByteOutNoVararg(short arg) + { + byte returnValue = short_in_byte_out(arg, __arglist()); + + return returnValue == (byte)arg; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static bool TestByteInShortOutNoVararg(byte arg) + { + short returnValue = byte_in_short_out(arg, __arglist()); + + return returnValue == (short)arg; + } + //////////////////////////////////////////////////////////////////////// // Report Failure //////////////////////////////////////////////////////////////////////// @@ -5006,8 +5028,7 @@ namespace NativeVarargTest // Echo types. success = ReportFailure(TestEchoByteNoVararg(1), "TestEchoByteNoVararg(1)", success, 85); success = ReportFailure(TestEchoCharNoVararg('c'), "TestEchoCharNoVararg(1)", success, 86); - // Issue: https://github.com/dotnet/coreclr/issues/19705 - // success = ReportFailure(TestEchoShortNoVararg(2), "TestEchoShortNoVararg(2)", success, 87); + success = ReportFailure(TestEchoShortNoVararg(2), "TestEchoShortNoVararg(2)", success, 87); success = ReportFailure(TestEchoIntNoVararg(3), "TestEchoIntNoVararg(3)", success, 88); success = ReportFailure(TestEchoLongNoVararg(4), "TestEchoLongNoVararg(4)", success, 89); success = ReportFailure(TestEchoFloatNoVararg(5.0f), "TestEchoFloatNoVararg(5.0f)", success, 90); @@ -5029,6 +5050,9 @@ namespace NativeVarargTest success = ReportFailure(TestEchoFourFloatStructNoVararg(), "TestEchoFourFloatStructNoVararg()", success, 106); success = ReportFailure(TestEchoFourDoubleStructNoVararg(), "TestEchoFourDoubleStructNoVararg()", success, 107); + success = ReportFailure(TestShortInByteOutNoVararg(7), "TestShortInByteOutNoVararg(7)", success, 108); + success = ReportFailure(TestByteInShortOutNoVararg(8), "TestByteInShortOutNoVararg(8)", success, 109); + printf("\n", __arglist()); printf("%d Tests run. %d Passed, %d Failed.\n", __arglist(m_testCount, m_passCount, m_failCount)); diff --git a/tests/src/JIT/Directed/arglist/varargnative.c b/tests/src/JIT/Directed/arglist/varargnative.c index b14b5569b1..b0e1941916 100644 --- a/tests/src/JIT/Directed/arglist/varargnative.c +++ b/tests/src/JIT/Directed/arglist/varargnative.c @@ -653,7 +653,7 @@ DLLEXPORT char _cdecl echo_char(char arg, ...) return arg; } -DLLEXPORT __int8 _cdecl echo_short(__int8 arg, ...) +DLLEXPORT __int16 _cdecl echo_short(__int16 arg, ...) { return arg; } @@ -757,3 +757,13 @@ DLLEXPORT four_double_struct _cdecl echo_four_double_struct(four_double_struct a { return arg; } + +DLLEXPORT __int8 _cdecl short_in_byte_out(__int16 arg, ...) +{ + return (__int8)arg; +} + +DLLEXPORT __int16 _cdecl byte_in_short_out(__int8 arg, ...) +{ + return (__int16)arg; +} -- cgit v1.2.3