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