75 lines
2.9 KiB
C++
75 lines
2.9 KiB
C++
/**
|
||||
|
|
* @file plugin_load_smoke.cpp
|
|||
|
|
* @brief 微内核 P3-2 plugin 模式 smoke:发现/加载部署目录中的官方+示例插件
|
|||
|
|
*
|
|||
|
|
* 验证 VDE_MODULES_MODE=plugin 的部署产物:<build>/plugins/ 下官方格式插件
|
|||
|
|
* (STL/OBJ/PLY/STEP/IGES/DXF)、CAE solver / CAM strategy 示例插件、sample_vbox、
|
|||
|
|
* ABI 1.1 兼容插件均能被 PluginManager 发现、按 ABI 校验、加载并注册能力。
|
|||
|
|
* 使用内核真实宿主服务表(make_geometry_host_services,vde_brep 提供)——
|
|||
|
|
* 插件 init 会校验必需几何入口;不链接 io/格式层。
|
|||
|
|
* 成功输出含 PLUGIN_LOAD_SMOKE_PASS。
|
|||
|
|
*/
|
|||
|
|
#include "vde/plugin/geometry_host_services.h"
|
|||
|
|
#include "vde/plugin/plugin_manager.h"
|
|||
|
|
#include "vde/plugin/vde_plugin_api.h"
|
|||
|
|
|
|||
|
|
#include <cstdio>
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
|
|||
|
|
int main() {
|
|||
|
|
auto& pm = vde::plugin::PluginManager::instance();
|
|||
|
|
pm.clear();
|
|||
|
|
pm.set_host_services(vde::plugin::make_geometry_host_services());
|
|||
|
|
std::string error;
|
|||
|
|
pm.add_search_path(VDE_PLUGIN_BUILD_DIR);
|
|||
|
|
const std::size_t discovered = pm.scan_search_paths(&error);
|
|||
|
|
if (!error.empty()) {
|
|||
|
|
std::fprintf(stderr, "scan warnings: %s\n", error.c_str());
|
|||
|
|
}
|
|||
|
|
if (discovered == 0) {
|
|||
|
|
std::fprintf(stderr, "no plugins discovered in '%s'\n", VDE_PLUGIN_BUILD_DIR);
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::size_t loaded = 0;
|
|||
|
|
std::vector<std::string> failed;
|
|||
|
|
for (const auto& manifest : pm.plugins()) {
|
|||
|
|
std::string load_error;
|
|||
|
|
if (pm.load(manifest.id, &load_error)) {
|
|||
|
|
++loaded;
|
|||
|
|
} else {
|
|||
|
|
failed.push_back(manifest.id + ": " + load_error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
for (const auto& failure : failed) {
|
|||
|
|
std::fprintf(stderr, "load failed: %s\n", failure.c_str());
|
|||
|
|
}
|
|||
|
|
const auto formats = pm.formats();
|
|||
|
|
const auto cae_solvers = pm.cae_solvers();
|
|||
|
|
const auto cam_strategies = pm.cam_strategies();
|
|||
|
|
const std::size_t capabilities = pm.capabilities().size();
|
|||
|
|
|
|||
|
|
// 部署基线:sample_vbox / abi11_compat / official stl,obj,ply,step,iges,dxf /
|
|||
|
|
// sample_cae / sample_cam_post = 10 个(新增官方插件只会增加 discovered)。
|
|||
|
|
constexpr std::size_t kExpectedMinimum = 7;
|
|||
|
|
bool ok = failed.empty() && discovered >= kExpectedMinimum &&
|
|||
|
|
loaded >= kExpectedMinimum && !formats.empty() &&
|
|||
|
|
!cae_solvers.empty() && !cam_strategies.empty() &&
|
|||
|
|
capabilities >= kExpectedMinimum;
|
|||
|
|
std::printf(
|
|||
|
|
"PLUGIN_LOAD_SMOKE%s discovered=%zu loaded=%zu formats=%zu cae_solvers=%zu "
|
|||
|
|
"cam_strategies=%zu capabilities=%zu\n",
|
|||
|
|
ok ? "_PASS" : "_FAIL", discovered, loaded, formats.size(),
|
|||
|
|
cae_solvers.size(), cam_strategies.size(), capabilities);
|
|||
|
|
pm.clear();
|
|||
|
|
if (!ok) {
|
|||
|
|
std::fprintf(stderr,
|
|||
|
|
"plugin load smoke failed (expected >= %zu plugins with "
|
|||
|
|
"format + cae + cam registrations)\n",
|
|||
|
|
kExpectedMinimum);
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
return 0;
|
|||
|
|
}
|