Verify that dump file exists

Resolves openbmc/openbmc-test-automation#1052

Change-Id: I41e6766ba57aa51fd34dcc3227fc0af225006137
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
index 09abbdc..8607195 100644
--- a/lib/dump_utils.robot
+++ b/lib/dump_utils.robot
@@ -87,10 +87,25 @@
     ${resp}=  Openbmc Post Request  ${DUMP_URI}action/DeleteAll  data=${data}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
 
-
 Dump Should Not Exist
     [Documentation]  Verify that BMC dumps do not exist.
 
     ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/list  quiet=${1}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
 
+Check Existence of BMC Dump file
+    [Documentation]  Verify existence of BMC dump file.
+    [Arguments]  ${dump_id}
+
+    # Description of argument(s):
+    # dump_id  BMC dump identifier
+
+    ${dump_check_cmd}=  Set Variable
+    ...  ls /var/lib/phosphor-debug-collector/dumps
+
+    # Output of sample BMC Execute command with '2' as dump id is as follows
+    # ls /var/lib/phosphor-debug-collector/dumps/2
+    # obmcdump_2_XXXXXXXXXX.tar.xz
+    ${file_there}  ${stderr}  ${rc}=  BMC Execute Command
+    ...  ${dump_check_cmd}/${dump_id}
+    Should End With  ${file_there}  tar.xz  msg=BMC dump file not found.
diff --git a/tests/test_bmc_dump.robot b/tests/test_bmc_dump.robot
index bd21288..7204d50 100644
--- a/tests/test_bmc_dump.robot
+++ b/tests/test_bmc_dump.robot
@@ -28,19 +28,8 @@
     [Tags]  Verify_User_Initiated_BMC_Dump_When_Powered_Off
 
     REST Power Off  stack_mode=skip  quiet=1
-    Create User Initiated Dump
-
-
-Verify Dump Persistency On Reset
-    [Documentation]  Create user dump, reset BMC and verify dump persistency.
-    [Tags]  Verify_Dump_Persistency_On_Reset
-
-    Delete All BMC Dump
-    Create User Initiated Dump
-    OBMC Reboot (off)
-    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/list
-    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
-
+    ${dump_id}=  Create User Initiated Dump
+    Check Existence of BMC Dump file  ${dump_id}
 
 Verify Dump Persistency On Service Restart
     [Documentation]  Create user dump, restart BMC service and verify dump
@@ -48,13 +37,26 @@
     [Tags]  Verify_Dump_Persistency_On_Service_Restart
 
     Delete All BMC Dump
-    Create User Initiated Dump
+    ${dump_id}=  Create User Initiated Dump
     BMC Execute Command
     ...  systemctl restart xyz.openbmc_project.Dump.Manager.service
     Sleep  10s  reason=Wait for BMC dump service to restart properly.
 
     ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/list
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+    Check Existence of BMC Dump file  ${dump_id}
+
+
+Verify Dump Persistency On Reset
+    [Documentation]  Create user dump, reset BMC and verify dump persistency.
+    [Tags]  Verify_Dump_Persistency_On_Reset
+
+    Delete All BMC Dump
+    ${dump_id}=  Create User Initiated Dump
+    OBMC Reboot (off)
+    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/list
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+    Check Existence of BMC Dump file  ${dump_id}
 
 
 Delete User Initiated BMC Dump And Verify
@@ -62,6 +64,7 @@
     [Tags]  Delete_User_Initiated_Dump_And_Verify
 
     ${dump_id}=  Create User Initiated Dump
+    Check Existence of BMC Dump file  ${dump_id}
 
     Delete BMC Dump  ${dump_id}
 
@@ -75,6 +78,7 @@
     ${dump_size}=  Read Attribute  ${DUMP_ENTRY_URI}/${dump_id}  Size
     # Max size for dump is 200k = 200x1024
     Should Be True  0 < ${dump_size} < 204800
+    Check Existence of BMC Dump file  ${dump_id}
 
 
 Create Two User Initiated Dump And Delete One
@@ -91,6 +95,7 @@
 
     ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/${dump_id_2}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+    Check Existence of BMC Dump file  ${dump_id_2}
 
 
 Create And Delete BMC Dump Multiple Times
@@ -143,7 +148,6 @@
     [Documentation]  Do the post test teardown.
 
     Wait Until Keyword Succeeds  3 min  15 sec  Verify No Dump In Progress
-
     FFDC On Test Case Fail
     Delete All BMC Dump
     Close All Connections