Added tests for IPMI payload commands

Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: I1396ea72feed442882685fb3d3c45eab8156efc0
diff --git a/data/ipmi_raw_cmd_table.py b/data/ipmi_raw_cmd_table.py
index f68f5ac..9dbd8cc 100644
--- a/data/ipmi_raw_cmd_table.py
+++ b/data/ipmi_raw_cmd_table.py
@@ -119,5 +119,37 @@
             "11 02",
             "11 is Parameter revision, 02 is Configuration parameter data e.g. Cipher Suite Entry count",
         ]
+    },
+    'Payload':
+    {
+        'Get_Payload_Activation_Status':
+        [
+            # raw command, expected output(s), comment
+            "0x06 0x4a 0x01",
+            "01 00 00",
+            "1st byte is instance capacity, last two bytes is activation status of instances",
+        ],
+        'Activate_Payload':
+        [
+            # raw command, expected output(s), comment
+            "0x06 0x48 0x01 0x01 0xc6 0x00 0x00 0x00",
+            "00 00 00 00 ff 00 ff 00 6f 02 ff ff",
+            "Last two bits are payload vlan number, - FFFFh if VLAN addressing is not used",
+        ],
+        'Deactivate_Payload':
+        [
+            # raw command, expected output(s), comment
+            "0x06 0x49 0x01 0x01 0x00 0x00 0x00 0x00",
+            "",
+            "Line feed only",
+        ],
+        'Get_Payload_Instance_Info':
+        [
+            # raw command, expected output(s), comment
+            "0x06 0x4b 0x01 0x01",
+            "00 00 00 00 00 00 00 00 00 00 00 00",
+            "When the payload is activated, the first four bytes are the session ID,"
+            "otherwise it should be 00."
+        ]
     }
 }
diff --git a/ipmi/test_ipmi_payload.robot b/ipmi/test_ipmi_payload.robot
new file mode 100644
index 0000000..ed9d47c
--- /dev/null
+++ b/ipmi/test_ipmi_payload.robot
@@ -0,0 +1,98 @@
+*** Settings ***
+Documentation       This suite tests IPMI Payload in OpenBMC.
+
+Resource            ../lib/ipmi_client.robot
+Resource            ../lib/openbmc_ffdc.robot
+Variables           ../data/ipmi_raw_cmd_table.py
+
+
+*** Test Cases ***
+
+Test Get Payload Activation Status
+    [Documentation]  Test get payload activation status.
+    [Tags]  Test_Get_Payload_Activation_Status
+
+    # SOL is the payload currently supported for payload status.
+    # Currently supports only one SOL session.
+    # Response Data
+    # 01   instance 1 is activated.
+    # 00   instance 1 is deactivated.
+    ${payload_status}=  Get Payload Activation Status
+    Should Contain Any  ${payload_status}  01  00
+
+
+Test Activate Payload
+    [Documentation]  Test activate payload via IPMI raw command.
+    [Tags]  Test_Activate_Payload
+
+    ${payload_status}=  Get Payload Activation Status
+    Run Keyword If  '${payload_status}' == '01'  Deactivate Payload
+
+    Activate Payload
+
+    ${payload_status}=  Get Payload Activation Status
+    Should Contain  ${payload_status}  01
+
+
+Test Deactivate Payload
+    [Documentation]  Test deactivate payload via IPMI raw command.
+    [Tags]  Test_Deactivate_Payload
+
+    ${payload_status}=  Get Payload Activation Status
+    Run Keyword If  '${payload_status}' == '00'  Activate Payload
+
+    Deactivate Payload
+
+    ${payload_status}=  Get Payload Activation Status
+    Should Contain  ${payload_status}  00
+
+
+Test Get Payload Instance Info
+    [Documentation]  Test Get Payload Instance via IPMI raw command.
+    [Tags]  Test_Get_Payload_Instance_Info
+
+    ${payload_status}=  Get Payload Activation Status
+    Run keyword If  '${payload_status}' == '01'
+    ...  Deactivate Payload
+
+    # First four bytes should be 00 if given instance is not activated.
+    ${resp}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]}
+    Should Contain  ${resp}  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]}
+    Activate Payload
+
+    # First four bytes should be session ID when payload is activated.
+    ${resp}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]}
+    Should Not Contain  ${resp}  ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]}
+
+
+*** Keywords ***
+
+Get Payload Activation Status
+    [Documentation]  Get payload activation status.
+
+    ${resp}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['Payload']['Get_Payload_Activation_Status'][0]}
+
+    @{resp}=  Split String  ${resp}
+
+    ${payload_status}=  Set Variable  ${resp[1]}
+
+    [return]  ${payload_status}
+
+
+Activate Payload
+    [Documentation]  Activate Payload.
+
+    ${resp}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['Payload']['Activate_Payload'][0]}
+    Should Contain  ${resp}  ${IPMI_RAW_CMD['Payload']['Activate_Payload'][1]}
+
+
+Deactivate Payload
+    [Documentation]  Deactivate Payload.
+
+    ${resp}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['Payload']['Deactivate_Payload'][0]}
+    Should Be Empty  ${resp}