EXPECT_STREQ("/test1/test2", file_util::path_join(s1, s2).c_str());
}
}
+
+TEST(file_util, santize_path)
+{
+ {
+ string path = "../../tensor.data";
+ EXPECT_STREQ("tensor.data", file_util::sanitize_path(path).c_str());
+ }
+ {
+ string path = "/../tensor.data";
+ EXPECT_STREQ("tensor.data", file_util::sanitize_path(path).c_str());
+ }
+ {
+ string path = "..";
+ EXPECT_STREQ("", file_util::sanitize_path(path).c_str());
+ }
+ {
+ string path = "workspace/data/tensor.data";
+ EXPECT_STREQ("workspace/data/tensor.data", file_util::sanitize_path(path).c_str());
+ }
+ {
+ string path = "..\\..\\tensor.data";
+ EXPECT_STREQ("tensor.data", file_util::sanitize_path(path).c_str());
+ }
+ {
+ string path = "C:\\workspace\\tensor.data";
+ EXPECT_STREQ("workspace\\tensor.data", file_util::sanitize_path(path).c_str());
+ }
+}
NGRAPH_TEST(${BACKEND_NAME}, onnx_external_data)
{
const auto function = onnx_import::import_onnx_model(
- file_util::path_join(SERIALIZED_ZOO, "onnx/external_data.prototxt"));
+ file_util::path_join(SERIALIZED_ZOO, "onnx/external_data/external_data.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
NGRAPH_TEST(${BACKEND_NAME}, onnx_external_data_from_stream)
{
- std::string path = file_util::path_join(SERIALIZED_ZOO, "onnx/external_data.prototxt");
+ std::string path =
+ file_util::path_join(SERIALIZED_ZOO, "onnx/external_data/external_data.prototxt");
std::ifstream stream{path, std::ios::in | std::ios::binary};
ASSERT_TRUE(stream.is_open());
const auto function = onnx_import::import_onnx_model(stream, path);
NGRAPH_TEST(${BACKEND_NAME}, onnx_external_data_optinal_fields)
{
- const auto function = onnx_import::import_onnx_model(
- file_util::path_join(SERIALIZED_ZOO, "onnx/external_data_optional_fields.prototxt"));
+ const auto function = onnx_import::import_onnx_model(file_util::path_join(
+ SERIALIZED_ZOO, "onnx/external_data/external_data_optional_fields.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
NGRAPH_TEST(${BACKEND_NAME}, onnx_external_data_in_different_paths)
{
- auto function = onnx_import::import_onnx_model(
- file_util::path_join(SERIALIZED_ZOO, "onnx/external_data_different_paths.prototxt"));
+ auto function = onnx_import::import_onnx_model(file_util::path_join(
+ SERIALIZED_ZOO, "onnx/external_data/external_data_different_paths.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
// first input: {3.f}, second: {1.f, 2.f, 5.f} read from external files
NGRAPH_TEST(${BACKEND_NAME}, onnx_external_two_tensors_data_in_the_same_file)
{
auto function = onnx_import::import_onnx_model(file_util::path_join(
- SERIALIZED_ZOO, "onnx/external_data_two_tensors_data_in_the_same_file.prototxt"));
+ SERIALIZED_ZOO,
+ "onnx/external_data/external_data_two_tensors_data_in_the_same_file.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
// first input: {3, 2, 1}, second: {1, 2, 3} read from external file
{
try
{
- auto function = onnx_import::import_onnx_model(
- file_util::path_join(SERIALIZED_ZOO, "onnx/external_data_file_not_found.prototxt"));
+ auto function = onnx_import::import_onnx_model(file_util::path_join(
+ SERIALIZED_ZOO, "onnx/external_data/external_data_file_not_found.prototxt"));
FAIL() << "Incorrect path to external data not detected";
}
catch (const ngraph_error& error)
FAIL() << "Importing onnx model failed for unexpected reason";
}
}
+
+NGRAPH_TEST(${BACKEND_NAME}, onnx_external_invalid_up_dir_path)
+{
+ try
+ {
+ auto function = onnx_import::import_onnx_model(file_util::path_join(
+ SERIALIZED_ZOO,
+ "onnx/external_data/inner_scope/external_data_file_in_up_dir.prototxt"));
+ FAIL() << "Incorrect path to external data not detected";
+ }
+ catch (const ngraph_error& error)
+ {
+ EXPECT_PRED_FORMAT2(testing::IsSubstring,
+ std::string("tensor.data, offset: 4096, "
+ "data_lenght: 16, sha1_digest: 0)"),
+ error.what());
+ }
+ catch (...)
+ {
+ FAIL() << "Importing onnx model failed for unexpected reason";
+ }
+}
+
+NGRAPH_TEST(${BACKEND_NAME}, onnx_external_data_sanitize_path)
+{
+ const auto function = onnx_import::import_onnx_model(file_util::path_join(
+ SERIALIZED_ZOO, "onnx/external_data/external_data_sanitize_test.prototxt"));
+
+ auto test_case = test::TestCase<TestEngine>(function);
+ test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
+ test_case.add_expected_output<float>(Shape{2, 2}, {3.f, 6.f, 9.f, 12.f});
+
+ test_case.run();
+}