Skip to content

Commit a2d2a37

Browse files
committed
Test native dll can be copied automatically
1 parent 9d04620 commit a2d2a37

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,28 @@ IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu" set gpu_package=T
5757
IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu.Windows" set gpu_package=T
5858
IF %%gpu_package%%=="T" (
5959
set TESTONGPU=ON
60-
%dn% test -p:DefineConstants=USE_TENSORRT test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --filter TensorRT
60+
%dn% build test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore -p:DefineConstants=USE_TENSORRT
61+
dir /s /b test\Microsoft.ML.OnnxRuntime.EndToEndTests\bin\onnxruntime.dll
62+
IF %ERRORLEVEL% NEQ 0 (
63+
@echo "Error: onnxruntime.dll not found in the output directory after build"
64+
EXIT 1
65+
)
66+
%dn% test -p:DefineConstants=USE_TENSORRT test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --no-build --filter TensorRT
6167

6268
IF NOT errorlevel 0 (
6369
@echo "Failed to build or execute the end-to-end test"
6470
EXIT 1
6571
)
6672

67-
%dn% test -p:DefineConstants=USE_CUDA test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore
73+
%dn% test -p:DefineConstants=USE_CUDA test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --no-build
6874
) ELSE (
69-
%dn% test test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore
75+
%dn% build test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore
76+
dir /s /b test\Microsoft.ML.OnnxRuntime.EndToEndTests\bin\onnxruntime.dll
77+
IF %ERRORLEVEL% NEQ 0 (
78+
@echo "Error: onnxruntime.dll not found in the output directory after build"
79+
EXIT 1
80+
)
81+
%dn% test test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --no-build
7082
)
7183

7284
IF NOT errorlevel 0 (

csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,31 @@ if [ $RunTestCsharp = "true" ]; then
3333

3434
if [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu" ] || [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu.Linux" ]; then
3535
export TESTONGPU=ON
36-
dotnet test -p:DefineConstants=USE_CUDA $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed
36+
dotnet build -p:DefineConstants=USE_CUDA $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore
37+
native_lib=$(find $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/bin -name "libonnxruntime.so*" -o -name "libonnxruntime.dylib" | head -1)
38+
if [ -z "$native_lib" ]; then
39+
echo "Error: libonnxruntime not found in output directory after build"
40+
exit 1
41+
fi
42+
echo "Found native library: $native_lib"
43+
dotnet test -p:DefineConstants=USE_CUDA $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --no-build --verbosity detailed
3744
if [ $? -ne 0 ]; then
3845
echo "Failed to build or execute the end-to-end test"
3946
exit 1
4047
fi
4148
dotnet test -p:DefineConstants=USE_TENSORRT $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed
4249
else
43-
dotnet test $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed
50+
dotnet build $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore
51+
native_lib=$(find $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/bin -name "libonnxruntime.so*" -o -name "libonnxruntime.dylib" | head -1)
52+
if [ -z "$native_lib" ]; then
53+
echo "Error: libonnxruntime not found in output directory after build"
54+
exit 1
55+
fi
56+
echo "Found native library: $native_lib"
57+
dotnet test $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --no-build --verbosity detailed
4458
fi
4559
if [ $? -ne 0 ]; then
4660
echo "Failed to build or execute the end-to-end test"
4761
exit 1
4862
fi
4963
fi
50-

0 commit comments

Comments
 (0)