blob: 6c69cde1e5555374e6fd38446509d60e6ef69496 [file] [log] [blame]
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -05001*** Settings ***
2Documentation Test IPMI FRU data.
3
4Resource ../../lib/rest_client.robot
5Resource ../../lib/ipmi_client.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/boot_utils.robot
8Library ../../lib/ipmi_utils.py
Tony Lee1e303ca2020-02-27 10:53:47 +08009Library ../../data/model.py
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -050010
11Test Teardown Test Teardown Execution
12Suite Setup Suite Setup Execution
13
14
15*** Test Cases ***
16
17Test FRU Info At Power On
18 [Documentation] Verify FRU info via IPMI and REST at power on.
19 [Tags] Test_FRU_Info_At_Power_On
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -050020
Tony Lee1e303ca2020-02-27 10:53:47 +080021 ${component_name_list}= Get FRU Component Name List ${OPENBMC_MODEL}
22 &{ipmi_rest_fru_field_map}= Get Ipmi Rest Fru Field Map ${OPENBMC_MODEL}
23 Set Global Variable ${ipmi_rest_fru_field_map}
24 Rprint Vars ipmi_rest_fru_field_map component_name_list
25
26 FOR ${component_name} IN @{component_name_list}
27 Verify FRU Info ${component_name}
28 END
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -050029
30
31*** Keywords ***
32
33Get Component Fru Info Via REST
34 [Documentation] Get FRU Information Via REST for the given component.
35 [Arguments] ${component_name}
36
37 # Description of argument(s):
38 # component_name The name of the component (e.g. "cpu", "dimm", etc.).
39
40 ${inventory_uris}= Read Properties ${HOST_INVENTORY_URI}list quiet=${1}
41 # From the inventory_uris, select just the ones for the component of
42 # interest.
43 ${component_uris}= Get Matches ${inventory_uris}
Michael Walshd917c6e2018-12-11 10:09:09 -060044 ... regexp=^.*[0-9a-z_].${component_name}\[0-9]*$
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -050045
46 # Get the component information for each record.
47 ${component_frus}= Create List
Sushil Singhbe97ffc2019-06-04 06:34:24 -050048 FOR ${component_uri} IN @{component_uris}
49 ${result}= Read Properties ${component_uri} quiet=${1}
50 ${component}= Fetch From Right ${component_uri} /
51 Set To Dictionary ${result} fru_device_description ${component}
52 Append To List ${component_frus} ${result}
53 END
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -050054 [Return] ${component_frus}
55
56
57Verify FRU Info
58 [Documentation] Verify FRU information of given component.
59 [Arguments] ${component_name}
60
61 # Description of argument(s):
62 # component_name The name of the component (e.g. "cpu", "dimm", etc.).
63
64 ${ipmi_fru_component_info}= Get Component FRU Info ${component_name}
65 ... ${fru_objs}
66 # Example of output from "Get Component FRU Info" keyword for CPU component.
67 #
68 # ipmi_fru_info:
69 # ipmi_fru_info[0]:
70 # [fru_device_description]: cpu0 (ID 1)
71 # [board_mfg_date]: Sun Dec 31 18:00:00 1995
72 # [board_mfg]: <Manufacturer Name>
73 # [board_product]: PROCESSOR MODULE
74 # [board_serial]: YA1934301835
75 # [board_part_number]: 02CY211
76 # ipmi_fru_info[1]:
77 # [fru_device_description]: cpu1 (ID 2)
78 # [board_mfg_date]: Sun Dec 31 18:00:00 1995
79 # [board_mfg]: <Manufacturer Name>
80 # [board_product]: PROCESSOR MODULE
81 # [board_serial]: YA1934301834
82 # [board_part_number]: 02CY211
83
84 ${rest_fru_component_info}= Get Component FRU Info Via REST
85 ... ${component_name}
86 # Example of output from "Get Component FRU Info Via REST" keyword for
87 # CPU component.
88 #
89 # rest_fru_info:
90 # rest_fru_info[0]:
91 # [FieldReplaceable]: 1
92 # [BuildDate]: 1996-01-01 - 00:00:00
93 # [fru_device_description]: cpu0
94 # [Cached]: 0
95 # [SerialNumber]: YA1934301835
96 # [Functional]: 1
97 # [Version]: 22
98 # [Model]: <blank>
99 # [PrettyName]: PROCESSOR MODULE
100 # [PartNumber]: 02CY211
101 # [Present]: 1
102 # [Manufacturer]: <Manufacturer Name>
103 # rest_fru_info[1]:
104 # [FieldReplaceable]: 1
105 # [BuildDate]: 1996-01-01 - 00:00:00
106 # [fru_device_description]: cpu1
107 # [Cached]: 0
108 # [SerialNumber]: YA1934301834
109 # [Functional]: 1
110 # [Version]: 22
111 # [Model]: <blank>
112 # [PrettyName]: PROCESSOR MODULE
113 # [PartNumber]: 02CY211
114 # [Present]: 1
115 # [Manufacturer]: <Manufacturer Name>
116
117 ${inventory_uris}= Read Properties
118 ... ${HOST_INVENTORY_URI}list quiet=${1}
119
120 # From the inventory_uris, select just the ones for the component of
121 # interest. Example for cpu:
122 # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
123 # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1
124 ${component_uris}= Get Matches ${inventory_uris}
Michael Walshd917c6e2018-12-11 10:09:09 -0600125 ... regexp=^.*[0-9a-z_].${component_name}\[0-9]*$
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -0500126
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500127 FOR ${uri} IN @{component_uris}
128 ${sub_component}= Fetch From Right ${uri} /
129 ${ipmi_index}= Get Index Of FRU Sub Component Info
130 ... ${ipmi_fru_component_info} ${sub_component}
131 ${rest_index}= Get Index Of FRU Sub Component Info
132 ... ${rest_fru_component_info} ${sub_component}
133 ${ipmi_fru_sub_component}=
134 ... Get From List ${ipmi_fru_component_info} ${ipmi_index}
135 ${rest_fru_sub_component}=
136 ... Get From List ${rest_fru_component_info} ${rest_index}
137 Compare IPMI And REST FRU Component Info ${ipmi_fru_sub_component}
138 ... ${rest_fru_sub_component} ${component_name}
139 END
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -0500140
141
142Get Index Of FRU Sub Component Info
143 [Documentation] Get index of FRU sub component info from FRU component
144 ... data.
145 [Arguments] ${fru_component_info} ${sub_component}
146 # fru_component_info FRU component data as a list of dictionaries.
147 # ipmi_cpu_fru_info[0]:
148 # fru_device_description: cpu0 (ID 1)
149 # board_mfg_date: Sun Dec 31 18:00:00 1995
150 # board_mfg: <Manufacturer Name>
151 # board_product: PROCESSOR MODULE
152 # board_serial: YA1934302970
153 # board_part_number: 02CY211
154 # ipmi_cpu_fru_info[1]:
155 # fru_device_description: cpu1 (ID 2)
156 # board_mfg_date: Sun Dec 31 18:00:00 1995
157 # board_mfg: <Manufacturer Name>
158 # board_product: PROCESSOR MODULE
159 # board_serial: YA1934302965
160 # board_part_number: 02CY211
161 # sub_component Sub component name (e.g. "cpu0", "cpu1", etc.).
162
163 ${sub_component_count}= Get Length ${fru_component_info}
164 ${index}= Set Variable ${0}
165
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500166 FOR ${rest_fru_sub_component} IN @{fru_component_info}
167 ${fru_component_section}=
168 ... Get From List ${fru_component_info} ${index}
169 # Get FRU name from IPMI's fru_device_description field.
170 # Example "cpu0" from "cpu0 (ID 1)".
171 ${fru_name}= Fetch From Left
172 ... ${fru_component_section['fru_device_description']} ${SPACE}
173 ${status}= Run Keyword And Return Status Should Be Equal
174 ... ${fru_name} ${sub_component}
175 Exit For Loop If '${status}' == '${True}'
176 ${index}= Evaluate ${index} + 1
177 Exit For Loop If ${index} >= ${sub_component_count}
178 END
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -0500179 [Return] ${index}
180
181
182Compare IPMI And REST FRU Component Info
183 [Documentation] Compare IPMI And REST FRU Component data objects.
184 [Arguments] ${ipmi_fru_component_obj} ${rest_fru_component_obj}
185 ... ${component_name}
186
187 # Description of argument(s):
188 # ipmi_fru_component_obj IPMI FRU component data in dictionary.
189 # Example:
190 # fru_device_description: cpu0 (ID 1)
191 # board_mfg_date: Sun Dec 31 18:00:00 1995
192 # board_mfg: <Manufacturer Name>
193 # board_product: PROCESSOR MODULE
194 # board_serial: YA1934302970
195 # board_part_number: 02CY211
196 # rest_fru_component_obj REST FRU component data in dictionary.
197 # Example:
198 # FieldReplaceable: 1
199 # BuildDate: 1996-01-01 - 00:00:00
200 # Cached: 0
201 # SerialNumber: YA1934302970
202 # Functional: 1
203 # Version: 22
204 # Model: <blank>
205 # PrettyName: PROCESSOR MODULE
206 # PartNumber: 02CY211
207 # Present: 1
208 # Manufacturer: <Manufacturer Name>
209 # component_name The name of the component (e.g. "cpu", "dimm", etc.).
210
211 # Get key_map from ipmi_rest_fru_field_map.
212 ${key_map}= Set Variable ${ipmi_rest_fru_field_map['${component_name}']}
Sushil Singhbe97ffc2019-06-04 06:34:24 -0500213 FOR ${ipmi_key} IN @{ipmi_rest_fru_field_map['${component_name}'].keys()}
214 ${rest_key}= Set Variable ${key_map['${ipmi_key}']}
215 Should Contain ${rest_fru_component_obj['${rest_key}']}
216 ... ${ipmi_fru_component_obj['${ipmi_key}']}
217 ... msg=Comparison failed.
218 END
Rahul Maheshwari35aa8d52018-03-11 23:56:51 -0500219
220
221Test Teardown Execution
222 [Documentation] Do the post test teardown.
223
224 FFDC On Test Case Fail
225
226
227Suite Setup Execution
228 [Documentation] Do test setup initialization.
229
230 REST Power On stack_mode=skip quiet=1
231 ${fru_objs}= Get Fru Info
232 Set Suite Variable ${fru_objs}
233