mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-10 00:38:54 +00:00
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:
parent
c7da194313
commit
6d2d927809
3 changed files with 17 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
1
winml/test/collateral/models/corrupt-model.onnx
Normal file
1
winml/test/collateral/models/corrupt-model.onnx
Normal file
|
|
@ -0,0 +1 @@
|
|||
this is not a valid onnx model
|
||||
Loading…
Reference in a new issue