fix: tests failing

This commit is contained in:
2025-07-19 00:54:42 +01:00
parent 2d9b9e9c70
commit 67dc55dfb2
8 changed files with 72 additions and 66 deletions

View File

@@ -73,37 +73,37 @@ target_link_libraries(${AppExec} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets
target_include_directories(${AppExec} PUBLIC src) target_include_directories(${AppExec} PUBLIC src)
# tests # tests
# Include(FetchContent) Include(FetchContent)
# FetchContent_Declare( FetchContent_Declare(
# Catch2 Catch2
# GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_REPOSITORY https://github.com/catchorg/Catch2.git
# GIT_TAG v3.8.1 # or a later release GIT_TAG v3.8.1 # or a later release
# ) )
# FetchContent_MakeAvailable(Catch2) FetchContent_MakeAvailable(Catch2)
# add_executable(${TestExec} add_executable(${TestExec}
# ${ENGINE_SOURCES} ${ENGINE_SOURCES}
# tests/main-tests.cpp tests/main-tests.cpp
# tests/OperatorTests.cpp tests/OperatorTests.cpp
# tests/NetworkTests.cpp tests/NetworkTests.cpp
# ) )
# target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system) target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
# target_compile_definitions(${TestExec} PRIVATE UNIT_TEST) target_compile_definitions(${TestExec} PRIVATE UNIT_TEST)
# target_include_directories(${TestExec} PUBLIC target_include_directories(${TestExec} PUBLIC
# src src
# ${BOOST_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS}
# ) )
# # benchmarks # benchmarks
# add_executable(${BenchExec} add_executable(${BenchExec}
# ${ENGINE_SOURCES} ${ENGINE_SOURCES}
# tests/Benchmarks.cpp tests/Benchmarks.cpp
# ) )
# target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb) target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
# target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST) target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
# target_include_directories(${BenchExec} PUBLIC src) target_include_directories(${BenchExec} PUBLIC src)
add_subdirectory(src/OpDefs) add_subdirectory(src/OpDefs)

View File

@@ -24,6 +24,8 @@ Enzo is a 3D animation software application focused on procedural geometry editi
- glm - glm
- catch2 - catch2
- oneTBB - oneTBB
- TBB
- boost
> [!IMPORTANT] > [!IMPORTANT]

View File

@@ -1,4 +1,5 @@
#include "Engine/Operator/OperatorTable.h" #include "Engine/Operator/OperatorTable.h"
#include <boost/dll/import.hpp>
#include <iostream> #include <iostream>
@@ -26,5 +27,18 @@ std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::getData()
return opInfoStore_; return opInfoStore_;
} }
void enzo::op::OperatorTable::initPlugins()
{
static bool pluginsLoaded=false;
if(pluginsLoaded) return;
auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
"build/src/OpDefs/libenzoOps1.so", "newSopOperator"
);
initPlugin(enzo::op::OperatorTable::addOperator);
pluginsLoaded = true;
}
std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::opInfoStore_; std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::opInfoStore_;

View File

@@ -20,6 +20,8 @@ public:
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc); static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc);
static nt::opConstructor getOpConstructor(std::string name); static nt::opConstructor getOpConstructor(std::string name);
static std::vector<OpInfo> getData(); static std::vector<OpInfo> getData();
// TODO: move to better spot (maybe engine class)
static void initPlugins();
private: private:
static std::vector<OpInfo> opInfoStore_; static std::vector<OpInfo> opInfoStore_;
}; };

View File

@@ -2,7 +2,6 @@
#include <QPushButton> #include <QPushButton>
#include <QSurfaceFormat> #include <QSurfaceFormat>
#include "Engine/Operator/OperatorTable.h" #include "Engine/Operator/OperatorTable.h"
#include <boost/dll/import.hpp>
#include "Interface.h" #include "Interface.h"
@@ -16,12 +15,7 @@ int main(int argc, char **argv)
format.setSamples(4); format.setSamples(4);
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);
// setup table enzo::op::OperatorTable::initPlugins();
auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
"build/src/OpDefs/libenzoOps1.so", "newSopOperator"
);
initPlugin(enzo::op::OperatorTable::addOperator);
QApplication app (argc, argv); QApplication app (argc, argv);

View File

@@ -4,7 +4,7 @@
#include "Engine/Network/NetworkManager.h" #include "Engine/Network/NetworkManager.h"
#include "Engine/Operator/GeometryOperator.h" #include "Engine/Operator/GeometryOperator.h"
#include "Engine/Types.h" #include "Engine/Types.h"
#include "Engine/Operator/GOP_test.h" #include "Engine/Operator/OperatorTable.h"
#include <iostream> #include <iostream>
struct NMReset struct NMReset
@@ -20,13 +20,21 @@ struct NMReset
}; };
// TODO: fix this init monstrosity
struct OperatorTableInit
{
OperatorTableInit() { enzo::op::OperatorTable::initPlugins(); }
};
static OperatorTableInit _operatorTableInit;
auto testOpCtor = enzo::op::OperatorTable::getOpConstructor("house");
TEST_CASE_METHOD(NMReset, "Network Manager") TEST_CASE_METHOD(NMReset, "Network Manager")
{ {
using namespace enzo; using namespace enzo;
auto& nm = nt::nm(); auto& nm = nt::nm();
nt::OpId startOp = nm.addOperator(&GOP_test::ctor); nt::OpId startOp = nm.addOperator(testOpCtor);
nt::OpId prevOp = startOp; nt::OpId prevOp = startOp;
std::vector<nt::OpId> prevOps; std::vector<nt::OpId> prevOps;
@@ -34,7 +42,7 @@ TEST_CASE_METHOD(NMReset, "Network Manager")
{ {
for(int i=0; i<4; ++i) for(int i=0; i<4; ++i)
{ {
nt::OpId newOp = nm.addOperator(&GOP_test::ctor); nt::OpId newOp = nm.addOperator(testOpCtor);
prevOps.push_back(newOp); prevOps.push_back(newOp);
nt::connectOperators(newOp, i, prevOp, 0); nt::connectOperators(newOp, i, prevOp, 0);
} }
@@ -44,7 +52,7 @@ TEST_CASE_METHOD(NMReset, "Network Manager")
for(int i=0; i<size(prevOpsBuffer); ++i) for(int i=0; i<size(prevOpsBuffer); ++i)
{ {
prevOps.clear(); prevOps.clear();
nt::OpId newOp = nm.addOperator(GOP_test::ctor); nt::OpId newOp = nm.addOperator(testOpCtor);
prevOps.push_back(newOp); prevOps.push_back(newOp);
nt::connectOperators(newOp, 0, prevOpsBuffer[i], 0); nt::connectOperators(newOp, 0, prevOpsBuffer[i], 0);

View File

@@ -3,8 +3,8 @@
#include <memory> #include <memory>
#include "Engine/Network/NetworkManager.h" #include "Engine/Network/NetworkManager.h"
#include "Engine/Operator/GeometryOperator.h" #include "Engine/Operator/GeometryOperator.h"
#include "Engine/Operator/OperatorTable.h"
#include "Engine/Types.h" #include "Engine/Types.h"
#include "Engine/Operator/GOP_test.h"
#include <iostream> #include <iostream>
struct NMReset struct NMReset
@@ -20,12 +20,20 @@ struct NMReset
}; };
// TODO: fix this init monstrosity
struct OperatorTableInit
{
OperatorTableInit() { enzo::op::OperatorTable::initPlugins(); }
};
static OperatorTableInit _operatorTableInit;
auto testOpCtor = enzo::op::OperatorTable::getOpConstructor("house");
TEST_CASE_METHOD(NMReset, "network fixture separation start") TEST_CASE_METHOD(NMReset, "network fixture separation start")
{ {
using namespace enzo; using namespace enzo;
auto& nm = nt::nm(); auto& nm = nt::nm();
nt::OpId newOpId = nm.addOperator(GOP_test::ctor); nt::OpId newOpId = nm.addOperator(testOpCtor);
REQUIRE(newOpId==1); REQUIRE(newOpId==1);
REQUIRE(nm.isValidOp(1)); REQUIRE(nm.isValidOp(1));
@@ -45,8 +53,8 @@ TEST_CASE_METHOD(NMReset, "network")
using namespace enzo; using namespace enzo;
auto& nm = nt::nm(); auto& nm = nt::nm();
nt::OpId newOpId = nm.addOperator(GOP_test::ctor); nt::OpId newOpId = nm.addOperator(testOpCtor);
nt::OpId newOpId2 = nm.addOperator(GOP_test::ctor); nt::OpId newOpId2 = nm.addOperator(testOpCtor);
REQUIRE(nm.isValidOp(newOpId)); REQUIRE(nm.isValidOp(newOpId));
if(nm.isValidOp(newOpId)) if(nm.isValidOp(newOpId))
@@ -70,13 +78,13 @@ TEST_CASE_METHOD(NMReset, "reset")
using namespace enzo; using namespace enzo;
auto& nm = nt::nm(); auto& nm = nt::nm();
nt::OpId newOpId = nm.addOperator(GOP_test::ctor); nt::OpId newOpId = nm.addOperator(testOpCtor);
nm._reset(); nm._reset();
REQUIRE_FALSE(nm.isValidOp(newOpId)); REQUIRE_FALSE(nm.isValidOp(newOpId));
nt::OpId newOpId2 = nm.addOperator(GOP_test::ctor); nt::OpId newOpId2 = nm.addOperator(testOpCtor);
REQUIRE(nm.isValidOp(newOpId2)); REQUIRE(nm.isValidOp(newOpId2));

View File

@@ -20,25 +20,3 @@ TEST_CASE("tbb")
<< std::this_thread::get_id() << std::endl; << std::this_thread::get_id() << std::endl;
}); });
} }
TEST_CASE("boost dll")
{
std::cout << "Using Boost "
<< BOOST_VERSION / 100000 << "." // major version
<< BOOST_VERSION / 100 % 1000 << "." // minor version
<< BOOST_VERSION % 100 // patch level
<< std::endl;
boost::shared_ptr<std::string> cpp_var = boost::dll::import_symbol<std::string>(
"build/src/OpDefs/libenzoOps1.so", "myVar"
);
std::cout << "VAR: " << *cpp_var << "\n";
auto cpp11_func = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
"build/src/OpDefs/libenzoOps1.so", "newSopOperator"
);
cpp11_func(enzo::op::OperatorTable::addOperator);
}