add test to api tests to ensure correct hresult is returned for corrupt model file (#3796)

Co-authored-by: Ori Levari <orlevari@microsoft.com>
This commit is contained in:
Ori Levari 2020-05-11 13:22:22 -07:00 committed by GitHub
parent c7da194313
commit 6d2d927809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -42,6 +42,18 @@ static void CreateModelFileNotFound() {
});
}
static void CreateCorruptModel() {
LearningModel learningModel = nullptr;
WINML_EXPECT_THROW_SPECIFIC(
APITest::LoadModel(L"corrupt-model.onnx", learningModel),
winrt::hresult_error,
[](const winrt::hresult_error& e) -> bool {
auto f = __HRESULT_FROM_WIN32(e.code());
return e.code() == __HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT);
});
}
static void CreateModelFromIStorage() {
std::wstring path = FileHelpers::GetModulePath() + L"squeezenet_modifiedforruntimestests.onnx";
auto storageFile = ws::StorageFile::GetFileFromPathAsync(path).get();
@ -294,7 +306,8 @@ const LearningModelApiTestsApi& getapi() {
CloseModelCheckMetadata,
CloseModelCheckEval,
CloseModelNoNewSessions,
CheckMetadataCaseInsensitive
CheckMetadataCaseInsensitive,
CreateCorruptModel
};
return api;
}

View file

@ -23,6 +23,7 @@ struct LearningModelApiTestsApi
VoidTest CloseModelCheckEval;
VoidTest CloseModelNoNewSessions;
VoidTest CheckMetadataCaseInsensitive;
VoidTest CreateCorruptModel;
};
const LearningModelApiTestsApi& getapi();
@ -45,6 +46,7 @@ WINML_TEST(LearningModelAPITests, EnumerateOutputs)
WINML_TEST(LearningModelAPITests, CloseModelCheckMetadata)
WINML_TEST(LearningModelAPITests, CloseModelNoNewSessions)
WINML_TEST(LearningModelAPITests, CheckMetadataCaseInsensitive)
WINML_TEST(LearningModelAPITests, CreateCorruptModel)
WINML_TEST_CLASS_END()
WINML_TEST_CLASS_BEGIN(LearningModelAPITestsGpu)

View file

@ -0,0 +1 @@
this is not a valid onnx model