Hard bootme test

Resolves openbmc/openbmc-test-automation#553

Change-Id: I2237f117701e1b8e82f66a001e15cfe83126c421
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/systest/htx_hardbootme_test.robot b/systest/htx_hardbootme_test.robot
index 13d769d..6896815 100644
--- a/systest/htx_hardbootme_test.robot
+++ b/systest/htx_hardbootme_test.robot
@@ -2,39 +2,72 @@
 Documentation    Stress the system using HTX exerciser.
 
 Resource         ../syslib/utils_os.robot
-Suite Setup      Power Off Host
-Suite Teardown   Shutdown HTX Exerciser
+Library          ../lib/gen_robot_print.py
+
+Test Setup      Pre Test Case Execution
+Test Teardown   Post Test Case Execution
 
 *** Variables ****
 
+${stack_mode}        skip
+
 # Default duration and interval of HTX exerciser to run.
-${HTX_DURATION}     4 hours
+${HTX_DURATION}     2 hours
 ${HTX_INTERVAL}     15 min
 
+# Default hardbootme loop times HTX exerciser to run.
+${HTX_LOOP}         4
+
 *** Test Cases ***
 
 Hard Bootme Test
     [Documentation]  Stress the system using HTX exerciser.
+    [Tags]  Hard_Bootme_Test
 
-    Log To Console  \n HTX Test run: ${HTX_DURATION} interval: ${HTX_INTERVAL}
+    Rprintn
+    Rpvars  HTX_DURATION  HTX_INTERVAL
+
+    Repeat Keyword  ${HTX_LOOP} times  Start HTX Exerciser
+
+
+*** Keywords ***
+
+Start HTX Exerciser
+    [Documentation]  Start HTX exerciser.
+    # Test Flow:
+    #              - Power on
+    #              - Establish SSH connection session
+    #              - Create HTX mdt profile
+    #              - Run HTX exerciser
+    #              - Check HTX status for errors
+    #              - Power off
+
+    Boot To OS
+
+    # Post Power off and on, the OS SSH session needs to be established.
     Login To OS
 
-    Log To Console  \n *** Create HTX mdt profile ***
+    Rprint Timen  Create HTX mdt profile.
     ${profile}=  Execute Command On OS  htxcmdline -createmdt
-    Log To Console  \n ${profile}
+    Rprint Timen  ${profile}
     Should Contain  ${profile}  mdts are created successfully
 
-    Log To Console  \n *** Start HTX mdt profile execution ***
+    Rprint Timen  Start HTX mdt profile execution.
     ${htx_run}=  Execute Command On OS  htxcmdline -run -mdt mdt.bu
-    Log To Console  \n ${htx_run}
+    Rprint Timen  ${htx_run}
     Should Contain  ${htx_run}  Activated
 
     Loop HTX Health Check
 
-*** Keywords ***
+    Shutdown HTX Exerciser
+
+    Power Off Host
+
+    Rprint Timen  HTX Test ran for: ${HTX_DURATION}
 
 Loop HTX Health Check
-    [Documentation]  Run until keyword fails.
+    [Documentation]  Run until HTX exerciser fails.
+
     Repeat Keyword  ${HTX_DURATION}
     ...  Run Keywords  Check HTX Run Status
     ...  AND  Sleep  ${HTX_INTERVAL}
@@ -43,12 +76,14 @@
 Check HTX Run Status
     [Documentation]  Get HTX exerciser status and check for error.
 
-    Log To Console  \n *** Check HTX mdt Status and error ***
+    Rprint Timen  Check HTX mdt Status and error.
     ${status}=  Execute Command On OS  htxcmdline -status -mdt mdt.bu
     Log  ${status}
+    Rprint Timen  ${status}
 
     ${errlog}=  Execute Command On OS  htxcmdline -geterrlog
     Log  ${errlog}
+    Rprint Timen  ${errlog}
 
     Should Contain  ${errlog}  file </tmp/htxerr> is empty
 
@@ -56,11 +91,30 @@
 Shutdown HTX Exerciser
     [Documentation]  Shut down HTX exerciser run.
 
-    Log To Console  \n *** Shutdown HTX Run ***
+    Rprint Timen  Shutdown HTX Run
     ${shutdown}=  Execute Command On OS  htxcmdline -shutdown -mdt mdt.bu
-    Log To Console  \n ${shutdown}
+    Rprint Timen  ${shutdown}
     Should Contain  ${shutdown}  shutdown successfully
 
-    # Power Off only if there is no error
+
+Pre Test Case Execution
+    [Documentation]  Do the initial test setup.
+    # 1. Check if HTX tool exist.
+    # 2. Power on
+
+    Boot To OS
+    HTX Tool Exist
+
+
+Post Test Case Execution
+    [Documentation]  Do the post test teardown.
+    # 1. Shut down HTX exerciser if test Failed.
+    # 2. Capture FFDC on test failure.
+    # 3. Close all open SSH connections.
+
     Run Keyword If  '${TEST_STATUS}' == 'FAIL'
-    ...  Power Off Host
+    ...  Shutdown HTX Exerciser
+
+    FFDC On Test Case Fail
+    Close All Connections
+