Journald persistency check on BMC reset

Changes:
     - Added changes to lookup for "-- Reboot --" footprint from
       the journald log post reset.
     - Added new keyword to parse and check for error type user
       specified.

Resolves  openbmc/openbmc-test-automation#1418

Change-Id: I1ddfd19f719c1be7c1756d1f4ca1bbf6c545afb0
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index fc6a488..2586e6b 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -1535,3 +1535,15 @@
 
     [Return]  ${boot_side}
 
+
+Check For Regex In Journald
+    [Documentation]  Parse the journal log and check for regex string.
+    [Arguments]  ${regex}=${ERROR_REGEX}  ${error_check}=${0}
+
+    ${journal_log}  ${stderr}  ${rc}=  BMC Execute Command
+    ...  journalctl --no-pager | egrep '${regex}'  ignore_err=1
+
+    Run Keyword If  ${error_check} == ${0}
+    ...    Should Be Empty  ${journal_log}
+    ...  ELSE
+    ...    Should Not Be Empty  ${journal_log}
diff --git a/tests/test_basic_poweron.robot b/tests/test_basic_poweron.robot
index 147af86..bb5e780 100644
--- a/tests/test_basic_poweron.robot
+++ b/tests/test_basic_poweron.robot
@@ -36,6 +36,7 @@
     REST Power Off  stack_mode=skip  quiet=1
     Verify Identify LED State  Off
 
+
 Power On Test
     [Documentation]  Power off and on.
     [Tags]  Power_On_Test
@@ -44,14 +45,12 @@
 
     Repeat Keyword  ${LOOP_COUNT} times  Host Off And On
 
+
 Check For Application Failures
     [Documentation]  Parse the journal log and check for failures.
     [Tags]  Check_For_Application_Failures
 
-    ${journal_log}  ${stderr}  ${rc}=  BMC Execute Command
-    ...  journalctl --no-pager | egrep '${ERROR_REGEX}'  ignore_err=1
-
-    Should Be Empty  ${journal_log}
+    Check For Regex In Journald  ${ERROR_REGEX}  error_check=${0}
 
 
 Verify Uptime Average Against Threshold
@@ -118,4 +117,3 @@
 
     Should Be True  ${startup_time} < ${startup_time_threshold}
     ...  msg=${startup_time} greater than threshold value of ${startup_time_threshold}.
-
diff --git a/tests/test_bmc_reboot.robot b/tests/test_bmc_reboot.robot
index d168047..79fbb9a 100644
--- a/tests/test_bmc_reboot.robot
+++ b/tests/test_bmc_reboot.robot
@@ -17,6 +17,10 @@
 *** Variables ***
 ${SYSTEM_SHUTDOWN_TIME}    ${5}
 
+# Strings to check from journald.
+${REBOOT_REGEX}    ^\-- Reboot --
+
+
 *** Test Cases ***
 
 Test BMC Reboot via REST
@@ -31,3 +35,6 @@
     BMC Execute Command  if [ -f ${test_file_path} ] ; then false ; fi
     Verify BMC RTC And UTC Time Drift
 
+    # Check for journald persistency post reboot.
+    Check For Regex In Journald  ${REBOOT_REGEX}  error_check=${1}
+