Core and FRU functional state validation

If "core" and FRU property "Functional" state is set then the
"Present" property should also be set.

Resolves openbmc/openbmc-test-automation#416

Change-Id: I00d7057d580f18c7c9d2ddd2ab1f14dd1150a204
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/tests/test_inventory.robot b/tests/test_inventory.robot
index 5937a1c..841ac30a 100644
--- a/tests/test_inventory.robot
+++ b/tests/test_inventory.robot
@@ -142,6 +142,55 @@
     ${fru_list}=  Qualified FRU List  @{system_list}
     Validate FRU Properties Fields  @{fru_list}
 
+
+Verify Core Functional State
+    [Documentation]  Verify that "Present" core property is set if "Functional"
+    ...              core property is set.
+    [Tags]  Verify_Core_Functional_State
+    # Example:
+    #  "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core5":{
+    #    "Functional": 1,
+    #    "Present": 1,
+    #    "PrettyName": ""
+    # },
+    ${core_list}=  Get Endpoint Paths  ${HOST_INVENTORY_URI}system  core
+    :FOR  ${core_uri}  IN  @{core_list}
+    \  ${status}=  Run Keyword And Return Status
+    ...  Check URL Property If Functional  ${core_uri}
+    \  Continue For Loop If  '${status}' == '${True}'
+    \  ${present}=  Read Attribute  ${core_uri}  Present
+    \  Should Be True  ${present}
+    ...  msg=${core_uri} is functional but not present.
+
+
+Verify DIMM Functional State
+    [Documentation]  Verify that "Present" DIMM property is set if "Functional"
+    ...              DIMM property is set.
+    [Tags]  Verify_DIMM_Functional_State
+    # Example:
+    #   "/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0": {
+    #    "BuildDate": "",
+    #    "Cached": 0,
+    #    "FieldReplaceable": 1,
+    #    "Functional": 1,
+    #    "Manufacturer": "0xce80",
+    #    "Model": "M393A1G40EB1-CRC    ",
+    #    "PartNumber": "",
+    #    "Present": 1,
+    #    "PrettyName": "0x0c",
+    #    "SerialNumber": "0x0300cf4f",
+    #    "Version": "0x00"
+    # },
+
+    ${dimm_list}=  Get Endpoint Paths  ${HOST_INVENTORY_URI}system  dimm
+    :FOR  ${dimm_uri}  IN  @{dimm_list}
+    \  ${status}=  Run Keyword And Return Status
+    ...  Check URL Property If Functional  ${dimm_uri}
+    \  Continue For Loop If  '${status}' == '${True}'
+    \  ${present}=  Read Attribute  ${dimm_uri}  Present
+    \  Should Be True  ${present}
+    ...  msg=${dimm_uri} is functional but not present.
+
 *** Keywords ***
 
 Test Suite Setup
@@ -220,3 +269,13 @@
     # ------------------------------------------------------------
     \  Should Be Equal  ${fru_field.viewkeys()}  ${fru_set}
 
+
+Check URL Property If Functional
+    [Arguments]  ${url_path}
+    # Description of arguments:
+    # url_path  Full url path of the inventory object.
+    #           Example: DIMM / core property url's
+    # /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0
+    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core0
+    ${state}=  Read Attribute  ${url_path}  Functional
+    Should Be True  ${state}