Added test cases for IPMI SOL testing.

This change includes:
   - Added test case to verify SOL during boot.
   - Added test case to verify deactivate non existing SOL.
   - Added keyword to get host state via IPMI.
   - Added an argument to indicate if we need to wait
     for host state.

Resolves openbmc/openbmc-test-automation#602

Change-Id: Ia5e8f98e53e6b1ac3188f554b99bd9a5562cf7a2
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 5d61eb8..424f67e 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -240,14 +240,33 @@
 
 Initiate Host Boot Via External IPMI
     [Documentation]  Initiate host power on using external IPMI.
+    [Arguments]  ${wait}=${1}
+    # Description of argument(s):
+    # wait  Indicates that this keyword should wait for host running state.
+
     ${output}=  Run External IPMI Standard Command  chassis power on
     Should Not Contain  ${output}  Error
-    Wait Until Keyword Succeeds
-    ...  10 min  10 sec  Is Host Running
+
+    Run Keyword If  '${wait}' == '${0}'  Return From Keyword
+    Wait Until Keyword Succeeds  10 min  10 sec  Is Host Running
 
 Initiate Host PowerOff Via External IPMI
     [Documentation]  Initiate host power off using external IPMI.
+    [Arguments]  ${wait}=${1}
+    # Description of argument(s):
+    # wait  Indicates that this keyword should wait for host off state.
+
     ${output}=  Run External IPMI Standard Command  chassis power off
     Should Not Contain  ${output}  Error
-    Wait Until Keyword Succeeds
-    ...  3 min  10 sec  Is Host Off
+
+    Run Keyword If  '${wait}' == '${0}'  Return From Keyword
+    Wait Until Keyword Succeeds  3 min  10 sec  Is Host Off
+
+Get Host State Via External IPMI
+    [Documentation]  Returns host state using external IPMI.
+
+    ${output}=  Run External IPMI Standard Command  chassis power status
+    Should Not Contain  ${output}  Error
+    ${output}=  Fetch From Right  ${output}  ${SPACE}
+
+    [Return]  ${output}
diff --git a/tests/ipmi/test_sol.robot b/tests/ipmi/test_sol.robot
new file mode 100644
index 0000000..970d5e4
--- /dev/null
+++ b/tests/ipmi/test_sol.robot
@@ -0,0 +1,54 @@
+*** Settings ***
+Documentation       This suite tests IPMI SOL in OpenBMC.
+
+Resource            ../../lib/ipmi_client.robot
+Resource            ../../lib/openbmc_ffdc.robot
+
+Test Teardown       Post Test Case Execution
+
+*** Variables ***
+
+*** Test Cases ***
+
+Verify SOL During Boot
+    [Documentation]  Verify SOL during boot.
+    [Tags]  Verify_SOL_During_Boot
+
+    ${current_state}=  Get Host State Via External IPMI
+    Run Keyword If  '${current_state}' == 'On'
+    ...  Initiate Host PowerOff Via External IPMI
+    Initiate Host Boot Via External IPMI  wait=${0}
+
+    Activate SOL Via IPMI
+    Wait Until Keyword Succeeds  10 mins  30 secs
+    ...  Check IPMI SOL Output Content  Petitboot
+
+Verify Deactivate Non Existing SOL
+    [Documentation]  Verify deactivate non existing SOL session.
+    [Tags]  Verify_Deactivate_Non_Existing_SOL
+
+    ${resp}=  Deactivate SOL Via IPMI
+    Should Contain  ${resp}  SOL payload already de-activated
+    ...  case_insensitive=True
+
+
+*** Keywords ***
+
+Post Test Case Execution
+    [Documentation]  Do the post test teardown.
+
+    Deactivate SOL Via IPMI
+    FFDC On Test Case Fail
+
+Check IPMI SOL Output Content
+    [Documentation]  Check if SOL has given content.
+    [Arguments]  ${data}  ${file_path}=/tmp/sol_${OPENBMC_HOST}
+    # Description of argument(s):
+    # data       Content which need to be checked(e.g. Petitboot, ISTEP).
+    # file_path  The file path on the local machine to check SOL content.
+    #            By default it check SOL content from /tmp/sol_<BMC_IP>.
+
+    ${rc}  ${output}=  Run and Return RC and Output  cat ${file_path}
+    Should Be Equal  ${rc}  ${0}  msg=${output}
+
+    Should Contain  ${output}  ${data}  case_insensitive=True