summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/.gitignore2
-rw-r--r--src/test/Makefile.am25
-rw-r--r--src/test/callbackgroupgentest.cpp31
-rw-r--r--src/test/templates/callbackgroupgentest.mako.hpp5
-rw-r--r--src/test/yaml/callbackgroupgentest/test.yaml88
5 files changed, 151 insertions, 0 deletions
diff --git a/src/test/.gitignore b/src/test/.gitignore
index 9c5e674..55db6d7 100644
--- a/src/test/.gitignore
+++ b/src/test/.gitignore
@@ -9,3 +9,5 @@
/propertywatchgentest
/callbackgentest.hpp
/callbackgentest
+/callbackgroupgentest.hpp
+/callbackgroupgentest
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index f4e2e46..893f264 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -129,3 +129,28 @@ callbackgentest.hpp: $(CALLBACK_TEST_GEN_DEPS)
-d yaml/callbackgentest \
-o $(builddir)/$@ \
generate-cpp
+
+check_PROGRAMS += callbackgroupgentest
+callbackgroupgentest_SOURCES = \
+ callbackgroupgentest.cpp
+callbackgroupgentest_CXXFLAGS = \
+ $(gtest_cflags)
+callbackgroupgentest_LDFLAGS = \
+ $(OESDK_TESTCASE_FLAGS)
+callbackgroupgentest_LDADD = \
+ ${gtest_ldadd}
+
+BUILT_SOURCES += callbackgroupgentest.hpp
+CLEANFILES += callbackgroupgentest.hpp
+
+CALLBACKGROUP_TEST_GEN_DEPS = \
+ templates/callbackgroupgentest.mako.hpp \
+ yaml/callbackgroupgentest
+
+callbackgroupgentest.hpp: $(CALLBACKGROUP_TEST_GEN_DEPS)
+ $(AM_V_GEN) $(PYTHON) $(PDMGEN) \
+ -t callbackgroupgentest.mako.hpp \
+ -p "${TEMPLATESEARCH}" \
+ -d yaml/callbackgroupgentest \
+ -o $(builddir)/$@ \
+ generate-cpp
diff --git a/src/test/callbackgroupgentest.cpp b/src/test/callbackgroupgentest.cpp
new file mode 100644
index 0000000..6493d9a
--- /dev/null
+++ b/src/test/callbackgroupgentest.cpp
@@ -0,0 +1,31 @@
+#include <array>
+#include <string>
+#include <gtest/gtest.h>
+#include "data_types.hpp"
+
+using namespace phosphor::dbus::monitoring;
+
+#include "callbackgroupgentest.hpp"
+
+const std::array<std::vector<size_t>, 4> expectedGroups = {{
+ {0, 1, 2},
+ {0, 1},
+ {2, 4, 5},
+ {5},
+ }
+};
+
+TEST(CallbackGroupGenTest, GroupsSameSize)
+{
+ ASSERT_EQ(sizeof(expectedGroups), sizeof(groups));
+}
+
+TEST(CallbackGroupGenTest, GroupsSameContent)
+{
+ size_t i;
+ for (i = 0; i < expectedGroups.size(); ++i)
+ {
+ ASSERT_EQ(groups[i],
+ expectedGroups[i]);
+ }
+}
diff --git a/src/test/templates/callbackgroupgentest.mako.hpp b/src/test/templates/callbackgroupgentest.mako.hpp
new file mode 100644
index 0000000..28b8ed8
--- /dev/null
+++ b/src/test/templates/callbackgroupgentest.mako.hpp
@@ -0,0 +1,5 @@
+const std::array<std::vector<size_t>, ${len(callbackgroups)}> groups = {{
+% for g in callbackgroups:
+ {${', '.join([str(x) for x in g.members])}},
+% endfor
+}};
diff --git a/src/test/yaml/callbackgroupgentest/test.yaml b/src/test/yaml/callbackgroupgentest/test.yaml
new file mode 100644
index 0000000..03962ba
--- /dev/null
+++ b/src/test/yaml/callbackgroupgentest/test.yaml
@@ -0,0 +1,88 @@
+# Validate nested callback groups.
+
+- name: test path group 1
+ class: group
+ group: path
+ members:
+ - meta: path
+ path: /xyz/openbmc_project/testing/inst4
+
+- name: test path group 2
+ class: group
+ group: path
+ members:
+ - meta: path
+ path: /xyz/openbmc_project/testing/inst4
+ - meta: path
+ path: /xyz/openbmc_project/testing/inst6
+
+- name: test property group 1
+ class: group
+ group: property
+ type: int32
+ members:
+ - interface: xyz.openbmc_project.Sensor.Iface1
+ meta: property
+ property: Value
+
+- name: test property group 2
+ class: group
+ group: property
+ type: string
+ members:
+ - interface: xyz.openbmc_project.Sensor.Iface3
+ meta: property
+ property: Value2
+
+- name: test journal callback 1
+ class: callback
+ callback: journal
+ paths: test path group 1
+ properties: test property group 1
+ severity: INFO
+ message: Hello world from PDM!
+
+- name: test journal callback 2
+ class: callback
+ callback: journal
+ paths: test path group 1
+ properties: test property group 1
+ severity: INFO
+ message: Hello world from PDM!
+
+- name: test journal callback 3
+ class: callback
+ callback: journal
+ paths: test path group 2
+ properties: test property group 2
+ severity: INFO
+ message: Hello world from PDM!
+
+- name: test group callback 1
+ class: callback
+ callback: group
+ members:
+ - test journal callback 1
+ - test journal callback 2
+ - test journal callback 3
+
+- name: test group callback 2
+ class: callback
+ callback: group
+ members:
+ - test journal callback 1
+ - test journal callback 2
+
+- name: test group callback 3
+ class: callback
+ callback: group
+ members:
+ - test journal callback 3
+ - test group callback 2
+ - test group callback 3
+
+- name: test group callback 4
+ class: callback
+ callback: group
+ members:
+ - test group callback 3
OpenPOWER on IntegriCloud