mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-10 17:37:14 +00:00
add test for LearningModel creation from missing model path (#3661)
This commit is contained in:
parent
2d2375aa23
commit
bae1dd7f04
2 changed files with 15 additions and 1 deletions
|
|
@ -26,6 +26,17 @@ static void CreateModelFromFilePath() {
|
|||
WINML_EXPECT_NO_THROW(APITest::LoadModel(L"squeezenet_modifiedforruntimestests.onnx", learningModel));
|
||||
}
|
||||
|
||||
static void CreateModelFileNotFound() {
|
||||
LearningModel learningModel = nullptr;
|
||||
|
||||
WINML_EXPECT_THROW_SPECIFIC(
|
||||
APITest::LoadModel(L"missing_model.onnx", learningModel),
|
||||
winrt::hresult_error,
|
||||
[](const winrt::hresult_error& e) -> bool {
|
||||
return e.code() == __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
||||
});
|
||||
}
|
||||
|
||||
static void CreateModelFromIStorage() {
|
||||
std::wstring path = FileHelpers::GetModulePath() + L"squeezenet_modifiedforruntimestests.onnx";
|
||||
auto storageFile = ws::StorageFile::GetFileFromPathAsync(path).get();
|
||||
|
|
@ -242,7 +253,7 @@ static void CloseModelNoNewSessions() {
|
|||
WINML_EXPECT_NO_THROW(learningModel.Close());
|
||||
LearningModelSession session = nullptr;
|
||||
WINML_EXPECT_THROW_SPECIFIC(
|
||||
session = LearningModelSession(learningModel);,
|
||||
session = LearningModelSession(learningModel),
|
||||
winrt::hresult_error,
|
||||
[](const winrt::hresult_error& e) -> bool {
|
||||
return e.code() == E_INVALIDARG;
|
||||
|
|
@ -255,6 +266,7 @@ const LearningModelApiTestsApi& getapi() {
|
|||
LearningModelAPITestsClassSetup,
|
||||
LearningModelAPITestsGpuMethodSetup,
|
||||
CreateModelFromFilePath,
|
||||
CreateModelFileNotFound,
|
||||
CreateModelFromIStorage,
|
||||
CreateModelFromIStorageOutsideCwd,
|
||||
CreateModelFromIStream,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ struct LearningModelApiTestsApi
|
|||
SetupClass LearningModelAPITestsClassSetup;
|
||||
SetupTest LearningModelAPITestsGpuMethodSetup;
|
||||
VoidTest CreateModelFromFilePath;
|
||||
VoidTest CreateModelFileNotFound;
|
||||
VoidTest CreateModelFromIStorage;
|
||||
VoidTest CreateModelFromIStorageOutsideCwd;
|
||||
VoidTest CreateModelFromIStream;
|
||||
|
|
@ -27,6 +28,7 @@ WINML_TEST_CLASS_BEGIN(LearningModelAPITests)
|
|||
WINML_TEST_CLASS_SETUP_CLASS(LearningModelAPITestsClassSetup)
|
||||
WINML_TEST_CLASS_BEGIN_TESTS
|
||||
WINML_TEST(LearningModelAPITests, CreateModelFromFilePath)
|
||||
WINML_TEST(LearningModelAPITests, CreateModelFileNotFound)
|
||||
WINML_TEST(LearningModelAPITests, CreateModelFromIStorage)
|
||||
WINML_TEST(LearningModelAPITests, CreateModelFromIStorageOutsideCwd)
|
||||
WINML_TEST(LearningModelAPITests, CreateModelFromIStream)
|
||||
|
|
|
|||
Loading…
Reference in a new issue