1*** Settings ***
2Documentation  Test IPMI sensor IDs.
3
4Resource               ../../lib/rest_client.robot
5Resource               ../../lib/ipmi_client.robot
6Resource               ../../lib/openbmc_ffdc.robot
7Resource               ../../lib/boot_utils.robot
8Resource               ../../lib/bmc_redfish_resource.robot
9
10Suite setup             Suite Setup Execution
11Suite Teardown          Redfish.Logout
12Test Teardown           Test Teardown Execution
13
14Force Tags              SDR_Test
15
16
17*** Test Cases ***
18
19Test Turbo Allowed SDR Info
20    [Documentation]  Verify turbo allowed SDR info via IPMI and Redfish.
21    [Tags]  Test_Turbo_Allowed_SDR_Info
22
23    ${component_uri_list}=  Get Component URIs  turbo_allowed
24    ${component_uri}=  Get From List  ${component_uri_list}  0
25    ${state_rest}=  Read Attribute  ${component_uri}  TurboAllowed
26
27    ${state_ipmi}=  Get SDR Presence Via IPMI  turbo_allowed${SPACE}
28
29    Run Keyword If  '${state_ipmi}' == 'Disabled'
30    ...    Should Be True  ${state_rest} == ${0}
31    ...  ELSE IF  '${state_ipmi}' == 'State Asserted'
32    ...    Should Be True  ${state_rest} == ${1}
33
34
35*** Keywords ***
36
37Get Component URIs
38    [Documentation]  Get URIs for given component from given URIs
39    ...  and return as a list.
40    [Arguments]  ${component_name}  ${uri_list}=${SYSTEM_URI}
41
42    # A sample result returned for the "core" component:
43    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core0
44    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core1
45    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core10
46    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core11
47    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core12
48    # (etc.)
49
50    # Description of argument(s):
51    # component_name    Component name (e.g. "core", "dimm", etc.).
52    # uri_list          URI list.
53
54    ${component_uris}=  Get Matches  ${uri_list}
55    ...  regexp=^.*[0-9a-z_].${component_name}\[_0-9a-z]*$
56    ...  case_insensitive=${True}
57    [Return]  ${component_uris}
58
59
60Get SDR Presence Via IPMI
61    [Documentation]  Return presence info from IPMI sensor data record.
62    [Arguments]  ${component_name}
63
64    # Description of argument(s):
65    # component_name    Component name (e.g. "cpu0_core0", "dimm0", etc.).
66
67    # Example of IPMI SDR elist output.
68    # BootProgress     | 03h | ok  | 34.2 |
69    # OperatingSystemS | 05h | ok  | 35.1 | boot completed - device not specified
70    # AttemptsLeft     | 07h | ok  | 34.1 |
71    # occ0             | 08h | ok  | 210.1 | Device Disabled
72    # occ1             | 09h | ok  | 210.2 | Device Disabled
73    # cpu0_core0       | 12h | ok  | 208.1 | Presence detected
74    # cpu0_core1       | 15h | ok  | 208.2 | Disabled
75    # cpu0_core2       | 18h | ok  | 208.3 | Presence detected
76    # dimm0            | A6h | ok  | 32.1 | Presence Detected
77    # dimm1            | A8h | ok  | 32.2 | Presence Detected
78    # dimm2            | AAh | ok  | 32.9 | Presence Detected
79    # gv100card0       | C5h | ok  | 216.1 | 0 unspecified
80    # gv100card1       | C8h | ok  | 216.2 | 0 unspecified
81    # TPMEnable        | D7h | ok  |  3.3 | State Asserted
82    # auto_reboot      | DAh | ok  | 33.2 | State Asserted
83    # volatile         | DBh | ok  | 33.1 | State Deasserted
84
85    ${sdr_elist_output}=  Run IPMI Standard Command  sdr elist
86    ${sdr_component_line}=
87    ...  Get Lines Containing String  ${sdr_elist_output}  ${component_name}
88    ...  case-insensitive
89
90    ${presence_ipmi}=  Fetch From Right  ${sdr_component_line}  |
91    ${presence_ipmi}=  Strip String  ${presence_ipmi}
92    [Return]  ${presence_ipmi}
93
94
95Get SDR Record ID
96    [Documentation]  Fetch one record ID from SDR elist IPMI cmd response.
97
98    ${resp}=  Run External IPMI Standard Command  sdr elist
99    ${record_id}=  Get Regexp Matches  ${resp}  \\|\\s+([0-9]+)h\\s+\\|  1
100
101    [Return]  ${record_id[0]}
102
103
104Suite Setup Execution
105    [Documentation]  Do the initial suite setup.
106
107    Redfish.Login
108    Redfish Power On  stack_mode=skip  quiet=1
109
110    ${record_id}=  Get SDR Record ID
111    Set Suite Variable  ${record_id}
112
113    ${uri_list}=  Read Properties  ${OPENBMC_BASE_URI}list
114    Set Suite Variable  ${SYSTEM_URI}  ${uri_list}
115    Log  ${uri_list}
116
117
118Test Teardown Execution
119    [Documentation]  Do the post test teardown.
120
121    FFDC On Test Case Fail
122