pldmd: implement PLDM.Requester D-Bus API
Implement D-Bus API defined at
https://gerrit.openbmc-project.xyz/#/c/openbmc/phosphor-dbus-interfaces/+/27077/.
This commit provides an implementation of the PLDM instance id as per
DSP0240 v1.0.0. Ids are tracked per MCTP EID.
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I8a1ef213646529b71d9bf33edda67537f7c0f32a
diff --git a/test/meson.build b/test/meson.build
index 1749605..ee509db 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -14,6 +14,7 @@
gtest = dependency('gtest', main: true, disabler: true, required: true)
gmock = dependency('gmock', disabler: true, required: true)
+pldmd = declare_dependency(sources: '../instance_id.cpp')
tests = [
'libpldm_base_test',
@@ -26,7 +27,8 @@
'libpldmresponder_bios_table_test',
'libpldmresponder_platform_test',
'libpldm_fru_test',
- 'libpldm_utils_test'
+ 'libpldm_utils_test',
+ 'pldmd_instanceid_test',
]
if get_option('oem-ibm').enabled()
@@ -41,6 +43,14 @@
implicit_include_directories: false,
link_args: dynamic_linker,
build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
- dependencies: [libpldm, libpldmresponder, gtest, gmock, dependency('sdbusplus'),dependency('phosphor-logging')]),
+ dependencies: [
+ libpldm,
+ libpldmresponder,
+ gtest,
+ gmock,
+ pldmd,
+ dependency('phosphor-dbus-interfaces'),
+ dependency('phosphor-logging'),
+ dependency('sdbusplus')]),
workdir: meson.current_source_dir())
endforeach
diff --git a/test/pldmd_instanceid_test.cpp b/test/pldmd_instanceid_test.cpp
new file mode 100644
index 0000000..35ff146
--- /dev/null
+++ b/test/pldmd_instanceid_test.cpp
@@ -0,0 +1,39 @@
+#include "instance_id.hpp"
+
+#include <stdexcept>
+
+#include <gtest/gtest.h>
+
+using namespace pldm;
+
+TEST(InstanceId, testNext)
+{
+ InstanceId id;
+ ASSERT_EQ(id.next(), 0);
+ ASSERT_EQ(id.next(), 1);
+}
+
+TEST(InstanceId, testAllUsed)
+{
+ InstanceId id;
+ for (size_t i = 0; i < maxInstanceIds; ++i)
+ {
+ ASSERT_EQ(id.next(), i);
+ }
+ EXPECT_THROW(id.next(), std::runtime_error);
+}
+
+TEST(InstanceId, testMarkfree)
+{
+ InstanceId id;
+ for (size_t i = 0; i < maxInstanceIds; ++i)
+ {
+ ASSERT_EQ(id.next(), i);
+ }
+ id.markFree(5);
+ ASSERT_EQ(id.next(), 5);
+ id.markFree(0);
+ ASSERT_EQ(id.next(), 0);
+ EXPECT_THROW(id.next(), std::runtime_error);
+ EXPECT_THROW(id.markFree(32), std::out_of_range);
+}