Commit 95920630 authored by Samuel Debionne's avatar Samuel Debionne

Add tests

parent ae30a4bb
......@@ -285,8 +285,13 @@ endif()
## Tests
if(PROCESSLIB_ENABLE_TESTS)
find_package(Boost COMPONENTS
unit_test_framework
REQUIRED
)
enable_testing()
#add_subdirectory(test)
add_subdirectory(test)
endif()
# Packages
......
add_subdirectory(cpp)
macro(add_utf_test name)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name}
core-headers
Boost::unit_test_framework
)
add_test(NAME ${name} COMMAND ${name})
endmacro(add_utf_test)
add_utf_test(test_data)
add_utf_test(test_pool_thread_mgr)
#define BOOST_TEST_MODULE core
#include <boost/test/unit_test.hpp>
#define BOOST_TEST_MODULE data
#include <boost/test/unit_test.hpp>
#include <processlib/Data.h>
BOOST_AUTO_TEST_CASE(test_data)
{
Data beam_data;
beam_data.frameNumber = 1;
beam_data.dimensions = { 2048, 2048 };
beam_data.type = Data::INT8;
Buffer *buffer = new Buffer(2048 * 2048);
//Transfer ownership to Data
beam_data.setBuffer(buffer);
buffer->unref();
BOOST_CHECK_EQUAL(0, 0);
}
#define BOOST_TEST_MODULE pool_thread_mgr
#include <boost/test/unit_test.hpp>
#include <processlib/PoolThreadMgr.h>
BOOST_AUTO_TEST_CASE(test_pool_thread_mgr)
{
// Order of Data, Buffer and TaskMgr construction matters!
Buffer *backgroundBuffer = new Buffer(2048 * 2048);
TaskMgr *task_mgr = new TaskMgr();
// Background
Tasks::BackgroundSubstraction *bckground = new Tasks::BackgroundSubstraction();
Data backgroundData;
backgroundData.setBuffer(backgroundBuffer);
backgroundBuffer->unref();
backgroundData.type = Data::INT8;
backgroundData.dimensions = { 2048, 2048 };
bckground->setBackgroundImageData(backgroundData);
task_mgr->setLinkTask(0, bckground);
// Binning
Tasks::Binning *binning = new Tasks::Binning();
binning->mXFactor = 2;
binning->mYFactor = 2;
task_mgr->setLinkTask(1, binning);
// Roi Counter
Tasks::RoiCounterManager rc_mgr;
Tasks::RoiCounterTask *RCTask = new Tasks::RoiCounterTask(rc_mgr);
RCTask->setRoi(0, 0, 2048, 2048);
task_mgr->addSinkTask(1, RCTask);
// NOTE: TaskMgr takes ownership of the tasks pointer
// And finnaly set the chain task for all input images
PoolThreadMgr& poolThreadMgr = PoolThreadMgr::get();
poolThreadMgr.setNumberOfThread(2);
Buffer *inputBuffer = new Buffer(2048 * 2048);
Data inputData;
inputData.setBuffer(inputBuffer);
inputBuffer->unref();
inputData.type = Data::INT8;
inputData.dimensions = { 2048, 2048 };
task_mgr->setInputData(inputData);
poolThreadMgr.addProcess(task_mgr);
poolThreadMgr.wait(5);
BOOST_CHECK_EQUAL(0, 0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment