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
11Test Teardown           Test Teardown Execution
12
13Force Tags              SDR_Test
14
15
16*** Test Cases ***
17
18
19Test CPU Core SDR Info At Power On
20    [Documentation]  Verify CPU core SDR info via IPMI and Redfish at power on.
21
22    [Tags]  Test_CPU_Core_SDR_Info_At_Power_On
23
24    Redfish Power On  stack_mode=skip  quiet=1
25    Test SDR Info  core
26
27
28Test DIMM SDR Info At Power On
29    [Documentation]  Verify DIMM SDR info via IPMI and Redfish at power on.
30
31    [Tags]  Test_DIMM_SDR_Info_At_Power_On
32
33    Redfish Power On  stack_mode=skip  quiet=1
34    Test SDR Info  dimm
35
36
37Test GPU SDR Info At Power On
38    [Documentation]  Verify GPU SDR info via IPMI and Redfish at power on.
39
40    [Tags]  Test_GPU_SDR_Info_At_Power_On
41
42    Redfish Power On  stack_mode=skip  quiet=1
43    Test SDR Info  gv100card
44
45
46Test CPU Core SDR Info At Power Off
47    [Documentation]  Verify CPU core SDR info via IPMI and Redfish at power off.
48
49    [Tags]  Test_CPU_Core_SDR_Info_At_Power_Off
50
51    Redfish Hard Power Off  stack_mode=skip  quiet=1
52    Test SDR Info  core
53
54
55Test DIMM SDR Info At Power Off
56    [Documentation]  Verify DIMM SDR info via IPMI and Redfish at power off.
57
58    [Tags]  Test_DIMM_SDR_Info_At_Power_Off
59
60    Redfish Hard Power Off  stack_mode=skip  quiet=1
61    Test SDR Info  dimm
62
63
64Test Turbo Allowed SDR Info
65    [Documentation]  Verify turbo allowed SDR info via IPMI and Redfish.
66    [Tags]  Test_Turbo_Allowed_SDR_Info
67
68    ${component_uri_list}=  Get Component URIs  turbo_allowed
69    ${component_uri}=  Get From List  ${component_uri_list}  0
70    ${state_rest}=  Read Attribute  ${component_uri}  TurboAllowed
71
72    ${state_ipmi}=  Get SDR Presence Via IPMI  turbo_allowed${SPACE}
73
74    Run Keyword If  '${state_ipmi}' == 'Disabled'
75    ...    Should Be True  ${state_rest} == 0
76    ...  ELSE IF  '${state_ipmi}' == 'State Asserted'
77    ...    Should Be True  ${state_rest} == 1
78
79
80Test Auto Reboot SDR Info
81    [Documentation]  Verify auto reboot SDR info via IPMI and Redfish.
82    [Tags]  Test_Auto_Reboot_SDR_Info
83
84
85    ${component_uri_list}=  Get Component URIs  auto_reboot
86    ${component_uri}=  Get From List  ${component_uri_list}  0
87    ${state_rest}=  Read Attribute  ${component_uri}  AutoReboot
88
89    ${state_ipmi}=  Get SDR Presence Via IPMI  auto_reboot${SPACE}
90
91    Run Keyword If  '${state_ipmi}' == 'Disabled'
92    ...    Should Be True  ${state_rest} == 0
93    ...  ELSE IF  '${state_ipmi}' == 'State Asserted'
94    ...    Should Be True  ${state_rest} == 1
95
96
97Test TPM Enable SDR Info
98    [Documentation]  Verify auto reboot SDR info via IPMI and Redfish.
99    [Tags]  Test_TPM_Enable_SDR_Info
100
101
102    ${component_uri_list}=  Get Component URIs  TPMEnable
103    ${component_uri}=  Get From List  ${component_uri_list}  0
104    ${state_rest}=  Read Attribute  ${component_uri}  TPMEnable
105
106    ${state_ipmi}=  Get SDR Presence Via IPMI  auto_reboot${SPACE}
107
108    Run Keyword If  '${state_ipmi}' == 'Disabled'
109    ...    Should Be True  ${state_rest} == 0
110    ...  ELSE IF  '${state_ipmi}' == 'State Asserted'
111    ...    Should Be True  ${state_rest} == 1
112
113
114*** Keywords ***
115
116Get Component URIs
117    [Documentation]  Get URIs for given component from given URIs
118    ...  and return as a list.
119    [Arguments]  ${component_name}  ${uri_list}=${SYSTEM_URI}
120
121    # A sample result returned for the "core" component:
122    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core0
123    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core1
124    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core10
125    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core11
126    # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core12
127    # (etc.)
128
129    # Description of argument(s):
130    # component_name    Component name (e.g. "core", "dimm", etc.).
131    # uri_list          URI list.
132
133    ${component_uris}=  Get Matches  ${uri_list}
134    ...  regexp=^.*[0-9a-z_].${component_name}\[0-9]*$
135    [Return]  ${component_uris}
136
137
138Get SDR Presence Via IPMI
139    [Documentation]  Return presence info from IPMI sensor data record.
140    [Arguments]  ${component_name}
141
142    # Description of argument(s):
143    # component_name    Component name (e.g. "cpu0_core0", "dimm0", etc.).
144
145    # Example of IPMI SDR elist output.
146    # BootProgress     | 03h | ok  | 34.2 |
147    # OperatingSystemS | 05h | ok  | 35.1 | boot completed - device not specified
148    # AttemptsLeft     | 07h | ok  | 34.1 |
149    # occ0             | 08h | ok  | 210.1 | Device Disabled
150    # occ1             | 09h | ok  | 210.2 | Device Disabled
151    # cpu0_core0       | 12h | ok  | 208.1 | Presence detected
152    # cpu0_core1       | 15h | ok  | 208.2 | Disabled
153    # cpu0_core2       | 18h | ok  | 208.3 | Presence detected
154    # dimm0            | A6h | ok  | 32.1 | Presence Detected
155    # dimm1            | A8h | ok  | 32.2 | Presence Detected
156    # dimm2            | AAh | ok  | 32.9 | Presence Detected
157    # gv100card0       | C5h | ok  | 216.1 | 0 unspecified
158    # gv100card1       | C8h | ok  | 216.2 | 0 unspecified
159    # TPMEnable        | D7h | ok  |  3.3 | State Asserted
160    # auto_reboot      | DAh | ok  | 33.2 | State Asserted
161    # volatile         | DBh | ok  | 33.1 | State Deasserted
162
163    ${sdr_elist_output}=  Run IPMI Standard Command  sdr elist
164    ${sdr_component_line}=
165    ...  Get Lines Containing String  ${sdr_elist_output}  ${component_name}
166    ...  case-insensitive
167
168    ${presence_ipmi}=  Fetch From Right  ${sdr_component_line}  |
169    ${presence_ipmi}=  Strip String  ${presence_ipmi}
170    [Return]  ${presence_ipmi}
171
172
173Verify SDR
174    [Documentation]  Verify IPMI sensor data record for given component
175    ...  with Redfish.
176    [Arguments]  ${component_name}
177
178    # Description of argument(s):
179    # component_name    Component name (e.g. "cpu0/core0", "dimm0", etc.).
180
181    ${presence_rest}=  Read Attribute
182    ...  ${HOST_INVENTORY_URI}system/chassis/motherboard/${component_name}
183    ...  Present
184    ${functional_rest}=  Read Attribute
185    ...  ${HOST_INVENTORY_URI}system/chassis/motherboard/${component_name}
186    ...  Functional
187
188    # Replace "/" with "_" if there is any "/" in component name.
189    # e.g. cpu0/core0 to cpu0_core0
190    ${component_name}=  Replace String  ${component_name}  /  _
191    ${presence_ipmi}=  Get SDR Presence Via IPMI  ${component_name}${SPACE}
192
193    Run Keyword If  '${presence_ipmi}' == 'Disabled'
194    ...    Should Be True  ${presence_rest} == 0 and ${functional_rest} == 0
195    ...  ELSE IF  '${presence_ipmi}' == 'Presence Detected' or '${presence_ipmi}' == 'Presence detected'
196    ...    Should Be True  ${presence_rest} == 1 and ${functional_rest} == 1
197    ...  ELSE IF  '${presence_ipmi}' == 'State Asserted'
198    ...    Should Be True  ${presence_rest} == 1 and ${functional_rest} == 1
199    ...  ELSE IF  '${presence_ipmi}' == 'State Deasserted'
200    ...    Should Be True  ${presence_rest} == 1 and ${functional_rest} == 0
201    ...  ELSE  Fail  msg=Invalid Presence${presence_ipmi}
202
203
204Test SDR Info
205    [Documentation]  Test SDR info for given component.
206    [Arguments]  ${component_name}
207
208    # Description of argument(s):
209    # component_name    Component name (e.g. "core", "dimm", etc.).
210
211    ${component_uri_list}=  Get Component URIs  ${component_name}
212    : FOR  ${uri}  IN  @{component_uri_list}
213    \  ${component_name}=  Fetch From Right  ${uri}  motherboard/
214    \  Log To Console  ${component_name}
215    \  Verify SDR  ${component_name}
216
217
218Suite Setup Execution
219    [Documentation]  Do the initial suite setup.
220
221    Redfish Power On  stack_mode=skip  quiet=1
222
223    ${uri_list}=  Read Properties  ${OPENBMC_BASE_URI}list
224    Set Suite Variable  ${SYSTEM_URI}  ${uri_list}
225    Log  ${uri_list}
226
227
228Test Teardown Execution
229    [Documentation]  Do the post test teardown.
230
231    FFDC On Test Case Fail
232