summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-03-09 15:06:23 -0600
committerMatt Spinler <spinler@us.ibm.com>2017-03-14 15:37:27 -0500
commitd9bdcf729783afbd32ec8d030cd49455dff88e9b (patch)
tree551937e94b86854e88ed7a5e1d3fb627f0ffc347 /test
parent83e37327235e0f5eb39d4d66c16d72833394615d (diff)
downloadopenpower-proc-control-d9bdcf729783afbd32ec8d030cd49455dff88e9b.tar.gz
openpower-proc-control-d9bdcf729783afbd32ec8d030cd49455dff88e9b.zip
Register procedures
For a procedure to be available to run, it needs to have a call to a REGISTER_PROCEDURE macro. This macro wraps a call to a Register class that adds the procedure to the list along with the name to call it. Change-Id: I20d02e8f004c1c726228469465ae89b60ee52d66 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rw-r--r--test/utest.cpp30
2 files changed, 31 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index ce78754..bf86e6a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -13,4 +13,4 @@ utest_LDFLAGS = -lgtest_main -lgtest $(PTHREAD_LIBS) $(OESDK_TESTCASE_FLAGS) \
$(PHOSPHOR_LOGGING_LIBS) -lstdc++fs
utest_SOURCES = utest.cpp
-utest_LDADD = $(top_srcdir)/targeting.cpp
+utest_LDADD = $(top_srcdir)/targeting.cpp $(top_srcdir)/registration.cpp
diff --git a/test/utest.cpp b/test/utest.cpp
index d91004d..0d3c2c9 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -17,8 +17,10 @@
#include <experimental/filesystem>
#include <fstream>
#include <stdlib.h>
+#include "registration.hpp"
#include "targeting.hpp"
+using namespace openpower::util;
using namespace openpower::targeting;
namespace fs = std::experimental::filesystem;
@@ -98,3 +100,31 @@ TEST_F(TargetingTest, CreateTargets)
}
}
}
+
+
+void func1()
+{
+ std::cout << "Hello\n";
+}
+
+void func2()
+{
+ std::cout << "World\n";
+}
+
+REGISTER_PROCEDURE("hello", func1);
+REGISTER_PROCEDURE("world", func2);
+
+
+TEST(RegistrationTest, TestReg)
+{
+ int count = 0;
+ for (const auto& p : Registration::getProcedures())
+ {
+ std::cout << p.first << std::endl;
+ p.second();
+ count++;
+ }
+
+ ASSERT_EQ(count, 2);
+}
OpenPOWER on IntegriCloud