Update v2.0-stable branch to work with new robot package 3.x version

Change-Id: I52262e13ce2450ce5dae81f56cf5079017238072
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/extended/test_association.robot b/extended/test_association.robot
index e988caf..e7446bc 100755
--- a/extended/test_association.robot
+++ b/extended/test_association.robot
@@ -8,7 +8,7 @@
 Resource            ../lib/boot_utils.robot
 
 Test Setup          Test Setup Execution
-Test Teardown       Close All Connections
+Test Teardown       FFDC On Test Case Fail
 
 ***Variables***
 ${target_device_path}  /sys/devices/platform/gpio-fsi/fsi0/slave@00:00/raw
@@ -41,8 +41,9 @@
     ${elog_entry}=  Get Elog URL List
     ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
     ${jsondata}=  To JSON  ${resp.content}
-    Should Contain  ${jsondata}["data"]["AdditionalData"]}  ${target_device_path}
-    Should Contain  ${jsondata}["data"]["AdditionalData"]}  0x0DEADEAD
+    List Should Contain Value
+    ...  ${jsondata["data"]["AdditionalData"]}  CALLOUT_DEVICE_PATH_TEST=${target_device_path}
+    List Should Contain Value  ${jsondata["data"]["AdditionalData"]}  DEV_ADDR=0x0DEADEAD
 
 
 Create Test Error Callout And Verify Associations
@@ -62,10 +63,10 @@
     ${elog_entry}=  Get Elog URL List
     ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
     ${jsondata}=  To JSON  ${resp.content}
-    List Should Contain Value  ${jsondata}["data"]["associations"]}  callout
-    List Should Contain Value  ${jsondata}["data"]["associations"]}  fault
+    List Should Contain Value  ${jsondata["data"]["associations"][0]}  callout
+    List Should Contain Value  ${jsondata["data"]["associations"][0]}  fault
     List Should Contain Value
-    ...  ${jsondata}["data"]["associations"]}
+    ...  ${jsondata["data"]["associations"][0]}
     ...  /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
 
 
@@ -193,7 +194,7 @@
     ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
     ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
     ${jsondata}=  To JSON  ${resp.content}
-    Should Contain  ${jsondata}["data"]["AdditionalData"]  callout
+    Should Contain  ${jsondata["data"]["associations"][0]}  callout
 
     # Set the error log field "Resolved".
     # By doing so, the callout object should get deleted automatically.
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 4f6e0f2..267e1a7 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -200,7 +200,7 @@
     Set Global Variable  ${arrayByte}   array:byte:
     @{listargs}=   Split String  ${args}
     ${index}=   Set Variable   ${0}
-    :FOR   ${word}   in   @{listargs}
+    :FOR  ${word}  IN  @{listargs}
     \    Run Keyword if   ${index} == 0   Set NetFn Byte  ${word}
     \    Run Keyword if   ${index} == 1   Set Cmd Byte    ${word}
     \    Run Keyword if   ${index} > 1    Set Array Byte  ${word}
diff --git a/lib/utils.robot b/lib/utils.robot
index 8f6db0b..f73a7a3 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -899,21 +899,21 @@
 
 Check BMC CPU Performance
     [Documentation]   Minimal 10% of proc should be free in 3 sample
-    :FOR  ${var}  IN Range  1  4
+    :FOR  ${var}  IN RANGE  1  4
     \     BMC CPU Performance check
 
 
 Check BMC Mem Performance
     [Documentation]   Minimal 10% of memory should be free
 
-    :FOR  ${var}  IN Range  1  4
+    :FOR  ${var}  IN RANGE  1  4
     \     BMC Mem Performance check
 
 
 Check BMC File System Performance
     [Documentation]  Check for file system usage for 4 times
 
-    :FOR  ${var}  IN Range  1  4
+    :FOR  ${var}  IN RANGE  1  4
     \     BMC File System Usage check
 
 
@@ -952,11 +952,10 @@
     # For a given string, look for prefix and suffix for matching expression.
     # Start of string followed by zero or more of any character followed by
     # any digit or lower case character.
-    ${resp}=  Get Matches  ${list}  regexp=^.*[0-9a-z_].${endpoint}[0-9a-z]*$
+    ${resp}=  Get Matches  ${list}  regexp=^.*[0-9a-z_].${endpoint}\[0-9a-z]*$
 
     [Return]  ${resp}
 
-
 Check Zombie Process
     [Documentation]    Check if any defunct process exist or not on BMC
     ${count}  ${stderr}  ${rc}=  Execute Command  ps -o stat | grep Z | wc -l
diff --git a/tests/ipmi/test_fru.robot b/tests/ipmi/test_fru.robot
index ed8cc56..10eb793 100644
--- a/tests/ipmi/test_fru.robot
+++ b/tests/ipmi/test_fru.robot
@@ -43,7 +43,7 @@
     # From the inventory_uris, select just the ones for the component of
     # interest.
     ${component_uris}=  Get Matches  ${inventory_uris}
-    ...  regexp=^.*[0-9a-z_].${component_name}[0-9]*$
+    ...  regexp=^.*[0-9a-z_].${component_name}\[0-9]*$
 
     # Get the component information for each record.
     ${component_frus}=  Create List
@@ -123,7 +123,7 @@
     #     /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
     #     /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1
     ${component_uris}=  Get Matches  ${inventory_uris}
-    ...  regexp=^.*[0-9a-z_].${component_name}[0-9]*$
+    ...  regexp=^.*[0-9a-z_].${component_name}\[0-9]*$
 
     : FOR  ${uri}  IN  @{component_uris}
     \  ${sub_component}=  Fetch From Right  ${uri}  /
@@ -166,9 +166,12 @@
     : FOR  ${rest_fru_sub_component}  IN  @{fru_component_info}
     \  ${fru_component_section}=
     \  ...  Get From List  ${fru_component_info}  ${index}
-    \  ${status}=  Run Keyword And Return Status  Should Contain
-    \  ...  ${fru_component_section['fru_device_description']}
-    \  ...  ${sub_component}
+    \  # Get FRU name from IPMI's fru_device_description field.
+    \  # Example "cpu0" from "cpu0 (ID 1)".
+    \  ${fru_name}=  Fetch From Left
+    \  ...  ${fru_component_section['fru_device_description']}  ${SPACE}
+    \  ${status}=  Run Keyword And Return Status  Should Be Equal
+    \  ...  ${fru_name}  ${sub_component}
     \  Exit For Loop If  '${status}' == '${True}'
     \  ${index}=  Evaluate  ${index} + 1
     \  Exit For Loop If  ${index} >= ${sub_component_count}
diff --git a/tests/ipmi/test_sdr.robot b/tests/ipmi/test_sdr.robot
index b70d0d1..cd6ed0f 100755
--- a/tests/ipmi/test_sdr.robot
+++ b/tests/ipmi/test_sdr.robot
@@ -130,7 +130,7 @@
     # uri_list          URI list.
 
     ${component_uris}=  Get Matches  ${uri_list}
-    ...  regexp=^.*[0-9a-z_].${component_name}[0-9]*$
+    ...  regexp=^.*[0-9a-z_].${component_name}\[0-9]*$
     [Return]  ${component_uris}
 
 
diff --git a/tests/test_inventory.robot b/tests/test_inventory.robot
index 00985a2..eff05c1 100644
--- a/tests/test_inventory.robot
+++ b/tests/test_inventory.robot
@@ -695,7 +695,7 @@
     # item  Inventory name (example: "fan/cpu/dimm/etc").
 
     ${count_inventory}  Set Variable  ${0}
-    ${list}=  Get Endpoint Paths  ${HOST_INVENTORY_URI}/system/
+    ${list}=  Get Endpoint Paths  ${HOST_INVENTORY_URI}system/
     ...  ${item}
 
     : FOR  ${element}  IN  @{list}