init
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/*********************************************************************
|
||||
* Software License Agreement (AGPL-3 License)
|
||||
*
|
||||
* OpenViBE SDK Test Software
|
||||
* Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
|
||||
* Copyright (C) Inria, 2015-2017,V1.0
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ovtAssert.h"
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Test {
|
||||
static void printErrorCore(const char* expression, const char* file, const int line)
|
||||
{
|
||||
std::cerr << "Failed to evaluate: " << expression << std::endl;
|
||||
std::cerr << "File = " << file << std::endl;
|
||||
std::cerr << "Line = " << line << std::endl;
|
||||
}
|
||||
|
||||
void printError(const char* expression, const char* message, const char* file, const int line)
|
||||
{
|
||||
printErrorCore(expression, file, line);
|
||||
std::cerr << "Error message: " << message << std::endl;
|
||||
}
|
||||
|
||||
void printError(const char* expression, const std::string& message, const char* file, const int line) { printError(expression, message.c_str(), file, line); }
|
||||
|
||||
void printError(const char* expression, const std::ostream& message, const char* file, const int line)
|
||||
{
|
||||
printErrorCore(expression, file, line);
|
||||
std::cerr << "Error message: " << message.rdbuf() << std::endl;
|
||||
}
|
||||
|
||||
void printExpressionPair(const char* str1, const char* str2)
|
||||
{
|
||||
std::cerr << "Expression 1 is : " << str1 << std::endl;
|
||||
std::cerr << "Expression 2 is : " << str2 << std::endl;
|
||||
}
|
||||
|
||||
std::string buildExpressionFromPair(const char* str1, const char* str2)
|
||||
{
|
||||
std::string expression = "( " + std::string(str1);
|
||||
expression += " = ";
|
||||
expression += std::string(str2) + " )";
|
||||
|
||||
return expression;
|
||||
}
|
||||
} // namespace Test
|
||||
} // namespace OpenViBE
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*********************************************************************
|
||||
* Software License Agreement (AGPL-3 License)
|
||||
*
|
||||
* OpenViBE SDK Test Software
|
||||
* Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
|
||||
* Copyright (C) Inria, 2015-2017,V1.0
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <toolkit/ovtk_all.h>
|
||||
|
||||
#include "ovtTestFixtureCommon.h"
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Test {
|
||||
void SKernelFixture::setUp()
|
||||
{
|
||||
#if defined TARGET_OS_Windows
|
||||
const CString kernelFile = Directories::getLibDir() + "/openvibe-kernel.dll";
|
||||
#elif defined TARGET_OS_Linux
|
||||
const CString kernelFile = Directories::getLibDir() + "/libopenvibe-kernel.so";
|
||||
#elif defined TARGET_OS_MacOS
|
||||
const CString kernelFile = Directories::getLibDir() + "/libopenvibe-kernel.dylib";
|
||||
#endif
|
||||
CString error;
|
||||
|
||||
if (!m_kernelLoader.load(kernelFile, &error))
|
||||
{
|
||||
std::cerr << "ERROR: impossible to load kernel from file located at: " << kernelFile << std::endl;
|
||||
std::cerr << "ERROR: kernel error: " << error << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
m_kernelLoader.initialize();
|
||||
|
||||
Kernel::IKernelDesc* kernelDesc = nullptr;
|
||||
m_kernelLoader.getKernelDesc(kernelDesc);
|
||||
|
||||
if (!kernelDesc)
|
||||
{
|
||||
std::cerr << "ERROR: impossible to retrieve kernel descriptor " << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
CString configFile;
|
||||
|
||||
if (!m_configFile.empty()) { configFile = m_configFile.c_str(); }
|
||||
else { configFile = CString(Directories::getDataDir() + "/kernel/openvibe.conf"); }
|
||||
|
||||
|
||||
Kernel::IKernelContext* ctx = kernelDesc->createKernel("test-kernel", configFile);
|
||||
|
||||
if (!ctx)
|
||||
{
|
||||
std::cerr << "ERROR: impossible to create kernel context " << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->initialize();
|
||||
Toolkit::initialize(*ctx);
|
||||
context = ctx;
|
||||
}
|
||||
|
||||
void SKernelFixture::tearDown()
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
Toolkit::uninitialize(*context);
|
||||
Kernel::IKernelDesc* kernelDesc = nullptr;
|
||||
m_kernelLoader.getKernelDesc(kernelDesc);
|
||||
kernelDesc->releaseKernel(context);
|
||||
context = nullptr;
|
||||
}
|
||||
|
||||
m_kernelLoader.uninitialize();
|
||||
m_kernelLoader.unload();
|
||||
}
|
||||
} // namespace Test
|
||||
} // namespace OpenViBE
|
||||
Reference in New Issue
Block a user