Library to get FIR address translation through HOST OS.

Resolves openbmc/openbmc-test-automation#1033

Change-Id: I33501fc9ba4a12b289096820f14874a50566c38c
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/extended/test_host_ras.robot b/extended/test_host_ras.robot
index c002c63..8f6c0de 100755
--- a/extended/test_host_ras.robot
+++ b/extended/test_host_ras.robot
@@ -11,6 +11,8 @@
 
 Library             DateTime
 Library             OperatingSystem
+Library             random
+Library             Collections
 
 Suite Setup         RAS Suite Setup
 Test Setup          RAS Test Setup
@@ -44,7 +46,6 @@
     Inject Recoverable Error With Threshold Limit Through Host
     ...  ${value[0]}  ${value[1]}  32  ${value[2]}  ${err_log_path}
 
-
 Verify Unrecoverable Callout Handling For MCA
     [Documentation]  Verify unrecoverable callout handling for MCACALIFIR.
     [Tags]  Verify_Unrecoverable_Callout_Handling_For_MCA
@@ -76,6 +77,15 @@
     ...  ${value[0]}  ${value[1]}  1  ${value[2]}  ${err_log_path}
 
 
+Verify Unrecoverable Callout Handling For NXDMAENG
+    [Documentation]  Verify unrecoverable callout handling for NXDMAENG.
+    [Tags]  Verify_Unrecoverable_Callout_Handling_For_NXDMAENG
+
+    ${value}=  Get From Dictionary  ${ERROR_INJECT_DICT}  NX_UE
+    ${err_log_path}=  Catenate  ${RAS_LOG_DIR_PATH}nxfir_ue
+    Inject Unrecoverable Error Through Host
+    ...  ${value[0]}  ${value[1]}  1  ${value[2]}  ${err_log_path}
+
 # CAPP accelerator (CXAFIR) related error injection.
 
 Verify Recoverable Callout Handling For CXA With Threshold 5
@@ -162,9 +172,9 @@
     ...              1. Boot To HOST
     ...              2. Clear any existing gard records
     ...              3. Inject Error on processor/centaur
-    [Arguments]      ${fri}  ${chip_address}  ${threshold_limit}
+    [Arguments]      ${fir}  ${chip_address}  ${threshold_limit}
     # Description of argument(s):
-    # fri                 FRI value (e.g. 2011400).
+    # fir                 FIR (Fault isolation register) value (e.g. 2011400).
     # chip_address        chip address (e.g 2000000000000000).
     # threshold_limit     Threshold limit (e.g 1, 5, 32).
 
@@ -173,13 +183,13 @@
     Gard Operations On OS  clear all
 
     # Fetch processor chip IDs.
-    ${chip_ids}=  Get ChipID From OS  Processor
+    ${chip_ids}=  Get ProcChipId From OS  Processor
     ${proc_ids}=  Split String  ${chip_ids}
     ${proc_id}=  Get From List  ${proc_ids}  1
 
     ${threshold_limit}=  Convert To Integer  ${threshold_limit}
     :FOR  ${i}  IN RANGE  ${threshold_limit}
-    \  Run Keyword  Putscom Through OS  ${proc_id}  ${fri}  ${chip_address}
+    \  Run Keyword  Putscom Operations On OS  ${proc_id}  ${fir}  ${chip_address}
     # Adding delay after each error injection.
     \  Sleep  10s
     # Adding delay to get error log after error injection.
@@ -188,7 +198,6 @@
 Verify And Clear Gard Records On HOST
     [Documentation]  Verify And Clear gard records on HOST.
 
-    Login To OS Host
     ${output}=  Gard Operations On OS  list
     Should Not Contain  ${output}  'No GARD entries to display'
     Gard Operations On OS  clear all
@@ -218,17 +227,17 @@
     ...              3. Check If HOST is running.
     ...              4. Verify error log entry & signature description.
     ...              4. Verify & clear gard records.
-    [Arguments]      ${fri}  ${chip_address}  ${threshold_limit}
+    [Arguments]      ${fir}  ${chip_address}  ${threshold_limit}
     ...              ${signature_desc}  ${log_prefix}
     # Description of argument(s):
-    # fri                 FRI(Fault isolation register) value (e.g. 2011400).
+    # fir                 FIR (Fault isolation register) value (e.g. 2011400).
     # chip_address        Chip address (e.g 2000000000000000).
     # threshold_limit     Threshold limit (e.g 1, 5, 32).
     # signature_desc      Error log signature description.
     # log_prefix          Log path prefix.
 
     Set Auto Reboot  1
-    Inject Error Through HOST  ${fri}  ${chip_address}  ${threshold_limit}
+    Inject Error Through HOST  ${fir}  ${chip_address}  ${threshold_limit}
     Is Host Running
     ${output}=  Gard Operations On OS  list
     Should Contain  ${output}  No GARD
@@ -244,10 +253,10 @@
     ...              3. Check If HOST is rebooted.
     ...              4. Verify error log entry & signature description.
     ...              4. Verify & clear gard records.
-    [Arguments]      ${fri}  ${chip_address}  ${threshold_limit}
+    [Arguments]      ${fir}  ${chip_address}  ${threshold_limit}
     ...              ${signature_desc}  ${log_prefix}
     # Description of argument(s):
-    # fri                 FRI value (e.g. 2011400).
+    # fir                 FIR (Fault isolation register) value (e.g. 2011400).
     # chip_address        Chip address (e.g 2000000000000000).
     # threshold_limit     Threshold limit (e.g 1, 5, 32).
     # signature_desc      Error Log signature description.
@@ -255,12 +264,34 @@
     # log_prefix          Log path prefix.
 
     Set Auto Reboot  1
-    Inject Error Through HOST  ${fri}  ${chip_address}  ${threshold_limit}
+    Inject Error Through HOST  ${fir}  ${chip_address}  ${threshold_limit}
     Wait Until Keyword Succeeds  500 sec  20 sec  Is Host Rebooted
     Wait for OS
     Verify And Clear Gard Records On HOST
     Verify Error Log Entry  ${signature_desc}  ${log_prefix}
 
+Fetch FIR Address Translation Value
+    [Documentation]  Fetch FIR address translation value through HOST.
+    [Arguments]  ${proc_chip_id}  ${fir}  ${target_type}
+    # Description of argument(s):
+    # proc_chip_id      Processor chip ID (e.g '0', '8').
+    # fir               FIR (Fault isolation register) value (e.g. 2011400).
+    # core_id           Core ID (e.g. 9).
+    # target_type       Target type (e.g. 'EX', 'EQ', 'C').
+
+    Login To OS Host
+    Copy Address Translation Utils To HOST OS
+
+    ${core_ids}=  Get Core IDs From OS  0
+    # Ignoring master core ID.
+    ${output}=  Get Slice From List  ${core_ids}  1
+    # Feth random non-master core ID.
+    ${core_ids_sub_list}=   Evaluate  random.sample(${core_ids}, 1)  random
+    ${core_id}=  Get From List  ${core_ids_sub_list}  0
+    ${translated_fir_addr}=  FIR Address Translation Through HOST
+    ...  ${fir}  ${core_id}  ${target_type}
+
+    [Return]  ${translated_fir_addr}
 
 RAS Test SetUp
     [Documentation]  Validates input parameters.
@@ -273,8 +304,9 @@
     ...  ${OS_PASSWORD}  msg=You must provide OS host user password.
 
     # Boot to OS.
-
     REST Power On  quiet=${1}
+    # Adding delay to after host bring up.
+    Sleep  60s
 
 RAS Suite Setup
     [Documentation]  Create RAS log directory to store all RAS test logs.
@@ -292,5 +324,4 @@
     # Boot to OS.
     REST Power On  quiet=${1}
     Delete Error Logs
-    Login To OS Host
     Gard Operations On OS  clear all