Commit f65fdf82 authored by Avijit's avatar Avijit

Renamed the functions and ran clang-format.

parent 6ec2b865
......@@ -14,17 +14,17 @@
#include "ngraph.hpp"
#include "log.hpp"
NGraph* create_plugin()
NGraph* create_ngraph_object()
{
return new NGraph();
}
void destroy_plugin(NGraph* pObj)
void destroy_ngraph_object(NGraph* pObj)
{
delete pObj;
}
void NGraph::add_params( const std::vector<std::string>& paramList )
void NGraph::add_params(const std::vector<std::string>& paramList)
{
INFO << "Adding parameters";
m_params.insert(m_params.end(), paramList.begin(), paramList.end());
......
......@@ -21,16 +21,15 @@ class NGraph
public:
void add_params(const std::vector<std::string>& paramList);
const std::vector<std::string>& get_params() const;
std::string get_name() const { return "NGraph Plugin"; }
std::string get_name() const { return "NGraph Implementation Object"; }
private:
std::vector<std::string> m_params;
};
// Factory methods
extern "C" NGraph* create_plugin();
extern "C" void destroy_plugin(NGraph* pObj);
extern "C" NGraph* create_ngraph_object();
extern "C" void destroy_ngraph_object(NGraph* pObj);
// FUnction pointers to the factory methods
typedef NGraph* (*CreatePluginPfn)();
typedef void (*DestroyPluginPfn)(NGraph*);
typedef NGraph* (*CreateNGraphObjPfn)();
typedef void (*DestroyNGraphObjPfn)(NGraph*);
......@@ -27,8 +27,8 @@ using namespace std;
TEST(NGraph, loadTest)
{
// load the triangle library
void* pluginLib = dlopen("../src/libngraph.so", RTLD_LAZY);
if (!pluginLib)
void* ngraphImplLib = dlopen("../src/libngraph.so", RTLD_LAZY);
if (!ngraphImplLib)
{
std::cerr << "Cannot load library: " << dlerror() << '\n';
ASSERT_FALSE(true);
......@@ -38,33 +38,35 @@ TEST(NGraph, loadTest)
dlerror();
// Get the symbols
auto createPfn = reinterpret_cast<CreatePluginPfn>(dlsym(pluginLib, "create_plugin"));
auto createPfn =
reinterpret_cast<CreateNGraphObjPfn>(dlsym(ngraphImplLib, "create_ngraph_object"));
ASSERT_FALSE(createPfn == nullptr);
auto destroyPfn = reinterpret_cast<DestroyPluginPfn>(dlsym(pluginLib, "destroy_plugin"));
auto destroyPfn =
reinterpret_cast<DestroyNGraphObjPfn>(dlsym(ngraphImplLib, "destroy_ngraph_object"));
ASSERT_FALSE(destroyPfn == nullptr);
NGraph* pluginObj = createPfn();
NGraph* nGraphObj = createPfn();
INFO << "Call a method on the Object";
ASSERT_EQ("NGraph Plugin", pluginObj->get_name());
INFO << "Plugin Name: " << pluginObj->get_name();
ASSERT_EQ("NGraph Implementation Object", nGraphObj->get_name());
INFO << "Object Name: " << nGraphObj->get_name();
// Add some parameters
const vector<string> TEST_PARAMS = {"param-1", "param-2", "param-3"};
pluginObj->add_params( TEST_PARAMS );
nGraphObj->add_params(TEST_PARAMS);
// Get the list of params
auto& storedParams = pluginObj->get_params();
EXPECT_EQ( TEST_PARAMS.size(), storedParams.size() );
auto& storedParams = nGraphObj->get_params();
EXPECT_EQ(TEST_PARAMS.size(), storedParams.size());
for (int i = 0; i < TEST_PARAMS.size(); i++)
{
EXPECT_EQ( TEST_PARAMS[i], storedParams[i] );
EXPECT_EQ(TEST_PARAMS[i], storedParams[i]);
}
INFO << "Destroy the Plugin Object";
destroyPfn(pluginObj);
INFO << "Destroy the NGraph Object";
destroyPfn(nGraphObj);
dlclose(pluginLib);
dlclose(ngraphImplLib);
}
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