oem: meta: Add decode_oem_meta_file_io_read_req()

Add decode_oem_meta_file_io_read_req function.

This function is used to decode the message of reading file IO.
Need to include read_option (read file attributes or data), length
(the length of the read data) and read_info (The information
needed to read the file).
Take reading file data as an example:
read_info needs to contain transferFlag, offset to know the
starting position and transfer progress of the read file.

Change-Id: I425476d36e3cd69d2da45beceff1c4a2362640dc
Signed-off-by: Lora Lin <lora.lin.wiwynn@gmail.com>
diff --git a/tests/oem/meta/fileio.cpp b/tests/oem/meta/fileio.cpp
index 48c0778..a40e43b 100644
--- a/tests/oem/meta/fileio.cpp
+++ b/tests/oem/meta/fileio.cpp
@@ -87,3 +87,74 @@
     EXPECT_EQ(rc, -EOVERFLOW);
 }
 #endif
+
+#ifdef LIBPLDM_API_TESTING
+TEST(DecodeOemMetaFileIoReadReq, testGoodDecodeRequest)
+{
+    struct pldm_msgbuf _ctx;
+    struct pldm_msgbuf* ctx = &_ctx;
+    int rc;
+
+    constexpr size_t payloadLen = PLDM_OEM_META_FILE_IO_READ_REQ_MIN_LENGTH +
+                                  PLDM_OEM_META_FILE_IO_READ_DATA_INFO_LENGTH;
+    alignas(pldm_msg) unsigned char buf[sizeof(pldm_msg_hdr) + payloadLen]{};
+    auto* msg = new (buf) pldm_msg;
+
+    rc = pldm_msgbuf_init_errno(ctx, 0, msg->payload, payloadLen);
+    ASSERT_EQ(rc, 0);
+
+    pldm_msgbuf_insert_uint8(ctx, 0);
+    pldm_msgbuf_insert_uint8(ctx, PLDM_OEM_META_FILE_IO_READ_DATA);
+    pldm_msgbuf_insert_uint8(ctx, PLDM_OEM_META_FILE_IO_READ_DATA_INFO_LENGTH);
+    pldm_msgbuf_insert_uint8(ctx, 1);
+    pldm_msgbuf_insert_uint16(ctx, 1223);
+
+    rc = pldm_msgbuf_destroy_consumed(ctx);
+    ASSERT_EQ(rc, 0);
+
+    struct pldm_oem_meta_file_io_read_req req = {};
+    req.version = sizeof(req);
+    rc = decode_oem_meta_file_io_read_req(msg, payloadLen, &req);
+    ASSERT_EQ(rc, 0);
+
+    EXPECT_EQ(req.handle, 0);
+    EXPECT_EQ(req.option, PLDM_OEM_META_FILE_IO_READ_DATA);
+    EXPECT_EQ(req.length, PLDM_OEM_META_FILE_IO_READ_DATA_INFO_LENGTH);
+    EXPECT_EQ(req.info.data.transferFlag, 1);
+    EXPECT_EQ(req.info.data.offset, 1223);
+}
+#endif
+
+#ifdef LIBPLDM_API_TESTING
+TEST(DecodeOemMetaFileIoReadReq, testInvalidFieldsDecodeRequest)
+{
+    struct pldm_msg msg = {};
+
+    auto rc = decode_oem_meta_file_io_read_req(
+        &msg, PLDM_OEM_META_FILE_IO_READ_REQ_MIN_LENGTH, NULL);
+    EXPECT_EQ(rc, -EINVAL);
+}
+#endif
+
+#ifdef LIBPLDM_API_TESTING
+TEST(DecodeOemMetaFileIoReadReq, testInvalidLengthDecodeRequest)
+{
+    struct pldm_oem_meta_file_io_read_req req = {};
+    struct pldm_msg msg = {};
+
+    auto rc = decode_oem_meta_file_io_read_req(&msg, 0, &req);
+    EXPECT_EQ(rc, -EOVERFLOW);
+}
+#endif
+
+#ifdef LIBPLDM_API_TESTING
+TEST(DecodeOemMetaFileIoReadReq, testInvalidDataRequest)
+{
+    struct pldm_oem_meta_file_io_read_req req = {};
+    struct pldm_msg msg = {};
+
+    auto rc = decode_oem_meta_file_io_read_req(
+        &msg, PLDM_OEM_META_FILE_IO_READ_REQ_MIN_LENGTH - 1, &req);
+    EXPECT_EQ(rc, -EOVERFLOW);
+}
+#endif