Application core dumps files FFDC collection

Fix includes:
   - Lib keyword to enable core dump
   - Method keyword for SCP
   - Add entry in FFDC default method list
   - Enable core dump setting in __init__.txt

Resolves openbmc/openbmc-test-automation#373

Change-Id: I2a3885911fd361181ad664bddbf40e508bc03a5f
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index 86cf74b..1283dbf 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -134,6 +134,7 @@
         'BMC Specific Files': 'BMC FFDC Files',
         'Get Request FFDC': 'BMC FFDC Get Requests',
         'OS FFDC': 'OS FFDC Files',
+        'Core Files': 'SCP Coredump Files',
     },
 }
 
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index ba231ab..cdd94fa 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -230,3 +230,20 @@
     @{entries}=  Get ffdc os distro index  ${linux_distro}
     :FOR  ${index}  IN  @{entries}
     \   Log OS SPECIFIC DISTRO FFDC  ${index}  ${linux_distro}
+
+
+##############################################################################
+SCP Coredump Files
+    [Documentation]  Copy core dump file from BMC to local system.
+    # Check if core dump exist in the /tmp
+    Open Connection And Log In
+    ${core_files}=  Execute Command On BMC  ls /tmp/core_*
+    Should Not Contain  ${core_files}  No such file or directory
+    @{core_list} =  Split String    ${core_files}
+    # Copy the core files
+    Open Connection for SCP
+    :FOR  ${index}  IN  @{core_list}
+    \  scp.Get File  ${index}  ${LOG_PREFIX}${index.lstrip("/tmp/")}
+    # Remove the file from remote to avoid re-copying on next FFDC call
+    \  Execute Command On BMC  rm ${index}
+
diff --git a/lib/utils.robot b/lib/utils.robot
index 8a5da12..3e4063a 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -693,3 +693,10 @@
     Should Be Empty  ${stderr}
     [Return]  ${stdout}
 
+
+Enable Core Dump On BMC
+    [Documentation]  Enable core dump collection.
+    Open Connection And Log In
+    ${core_pattern}=  Execute Command On BMC
+    ...  echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
+    Should Be Equal As Strings  ${core_pattern}  /tmp/core_%e.%p