1*** Settings ***
2
3Documentation  Compare processor speed in turbo and non-turbo modes.
4
5# Test Parameters:
6# OPENBMC_HOST   The BMC host name or IP address.
7# OS_HOST        The OS host name or IP Address.
8# OS_USERNAME    The OS login userid (usually root).
9# OS_PASSWORD    The password for the OS login.
10
11Resource        ../syslib/utils_os.robot
12Resource        ../lib/boot_utils.robot
13Library         ../syslib/utils_keywords.py
14Variables       ../data/variables.py
15Library         ../lib/bmc_ssh_utils.py
16Resource        ../lib/connection_client.robot
17Resource        ../lib/resource.txt
18Resource        ../lib/rest_client.robot
19Resource        ../lib/utils.robot
20
21
22Test Setup      Pre Test Case Execution
23Test Teardown   Post Test Case Execution
24
25
26*** Test Cases ***
27
28Turbo And Non-Turbo Processor Speed Test
29    [Documentation]  Compare processor turbo and non-turbo speeds.
30    [Tags]  Turbo_And_Non-Turbo_Processor_Speed_Test
31
32    Set Turbo Setting Via REST  True
33    ${mode}=  Read Turbo Setting Via REST
34    Should Be Equal  ${mode}  True
35    ...  msg=Issued call to set Turbo mode but it was not set.
36
37    # The OS governor determines the maximum processor speed at boot-up time.
38    REST Power On  stack_mode=skip
39    ${proc_speed_turbo}=  Get Processor Max Speed Setting
40
41    Smart Power Off
42
43    Set Turbo Setting Via REST  False
44    ${mode}=  Read Turbo Setting Via REST
45    Should Be Equal  ${mode}  False
46    ...  msg=Issued call to disable Turbo mode but it was not disabled.
47
48    REST Power On  stack_mode=skip
49    ${proc_speed_non_turbo}=  Get Processor Max Speed Setting
50
51    Rprintn
52    Rpvars  proc_speed_turbo  proc_speed_non_turbo
53
54    ${err_msg}=  Catenate  Reported turbo processor speed should be
55    ...  greater than non-turbo speed.
56    Should Be True  ${proc_speed_turbo} > ${proc_speed_non_turbo}
57    ...  msg=${err_msg}
58
59
60*** Keywords ***
61
62Get Processor Max Speed Setting
63    [Documentation]  Get processor maximum speed setting from the OS.
64    # - On the OS run: ppc64_cpu --frequency
65    # - Return the maximum frequency value reported.
66    # The command ppc64_cpu is provided in both Ubuntu and RHEL on Power.
67
68    ${command}=  Set Variable
69    ...  ppc64_cpu --frequency | grep max | cut -f 2 | cut -d ' ' -f 1
70    # The ppc64_cpu --frequency command returns min, max, and average
71    # cpu frequencies. For example,
72    # min:    2.500 GHz (cpu 143)
73    # max:    2.700 GHz (cpu 1)
74    # avg:    2.600 GHz
75    # The ${command} selects the max: line, selects only the
76    # 2.700 GHz (cpu 1) part, then selects the 2.700 number.
77
78    # Get the maximum processor frequency reported.
79    ${output}  ${stderr}  ${rc}=  OS Execute Command
80    ...  ${command}  print_out=${1}
81
82    ${frequency}=  Convert To Number  ${output}
83    [Return]  ${frequency}
84
85
86Pre Test Case Execution
87    [Documentation]  Do the pre test setup.
88    # Save the initial system turbo setting.
89    # Start (setup) console logging.
90
91    ${initial_turbo_setting}=  Read Turbo Setting Via REST
92    Set Suite Variable  ${initial_turbo_setting}  children=true
93    Start SOL Console Logging
94
95
96Post Test Case Execution
97    [Documentation]  Do the post test teardown.
98    # - Restore original turbo setting on the system.
99    # - Capture FFDC on test failure.
100    # - Power off the OS and close all open SSH connections.
101
102    Set Turbo Setting Via REST  ${initial_turbo_setting}
103
104    FFDC On Test Case Fail
105    Smart Power Off
106    Close All Connections
107