Commit ae738690 authored by Tomasz Dołbniak's avatar Tomasz Dołbniak Committed by Michał Karzyński

[ONNX] Import functions input validation (#2475)

parent 8458b7f4
......@@ -35,7 +35,7 @@ namespace ngraph
struct file_open : ngraph_error
{
explicit file_open(const std::string& path)
: ngraph_error{"failure opening file:" + path}
: ngraph_error{"Failure opening file: " + path}
{
}
};
......@@ -43,7 +43,7 @@ namespace ngraph
struct stream_parse : ngraph_error
{
explicit stream_parse(std::istream&)
: ngraph_error{"failure parsing data from the stream"}
: ngraph_error{"Failure parsing data from the provided input stream"}
{
}
};
......
ngraph ONNXImporter:D
xy"Sign
ign_graphZ
x


b
y


B
......@@ -2030,3 +2030,29 @@ TEST(onnx_${BACKEND_NAME}, model_where)
EXPECT_EQ(expected_outputs.front(), outputs.front());
}
TEST(onnx_${BACKEND_NAME}, import_non_existing_file)
{
try
{
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/i.dont.exist"));
}
catch (const std::runtime_error& exc)
{
// asserts that an exception was thrown and that the error message contains the file name
std::string msg{exc.what()};
EXPECT_TRUE(msg.find("i.dont.exist") != std::string::npos);
}
}
TEST(onnx_${BACKEND_NAME}, import_malformed_model)
{
try
{
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/malformed.onnx"));
}
catch (const std::runtime_error& exc)
{
EXPECT_EQ(exc.what(), std::string{"Failure parsing data from the provided input stream"});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment