Release: cut over Echoion 2.0 components
Modular container CI / release-build (push) Has been cancelled
Modular container CI / release-build (push) Has been cancelled
This commit is contained in:
169 files changed
+3069
-32261
No files matched your search
@@ -0,0 +1,86 @@
|
||||
#include <echoion/api/module/Module.hpp>
|
||||
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct ModuleExpectation
|
||||
{
|
||||
const char* path;
|
||||
std::string_view moduleId;
|
||||
std::string_view version;
|
||||
};
|
||||
}
|
||||
|
||||
Void::Testing::Test component_module_descriptors_are_loadable()
|
||||
{
|
||||
const std::array modules{
|
||||
ModuleExpectation{
|
||||
.path = ECHOION_TEST_HOST,
|
||||
.moduleId = "EchoionHost",
|
||||
.version = "2.0.0",
|
||||
},
|
||||
ModuleExpectation{
|
||||
.path = ECHOION_TEST_CORE,
|
||||
.moduleId = "EchoionCore",
|
||||
.version = "2.0.0",
|
||||
},
|
||||
ModuleExpectation{
|
||||
.path = ECHOION_TEST_WEB,
|
||||
.moduleId = "EchoionWeb",
|
||||
.version = "2.0.0",
|
||||
},
|
||||
ModuleExpectation{
|
||||
.path = ECHOION_TEST_PLUGIN_INTERNAL,
|
||||
.moduleId = "url-shortener-internal",
|
||||
.version = "2.0.0",
|
||||
},
|
||||
ModuleExpectation{
|
||||
.path = ECHOION_TEST_PLUGIN_EXTERNAL,
|
||||
.moduleId = "url-shortener-external",
|
||||
.version = "2.0.0",
|
||||
},
|
||||
};
|
||||
|
||||
for (const auto& expected : modules) {
|
||||
void* library = dlopen(expected.path, RTLD_NOW | RTLD_LOCAL);
|
||||
Void::Testing::expect(library != nullptr);
|
||||
if (library == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto query = reinterpret_cast<Void::Plugin::module_query_fn>(
|
||||
dlsym(library, Echoion::Api::Module::querySymbol));
|
||||
Void::Testing::expect(query != nullptr);
|
||||
if (query == nullptr) {
|
||||
dlclose(library);
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto* descriptor = query();
|
||||
Void::Testing::expect(descriptor != nullptr);
|
||||
if (descriptor == nullptr) {
|
||||
dlclose(library);
|
||||
continue;
|
||||
}
|
||||
Void::Testing::expect(descriptor->validate().has_value());
|
||||
Void::Testing::expect_eq(
|
||||
std::string_view{descriptor->module_id}, expected.moduleId);
|
||||
Void::Testing::expect_eq(
|
||||
descriptor->component_version.to_string(), expected.version);
|
||||
|
||||
auto module = descriptor->create();
|
||||
Void::Testing::expect(module != nullptr);
|
||||
if (module != nullptr) {
|
||||
Void::Testing::expect_eq(module->name(), expected.moduleId);
|
||||
}
|
||||
module.reset();
|
||||
dlclose(library);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user