Add C++ API test for NuGet package (#1364)

This commit is contained in:
jignparm 2019-07-09 13:51:51 -07:00 committed by GitHub
parent 298f30546b
commit 57225cd4ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 2 deletions

View file

@ -32,7 +32,13 @@ int main(int argc, char* argv[]) {
// create session and load model into memory
// using squeezenet version 1.3
// URL = https://github.com/onnx/models/tree/master/squeezenet
#ifdef _WIN32
const wchar_t* model_path = L"squeezenet.onnx";
#else
const char* model_path = "squeezenet.onnx";
#endif
printf("Using Onnxruntime C++ API\n");
Ort::Session session(env, model_path, session_options);
//*************************************************************************

View file

@ -55,6 +55,7 @@ int main(int argc, char* argv[]) {
const char* model_path = "squeezenet.onnx";
#endif
printf("Using Onnxruntime C API\n");
CHECK_STATUS(OrtCreateSession(env, model_path, session_options, &session));
//*************************************************************************

View file

@ -4,6 +4,7 @@
<PropertyGroup>
<OnnxRuntimeCsharpRoot>$(MSBuildThisFileDirectory)..\..</OnnxRuntimeCsharpRoot>
<PackageName Condition="'$(PackageName)' == ''">Microsoft.ML.OnnxRuntime</PackageName>
<OnnxRuntimeSampleCode Condition="'$(OnnxRuntimeSampleCode)' == ''">C_Api_Sample.cpp</OnnxRuntimeSampleCode>
</PropertyGroup>
<Import Project="..\packages\$(PackageName).$(CurrentOnnxRuntimeVersion)\build\native\$(PackageName).props" Condition="Exists('..\packages\$(PackageName).$(CurrentOnnxRuntimeVersion)\build\native\$(PackageName).props')" />
@ -108,7 +109,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="C_Api_Sample.cpp" />
<ClCompile Include="$(OnnxRuntimeSampleCode)" />
</ItemGroup>
<ItemGroup>
<None Include="$(OnnxRuntimeCSharpRoot)\testdata\*">

View file

@ -67,7 +67,23 @@ jobs:
EXIT 1
}
workingDirectory: '$(Build.SourcesDirectory)\csharp'
displayName: 'Run End to End Test (C++) '
displayName: 'Run End to End Test (C-API) '
timeoutInMinutes: 30
continueOnError: true
# test C++ API sample
- script: |
@echo ##vso[task.setvariable variable=OnnxRuntimeSampleCode]CXX_Api_Sample.cpp
- script: |
@echo "Running runtest.bat"
test\Microsoft.ML.OnnxRuntime.EndToEndTests.Capi\runtest.bat $(Build.BinariesDirectory)\nuget-artifact
REM Need an ErrorLevel check, since the script uses Exit /B
IF NOT %ERRORLEVEL% EQU 0 {
EXIT 1
}
workingDirectory: '$(Build.SourcesDirectory)\csharp'
displayName: 'Run End to End Test (C++ API) '
timeoutInMinutes: 30
continueOnError: true