Basic BMC Performance at BMC READY state

What this fix focusses are as follows:
   - BMC CPU performance at BMC ready state
   - BMC Memory performance at BMC ready state

Resolves openbmc/openbmc-test-automation#212

Change-Id: Idf1a06819e214533d7df373c39e3b0fde6882c0c
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/extended/code_update/update_bmc.robot b/extended/code_update/update_bmc.robot
index 92ceeb7..837980f 100644
--- a/extended/code_update/update_bmc.robot
+++ b/extended/code_update/update_bmc.robot
@@ -70,3 +70,9 @@
     Check If BMC is Up    30 min   10 sec
     Sleep  1 min
     Validate BMC Version
+    Wait Until Keyword Succeeds
+    ...    10 min   10 sec   Verify BMC State   BMC_READY
+
+Test BMC CPU Mem Performance at Ready State
+    Check BMC CPU Performance
+    Check BMC Mem Performance
diff --git a/lib/utils.robot b/lib/utils.robot
index 95c3b91..502fcb4 100644
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -21,6 +21,12 @@
 
 # Assign default value to QUIET for programs which may not define it.
 ${QUIET}  ${0}
+${dbuscmdBase} =    dbus-send --system --print-reply --dest=org.openbmc.settings.Host
+${dbuscmdGet} =   /org/openbmc/settings/host0  org.freedesktop.DBus.Properties.Get
+${dbuscmdString} =   string:"org.openbmc.settings.Host" string:
+${bmc_mem_free_cmd}=   free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
+${bmc_mem_total_cmd}=   free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
+${bmc_cpu_usage_cmd}=   top -n 1  | grep CPU: | cut -c 7-9
 
 *** Keywords ***
 Wait For Host To Ping
@@ -443,3 +449,40 @@
     \   ${index}=  Set Variable    ${index + 1}
     ${ip_hex}=  Catenate    @{ip}
     [return]    ${ip_hex}
+
+BMC CPU Performance Check
+   [Documentation]   Minimal 10% of proc should be free in this instance
+
+    ${bmc_cpu_usage_output}  ${stderr}=  Execute Command  ${bmc_cpu_usage_cmd}
+    ...                   return_stderr=True
+    Should be empty  ${stderr}
+    ${bmc_cpu_percentage}=  Fetch From Left  ${bmc_cpu_usage_output}  %
+    Should be true  ${bmc_cpu_percentage} < 90
+
+BMC Mem Performance Check
+    [Documentation]   Minimal 10% of memory should be free in this instance
+
+    ${bmc_mem_free_output}  ${stderr}=   Execute Command  ${bmc_mem_free_cmd}
+    ...                   return_stderr=True
+    Should be empty  ${stderr}
+
+    ${bmc_mem_total_output}  ${stderr}=   Execute Command  ${bmc_mem_total_cmd}
+    ...                   return_stderr=True
+    Should be empty  ${stderr}
+
+    ${bmc_mem_percentage}=   Evaluate  ${bmc_mem_free_output}*100
+    ${bmc_mem_percentage}=  Evaluate
+    ...   ${bmc_mem_percentage}/${bmc_mem_total_output}
+    Should be true  ${bmc_mem_percentage} > 10
+
+Check BMC CPU Performance
+    [Documentation]   Minimal 10% of proc should be free in 3 sample
+    :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
+    \     BMC Mem Performance check
+