mmdeploy/tests/test_csrc/model/test_directory_model.cpp
lvhan028 3be1779e66
Refactor tests (#283)
* fix sdk model's pipeline.json

* resize INT64 mask

* refactor unit tests

* fix api in model.h

* remove 'customs' from meta info

* fix zip model

* fix clang-format issue

* put tc on each backend into a SECTION

* change SECTION title

* add DYNAMIC_SECTION for capi unit test

* change 'devices' to 'device_names'

* change trt to tensorrt

* remove uncessary check

* add color_type 'color_ignore_orientation' which is used in ocr

* 'min_width', 'max_width' and 'backend' might be null in pipeline config

* fix clang-format issue

* remove useless code
2021-12-17 19:57:37 +08:00

38 lines
1.2 KiB
C++

// Copyright (c) OpenMMLab. All rights reserved.
// clang-format off
#include "catch.hpp"
// clang-format on
#include "core/model.h"
#include "core/model_impl.h"
#include "test_resource.h"
using namespace mmdeploy;
TEST_CASE("test directory model", "[model]") {
std::unique_ptr<ModelImpl> model_impl;
for (auto& entry : ModelRegistry::Get().ListEntries()) {
if (entry.name == "DirectoryModel") {
model_impl = entry.creator();
break;
}
}
REQUIRE(model_impl);
auto& gResource = MMDeployTestResources::Get();
auto directory_model_list = gResource.LocateModelResources("sdk_models");
REQUIRE(!directory_model_list.empty());
auto model_dir = "sdk_models/good_model";
REQUIRE(gResource.IsDir(model_dir));
auto model_path = gResource.resource_root_path() + "/" + model_dir;
REQUIRE(!model_impl->Init(model_path).has_error());
REQUIRE(!model_impl->ReadFile("deploy.json").has_error());
REQUIRE(model_impl->ReadFile("not-existing-file").has_error());
model_dir = "sdk_models/bad_model";
REQUIRE(gResource.IsDir(model_dir));
model_path = gResource.resource_root_path() + "/" + model_dir;
REQUIRE(!model_impl->Init(model_path).has_error());
REQUIRE(model_impl->ReadMeta().has_error());
}