Add eSEL whitelist to BMC error polling test

Move the whitelist checking keyword from htx_hardbootme_test
to esel_utils.  Call the keyword from htx_hardbootme_test
and test_bmc_poll_errors.

Resolves openbmc/openbmc-test-automation#1945

Signed-off-by: Steven Sombar <ssombar@us.ibm.com>
Change-Id: Iebcc1e099704965727c8af2730863ef2bae77a45
diff --git a/lib/esel_utils.robot b/lib/esel_utils.robot
index 4cb7569..50f148b 100755
--- a/lib/esel_utils.robot
+++ b/lib/esel_utils.robot
@@ -59,3 +59,31 @@
     ${elog_entry}=  Get Event Logs
     Should Be Equal  ${elog_entry[0]["Message"]}  org.open_power.Host.Error.Event
     Should Be Equal  ${elog_entry[0]["Severity"]}  Critical
+
+
+Check For Error Logs
+    [Documentation]  Fail if there are error logs. Ignore logs with
+    ...              severity in the whitelist.
+
+    [Arguments]  ${whitelist}
+
+    # Description of Argument(s):
+    # whitelist  A list to be used to filter out esels which are
+    #            of no interest to the caller.
+    #            Error Logs with Severity field matching an
+    #            entry in this list will be ignored. (e.g.
+    #            xyz.openbmc_project.Logging.Entry.Level.Error)
+
+    Print Timen  Checking Error Logs.
+    ${error_logs}=  Get Error Logs
+
+    ${num_error_logs}=  Get Length  ${error_logs}
+    Return From Keyword If  ${num_error_logs} == ${0}
+
+    # Get a list of the severities of the error logs.
+    ${error_log_severities}=  Nested Get  Severity  ${error_logs}
+    # Subtract the WHITELIST from the error_log_severities.
+    ${problem_error_logs}=  Evaluate
+    ...  list(set($error_log_severities) - set($whitelist))
+
+    Valid Length  problem_error_logs   max_length=0
diff --git a/systest/htx_hardbootme_test.robot b/systest/htx_hardbootme_test.robot
index 149a0c9..b2399d4 100755
--- a/systest/htx_hardbootme_test.robot
+++ b/systest/htx_hardbootme_test.robot
@@ -40,6 +40,7 @@
 Resource        ../lib/openbmc_ffdc_utils.robot
 Resource        ../lib/logging_utils.robot
 Resource        ../lib/code_update_utils.robot
+Resource        ../lib/esel_utils.robot
 Library         ../syslib/utils_keywords.py
 Library         ../lib/utils_files.py
 Library         ../lib/logging_utils.py
@@ -62,11 +63,12 @@
 
 ${rest_keyword}              REST
 
-# Error log Severities to ignore when checking for eSELs.
+# Error log Severities to ignore when checking Error Logs.
 @{ESEL_WHITELIST}
 ...  xyz.openbmc_project.Logging.Entry.Level.Informational
 
 
+
 *** Test Cases ***
 
 Hard Bootme Test
@@ -213,36 +215,11 @@
     Fail  Significant difference in inventory found, rc=${diff_rc}
 
 
-Check For ESELs
-    [Documentation]  Terminate if eSELs with Severity field not on WHITELIST.
-
-    Print Timen  Checking eSEL Error Logs.
-    ${error_logs}=  Get Error Logs
-
-    ${num_error_logs}=  Get Length  ${error_logs}
-    Rprint Vars  num_error_logs
-    Return From Keyword If  ${num_error_logs} == ${0}
-
-    Print Error Logs  ${error_logs}
-
-    # Get a list of the severities of the error logs.
-    ${error_log_severities}=  Nested Get  Severity  ${error_logs}
-    # Subtract the WHITELIST from the error_log_severities.
-    ${problem_error_logs}=
-    ...  Evaluate  list(set($error_log_severities) - set($ESEL_WHITELIST))
-    ${num_error_logs_not_on_whitelist}=  Get Length  ${problem_error_logs}
-
-    Return From Keyword If  ${num_error_logs_not_on_whitelist} == ${0}
-
-    Rprint Vars  ESEL_WHITELIST
-    Fail  msg=Found error logs with Severity not matching ESEL_WHITELIST.
-
-
 Loop HTX Health Check
     [Documentation]  Run until HTX exerciser fails.
     Repeat Keyword  ${HTX_DURATION}
     ...  Run Keywords  Check HTX Run Status
-    ...  AND  Check For ESELs
+    ...  AND  Check For Error Logs  ${ESEL_WHITELIST}
     ...  AND  Sleep  ${HTX_INTERVAL}
 
 
diff --git a/systest/test_bmc_poll_errors.robot b/systest/test_bmc_poll_errors.robot
index 33631b2..fca158f 100755
--- a/systest/test_bmc_poll_errors.robot
+++ b/systest/test_bmc_poll_errors.robot
@@ -7,6 +7,7 @@
 Resource          ../lib/boot_utils.robot
 Resource          ../lib/boot_utils.robot
 Resource          ../lib/bmc_redfish_resource.robot
+Resource          ../lib/esel_utils.robot
 
 Suite Setup      Suite Setup Execution
 Test Teardown    Post Test Case Execution
@@ -17,6 +18,11 @@
 ${POLL_DURATION}  48 hours
 ${POLL_INTERVAL}  10 second
 
+# Error log Severities to ignore when checking Error Logs.
+@{ESEL_WHITELIST}
+...  xyz.openbmc_project.Logging.Entry.Level.Informational
+
+
 *** Test Cases ***
 
 Poll BMC For Errors
@@ -36,7 +42,7 @@
 
     Redfish.Get  /redfish/v1/Chassis/chassis/Sensors
 
-    Error Logs Should Not Exist
+    Check For Error Logs  ${ESEL_WHITELIST}
 
 
 Suite Setup Execution
@@ -49,8 +55,8 @@
     Should Not Be Empty
     ...  ${OS_PASSWORD}  msg=You must provide OS host user password.
 
+    Redfish Power On  stack_mode=skip
     Redfish.Login
-    Redfish Power On
 
     Delete Error Logs
     Error Logs Should Not Exist