Commit f797b322 authored by Philip ABBET's avatar Philip ABBET

Add a test for the C++ backend

parent c729b7db
Pipeline #5140 failed with stage
in 3 minutes and 38 seconds
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
"enum": [ "enum": [
"unknown", "unknown",
"python", "python",
"binary", "cxx",
"matlab", "matlab",
"r" "r"
] ]
......
{
"language": "cxx",
"splittable": true,
"groups": [
{
"name": "main",
"inputs": {
"in_data": {
"type": "user/single_integer/1"
}
},
"outputs": {
"out_data": {
"type": "user/single_integer/1"
}
}
}
]
}
cmake_minimum_required(VERSION 3.0)
project(BEAT_CORE_CXX_INTEGERS_ECHO)
set(BEAT_BACKEND_CXX_DIR "/usr/local/beat")
# CMake setup
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Retrieve the dependencies
find_package(Boost REQUIRED)
# Setup the search paths
include_directories(
"${BEAT_BACKEND_CXX_DIR}/include"
"${Boost_INCLUDE_DIRS}"
)
link_directories(
"${BEAT_BACKEND_CXX_DIR}/bin"
)
# List the source files
set(HEADERS "algorithm.h"
"beat_setup.h"
"user_single_integer_1.h"
)
set(SRCS "algorithm.cpp"
"beat_setup.cpp"
"user_single_integer_1.cpp"
)
# Create and link the library
add_library(cxx_integers_echo SHARED ${SRCS} ${HEADERS})
target_link_libraries(cxx_integers_echo beat_backend_cxx)
set_target_properties(cxx_integers_echo PROPERTIES
COMPILE_FLAGS "-fPIC"
OUTPUT_NAME "1"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${BEAT_CORE_CXX_INTEGERS_ECHO_SOURCE_DIR}"
)
// NOTE: This file implements the algorithm declared in the file
// 'user/cxx_integers_echo/1.json'
#include "algorithm.h"
#include "user_single_integer_1.h"
using namespace beat::backend::cxx;
Algorithm::Algorithm()
{
}
//---------------------------------------------------------
Algorithm::~Algorithm()
{
}
//---------------------------------------------------------
bool Algorithm::setup(const json& parameters)
{
return true;
}
//---------------------------------------------------------
bool Algorithm::process(const InputList& inputs, const OutputList& outputs)
{
auto data = inputs["in_data"]->data<user::single_integer_1>();
outputs["out_data"]->write(data);
return true;
}
//---------------------------------------------------------
IAlgorithm* create_algorithm()
{
return new Algorithm();
}
// NOTE: This file implements the algorithm declared in the file
// 'user/cxx_integers_echo/1.json'
#ifndef _BEAT_GENERATED_ALGORITHM_H_
#define _BEAT_GENERATED_ALGORITHM_H_
#include <beat.backend.cxx/algorithm.h>
class Algorithm: public beat::backend::cxx::IAlgorithm
{
public:
Algorithm();
virtual ~Algorithm();
virtual bool setup(const json& parameters);
virtual bool process(const beat::backend::cxx::InputList& inputs,
const beat::backend::cxx::OutputList& outputs);
};
extern "C" {
beat::backend::cxx::IAlgorithm* create_algorithm();
}
#endif
// NOTE: This file was automatically generated from the algorithm declaration file
// 'user/cxx_integers_echo/1.json'
#include <beat.backend.cxx/dataformatfactory.h>
#include "beat_setup.h"
#include "user_single_integer_1.h"
using namespace beat::backend::cxx;
void setup_beat_cxx_module()
{
DataFormatFactory* factory = DataFormatFactory::getInstance();
factory->registerDataFormat("user/single_integer/1", &user::single_integer_1::create);
}
// NOTE: This file was automatically generated from the algorithm declaration file
// 'user/cxx_integers_echo/1.json'
#ifndef _BEAT_SETUP_H_
#define _BEAT_SETUP_H_
extern "C" {
void setup_beat_cxx_module();
}
#endif
// NOTE: This file was automatically generated from the dataformat declaration file
// 'user/single_integer/1.json'
#include "user_single_integer_1.h"
#include <beat.backend.cxx/dataformatfactory.h>
using namespace beat::backend::cxx;
user::single_integer_1::single_integer_1()
{
}
//---------------------------------------------------------
size_t user::single_integer_1::size() const
{
return sizeof(int32_t);
}
//---------------------------------------------------------
void user::single_integer_1::pack(uint8_t** buffer) const
{
beat::backend::cxx::pack(value, buffer);
}
//---------------------------------------------------------
void user::single_integer_1::unpack(uint8_t** buffer)
{
value = beat::backend::cxx::unpack_scalar<int32_t>(buffer);
}
//---------------------------------------------------------
Data* user::single_integer_1::create()
{
return new user::single_integer_1();
}
// NOTE: This file was automatically generated from the dataformat declaration file
// 'user/single_integer/1.json'
#ifndef _BEAT_GENERATED_user_single_integer_1_H_
#define _BEAT_GENERATED_user_single_integer_1_H_
#include <beat.backend.cxx/data.h>
namespace user {
class single_integer_1: public beat::backend::cxx::Data
{
public:
single_integer_1();
virtual size_t size() const;
virtual void pack(uint8_t** buffer) const;
virtual void unpack(uint8_t** buffer);
static Data* create();
public:
int32_t value;
};
}
#endif
{
"analyzers": {
"analysis": {
"algorithm": "user/integers_echo_analyzer/1",
"inputs": {
"in_data": "in"
}
}
},
"blocks": {
"echo1": {
"algorithm": "user/cxx_integers_echo/1",
"inputs": {
"in_data": "in"
},
"outputs": {
"out_data": "out"
},
"environment": {
"name": "cxx_environment",
"version": "1"
}
},
"echo2": {
"algorithm": "user/cxx_integers_echo/1",
"inputs": {
"in_data": "in"
},
"outputs": {
"out_data": "out"
},
"environment": {
"name": "cxx_environment",
"version": "1"
}
}
},
"datasets": {
"set": {
"database": "simple/1",
"protocol": "protocol",
"set": "set"
}
},
"globals": {
"queue": "queue",
"environment": {
"name": "environment",
"version": "1"
}
}
}
...@@ -55,7 +55,7 @@ class AsyncTest(unittest.TestCase): ...@@ -55,7 +55,7 @@ class AsyncTest(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.host = Host() cls.host = Host(use_machine='default')
cls.host.setup() cls.host.setup()
......
...@@ -59,7 +59,7 @@ class TestExecution(unittest.TestCase): ...@@ -59,7 +59,7 @@ class TestExecution(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.host = Host() cls.host = Host(use_machine='default')
cls.host.setup() cls.host.setup()
...@@ -210,3 +210,6 @@ class TestExecution(unittest.TestCase): ...@@ -210,3 +210,6 @@ class TestExecution(unittest.TestCase):
def test_double_triangle_1(self): def test_double_triangle_1(self):
assert self.execute('user/user/double_triangle/1/double_triangle', [{'out_data': 42}]) is None assert self.execute('user/user/double_triangle/1/double_triangle', [{'out_data': 42}]) is None
def test_cxx_double_1(self):
assert self.execute('user/user/double/1/cxx_double', [{'out_data': 42}]) is None
...@@ -93,7 +93,7 @@ def extension_for_language(language): ...@@ -93,7 +93,7 @@ def extension_for_language(language):
return dict( return dict(
unknown = '', unknown = '',
binary = '.bin', cxx = '.so',
matlab = '.m', matlab = '.m',
python = '.py', python = '.py',
r = '.r', r = '.r',
......
[buildout] [buildout]
parts = scripts cpulimit index = https://pypi.org/simple
parts = scripts cpulimit cxx_integers_echo_algorithm
extensions = mr.developer extensions = mr.developer
auto-checkout = * auto-checkout = *
develop = . develop = .
...@@ -23,3 +24,20 @@ on_update = true ...@@ -23,3 +24,20 @@ on_update = true
[scripts] [scripts]
recipe = bob.buildout:scripts recipe = bob.buildout:scripts
[cxx_integers_echo_algorithm]
recipe = collective.recipe.cmd
cmds = cd beat/core/test/prefix/algorithms/user/
tar -cf cxx_integers_echo.tar cxx_integers_echo/
docker run -dti --name build beats/cxx_dev:0.1.2 > /dev/null
docker cp cxx_integers_echo.tar build:/tmp/cxx_integers_echo.tar
docker exec build bash -c 'cd /tmp ; tar -xf /tmp/cxx_integers_echo.tar'
docker exec build bash -c 'cd /tmp/cxx_integers_echo ; mkdir build ; cd build ; cmake .. ; make'
docker cp build:/tmp/cxx_integers_echo/1.so cxx_integers_echo/.
docker stop build > /dev/null
docker rm build > /dev/null
rm cxx_integers_echo.tar
cd ../../../../../..
uninstall_cmds = rm -f beat/core/test/prefix/algorithms/user/cxx_integers_echo/1.so
on_install = true
on_update = true
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