Base energy scale (power) tests
Base tests that can be run against the BMC.
Resolves openbmc/openbmc-test-automation#1143
Change-Id: I9234b6dbe15f72bc02c9f94e525a477adb05e147
Signed-off-by: Steven Sombar <ssombar@us.ibm.com>
diff --git a/lib/energy_scale_utils.robot b/lib/energy_scale_utils.robot
index fdb9479..a2f85fd 100755
--- a/lib/energy_scale_utils.robot
+++ b/lib/energy_scale_utils.robot
@@ -53,7 +53,7 @@
Run External IPMI Standard Command ${cmd}
${power}= Get DCMI Power Limit
Should Be True ${power} == ${power_limit}
- ... msg=Faied setting dcmi power limit to ${power_limit} watts.
+ ... msg=Failed setting dcmi power limit to ${power_limit} watts.
Activate DCMI Power And Verify
diff --git a/tests/test_escale_base.robot b/tests/test_escale_base.robot
new file mode 100755
index 0000000..51e08eb
--- /dev/null
+++ b/tests/test_escale_base.robot
@@ -0,0 +1,107 @@
+*** Settings ***
+Documentation Energy scale base tests.
+
+
+# Test Parameters:
+# OPENBMC_HOST The BMC host name or IP address.
+
+
+Resource ../lib/energy_scale_utils.robot
+Resource ../lib/openbmc_ffdc.robot
+
+
+Suite Setup Suite Setup Execution
+Test Teardown Test Teardown Execution
+
+
+
+*** Variables ****
+
+${over_max_power} 3051
+${max_power} 3050
+${mid_power} 1950
+${min_power} 500
+${below_min_power} 499
+${zero_power} 0
+# The power limits are documented at
+# open-power/witherspoon-xml/master/witherspoon.xml.
+
+
+
+*** Test Cases ***
+
+
+Escale Base Test Inactive Monitoring
+ [Documentation] Run base power tests with DCMI power montoring off.
+ [Tags] Escale_Base_Test_Deactive_Monitoring
+
+ Deactivate DCMI Power And Verify
+ Verify Power Limits
+
+
+Escale Base Test Active Monitoring
+ [Documentation] Run base power tests with DCMI power montoring on.
+ [Tags] Escale_Base_Test_Active_Monitoring
+
+ Activate DCMI Power And Verify
+ Verify Power Limits
+
+
+
+*** Keywords ***
+
+
+Verify Power Limits
+ [Documentation] Set power levels and verify limits.
+
+ Set DCMI Power Limit And Verify ${mid_power}
+ Test Power Limit ${min_power} ${below_min_power}
+ Test Power Limit ${min_power} ${zero_power}
+ Test Power Limit ${max_power} ${over_max_power}
+
+
+Test Power Limit
+ [Documentation] Set power and check limit.
+ [Arguments] ${good_power} ${outside_bounds_power}
+
+ # Description of argument(s):
+ # good_power A valid power setting, usually at a limit.
+ # outside_bounds_power A power level that is beyond the limit.
+
+ Set DCMI Power Limit And Verify ${good_power}
+
+ # Try to set out of bounds.
+ ${expected_error}= Set Variable
+ ... Failed setting dcmi power limit to ${outside_bounds_power} watts.
+ Run Keyword and Expect Error ${expected_error}
+ ... Set DCMI Power Limit And Verify ${outside_bounds_power}
+
+
+Suite Setup Execution
+ [Documentation] Do test setup initialization.
+
+ # Save the deactivation/activation setting.
+ ${cmd}= Catenate dcmi power get_limit | grep State
+ ${resp}= Run External IPMI Standard Command ${cmd}
+ # Response is either "Power Limit Active" or "No Active Power Limit".
+ ${initial_deactivation}= Get Count ${resp} No
+ # If deactivated: initial_deactivation = 1, 0 otherwise.
+ Set Suite Variable ${initial_deactivation} children=true
+
+ # Save the power limit setting.
+ ${initial_power_setting}= Get DCMI Power Limit
+ Set Suite Variable ${initial_power_setting} children=true
+
+
+Test Teardown Execution
+ [Documentation] Do the post test teardown.
+
+ FFDC On Test Case Fail
+
+ # Restore the system's intial power limit setting.
+ Run Keyword If '${initial_power_setting}' != '${0}'
+ ... Set DCMI Power Limit And Verify ${initial_power_setting}
+
+ # Restore the system's intial deactivation/activation setting.
+ Run Keyword If '${initial_deactivation}' == '${1}'
+ ... Deactivate DCMI Power And Verify ELSE Activate DCMI Power And Verify