Collect FFDC on failure and error log existence.

1. Call generic FFDa collection if test fails.
2. Collect FFDC if test "PASS" but error log exist.

Resolves  openbmc/openbmc-test-automation#905

Change-Id: I8e3accad57cdd5f8b40427aeffc4cb4368fbee42
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/extended/code_update/host_code_update.robot b/extended/code_update/host_code_update.robot
index 3e388ec..799e38f 100644
--- a/extended/code_update/host_code_update.robot
+++ b/extended/code_update/host_code_update.robot
@@ -24,7 +24,7 @@
 Resource          ../../lib/state_manager.robot
 Resource          ../../lib/dump_utils.robot
 
-Test Teardown     FFDC On Test Case Fail
+Test Teardown     Code Update Test Teardown
 
 *** Variables ***
 
@@ -37,6 +37,10 @@
 
 REST Host Code Update
     [Documentation]  Do a PNOR code update by uploading image on BMC via REST.
+    # 1. Delete error logs if there is any.
+    # 1. Do code update.
+    # 2. Do post update the following:
+    #    - Collect FFDC if error log exist and delete error logs.
     [Tags]  REST_Host_Code_Update
     [Setup]  Code Update Setup
 
@@ -44,6 +48,7 @@
     OBMC Reboot (off)
 
 
+
 Post Update Boot To OS
     [Documentation]  Boot the host OS
     [Tags]  Post_Update_Boot_To_OS
@@ -52,6 +57,7 @@
     Run Keyword If  '${PREV_TEST_STATUS}' == 'FAIL'
     ...  Fail  Code update failed. No need to boot to OS.
     Start SOL Console Logging
+    Delete Error Logs
     REST Power On
 
 
@@ -147,6 +153,7 @@
     # - Clean up all currently install PNOR images.
 
     Delete All Dumps
+    Delete Error Logs
     Run Keyword If  'true' == '${DELETE_OLD_PNOR_IMAGES}'
     ...  Delete All PNOR Images
 
@@ -168,3 +175,12 @@
     ${version}= BMC Execute Command
     ...  grep extended_version= ${manifest_path}
     [return] ${version.split(",")}
+
+
+Code Update Test Teardown
+    [Documentation]  Do code update test case teardown.
+    # 1. Collect FFDC if test case failed.
+    # 2. Collect FFDC if test PASS but error log exists.
+
+    FFDC On Test Case Fail
+    Run Keyword If  '${TEST_STATUS}' == 'PASS'  Check Error And Collect FFDC