summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-04-24 14:45:20 -0700
committerWilliam A. Kennington III <wak@google.com>2019-04-29 12:06:35 -0700
commite15e53eb5b3e8b279504710b5759fdfdd32bb128 (patch)
tree306f0ea70df5f16d4eccb0f9bcdb8cd17a09e95e /test
parente2aec26caacdc65711a96ce3b6dbaa5ea526fc1f (diff)
downloadphosphor-host-ipmid-e15e53eb5b3e8b279504710b5759fdfdd32bb128.tar.gz
phosphor-host-ipmid-e15e53eb5b3e8b279504710b5759fdfdd32bb128.zip
message/pack: Allow packing payloads
Some IPMI handlers need the ability to support variable return types. The easiest way to do that is to be able to return payloads and pack them into the final payload. Change-Id: I5098a1ab0998ada712096929eae40a3c88a6dea0 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/message/pack.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/message/pack.cpp b/test/message/pack.cpp
index 939b356..7fb67ba 100644
--- a/test/message/pack.cpp
+++ b/test/message/pack.cpp
@@ -282,6 +282,30 @@ TEST(PackBasics, OptionalContainsValue)
ASSERT_EQ(p.raw, k);
}
+TEST(PackBasics, Payload)
+{
+ ipmi::message::Payload p;
+ EXPECT_EQ(p.pack(true), 0);
+ EXPECT_EQ(p.pack(ipmi::message::Payload({0x24, 0x30})), 0);
+ EXPECT_EQ(p.raw, std::vector<uint8_t>({0b1, 0x24, 0x30}));
+}
+
+TEST(PackBasics, PayloadUnaligned)
+{
+ ipmi::message::Payload p;
+ EXPECT_EQ(p.pack(true, ipmi::message::Payload({0x24})), 1);
+ EXPECT_EQ(p.raw, std::vector<uint8_t>({0b1}));
+}
+
+TEST(PackBasics, PayloadOtherUnaligned)
+{
+ ipmi::message::Payload p, q;
+ q.appendBits(1, 1);
+ EXPECT_EQ(p.pack(true), 0);
+ EXPECT_EQ(p.pack(q), 1);
+ EXPECT_EQ(p.raw, std::vector<uint8_t>({0b1}));
+}
+
TEST(PackAdvanced, Uints)
{
// all elements will be processed in order, with each multi-byte
OpenPOWER on IntegriCloud