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>
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 @@
}
}
}
+
+
+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);
+}