Commit f65fdf82 authored by Avijit's avatar Avijit

Renamed the functions and ran clang-format.

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