base: GetTID responder implementation

A pldm terminus is defined as the point of communication termination
for PLDM messages and the PLDM functions associated with those messages.

The Terminus ID(TID) is a value that identifies a PLDM terminus.

This commit assignes 1 to the BMC as the TID.

Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I7adb0e1274f326fe6cf148771f230f530c9a567c
diff --git a/test/libpldm_base_test.cpp b/test/libpldm_base_test.cpp
index f17bccb..7aaf7e4 100644
--- a/test/libpldm_base_test.cpp
+++ b/test/libpldm_base_test.cpp
@@ -433,3 +433,36 @@
     ASSERT_EQ(versionOut.update, version.update);
     ASSERT_EQ(versionOut.alpha, version.alpha);
 }
+
+TEST(GetTID, testEncodeResponse)
+{
+    uint8_t completionCode = 0;
+    std::array<uint8_t, sizeof(pldm_msg_hdr) + PLDM_GET_TID_RESP_BYTES>
+        responseMsg{};
+    auto response = reinterpret_cast<pldm_msg*>(responseMsg.data());
+    uint8_t tid = 1;
+
+    auto rc = encode_get_tid_resp(0, PLDM_SUCCESS, tid, response);
+    ASSERT_EQ(rc, PLDM_SUCCESS);
+    uint8_t* payload = response->payload;
+    ASSERT_EQ(completionCode, payload[0]);
+    ASSERT_EQ(1, payload[sizeof(completionCode)]);
+}
+
+TEST(GetTID, testDecodeResponse)
+{
+    std::array<uint8_t, hdrSize + PLDM_GET_TID_RESP_BYTES> responseMsg{};
+    responseMsg[1 + hdrSize] = 1;
+
+    uint8_t tid;
+    uint8_t completion_code;
+
+    auto response = reinterpret_cast<pldm_msg*>(responseMsg.data());
+
+    auto rc = decode_get_tid_resp(response, responseMsg.size() - hdrSize,
+                                  &completion_code, &tid);
+
+    ASSERT_EQ(rc, PLDM_SUCCESS);
+    ASSERT_EQ(completion_code, PLDM_SUCCESS);
+    ASSERT_EQ(tid, 1);
+}
diff --git a/test/libpldmresponder_base_test.cpp b/test/libpldmresponder_base_test.cpp
index 6138341..bbd986a 100644
--- a/test/libpldmresponder_base_test.cpp
+++ b/test/libpldmresponder_base_test.cpp
@@ -37,7 +37,7 @@
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
     uint8_t* payload_ptr = responsePtr->payload;
     ASSERT_EQ(payload_ptr[0], 0);
-    ASSERT_EQ(payload_ptr[1], 56); // 56 = 0b111000
+    ASSERT_EQ(payload_ptr[1], 60); // 60 = 0b111100
     ASSERT_EQ(payload_ptr[2], 0);
 }
 
@@ -118,3 +118,18 @@
 
     ASSERT_EQ(responsePtr->payload[0], PLDM_ERROR_INVALID_PLDM_TYPE);
 }
+
+TEST(GetTID, testGoodRequest)
+{
+    std::array<uint8_t, sizeof(pldm_msg_hdr)> requestPayload{};
+    auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
+    size_t requestPayloadLength = 0;
+
+    auto response = getTID(request, requestPayloadLength);
+
+    auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
+    uint8_t* payload = responsePtr->payload;
+
+    ASSERT_EQ(payload[0], 0);
+    ASSERT_EQ(payload[1], 1);
+}