libpldm: Added encode API for GetStatus request

The UA sends this command to acquire the status of the FD/FDP. This
implementation works with DSP0267_1.1.0, DSP0267_1.0.1 and
DSP0267_1.0.0.

Tested: Unit tests passed

Signed-off-by: gokulsanker <gokul.sanker.v.g@intel.com>
Change-Id: I413a5456f56ddcf6de18ac373b203989a8020834
diff --git a/libpldm/tests/libpldm_firmware_update_test.cpp b/libpldm/tests/libpldm_firmware_update_test.cpp
index 350db59..0577c51 100644
--- a/libpldm/tests/libpldm_firmware_update_test.cpp
+++ b/libpldm/tests/libpldm_firmware_update_test.cpp
@@ -2451,4 +2451,30 @@
         responseMsg, sizeof(pldm_activate_firmware_resp) - 1, &completionCode,

         &estimatedTimeForActivation);

     EXPECT_EQ(rc, PLDM_ERROR_INVALID_LENGTH);

-}
\ No newline at end of file
+}

+

+TEST(GetStatus, goodPathEncodeRequest)

+{

+    constexpr uint8_t instanceId = 8;

+    std::array<uint8_t, hdrSize> request{};

+    auto requestMsg = reinterpret_cast<pldm_msg*>(request.data());

+

+    auto rc = encode_get_status_req(instanceId, requestMsg,

+                                    PLDM_GET_STATUS_REQ_BYTES);

+    EXPECT_EQ(rc, PLDM_SUCCESS);

+

+    constexpr std::array<uint8_t, hdrSize> outRequest{0x88, 0x05, 0x1B};

+    EXPECT_EQ(request, outRequest);

+}

+

+TEST(GetStatus, errorPathEncodeRequest)

+{

+    std::array<uint8_t, hdrSize + sizeof(uint8_t)> request{};

+    auto requestMsg = reinterpret_cast<pldm_msg*>(request.data());

+

+    auto rc = encode_get_status_req(0, nullptr, PLDM_GET_STATUS_REQ_BYTES);

+    EXPECT_EQ(rc, PLDM_ERROR_INVALID_DATA);

+

+    rc = encode_get_status_req(0, requestMsg, PLDM_GET_STATUS_REQ_BYTES + 1);

+    EXPECT_EQ(rc, PLDM_ERROR_INVALID_LENGTH);

+}