Verify dump after injecting host watchdog error

Resolves openbmc/openbmc-test-automation#1565

Change-Id: Ie1ac1015ce7b016845c79c31999a7ea6fe53798f
Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
diff --git a/extended/test_watchdog.robot b/extended/test_watchdog.robot
index 3050349..a9e38b4 100644
--- a/extended/test_watchdog.robot
+++ b/extended/test_watchdog.robot
@@ -141,11 +141,3 @@
 
     ${resp}=  OpenBMC Get Request  ${WATCHDOG_URI}host0
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
-
-
-Verify Watchdog Enabled
-    [Documentation]  Check that watchdog settings are enabled.
-
-    ${properties}=  Read Properties  /xyz/openbmc_project/watchdog/host0
-    Should Be Equal As Strings  ${properties["Enabled"]}  ${True}
-    Should Not Be Equal As Strings  ${properties["TimeRemaining"]}  0
diff --git a/lib/common_utils.robot b/lib/common_utils.robot
index 33585ef..711dbf0 100755
--- a/lib/common_utils.robot
+++ b/lib/common_utils.robot
@@ -926,3 +926,11 @@
     ...  systemctl -p ${option} show ${servicename} | cut -d = -f2
     ${attr}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
     [Return]  ${attr}
+
+
+Verify Watchdog Enabled
+    [Documentation]  Check that watchdog settings are enabled.
+
+    ${properties}=  Read Properties  /xyz/openbmc_project/watchdog/host0
+    Should Be Equal As Strings  ${properties["Enabled"]}  ${True}
+    Should Not Be Equal As Strings  ${properties["TimeRemaining"]}  0
diff --git a/tests/test_bmc_dump.robot b/tests/test_bmc_dump.robot
index 109eb95..5daa434 100644
--- a/tests/test_bmc_dump.robot
+++ b/tests/test_bmc_dump.robot
@@ -187,6 +187,38 @@
     Check For Core Dumps
 
 
+Verify Dump After Host Watchdog Error Injection
+    [Documentation]  Inject host watchdog error and verify whether dump is generated.
+    [Tags]  Verify_Dump_After_Host_Watchdog_Error_Injection
+
+    REST Power On
+
+    Run Keyword And Ignore Error  Delete All Dumps
+
+    # Enable auto reboot
+    Set Auto Reboot  ${1}
+
+    Trigger Host Watchdog Error  2000  30
+
+    Wait Until Keyword Succeeds  300 sec  20 sec  Is Host Rebooted
+
+    #Get dump details
+    @{dump_entry_list}=  Read Properties  ${DUMP_ENTRY_URI}
+
+    # Verifing that there is only one dump
+    ${length}=  Get length  ${dump_entry_list}
+    Should Be Equal As Integers  ${length}  ${1}
+
+    # Get dump id
+    ${value}=  Get From List  ${dump_entry_list}  0
+    @{split_value}=  Split String  ${value}  /
+    ${dump_id}=  Get From List  ${split_value}  -1
+
+    # Max size for dump is 200k = 200x1024
+    ${dump_size}=  Read Attribute  ${DUMP_ENTRY_URI}${dump_id}  Size
+    Should Be True  0 < ${dump_size} < 204800
+
+
 *** Keywords ***
 
 Test Teardown Execution