Files
ViewDesignEngine/tests/plugin/external/test_fake_container_runtime.cpp
hm 0d9108cd2a
Build & Test / build-and-test (push) Canceled after 0s
VDE Build & Test / build-and-test (push) Canceled after 0s
Build & Test / python-bindings (push) Canceled after 0s
feat: bridge TU 迁移 + cam/cae/ui/pdm 模块包 + 容器沙箱 + largeMesh 修复 + scaffold/远程索引(1.0.74)
### 宿主复测闭环
- VDE-1249/VDE-1250 标记 Fixed(宿主 1.0.68 复测记录:0 error、13,030/0 ctest、n42 82s、n49/n50/n60、save-load match=1);
- VDE-1251(dense pattern,1.0.72 修复)待宿主复测;

### P3-15c ui/pdm bridge TU 迁移
- geometric_snap/snap_ext→vde_ui、structural_profiles→vde_pdm;规范头 + 旧 brep 兼容转发头(不进 kernel SDK);
- check_kernel_boundary allowlist 清零;默认 build 0 error、定向 170/170、kernel-only 971 步 0 undefined;

### P3-15d/e 模块包
- 新增 vde-cam/vde-cae/vde-ui/vde-pdm 包(共 8 个模块包);独立 consumer:
  CAM_CONSUMER_PASS segments=1006 gcode=1011、CAE_CONSUMER_PASS tet=384 patches=6、
  UI_CONSUMER_PASS layouts=4 picked=1、PDM_CONSUMER_PASS materials=21 profiles=32 bom=1;
- 默认构建/聚合不变;docs module-packaging-split §7.1/§7.2;剩余 assembly/PMI/钣金;

### P3-14c 外部服务容器运行时抽象
- sandbox.container{runtime auto|docker|podman,image,network,read_only};argv 构造 docker/podman run(仅挂载 workdir、
  --network none、--read-only/tmpfs、env 白名单、超时/失败清理);无 runtime 默认 unsupported_sandbox,allow_unsandboxed 降级;
- fake runtime 测试 5/5;docs §7.3/§12.9;真实 docker e2e 需环境;

### P3-16c largeMesh O(F²) 修复
- display_conforming_patch 每体一次统计 sphere 面数;8192 面球 >600s→~2s(261k tris、deg/open/zeroArea=0);
- degenerate_triangles 语义澄清 + 回退场景用 B-Rep wireframe 的宿主指引;test_vde1250_large_mesh 3/3;

### P3-17 插件 SDK scaffold + 远程索引
- tool scaffold 四类模板(独立 build/--check/--list PASS)+ --fetch-index(本地/http WinHTTP,签名/路径/ABI/哈希校验);

### 工程
- 版本 1.0.74;全量构建 0 error(375 targets);全量 ctest 7540 注册、7445/7445 PASS(0 failed,25 skipped,224.07s)。
2026-10-29 08:20:26 +08:00

90 lines
3.4 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// tests/plugin/external/test_fake_container_runtime.cpp
// P3-14c:测试用 fake 容器 runtime(docker/podman 替身)。
// 行为:记录 argv 到 VDE_FAKE_CONTAINER_LOG;按 VDE_FAKE_CONTAINER_MODE 产生 ok/badjson/fail;
// 从 --volume <host>:<container-root> 映射容器内 request/response 路径到宿主文件并返回 ok 响应。
// 仅测试用;不链接 VDE。
#include "service_common.h"
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <string>
#include <vector>
namespace {
std::string env_or_empty(const char* name) {
const char* value = std::getenv(name);
return value ? std::string(value) : std::string();
}
void append_log(const std::vector<std::string>& argv) {
const std::string log_path = env_or_empty("VDE_FAKE_CONTAINER_LOG");
if (log_path.empty()) return;
std::ofstream out(log_path, std::ios::binary | std::ios::app);
if (!out) return;
for (std::size_t i = 0; i < argv.size(); ++i) {
out << i << ":" << argv[i] << "\n";
}
}
std::string map_container_path(const std::string& host_root, const std::string& path) {
const std::string container_root = "/vde/work";
if (path.compare(0, container_root.size(), container_root) == 0) {
return host_root + path.substr(container_root.size());
}
return path;
}
std::string find_arg(const std::vector<std::string>& argv, const std::string& name) {
for (std::size_t i = 0; i + 1 < argv.size(); ++i) {
if (argv[i] == name) return argv[i + 1];
}
return std::string();
}
} // namespace
int main(int argc, char** argv) {
std::vector<std::string> args;
for (int i = 0; i < argc; ++i) args.push_back(argv[i]);
append_log(args);
if (args.size() < 2) return 2;
if (args[1] == "rm") return 0; // 失败清理(runtime rm -f <name>)
if (args[1] != "run") return 2;
const std::string mode = env_or_empty("VDE_FAKE_CONTAINER_MODE");
if (mode == "fail") return 42;
const std::string volume = find_arg(args, "--volume");
const std::size_t separator = volume.rfind(':');
if (separator == std::string::npos) {
std::fprintf(stderr, "[fake-runtime] missing --volume host:container\n");
return 2;
}
const std::string host_root = volume.substr(0, separator);
const std::string request_path = map_container_path(host_root, find_arg(args, "--request"));
const std::string response_path = map_container_path(host_root, find_arg(args, "--response"));
std::string request_text;
if (!vde_service::read_file(request_path, &request_text)) {
std::fprintf(stderr, "[fake-runtime] cannot read request '%s'\n", request_path.c_str());
return 2;
}
const std::string request_id = vde_service::find_string(request_text, "request_id");
if (mode == "badjson") {
vde_service::write_file(response_path, "{ this is not valid json");
return 0;
}
if (mode == "noresponse") return 0;
std::string response = "{\"protocol\":\"";
response += vde_service::protocol_name();
response += "/";
response += vde_service::protocol_version();
response += "\",\"request_id\":\"";
response += vde_service::escape(request_id);
response += "\",\"status\":\"ok\",\"outputs\":[],\"metrics\":{\"container\":\"fake\"}}";
if (!vde_service::write_file(response_path, response)) {
std::fprintf(stderr, "[fake-runtime] cannot write response '%s'\n", response_path.c_str());
return 2;
}
return 0;
}