Collect HTX status and error log

Resolves  openbmc/openbmc-test-automation#578

Change-Id: I24c768f84e61fedd358d6e50a0e939176f842951
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/syslib/utils_os.robot b/syslib/utils_os.robot
index ffccdee..f566a22 100755
--- a/syslib/utils_os.robot
+++ b/syslib/utils_os.robot
@@ -8,8 +8,14 @@
 Resource           ../lib/utils.robot
 Resource           ../lib/state_manager.robot
 
+Library            OperatingSystem
+Library            DateTime
+
 *** Variables ***
 
+${htx_log_dir_path}   ${EXECDIR}${/}logs${/}
+
+
 *** Keywords ***
 
 Execute Command On OS
@@ -73,3 +79,35 @@
 
     ${status}=  Execute Command On OS  htxcmdline -status
     Should Not Contain  ${status}  Daemon state is <IDLE>
+
+
+Write Log Data To File
+    [Documentation]  Write log data to the logs directory.
+    [Arguments]  ${data}=  ${log_file_path}=
+    # Description of argument(s):
+    # data            String buffer.
+    # log_file_path   The log file path.
+
+    Create File  ${log_file_path}  ${data}
+
+
+Collect HTX Log Files
+    [Documentation]  Collect status and error log files.
+    # Collects the following files:
+    # HTX error log file /tmp/htxerr
+    # HTX status log file /tmp/htxstats
+
+    # Create logs directory and get current datetime.
+    Create Directory  ${htx_log_dir_path}
+    ${cur_datetime}=  Get Current Date  result_format=%Y%m%d%H%M%S%f
+
+    File Exist On OS  /tmp/htxerr
+    ${htx_err}=  Execute Command On BMC  cat /tmp/htxerr
+    Write Log Data To File
+    ...  ${htx_err}  ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr
+
+    File Exist On OS  /tmp/htxstats
+    ${htx_stats}=  Execute Command On BMC  cat /tmp/htxstats
+    Write Log Data To File
+    ...  ${htx_stats}  ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
+
diff --git a/systest/htx_hardbootme_test.robot b/systest/htx_hardbootme_test.robot
index ab8fc17..38c60a1 100644
--- a/systest/htx_hardbootme_test.robot
+++ b/systest/htx_hardbootme_test.robot
@@ -80,6 +80,9 @@
 Check HTX Run Status
     [Documentation]  Get HTX exerciser status and check for error.
 
+    Rprint Timen  Collect HTX status and error log files.
+    Run Key U  Collect HTX Log Files
+
     Rprint Timen  Check HTX mdt Status and error.
     ${status}=  Execute Command On OS
     ...  htxcmdline -status -mdt ${HTX_MDT_PROFILE}