blob: 09c8a48e67430d17e368b7e3991b297635c87273 [file] [log] [blame]
ganesanb5502e3e2022-12-13 11:07:43 +00001*** Settings ***
2Documentation Module to test dcmi management controller functionality.
3Resource ../../lib/ipmi_client.robot
4Resource ../../lib/openbmc_ffdc.robot
5Resource ../../lib/bmc_network_utils.robot
6Resource ../../lib/boot_utils.robot
7Resource ../../lib/bmc_redfish_utils.robot
8Variables ../../data/ipmi_raw_cmd_table.py
9Variables ../../data/dcmi_raw_cmd_table.py
10Variables ../../data/ipmi_variable.py
11Library ../../lib/ipmi_utils.py
12Library ../../lib/utilities.py
13Library ../../lib/utils.py
14Library JSONLibrary
15
George Keishing87dc4422023-10-20 12:56:30 +053016Force Tags DCMI_Management_Controller
17
ganesanb5502e3e2022-12-13 11:07:43 +000018*** Variables ***
George Keishing87dc4422023-10-20 12:56:30 +053019
ganesanb5502e3e2022-12-13 11:07:43 +000020${hostname_file_path} /etc/hostname
21
22*** Test Cases ***
23Validate IPMI Response Length
24 [Documentation] Check ipmi response length.
25 [Tags] Validate_IPMI_Response_Length
26
27 ${rsp}= Get DCMI Management Controller Identifier String
28 @{ipmi_cmd_rsp_list}= Split String ${rsp}
George Keishingc6185fa2023-05-30 14:54:59 +053029 # ipmi_cmd_rsp_list = ["00", "0a", "00", "01", "02", "03",
30 # "04", "05", "06", "07", "08", "09"]
ganesanb5502e3e2022-12-13 11:07:43 +000031 # rsp_length = 10
32 # string_length = 0a
33 ${rsp_length}= Get Length ${ipmi_cmd_rsp_list[2:]}
34 ${string_length}= Get Response Length In Hex ${rsp_length}
35
36 # ipmi_cmd_rsp_list[1] = 0a
37 # string_length = 0a
38 # the above condition is equal.
George Keishingc6185fa2023-05-30 14:54:59 +053039 # suppose if string_length and ipmi_cmd_rsp_list[1] not matches
40 # then it will fails.
ganesanb5502e3e2022-12-13 11:07:43 +000041 Should Be Equal As Strings ${ipmi_cmd_rsp_list[1]} ${string_length}
42 ... msg=Id string length in ipmi response is showing wrongly
43
George Keishingc6185fa2023-05-30 14:54:59 +053044Test Hostname Is Same With Management Controller Identifier String
45 [Documentation] Check hostname was verified with get management
46 ... controller identifier string.
47 [Tags] Test_Hostname_Is_Same_With_Management_Controller_Identifier_String
ganesanb5502e3e2022-12-13 11:07:43 +000048
49 ${rsp}= Get DCMI Management Controller Identifier String
50 @{ipmi_cmd_rsp_list}= Split String ${rsp}
51 ${bmc_console_hostname_bytes_list}= Get Hostname From BMC Console
52
53 Lists Should Be Equal ${ipmi_cmd_rsp_list[2:]} ${bmc_console_hostname_bytes_list}
54 ... msg=response get from dcmi get mcid cmd and hostname from "cat /etc/os-release" cmd is not same.
55
56Test Get Management Controller Identifier String
57 [Documentation] Validate set and get mcid string.
George Keishingc6185fa2023-05-30 14:54:59 +053058 [Tags] Test_Get_Management_Controller_Identifier_String
ganesanb5502e3e2022-12-13 11:07:43 +000059 [Setup] Get Default MCID
60 [Teardown] Set Default MCID
61
62 # Set Hostname via DCMI Management Controller Identifier String Command.
63 ${cmd_rsp}= Set DCMI Management Controller Identifier String
64 @{cmd_rsp_list}= Split String ${cmd_rsp}
65 Run Keyword And Continue On Failure
66 ... Valid Value cmd_rsp_list[1] valid_values=['${number_of_bytes_to_write}']
67
68 ${rsp}= Get DCMI Management Controller Identifier String
69 @{ipmi_cmd_rsp_list}= Split String ${rsp}
70
71 # Verify number of bytes that was set and id string length are same.
72 ${string_length}= Get Response Length In Hex ${random_int}
73 Run Keyword And Continue On Failure
74 ... Should Be Equal As Strings ${ipmi_cmd_rsp_list[1]} ${string_length}
75 ... msg=Number of bytes that was set and id string length are not same.
76
77 # Verify ID String Length and data.
George Keishingc6185fa2023-05-30 14:54:59 +053078 # ipmi_cmd_rsp_list = ["00", "0a", "00", "01", "02", "03", "04",
79 # "05", "06", "07", "08", "09"]
ganesanb5502e3e2022-12-13 11:07:43 +000080 # rsp_length = 10
81 # string_length = 0a
82 # ipmi_cmd_rsp_list[1] = 0a
83 # ipmi_cmd_rsp_list[1] is equal to string_length
84 # the above condition is equal.
George Keishingc6185fa2023-05-30 14:54:59 +053085 # suppose if string_length and ipmi_cmd_rsp_list[1] not matches then
86 # it will fails.
ganesanb5502e3e2022-12-13 11:07:43 +000087 ${rsp_length}= Get Length ${ipmi_cmd_rsp_list[2:]}
88 ${string_length}= Get Response Length In Hex ${rsp_length}
89 Run Keyword And Continue On Failure
90 ... Should Be Equal As Strings ${ipmi_cmd_rsp_list[1]} ${string_length}
91 ... msg=Id string length in ipmi response is showing wrongly
92
93 # Verify get dcmi management controller identifier string command response
94 # and the bytes used for Set DCMI MCID string.
95 ${set_dcmi_mcid_cmd}=
96 ... convert_prefix_hex_list_to_non_prefix_hex_list ${string_hex_list}
97 Run Keyword And Continue On Failure
98 ... Lists Should Be Equal ${ipmi_cmd_rsp_list[2:]} ${set_dcmi_mcid_cmd}
99 ... msg=Bytes given in dcmi set mcid command and string bytes got from dcmi get mcid command are not same
100
101 # Verify Hostname of cat /etc/hostname and get dcmi management controller identifier string command.
102 ${bytes_list}= Get Hostname From BMC Console
103 Run Keyword And Continue On Failure
104 ... Lists Should Be Equal ${ipmi_cmd_rsp_list[2:]} ${bytes_list}
105 ... msg=Bytes got from dcmi get mcid command and hostname from "cat /etc/os-release" command is not same.
106
107*** Keywords ***
108Get Default MCID
109 [Documentation] Get default mcid.
110
111 ${default_mcid}= Get DCMI Management Controller Identifier String
112 Set Test Variable ${default_mcid}
113
114Set Default MCID
115 [Documentation] Set default mcid.
116
117 @{ipmi_cmd_rsp_list}= Split String ${default_mcid}
118 ${number_of_bytes_to_write}= Set Variable ${ipmi_cmd_rsp_list[1]}
119 ${bytes_in_int}= Convert To Integer ${number_of_bytes_to_write} 16
120 ${bytes_to_write}= Evaluate ${bytes_in_int} + 1
121 ${no_of_bytes_to_write}= Get Response Length In Hex ${bytes_to_write}
122 @{tmp_lst}= Create List
123 FOR ${bytes} IN @{ipmi_cmd_rsp_list[2:]}
124 Append To List ${tmp_lst} 0x${bytes}
125 END
126 ${default_hex}= Catenate @{tmp_lst}
127
128 ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['SET']}
129 ... 0x${no_of_bytes_to_write} ${default_hex}
130 Run External IPMI Raw Command ${cmd}
131
132Get DCMI Management Controller Identifier String
133 [Documentation] Get DCMI MCID String.
134
135 ${mcid_get_cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['GET']}
136 ${resp}= Run External IPMI Raw Command ${mcid_get_cmd}
Wilson Suen8bd01302023-12-04 18:38:56 -0800137 ${resp}= Strip String ${resp} mode=right characters=${SPACE}00\n
ganesanb5502e3e2022-12-13 11:07:43 +0000138
139 [Return] ${resp}
140
141Set DCMI Management Controller Identifier String
142 [Documentation] Set DCMI MCID String.
143
144 # 16 bytes maximum as per dcmi spec
145 ${random_int}= Evaluate random.randint(1, 15) modules=random
146 ${random_string}= Generate Random String ${random_int}
147 ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string}
148 ${random_hex}= Catenate @{string_hex_list}
149 ${number_of_random_string}= Evaluate ${random_int} + 1
150 ${number_of_bytes_to_write}= Get Response Length In Hex ${number_of_random_string}
151
152 ${mcid_set_cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['SET']}
153 ... 0x${number_of_bytes_to_write} ${random_hex} 0x00
154 ${resp}= Run External IPMI Raw Command ${mcid_set_cmd}
155
156 Set Test Variable ${string_hex_list}
157 Set Test Variable ${random_int}
158 Set Test Variable ${number_of_bytes_to_write}
159
160 [Return] ${resp}
161
162Get Hostname From BMC Console
163 [Documentation] Get hostname.
164
165 ${cmd}= Catenate cat ${hostname_file_path}
166 ${bmc_hostname}= BMC Execute Command ${cmd}
167 ${name}= Convert To List ${bmc_hostname}
168 ${hostname_bytes}= convert_name_into_bytes_without_prefix ${name[0]}
169
170 [Return] ${hostname_bytes}
171
172Get Response Length In Hex
173 [Documentation] Get response length in hex.
174 [Arguments] ${resp_length}
175
176 ${length}= Convert To Hex ${resp_length}
177 ${length_1}= Get Length ${length}
178 ${length_2}= Set Variable IF
179 ... '${length_1}' == '1' 0${length}
180 ... '${length_1}' != '1' ${length}
181 ${resp_length_3}= Convert To Lower Case ${length_2}
182
183 [Return] ${resp_length_3}