[tests] Add MonoApi runtime tests (#65221)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Fri, 4 Mar 2022 13:46:02 +0000 (08:46 -0500)
committerGitHub <noreply@github.com>
Fri, 4 Mar 2022 13:46:02 +0000 (08:46 -0500)
commit483b8f241f608cacf25fc8f912e33034e05a448f
treeb93a212fb4b22f94cacd962fe21b63f89ea407fa
parent9053aa1e66ab7c1af7a14e649fb0bf0b0c501cde
[tests] Add MonoApi runtime tests (#65221)

Contributes to https://github.com/dotnet/runtime/issues/64456

Create a new directory src/tests/Interop/MonoAPI for tests that use the mono embedding API.

Move the mono libtest.c native library along with managed tests: InstallEHCallback.cs, PInvokeDetach.cs and Thunks.cs to src/tests/Interop/MonoAPI/...

The native library (now called mono-embedding-api-test.c) builds on all platforms where we build native support libraries for the runtime tests.

The managed tests only run on desktop mono configurations for now.

* copy libtest.c from mono to src/tests and add cmake builds

* Make it build with the monoapi project

* remove mono-compiler.h dependency

* Remove dependency on gmodule.h

   Had to copy the w32_find_symbol code that searches for a symbol in every module.

* Remove test library eglib dependency

   Delete some unrunnable tests.

   Copy some basic eglib utilities into the test.

* Move native embedding API test lib to Interop/MonoAPI/Native

* Move install_eh_callback test to src/tests/Interop/MonoAPI/MonoMono

* add issues.targets excludes for MonoAPI tests

  Not expected to run on coreclr or mono on wasm or mobile, for now.

* Add PInvokeDetach MonoAPI test

* Return exit code 100 on success

* Change test class names to be unique

* fix win32 and gcc builds

* simplify managed code

* put all the MonoMono tests in a single directory

* Use the new MONO_API_FUNCTION monoapi headers

* compile the native library as C, not C++, same as libtest.c in the past

* delete many unused test functions

* delete unused utilities

* Add Thunks.cs tests

* Use a common setup method to probe for symbols

* simplify the native test library

* Make the PInvokeDetach native code sleep less

* add MIT banner

* skip Thunks test on AOT

   In the mono/mono repo that test was not expected to work with AOT
15 files changed:
src/tests/Interop/CMakeLists.txt
src/tests/Interop/MonoAPI/Common/MonoAPISupport.cs [new file with mode: 0644]
src/tests/Interop/MonoAPI/MonoMono/Directory.Build.props [new file with mode: 0644]
src/tests/Interop/MonoAPI/MonoMono/InstallEHCallback.cs [moved from src/mono/mono/tests/install_eh_callback.cs with 88% similarity]
src/tests/Interop/MonoAPI/MonoMono/InstallEHCallback.csproj [new file with mode: 0644]
src/tests/Interop/MonoAPI/MonoMono/PInvokeDetach.cs [moved from src/mono/mono/tests/pinvoke-detach-1.cs with 67% similarity]
src/tests/Interop/MonoAPI/MonoMono/PInvokeDetach.csproj [new file with mode: 0644]
src/tests/Interop/MonoAPI/MonoMono/Thunks.cs [moved from src/mono/mono/tests/thunks.cs with 85% similarity]
src/tests/Interop/MonoAPI/MonoMono/Thunks.csproj [new file with mode: 0644]
src/tests/Interop/MonoAPI/Native/CMakeLists.txt [new file with mode: 0644]
src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/CMakeLists.txt [new file with mode: 0644]
src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/api-functions.h [new file with mode: 0644]
src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/api-types.h [new file with mode: 0644]
src/tests/Interop/MonoAPI/Native/mono-embedding-api-test/mono-embedding-api-test.c [new file with mode: 0644]
src/tests/issues.targets