Skip to content

Commit 6c23833

Browse files
author
Josh Peterson
committed
Run embedding API tests on Linux
With this change, we link pthreads properly in the embedding API tests on Linux, locate the CoreCLR runtime properly, and run the tests on CI.
1 parent c4800cf commit 6c23833

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

.yamato/scripts/test_linux.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ echo
2727

2828
echo
2929
echo "***********************************"
30-
echo "Unity: Skipping embedding API tests"
30+
echo "Unity: Running embedding API tests"
3131
echo "***********************************"
3232
echo
33-
# cd unity/embed_api_tests
34-
# cmake -DCMAKE_BUILD_TYPE=$configuration .
35-
# cmake --build .
36-
# ./mono_test_app
37-
# cd ../../
33+
cd unity/embed_api_tests
34+
cmake -DCMAKE_BUILD_TYPE=$configuration .
35+
cmake --build .
36+
./mono_test_app
37+
cd ../../
3838

3939
echo
4040
echo "**********************************"

unity/embed_api_tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ include_directories(${CLR_DIR}/src/inc)
1010

1111
add_executable(${PROJECT_NAME_STR} ${PROJECT_SRC_FILES})
1212
target_link_libraries(${PROJECT_NAME_STR} ${CMAKE_DL_LIBS})
13+
if(UNIX AND NOT APPLE)
14+
target_link_libraries(${PROJECT_NAME_STR} pthread)
15+
endif()
1316
target_compile_features(${PROJECT_NAME_STR} PRIVATE cxx_range_for)
1417
target_compile_definitions(${PROJECT_NAME_STR} PRIVATE ENABLE_MONO=1 PLATFORM_STANDALONE=1)

unity/embed_api_tests/main.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#define UNITY_EDITOR 1
1919
#define USE_CORECLR
2020

21-
// On macOS the compiler does not define _DEBUG, but CMake defines
21+
// On macOS and Linux the compiler does not define _DEBUG, but CMake defines
2222
// NDEBUG for release builds, so if NDEBUG is not defined, assume this
2323
// is a debug build and define _DEBUG.
24-
#if defined(__APPLE__)
24+
#if defined(__APPLE__) || defined(__linux__)
2525
#ifndef NDEBUG
2626
#define _DEBUG
2727
#endif
@@ -89,6 +89,7 @@ void* get_handle()
8989
if(s_MonoLibrary == nullptr)
9090
{
9191
assert(false && "Failed to load mono\n");
92+
printf("Failed to load mono from '%s'\n", g_monoDllPath.c_str());
9293
exit(1);
9394
}
9495
}
@@ -2439,8 +2440,13 @@ void SetupMono(Mode mode)
24392440
#endif // __aarch64__
24402441
#endif
24412442
#elif defined(__linux__)
2442-
monoLibFolder = "/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.0";
2443-
g_monoDllPath = "../../bin/Product/Linux.x64.Debug/libcoreclr.so";
2443+
#if defined(_DEBUG)
2444+
monoLibFolder = abs_path_from_file("../../artifacts/bin/microsoft.netcore.app.runtime.linux-x64/Debug/runtimes/linux-x64/lib/net7.0");
2445+
g_monoDllPath = abs_path_from_file("../../artifacts/bin/microsoft.netcore.app.runtime.linux-x64/Debug/runtimes/linux-x64/native/libcoreclr.so");
2446+
#else
2447+
monoLibFolder = abs_path_from_file("../../artifacts/bin/microsoft.netcore.app.runtime.linux-x64/Release/runtimes/linux-x64/lib/net7.0");
2448+
g_monoDllPath = abs_path_from_file("../../artifacts/bin/microsoft.netcore.app.runtime.linux-x64/Release/runtimes/linux-x64/native/libcoreclr.so");
2449+
#endif
24442450
#elif defined(WIN32)
24452451
#if defined(_DEBUG)
24462452
#ifdef _M_AMD64

0 commit comments

Comments
 (0)