Add dynamic backend load smoke test
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QOpenGLContext>
|
||||
|
||||
namespace olive
|
||||
@@ -39,8 +40,20 @@ QString DynamicRenderer::LibraryFilename() const
|
||||
#else
|
||||
const QString filename = QStringLiteral("lib") + base + QStringLiteral(".so");
|
||||
#endif
|
||||
return QDir(QCoreApplication::applicationDirPath()).filePath(
|
||||
filename);
|
||||
|
||||
const QDir app_dir(QCoreApplication::applicationDirPath());
|
||||
const QStringList candidates = {
|
||||
app_dir.filePath(filename),
|
||||
app_dir.filePath(QDir(QStringLiteral("render_backends")).filePath(filename)),
|
||||
app_dir.filePath(QDir(QStringLiteral("../app")).filePath(filename)),
|
||||
app_dir.filePath(QDir(QStringLiteral("../../app")).filePath(filename))
|
||||
};
|
||||
for (const QString &candidate : candidates) {
|
||||
if (QFileInfo::exists(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return candidates.first();
|
||||
}
|
||||
|
||||
bool DynamicRenderer::Load()
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
|
||||
当前实验构建已经可以通过 `OAK_ENABLE_DYNAMIC_RENDER_BACKEND=ON` 生成 `liboakgl.so`,做法是把相关 object/static 依赖切到 PIC 后链接进 OpenGL 后端库。这满足“动态库一侧 C++ 实现 + C ABI 导出”的第一步,但它仍不是最终边界:后端库暂时会带入较多 editor 代码和全局状态。
|
||||
|
||||
已新增 `DynamicRenderBackend.LoadsExperimentalOpenGLBackend` smoke test:默认构建跳过,实验构建会实际加载 `liboakgl` 并验证 create/destroy C ABI 路径。
|
||||
|
||||
因此动态后端成为默认路径前,仍需要把 OpenGL 后端库的链接边界收敛到最小集合:
|
||||
|
||||
- 后端库只拥有 OpenGL/Vulkan native 操作和必要的后端私有状态。
|
||||
|
||||
@@ -30,6 +30,7 @@ add_executable(olive-gtest
|
||||
plugin_format_conversion_test.cpp
|
||||
audio_smoke_test.cpp
|
||||
viewer_smoke_test.cpp
|
||||
dynamic_render_backend_test.cpp
|
||||
opengl_readback_guard_test.cpp
|
||||
plugin_render_pipeline_test.cpp
|
||||
plugin_renderer_readback_test.cpp
|
||||
@@ -80,6 +81,11 @@ target_compile_options(
|
||||
${OLIVE_COMPILE_OPTIONS}
|
||||
)
|
||||
|
||||
if (OAK_ENABLE_DYNAMIC_RENDER_BACKEND)
|
||||
target_compile_definitions(olive-gtest PRIVATE OAK_ENABLE_DYNAMIC_RENDER_BACKEND)
|
||||
add_dependencies(olive-gtest oakgl)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_test("Olive.gtest" olive-gtest)
|
||||
else()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "render/backend/dynamicrenderer.h"
|
||||
|
||||
TEST(DynamicRenderBackend, LoadsExperimentalOpenGLBackend)
|
||||
{
|
||||
#ifndef OAK_ENABLE_DYNAMIC_RENDER_BACKEND
|
||||
GTEST_SKIP() << "Dynamic render backend is not enabled in this build";
|
||||
#else
|
||||
olive::DynamicRenderer renderer(QStringLiteral("opengl"));
|
||||
ASSERT_TRUE(renderer.Load());
|
||||
EXPECT_EQ(renderer.OpenGLContext(), nullptr);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user