Add test case for rebooting the BMC during code updates
Resolves openbmc/openbmc-test-automation#993
Change-Id: I21ff4361214f8139c7188f8511c060e9921fd6f8
Signed-off-by: Charles Paul Hofer <Charles.Hofer@ibm.com>
diff --git a/extended/code_update/bmc_recoverable_error_test.robot b/extended/code_update/bmc_recoverable_error_test.robot
index 5cd08ad..3803c26 100644
--- a/extended/code_update/bmc_recoverable_error_test.robot
+++ b/extended/code_update/bmc_recoverable_error_test.robot
@@ -7,11 +7,17 @@
Suite Setup Suite Setup Execution
+Test Setup Test Setup Execution
Test Teardown FFDC On Test Case Fail
*** Variables ***
-${QUIET} ${1}
-${IMAGE_FILE_PATH} ${EMPTY}
+
+${QUIET} ${1}
+${IMAGE_FILE_PATH} ${EMPTY}
+
+# In order to test the code update features of the image at ${IMAGE_FILE_PATH},
+# we need another BMC image to update to.
+${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY}
*** Test Cases ***
@@ -22,7 +28,16 @@
[Template] Reset Network Interface During Code Update
# Image File Path Reboot
- ${IMAGE_FILE_PATH} ${TRUE}
+ ${ALTERNATE_IMAGE_FILE_PATH} ${TRUE}
+
+
+Reboot BMC During BMC Image Activation
+ [Documentation] Attempt to reboot the BMC while an image is activating,
+ ... checking that the reboot has no effect.
+ [Tags] Reboot_BMC_During_BMC_Image_Activation
+
+ Attempt To Reboot BMC During Image Activation ${ALTERNATE_IMAGE_FILE_PATH}
+ OBMC Reboot (off)
*** Keywords ***
@@ -32,7 +47,16 @@
Should Not Be Empty ${IMAGE_FILE_PATH}
... msg=IMAGE_FILE_PATH should be set.
+ Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH}
+ ... msg=ALTERNATE_IMAGE_FILE_PATH should be set.
Should Not Be Empty ${OPENBMC_SERIAL_HOST}
... msg=OPENBMC_SERIAL_HOST should be set.
Should Not Be Empty ${OPENBMC_SERIAL_PORT}
... msg=OPENBMC_SERIAL_PORT should be set.
+
+
+Test Setup Execution
+ [Documentation] Do setup tasks for every test case.
+
+ Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true
+ OBMC Reboot (off)
diff --git a/extended/code_update/host_recoverable_error_test.robot b/extended/code_update/host_recoverable_error_test.robot
index 01f00b9..029e5ad 100644
--- a/extended/code_update/host_recoverable_error_test.robot
+++ b/extended/code_update/host_recoverable_error_test.robot
@@ -7,9 +7,11 @@
Suite Setup Suite Setup Execution
+Test Setup Test Setup Execution
Test Teardown FFDC On Test Case Fail
*** Variables ***
+
${QUIET} ${1}
${IMAGE_FILE_PATH} ${EMPTY}
@@ -25,6 +27,15 @@
${IMAGE_FILE_PATH} ${FALSE}
+Reboot BMC During Host Code Update
+ [Documentation] Attempt to reboot the BMC while an image is activating,
+ ... checking that the reboot has no effect.
+ [Tags] Reboot_BMC_During_Host_Code_Update
+
+ Attempt To Reboot BMC During Image Activation ${IMAGE_FILE_PATH}
+ OBMC Reboot (off)
+
+
*** Keywords ***
Suite Setup Execution
@@ -36,3 +47,9 @@
... msg=OPENBMC_SERIAL_HOST should be set.
Should Not Be Empty ${OPENBMC_SERIAL_PORT}
... msg=OPENBMC_SERIAL_PORT should be set.
+
+
+Test Setup Execution
+ [Documentation] Do setup tasks for every test case.
+
+ Delete All PNOR Images
\ No newline at end of file
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index 38fef93..2815b65 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -202,6 +202,31 @@
[Return] ${version_id}
+Attempt To Reboot BMC During Image Activation
+ [Documentation] Attempt to reboot the BMC while an image is activating and
+ ... check that the BMC ignores the reboot command and finishes
+ ... activation.
+ [Arguments] ${image_file_path}
+
+ # Description of argument(s):
+ # image_file_path Path to the image to update to.
+
+ # Attempt to reboot during activation.
+ ${version_id}= Upload And Activate Image ${image_file_path}
+ ... wait=${0}
+ BMC Execute Command /sbin/reboot
+
+ # Wait for activation to finish.
+ Wait For Activation State Change ${version_id} ${ACTIVATING}
+ ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
+ Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
+
+ # Verify the image priority is 0.
+ ${priority}= Read Software Attribute ${SOFTWARE_VERSION_URI}${version_id}
+ ... Priority
+ Should Be Equal ${priority} ${0}
+
+
Switch To Active Image And Pass
[Documentation] Make the given active image the image running on the BMC
... and pass the test.