Automation of Sanity scenarios

Change-Id: I73b585c292aa53fcb64c1778b2264652ba619501
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/lib/ras/host_utils.robot b/lib/ras/host_utils.robot
index a4f2cee..8e58869 100755
--- a/lib/ras/host_utils.robot
+++ b/lib/ras/host_utils.robot
@@ -36,13 +36,13 @@
 Putscom Operations On OS
     [Documentation]  Executes putscom command on OS with the given
     ...              input arguments.
-    [Arguments]      ${proc_chip_id}  ${fru}  ${address}
+    [Arguments]      ${proc_chip_id}  ${fir_address}  ${value}
     # Description of arguments:
     # proc_chip_id        Processor ID (e.g '0', '8').
-    # fru            FRU value (e.g. 2011400).
-    # address        Chip address (e.g 4000000000000000).
+    # fir_address         FIR (Fault isolation register) value (e.g. 2011400).
+    # value               (e.g 4000000000000000).
 
-    ${cmd}=  Catenate  putscom -c 0x${proc_chip_id} 0x${fru} 0x${address}
+    ${cmd}=  Catenate  putscom -c 0x${proc_chip_id} 0x${fir_address} 0x${value}
     Start Command  ${cmd}
 
 Get ProcChipId From OS
@@ -85,13 +85,13 @@
 FIR Address Translation Through HOST
     [Documentation]  Do FIR address translation through host for given FIR,
     ...              core value & target type.
-    [Arguments]  ${fir}  ${core_id}  ${target_type}
+    [Arguments]  ${fir_address}  ${core_id}  ${target_type}
     # Description of argument(s):
-    # fir          FIR (Fault isolation register) value (e.g. 2011400).
-    # core_id      Core ID (e.g. 9).
-    # target_type  Target type (e.g. 'EQ', 'EX', 'C').
+    # fir_address     FIR (Fault isolation register) value (e.g. 2011400).
+    # core_id         Core ID (e.g. 9).
+    # target_type     Target type (e.g. 'EQ', 'EX', 'C').
 
-    ${cmd}=  Catenate  set -o pipefail ; ${addr_translation_file_path} ${fir}
+    ${cmd}=  Catenate  set -o pipefail ; ${addr_translation_file_path} ${fir_address}
     ...  ${core_id} | grep -i ${target_type}
     ${output}  ${stderr}  ${rc}=  OS Execute Command  ${cmd}
     ${translated_addr}=  Split String  ${output}  :${SPACE}0x
@@ -106,11 +106,11 @@
     ...              1. Boot To HOST.
     ...              2. Clear any existing gard records.
     ...              3. Inject Error on processor.
-    [Arguments]      ${fir}  ${chip_address}  ${threshold_limit}
+    [Arguments]      ${fir_address}  ${value}  ${threshold_limit}
     ...  ${master_proc_chip}=True
     # Description of argument(s):
-    # fir                 FIR (Fault isolation register) value (e.g. 2011400).
-    # chip_address        chip address (e.g 2000000000000000).
+    # fir_address         FIR (Fault isolation register) value (e.g. 2011400).
+    # value               (e.g 2000000000000000).
     # threshold_limit     Threshold limit (e.g 1, 5, 32).
     # master_proc_chip    Processor chip type (True' or 'False').
 
@@ -124,8 +124,8 @@
 
     ${threshold_limit}=  Convert To Integer  ${threshold_limit}
     :FOR  ${count}  IN RANGE  ${threshold_limit}
-    \  Run Keyword  Putscom Operations On OS  ${proc_chip_id}  ${fir}
-    ...  ${chip_address}
+    \  Run Keyword  Putscom Operations On OS  ${proc_chip_id}  ${fir_address}
+    ...  ${value}
     # Adding delay after each error injection.
     \  Sleep  10s
     # Adding delay to get error log after error injection.
@@ -171,19 +171,6 @@
     ${opal_prd_state}=  Is Opal-PRD Service Enabled
     Should Contain  ${opal_prd_state}  enabled
 
-BMC Putscom
-    [Documentation]  Executes putscom command through BMC.
-
-    [Arguments]      ${proc_chip_id}  ${fru}  ${chip_address}
-
-    # Description of argument(s):
-    # proc_chip_id        Processor ID (e.g '0', '8').
-    # fru                 FRU (field replaceable unit) (e.g. '2011400').
-    # chip_address        Chip address (e.g. '4000000000000000').
-
-    ${cmd}=  Catenate  pdbg -d p9w -p${proc_chip_id} putscom 0x${fru} 0x${chip_address}
-
-    BMC Execute Command  ${cmd}
 
 Inject Error Through BMC
     [Documentation]  Inject checkstop on multiple targets like
@@ -192,11 +179,11 @@
     ...              1. Boot To HOST.
     ...              2. Clear any existing gard records.
     ...              3. Inject Error on processor.
-    [Arguments]      ${fir}  ${chip_address}  ${threshold_limit}
+    [Arguments]      ${fir_address}  ${value}  ${threshold_limit}
     ...  ${master_proc_chip}=True
     # Description of argument(s):
-    # fir                 FIR (Fault isolation register) value (e.g. '2011400').
-    # chip_address        Chip address (e.g. '2000000000000000').
+    # fir_address         FIR (Fault isolation register) value (e.g. '2011400').
+    # value               (e.g. '2000000000000000').
     # threshold_limit     Recoverable error threshold limit (e.g. '1', '5', '32').
 
     Delete Error Logs
@@ -207,8 +194,7 @@
 
     ${threshold_limit}=  Convert To Integer  ${threshold_limit}
     :FOR  ${count}  IN RANGE  ${threshold_limit}
-    \  BMC Putscom  0  ${fir}
-    ...  ${chip_address}
+    \  Pdbg  -p0 putscom 0x${fir_address} 0x${value}
     # Adding delay after each error injection.
     \  Sleep  10s
     # Adding delay to get error log after error injection.
@@ -223,10 +209,10 @@
     ...              2. Clear any existing gard records.
     ...              3. Power off HOST and Boot.
     ...              4. Inject Error on processor through BMC.
-    [Arguments]      ${fir}  ${chip_address}
+    [Arguments]      ${fir_address}  ${value}
     # Description of argument(s):
-    # fir                 FIR (Fault isolation register) value (e.g. '2011400').
-    # chip_address        Chip address (e.g. '2000000000000000').
+    # fir_address    FIR (Fault isolation register) value (e.g. '2011400').
+    # value          (e.g. '2000000000000000').
 
     Delete Error Logs
 
@@ -244,7 +230,7 @@
     ...  Shell Cmd  grep 'ISTEP *14' ${EXECDIR}/esol.log  quiet=1
     ...  print_output=0  show_err=0  ignore_err=0
 
-    BMC Putscom  0  ${fir}  ${chip_address}
+    Pdbg  -p0 putscom 0x${fir_address} 0x${value}
     # Adding delay to get error log after error injection.
     Sleep  10s
 
diff --git a/lib/ras/variables.py b/lib/ras/variables.py
index 538403f..4525ef3 100644
--- a/lib/ras/variables.py
+++ b/lib/ras/variables.py
@@ -83,3 +83,6 @@
 # Address translation files
 probe_cpu_file_path = '/root/probe_cpus.sh'
 addr_translation_file_path = '/root/scom_addr_p9.sh'
+
+cfam_address = "2801"
+mem_address = "8208000"
diff --git a/lib/utils.py b/lib/utils.py
index 2443bdd..0049cca 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -360,3 +360,21 @@
 
     out_buf, stderr, rc = bsu.os_execute_command('cat /etc/os-release')
     return vf.key_value_outbuf_to_dict(out_buf, delim="=", strip='"')
+
+
+def pdbg(option_string, **bsu_options):
+    r"""
+    Run pdbg on the BMC with the caller's option string and return the output.
+
+    Description of argument(s):
+    option_string                   A string of options which are to be processed by the pdbg command.
+    bsu_options                     Options to be passed directly to bmc_execute_command.  See its prolog for
+                                    details.
+    """
+
+    # Default print_out to 1.
+    if 'print_out' not in bsu_options:
+        bsu_options['print_out'] = 1
+
+    stdout, stderr, rc = bsu.bmc_execute_command('pdbg ' + option_string, **bsu_options)
+    return stdout