-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a common setup method to probe for symbols
- Loading branch information
1 parent
a631c42
commit 4d063ea
Showing
6 changed files
with
68 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace MonoAPI.Tests { | ||
public class MonoAPISupport { | ||
public const string TestLibName = "mono-embedding-api-test"; | ||
namespace MonoAPI.Tests; | ||
|
||
public class MonoAPISupport | ||
{ | ||
public const string TestLibName = "mono-embedding-api-test"; | ||
|
||
[DllImport(TestLibName)] | ||
private static extern byte libtest_initialize_runtime_symbols(IntPtr libcoreclr_name); | ||
|
||
public static void Setup() | ||
{ | ||
string libName = TestLibrary.XPlatformUtils.GetStandardNativeLibraryFileName("coreclr"); | ||
if (!SetupSymbols(libName)) | ||
throw new Exception ($"Native library could not probe for runtime embedding API symbols in {libName}"); | ||
} | ||
|
||
private static bool SetupSymbols(string libName) | ||
{ | ||
IntPtr ptr = IntPtr.Zero; | ||
byte res = 0; | ||
try { | ||
ptr = Marshal.StringToHGlobalAnsi(libName); | ||
res = libtest_initialize_runtime_symbols(ptr); | ||
} finally { | ||
Marshal.FreeHGlobal(ptr); | ||
} | ||
return res != 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\..\Directory.Build.props" /> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters