To overcome IPMItool dependency

Resolves  openbmc/openbmc-test-automation#40

Change-Id: I136b2c6303d4c977d320dc1976e710031f174499
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index 572c901..accfdbb 100644
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -7,6 +7,9 @@
 
 *** Variables ***
 ${SYSTEM_SHUTDOWN_TIME}       ${5}
+${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:
 
 *** Keywords ***
 Wait For Host To Ping
@@ -211,3 +214,10 @@
     [Documentation]   Removes all the active session objects
     Delete All Sessions
 
+Initialize DBUS cmd
+    [Documentation]  Initialize dbus string with property string to extract
+    [arguments]   ${boot_property}
+    ${cmd} =     Catenate  ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString}
+    ${cmd} =     Catenate  ${cmd}${boot_property}
+    Set Global Variable   ${dbuscmd}     ${cmd}
+
diff --git a/tests/test_boot.robot b/tests/test_boot.robot
index 8eb52c2..d48d540 100644
--- a/tests/test_boot.robot
+++ b/tests/test_boot.robot
@@ -2,153 +2,167 @@
 
 Documentation   This testsuite is for testing the Boot Device Functions
 
-Resource          ../lib/rest_client.robot
-Resource          ../lib/ipmi_client.robot
-Resource          ../lib/openbmc_ffdc.robot
+Resource        ../lib/rest_client.robot
+Resource        ../lib/ipmi_client.robot
+Resource        ../lib/openbmc_ffdc.robot
 
-Suite Setup       Open Connection And Log In
-Suite Teardown    Close All Connections
-Test Teardown     Log FFDC
+Suite Setup     Open Connection And Log In
+Suite Teardown  Close All Connections
+Test Setup      Initialize DBUS cmd   "boot_flags"
+Test Teardown   Log FFDC
+*** Variables ***
 
 *** Test Cases ***
 
 Set the Boot Device as Default using REST API
    [Documentation]   This testcase is to set the boot device as Default using REST
    ...               URI. The Boot device is read using REST API and ipmitool.
-   
+
     ${bootDevice} =   Set Variable   Default
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
     Read the Attribute  /org/openbmc/settings/host0    boot_flags
     Response Should Be Equal   Default
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   No override
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   Default
+
 Set the Boot Device as Default using ipmitool
    [Documentation]   This testcase is to set the boot device as Default using
    ...               ipmitool. The Boot device is read using REST API and
    ...               ipmitool.
-   
+
     Run IPMI command   0x0 0x8 0x05 0x80 0x00 0x00 0x00 0x00
     Read the Attribute   /org/openbmc/settings/host0   boot_flags
     Response Should Be Equal   Default
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   No override
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   Default
+
 Set the Boot Device as Network using REST API
    [Documentation]   This testcase is to set the boot device as Network using REST
    ...               URI. The Boot device is read using REST API and ipmitool.
-   
+
     ${bootDevice} =   Set Variable   Network
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
     Read the Attribute  /org/openbmc/settings/host0    boot_flags
     Response Should Be Equal   Network
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force PXE
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}   return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}    Network
+
 Set the Boot Device as Network using ipmitool
    [Documentation]   This testcase is to set the boot device as Network using
    ...               ipmitool. The Boot device is read using REST API and
    ...               ipmitool.
-   
+
     Run IPMI command   0x0 0x8 0x05 0x80 0x04 0x00 0x00 0x00
     Read the Attribute   /org/openbmc/settings/host0   boot_flags
     Response Should Be Equal   Network
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force PXE
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}    Network
+
 Set the Boot Device as Disk using REST API
    [Documentation]   This testcase is to set the boot device as Disk using REST
    ...               URI. The Boot device is read using REST API and ipmitool.
-   
+
     ${bootDevice} =   Set Variable   Disk
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
     Read the Attribute  /org/openbmc/settings/host0    boot_flags
     Response Should Be Equal   Disk
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot from default Hard-Drive
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}    Disk
+
 Set the Boot Device as Disk using ipmitool
    [Documentation]   This testcase is to set the boot device as Disk using
    ...               ipmitool. The Boot device is read using REST API and
    ...               ipmitool.
-   
+
     Run IPMI command   0x0 0x8 0x05 0x80 0x08 0x00 0x00 0x00
     Read the Attribute   /org/openbmc/settings/host0   boot_flags
     Response Should Be Equal   Disk
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot from default Hard-Drive
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}    Disk
+
 Set the Boot Device as Safe using REST API
    [Documentation]   This testcase is to set the boot device as Safe using REST
    ...               URI. The Boot device is read using REST API and ipmitool.
-   
+
     ${bootDevice} =   Set Variable   Safe
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
     Read the Attribute  /org/openbmc/settings/host0    boot_flags
     Response Should Be Equal   Safe
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot from default Hard-Drive, request Safe-Mode
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   Safe
+
 Set the Boot Device as Safe using ipmitool
    [Documentation]   This testcase is to set the boot device as Safe using
    ...               ipmitool. The Boot device is read using REST API and
    ...               ipmitool.
-   
+
     Run IPMI command   0x0 0x8 0x05 0x80 0x0C 0x00 0x00 0x00
     Read the Attribute   /org/openbmc/settings/host0   boot_flags
     Response Should Be Equal   Safe
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot from default Hard-Drive, request Safe-Mode
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}   return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   Safe
 
 Set the Boot Device as CDROM using REST API
    [Documentation]   This testcase is to set the boot device as CDROM using REST
    ...               URI. The Boot device is read using REST API and ipmitool.
-   
+
     ${bootDevice} =   Set Variable   CDROM
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
     Read the Attribute  /org/openbmc/settings/host0    boot_flags
     Response Should Be Equal   CDROM
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot from CD/DVD
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   CDROM
+
 Set the Boot Device as CDROM using ipmitool
    [Documentation]   This testcase is to set the boot device as CDROM using
    ...               ipmitool. The Boot device is read using REST API and
    ...               ipmitool.
-   
+
     Run IPMI command   0x0 0x8 0x05 0x80 0x14 0x00 0x00 0x00
     Read the Attribute   /org/openbmc/settings/host0   boot_flags
     Response Should Be Equal   CDROM
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot from CD/DVD
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   CDROM
+
 Set the Boot Device as Setup using REST API
    [Documentation]   This testcase is to set the boot device as Setup using REST
    ...               URI. The Boot device is read using REST API and ipmitool.
-   
+
     ${bootDevice} =   Set Variable   Setup
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
     Read the Attribute  /org/openbmc/settings/host0    boot_flags
     Response Should Be Equal   Setup
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot into BIOS Setup
-    
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   Setup
+
 Set the Boot Device as Setup using ipmitool
    [Documentation]   This testcase is to set the boot device as Setup using
    ...               ipmitool. The Boot device is read using REST API and
    ...               ipmitool.
-   
+
     Run IPMI command   0x0 0x8 0x05 0x80 0x18 0x00 0x00 0x00
     Read the Attribute   /org/openbmc/settings/host0   boot_flags
     Response Should Be Equal   Setup
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Force Boot into BIOS Setup
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}   return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}   Setup
 
 *** Keywords ***
 
@@ -156,8 +170,9 @@
     [arguments]    ${args}
     Should Be Equal    ${OUTPUT}    ${args}
 
-Read the Attribute     
+Read the Attribute
     [arguments]    ${uri}    ${parm}
     ${output} =     Read Attribute      ${uri}    ${parm}
     set test variable    ${OUTPUT}     ${output}
 
+
diff --git a/tests/test_bootpolicy.robot b/tests/test_bootpolicy.robot
index 32e2477..bc635a6 100644
--- a/tests/test_bootpolicy.robot
+++ b/tests/test_bootpolicy.robot
@@ -5,10 +5,11 @@
 Resource           ../lib/rest_client.robot
 Resource           ../lib/ipmi_client.robot
 Resource           ../lib/utils.robot
-Resource          ../lib/openbmc_ffdc.robot
+Resource           ../lib/openbmc_ffdc.robot
 
 Suite Setup        Open Connection And Log In
 Suite Teardown     Close All Connections
+Test Setup         Initialize DBUS cmd   "boot_policy"
 Test Teardown      Log FFDC
 
 *** Variables ***
@@ -23,8 +24,9 @@
 
     ${boot} =   Read Attribute  /org/openbmc/settings/host0    boot_policy
     Should Be Equal    ${boot}    ONETIME
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Options apply to only next boot
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}    ONETIME
 
 Set Permanent boot policy using REST
     [Documentation]   This testcase is to set permanent boot policy using REST
@@ -34,8 +36,9 @@
 
     ${boot} =   Read Attribute  /org/openbmc/settings/host0    boot_policy
     Should Be Equal    ${boot}    PERMANENT
-    ${output} =    Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Options apply to all future boots
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}     PERMANENT
 
 Set Onetime boot policy using IPMITOOL
     [Documentation]   This testcase is to set boot policy to onetime boot using ipmitool
@@ -44,8 +47,9 @@
     Run IPMI command   0x0 0x8 0x05 0x80 0x00 0x00 0x00 0x00
     ${boot} =   Read Attribute  /org/openbmc/settings/host0    boot_policy
     Should Be Equal    ${boot}    ONETIME
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Options apply to only next boot
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}    ONETIME
 
 Set Permanent boot policy using IPMITOOL
     [Documentation]   This testcase is to set boot policy to permanent using ipmitool
@@ -54,8 +58,9 @@
     Run IPMI command   0x0 0x8 0x05 0xC0 0x00 0x00 0x00 0x00
     ${boot} =   Read Attribute  /org/openbmc/settings/host0    boot_policy
     Should Be Equal    ${boot}    PERMANENT
-    ${output} =   Run IPMI Standard command   chassis bootparam get 5
-    Should Contain   ${output}   Options apply to all future boots
+    ${output}   ${stderr}=  Execute Command  ${dbuscmd}  return_stderr=True
+    Should Be Empty     ${stderr}
+    Should Contain   ${output}     PERMANENT
 
 Boot order with permanent boot policy
     [Documentation]   This testcase is to verify that boot order does not change
@@ -137,3 +142,6 @@
     ${bootDevice} =   Set Variable   ${args}
     ${valueDict} =   create dictionary   data=${bootDevice}
     Write Attribute    /org/openbmc/settings/host0   boot_flags   data=${valueDict}
+
+
+