Enable test cases for dump function of OpenBMC.

This change includes:
    - Added keyword to create, check and delete bmc dump.
    - Added below test cases:
        1. Verify User Initiated Dump
        2. Delete User Initiated Dump And Verify
        3. Verify User Initiated Dump Size
        4. Create Two User Initiated Dump And Delete One

Resolves openbmc/openbmc-test-automation#232

Change-Id: Icffce866acbf630a6f28dd5d1cf5583bba267cd3
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
new file mode 100644
index 0000000..77887c9
--- /dev/null
+++ b/lib/dump_utils.robot
@@ -0,0 +1,64 @@
+*** Settings ***
+Documentation  This module provides general keywords for dump.
+
+
+*** Variables ***
+
+*** Keywords ***
+
+Create User Initiated Dump
+    [Documentation]  Generate user initiated dump and return
+    ...  dump id (e.g 1, 2 etc).
+
+    ${data}=  Create Dictionary  data=@{EMPTY}
+    ${resp}=  OpenBMC Post Request
+    ...  ${DUMP_URI}/action/CreateDump  data=${data}
+
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+    ${json}=  To JSON  ${resp.content}
+    ${dump_id}=  Set Variable  ${json["data"]}
+
+    Wait Until Keyword Succeeds  1 min  10 sec  Check Dump Existence
+    ...  ${dump_id}
+
+    [Return]  ${dump_id}
+
+
+Check Dump Existence
+    [Documentation]  Verify if given dump exist.
+    [Arguments]  ${dump_id}
+
+    # Description of Argument(s):
+    # dump_id  An integer value that identifies a particular dump
+    #          object(e.g. 1, 3, 5).
+
+    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/${dump_id}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+
+
+Delete BMC Dump
+    [Documentation]  Deletes a given bmc dump.
+    [Arguments]  ${dump_id}
+
+    # Description of Argument(s):
+    # dump_id  An interger value that identifies a particular dump (e.g. 1, 3).
+
+    ${data}=  Create Dictionary  data=@{EMPTY}
+    ${resp}=  OpenBMC Post Request
+    ...  ${DUMP_ENTRY_URI}/${dump_id}/action/Delete  data=${data}
+
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+
+Delete All Dumps
+    [Documentation]  Delete all dumps.
+
+    # Check if dump entries exist, if not return.
+    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}list
+    #  quiet=${1}
+    Return From Keyword If  ${resp.status_code} == ${HTTP_NOT_FOUND}
+
+    # Get the list of dump entries and delete them all.
+    ${dump_entries}=  Get URL List  ${DUMP_ENTRY_URI}
+    :FOR  ${entry}  IN  @{dump_entries}
+    \  ${dump_id}=  Fetch From Right  ${entry}  /
+    \  Delete BMC Dump  ${dump_id}
diff --git a/tests/test_bmc_dump.robot b/tests/test_bmc_dump.robot
new file mode 100644
index 0000000..358681f
--- /dev/null
+++ b/tests/test_bmc_dump.robot
@@ -0,0 +1,69 @@
+*** Settings ***
+
+Documentation       Test dump functionality of OpenBMC.
+
+Resource            ../lib/openbmc_ffdc.robot
+Resource            ../lib/rest_client.robot
+Resource            ../lib/dump_utils.robot
+
+Test Setup          Open Connection And Log In
+Test Teardown       Post Testcase Execution
+
+*** Variables ***
+
+
+*** Test Cases ***
+
+Verify User Initiated BMC Dump
+    [Documentation]  Create user initiated BMC dump and verify dump
+    ...  entry for it.
+    [Tags]  Verify_User_Initiated_Dump
+
+    Create User Initiated Dump
+
+
+Delete User Initiated BMC Dump And Verify
+    [Documentation]  Delete user initiated dump and verify.
+    [Tags]  Delete_User_Initiated_Dump_And_Verify
+
+    ${dump_id}=  Create User Initiated Dump
+
+    Delete BMC Dump  ${dump_id}
+
+
+Verify User Initiated Dump Size
+    [Documentation]  Verify user Initiated BMC dump size is under 500k.
+    [Tags]  Verify_User_Initiated_Dump_Size
+
+    ${dump_id}=  Create User Initiated Dump
+
+    ${dump_size}=  Read Attribute  ${DUMP_ENTRY_URI}/${dump_id}  Size
+    # Max size for dump is 500k
+    Should Be True  0 < ${dump_size} < 500000
+
+
+
+Create Two User Initiated Dump And Delete One
+    [Documentation]  Create two dumps and delete the first.
+    [Tags]  Create_Two_User_Initiated_Dump_And_Delete_One
+
+    ${dump_id_1}=  Create User Initiated Dump
+    ${dump_id_2}=  Create User Initiated Dump
+
+    Delete BMC Dump  ${dump_id_1}
+
+    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/${dump_id_1}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
+
+    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/${dump_id_2}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+
+
+*** Keywords ***
+
+Post Testcase Execution
+    [Documentation]  Do the post test teardown.
+
+    Delete All Dumps
+    FFDC On Test Case Fail
+    Close All Connections