Fail to perform firmware update

Changes:
   - Verify Code Update Fails When Kernel Panic Occur

Tested:
   - Ran successfully
     redfish/update_service/
     test_redfish_bmc_code_update.robot

Change-Id: Iae19c360248739ca94151e80e6904d8f1bec984e
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/lib/common_utils.robot b/lib/common_utils.robot
index 3c4d06c..26300da 100755
--- a/lib/common_utils.robot
+++ b/lib/common_utils.robot
@@ -999,7 +999,7 @@
     [Documentation]  Create kernel panic to reset BMC.
 
     ${kernel_panic_cmd_file}=  Set Variable  /bin/sh -c "echo c > /proc/sysrq-trigger"
-    ${status}=  Run Keyword And Return Status  BMC Execute Command  ${kernel_panic_cmd_file}  time_out=120
+    ${status}=  Run Keyword And Return Status  BMC Execute Command  ${kernel_panic_cmd_file}  time_out=20
 
     [Return]  ${status}
 
diff --git a/redfish/update_service/test_redfish_bmc_code_update.robot b/redfish/update_service/test_redfish_bmc_code_update.robot
index 83648d6..5a3e81b 100644
--- a/redfish/update_service/test_redfish_bmc_code_update.robot
+++ b/redfish/update_service/test_redfish_bmc_code_update.robot
@@ -64,9 +64,9 @@
     ${temp_update_loop_count}=  Evaluate  ${LOOP_COUNT} + 1
 
     FOR  ${count}  IN RANGE  1  ${temp_update_loop_count}
-       Print Timen  **************************************
+       Print Timen  ***************************************
        Print Timen  * The Current Loop Count is ${count} of ${LOOP_COUNT} *
-       Print Timen  **************************************
+       Print Timen  ***************************************
 
        Redfish Update Firmware  apply_time=OnReset
     END
@@ -126,6 +126,47 @@
     Redfish BMC Dump Should Not Exist
 
 
+Verify Code Update Fails When Kernel Panic Occur
+     [Documentation]  Ensure firmware update is un-successful when kernel panic
+     ...              occur during ongoing firmware update.
+     [Tags]  Verify_Code_Update_Fails_When_Kernel_Panic_Occur
+
+     ${before_update_activeswimage}=  Redfish.Get Attribute  /redfish/v1/Managers/bmc  Links
+     Rprint Vars  before_update_activeswimage
+
+     Set ApplyTime  policy=OnReset
+
+     ${task_inv_dict}=  Get Task State from File
+
+     ${file_bin_data}=  OperatingSystem.Get Binary File  ${image_file_path}
+
+     Log To Console   Start uploading image to BMC.
+     Upload Image To BMC  ${REDFISH_BASE_URI}UpdateService  timeout=${600}  data=${file_bin_data}
+     Log To Console   Completed image upload to BMC.
+
+     Sleep  5
+
+     ${task_inv}=  Check Task With Match TargetUri  /redfish/v1/UpdateService
+     Rprint Vars  task_inv
+
+     Run Keyword  Kernel Panic BMC Reset Operation
+
+     Is BMC Unpingable
+
+     Wait Until Keyword Succeeds  10 min  10 sec  Is BMC Standby
+
+     Redfish.Login
+
+     ${after_update_activeswimage}=  Redfish.Get Attribute  /redfish/v1/Managers/bmc  Links
+     Rprint Vars  after_update_activeswimage
+
+     Should Be Equal As Strings
+     ...  ${before_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
+     ...  ${after_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
+
+     Verify Get ApplyTime  OnReset
+
+
 Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
     [Documentation]  Verify updated admin credential remain same post switch to back up image.
     [Tags]  Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup
@@ -246,3 +287,5 @@
     Run Key  ${post_code_update_actions['BMC image']['${apply_time}']}
     Redfish.Login
     Redfish Verify BMC Version  ${IMAGE_FILE_PATH}
+
+