From 0a0bcebae483b434c70875707c0eb1a493eb2e66 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Wed, 28 Nov 2018 23:09:30 -0800 Subject: [PATCH] Fix #21209 (#21237) This commit has two changes to Native Load Library Tests fix the failures in: https://github.com/dotnet/coreclr/issues/21209 1) Windows: The test tried to load a DLL from Win32 directory which doesn't exist in Windows server 2016. So changed to use a file that exists. 2) Linux: Disable the test when run against packages -- because in this configuration the tests are built on Windows, and the native DLL is built separately and copied over to the CORE_ROOT directory instead of the test directory. [Several other tests are disabled with the comment "Issue building native DLL" on Linux] --- tests/issues.targets | 3 +++ .../MarshalAPI/NativeLibrary/NativeLibraryTests.cs | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/issues.targets b/tests/issues.targets index 5fe1694..9271921 100644 --- a/tests/issues.targets +++ b/tests/issues.targets @@ -807,6 +807,9 @@ + + Issue building native components for the test. Since tests are currently built on Windows, the native components end up at Core_Root instead of Test directory, which is not suitable for the test. + needs triage diff --git a/tests/src/Interop/MarshalAPI/NativeLibrary/NativeLibraryTests.cs b/tests/src/Interop/MarshalAPI/NativeLibrary/NativeLibraryTests.cs index 7ef2afb..dfc7335 100644 --- a/tests/src/Interop/MarshalAPI/NativeLibrary/NativeLibraryTests.cs +++ b/tests/src/Interop/MarshalAPI/NativeLibrary/NativeLibraryTests.cs @@ -106,14 +106,15 @@ public class NativeLibraryTest if (TestLibrary.Utilities.IsWindows) { + libName = GetWin32LibName(); + // Calls on a valid library from System32 directory - libName = GetNativeLibraryPlainName(); - success &= EXPECT(LoadLibraryAdvanced("mapi32", assembly, DllImportSearchPath.System32)); - success &= EXPECT(TryLoadLibraryAdvanced("mapi32", assembly, DllImportSearchPath.System32)); + success &= EXPECT(LoadLibraryAdvanced(libName, assembly, DllImportSearchPath.System32)); + success &= EXPECT(TryLoadLibraryAdvanced(libName, assembly, DllImportSearchPath.System32)); // Calls on a valid library from application directory - success &= EXPECT(LoadLibraryAdvanced("mapi32", assembly, DllImportSearchPath.ApplicationDirectory), TestResult.DllNotFound); - success &= EXPECT(TryLoadLibraryAdvanced("mapi32", assembly, DllImportSearchPath.ApplicationDirectory), TestResult.ReturnFailure); + success &= EXPECT(LoadLibraryAdvanced(libName, assembly, DllImportSearchPath.ApplicationDirectory), TestResult.DllNotFound); + success &= EXPECT(TryLoadLibraryAdvanced(libName, assembly, DllImportSearchPath.ApplicationDirectory), TestResult.ReturnFailure); } // Calls with null libName input @@ -179,6 +180,11 @@ public class NativeLibraryTest return "NativeLibrary"; } + static string GetWin32LibName() + { + return "msi.dll"; + } + static string GetNativeLibraryName() { string baseName = GetNativeLibraryPlainName(); -- 2.7.4