* build: standardize the Debug build dir on build/debug `docs/BUILD.md` and `AGENTS.md` document `./setup.sh Debug` producing `build/debug`, but `setup.sh`/`setup.ps1` created `builddir` and `.clangd` pointed there too, so the documented layout and the actual tree disagreed. Align the Debug mapping with the documented layout: - setup.sh / setup.ps1: Debug -> `build/debug` - CMakeLists.txt: Debug `_meson_build_dir` -> `build/debug` - .clangd: CompilationDatabase -> `build/debug` - plugin test fallbacks, S3 smoke default, quality-gate candidate list, and doc examples -> `build/debug` Legacy `builddir` trees stay readable: the quality gate and local-ci scripts still probe `builddir` as a fallback, and `plugin_trust` already treats `/build/` paths as build artifacts. * build: migrate remaining Debug consumers off builddir Follow-up to the Debug build-dir standardization: tracked consumers still hardcoded `builddir` and would break or silently skip against a fresh `build/debug` tree. Migrate them, keeping tolerant fallbacks where a legacy tree may still exist. - CI: `.github/workflows/tests.yml` runs `./setup.sh Debug` and then compiled `-C builddir`; switch BUILD_DIR/COMPILE_DB_DIR/compile paths to `build/debug`. Same for windows-test-diagnose.yml. - IDE: `.vscode/tasks.json` build/test/bench tasks target `build/debug`. - Runtime: `object_storage_plugin_loader` also probes `build/debug/plugins` (and the flat `build/debug`), retaining the `builddir` fallbacks. - Tests/docs: ONNX tuning integration plugin dir, benchmarks, and plugin READMEs/examples use `build/debug`. `./build/*` is already excluded from the quality-gate find and `.dockerignore`, so no exclusion lists change.
75 lines
2.6 KiB
C++
75 lines
2.6 KiB
C++
#include <nlohmann/json.hpp>
|
|
#include <string>
|
|
#include "../common/env_compat.h"
|
|
#include "../common/test_helpers_catch2.h"
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <yams/compat/dlfcn.h>
|
|
#include <yams/compat/unistd.h>
|
|
|
|
extern "C" {
|
|
#include <yams/plugins/abi.h>
|
|
#include <yams/plugins/onnx_request_v1.h>
|
|
}
|
|
|
|
static yams_onnx_request_v1* load_req_iface(void** handle) {
|
|
#ifndef ONNX_PLUGIN_PATH
|
|
#ifdef _WIN32
|
|
#define ONNX_PLUGIN_PATH "build/debug/plugins/onnx/yams_onnx_plugin.dll"
|
|
#elif defined(__APPLE__)
|
|
#define ONNX_PLUGIN_PATH "build/debug/plugins/onnx/libyams_onnx_plugin.dylib"
|
|
#else
|
|
#define ONNX_PLUGIN_PATH "build/debug/plugins/onnx/libyams_onnx_plugin.so"
|
|
#endif
|
|
#endif
|
|
const char* so = ONNX_PLUGIN_PATH;
|
|
*handle = dlopen(so, RTLD_LAZY | RTLD_LOCAL);
|
|
if (!*handle)
|
|
return nullptr;
|
|
auto getiface =
|
|
(int (*)(const char*, uint32_t, void**))dlsym(*handle, "yams_plugin_get_interface");
|
|
if (!getiface)
|
|
return nullptr;
|
|
void* p = nullptr;
|
|
int rc = getiface(YAMS_IFACE_ONNX_REQUEST_V1, YAMS_IFACE_ONNX_REQUEST_V1_VERSION, &p);
|
|
if (rc != 0 || !p)
|
|
return nullptr;
|
|
return reinterpret_cast<yams_onnx_request_v1*>(p);
|
|
}
|
|
|
|
TEST_CASE("OnnxRequestPluginTest.NoInputsError", "[plugin][onnxrequestplugintest]") {
|
|
// Avoid background preload threads during tests.
|
|
yams::test::ScopedEnvVar skipLoading{"YAMS_SKIP_MODEL_LOADING", std::string{"1"}};
|
|
void* h = nullptr;
|
|
auto* req = load_req_iface(&h);
|
|
if (!req)
|
|
SKIP("onnx plugin not available");
|
|
char* out = nullptr;
|
|
int rc = req->process_json(req->self, "{}", &out);
|
|
REQUIRE((rc == 0));
|
|
REQUIRE((out != nullptr));
|
|
auto j = nlohmann::json::parse(out);
|
|
req->free_string(req->self, out);
|
|
REQUIRE(j.contains("error"));
|
|
}
|
|
|
|
TEST_CASE("OnnxRequestPluginTest.EmbeddingMockBatchShape", "[plugin][onnxrequestplugintest]") {
|
|
// Avoid heavy model load on CI.
|
|
yams::test::ScopedEnvVar skipLoading{"YAMS_SKIP_MODEL_LOADING", std::string{"1"}};
|
|
void* h = nullptr;
|
|
auto* req = load_req_iface(&h);
|
|
if (!req)
|
|
SKIP("onnx plugin not available");
|
|
std::string body =
|
|
R"({"task":"embedding","model_id":"e5-small","inputs":["a","b"],"options":{"device":"cpu","batch":2}})";
|
|
char* out = nullptr;
|
|
int rc = req->process_json(req->self, body.c_str(), &out);
|
|
REQUIRE((rc == 0));
|
|
REQUIRE((out != nullptr));
|
|
auto j = nlohmann::json::parse(out, nullptr, false);
|
|
req->free_string(req->self, out);
|
|
REQUIRE_FALSE(j.is_discarded());
|
|
if (j.contains("error"))
|
|
SKIP(j.dump());
|
|
REQUIRE((j.value("task", "") == "embedding"));
|
|
REQUIRE((j.value("batch", 0) == 2));
|
|
}
|