xref: /openbmc/openbmc-test-automation/ipmi/dcmi/test_dcmi_management_controller.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
15502e3edSganesanb*** Settings ***
25502e3edSganesanbDocumentation    Module to test dcmi management controller functionality.
35502e3edSganesanbResource         ../../lib/ipmi_client.robot
45502e3edSganesanbResource         ../../lib/openbmc_ffdc.robot
55502e3edSganesanbResource         ../../lib/bmc_network_utils.robot
65502e3edSganesanbResource         ../../lib/boot_utils.robot
75502e3edSganesanbResource         ../../lib/bmc_redfish_utils.robot
85502e3edSganesanbVariables        ../../data/ipmi_raw_cmd_table.py
95502e3edSganesanbVariables        ../../data/dcmi_raw_cmd_table.py
105502e3edSganesanbVariables        ../../data/ipmi_variable.py
115502e3edSganesanbLibrary          ../../lib/ipmi_utils.py
125502e3edSganesanbLibrary          ../../lib/utilities.py
135502e3edSganesanbLibrary          ../../lib/utils.py
145502e3edSganesanbLibrary          JSONLibrary
155502e3edSganesanb
16*6fb70d98SMatt FischerTest Tags       DCMI_Management_Controller
1787dc442cSGeorge Keishing
185502e3edSganesanb*** Variables ***
1987dc442cSGeorge Keishing
205502e3edSganesanb${hostname_file_path}  /etc/hostname
215502e3edSganesanb
225502e3edSganesanb*** Test Cases ***
235502e3edSganesanbValidate IPMI Response Length
245502e3edSganesanb    [Documentation]  Check ipmi response length.
255502e3edSganesanb    [Tags]  Validate_IPMI_Response_Length
265502e3edSganesanb
275502e3edSganesanb    ${rsp}=  Get DCMI Management Controller Identifier String
285502e3edSganesanb    @{ipmi_cmd_rsp_list}=  Split String  ${rsp}
29c6185fa8SGeorge Keishing    # ipmi_cmd_rsp_list = ["00", "0a", "00", "01", "02", "03",
30c6185fa8SGeorge Keishing    #                      "04", "05", "06", "07", "08", "09"]
315502e3edSganesanb    # rsp_length = 10
325502e3edSganesanb    # string_length = 0a
335502e3edSganesanb    ${rsp_length}=  Get Length  ${ipmi_cmd_rsp_list[2:]}
345502e3edSganesanb    ${string_length}=  Get Response Length In Hex  ${rsp_length}
355502e3edSganesanb
365502e3edSganesanb    # ipmi_cmd_rsp_list[1] = 0a
375502e3edSganesanb    # string_length = 0a
385502e3edSganesanb    # the above condition is equal.
39c6185fa8SGeorge Keishing    # suppose if string_length and ipmi_cmd_rsp_list[1] not matches
40c6185fa8SGeorge Keishing    #  then it will fails.
415502e3edSganesanb    Should Be Equal As Strings  ${ipmi_cmd_rsp_list[1]}  ${string_length}
425502e3edSganesanb    ...  msg=Id string length in ipmi response is showing wrongly
435502e3edSganesanb
44c6185fa8SGeorge KeishingTest Hostname Is Same With Management Controller Identifier String
45c6185fa8SGeorge Keishing    [Documentation]  Check hostname was verified with get management
46c6185fa8SGeorge Keishing    ...              controller identifier string.
47c6185fa8SGeorge Keishing    [Tags]  Test_Hostname_Is_Same_With_Management_Controller_Identifier_String
485502e3edSganesanb
495502e3edSganesanb    ${rsp}=  Get DCMI Management Controller Identifier String
505502e3edSganesanb    @{ipmi_cmd_rsp_list}=  Split String  ${rsp}
515502e3edSganesanb    ${bmc_console_hostname_bytes_list}=  Get Hostname From BMC Console
525502e3edSganesanb
535502e3edSganesanb    Lists Should Be Equal  ${ipmi_cmd_rsp_list[2:]}  ${bmc_console_hostname_bytes_list}
545502e3edSganesanb    ...  msg=response get from dcmi get mcid cmd and hostname from "cat /etc/os-release" cmd is not same.
555502e3edSganesanb
565502e3edSganesanbTest Get Management Controller Identifier String
575502e3edSganesanb    [Documentation]  Validate set and get mcid string.
58c6185fa8SGeorge Keishing    [Tags]  Test_Get_Management_Controller_Identifier_String
595502e3edSganesanb    [Setup]  Get Default MCID
605502e3edSganesanb    [Teardown]  Set Default MCID
615502e3edSganesanb
625502e3edSganesanb    # Set Hostname via DCMI Management Controller Identifier String Command.
635502e3edSganesanb    ${cmd_rsp}=  Set DCMI Management Controller Identifier String
645502e3edSganesanb    @{cmd_rsp_list}=  Split String  ${cmd_rsp}
655502e3edSganesanb    Run Keyword And Continue On Failure
665502e3edSganesanb    ...  Valid Value  cmd_rsp_list[1]  valid_values=['${number_of_bytes_to_write}']
675502e3edSganesanb
685502e3edSganesanb    ${rsp}=  Get DCMI Management Controller Identifier String
695502e3edSganesanb    @{ipmi_cmd_rsp_list}=  Split String  ${rsp}
705502e3edSganesanb
715502e3edSganesanb    # Verify number of bytes that was set and id string length are same.
725502e3edSganesanb    ${string_length}=  Get Response Length In Hex  ${random_int}
735502e3edSganesanb    Run Keyword And Continue On Failure
745502e3edSganesanb    ...  Should Be Equal As Strings  ${ipmi_cmd_rsp_list[1]}  ${string_length}
755502e3edSganesanb    ...  msg=Number of bytes that was set and id string length are not same.
765502e3edSganesanb
775502e3edSganesanb    # Verify ID String Length and data.
78c6185fa8SGeorge Keishing    # ipmi_cmd_rsp_list = ["00", "0a", "00", "01", "02", "03", "04",
79c6185fa8SGeorge Keishing    #                      "05", "06", "07", "08", "09"]
805502e3edSganesanb    # rsp_length = 10
815502e3edSganesanb    # string_length = 0a
825502e3edSganesanb    # ipmi_cmd_rsp_list[1] = 0a
835502e3edSganesanb    # ipmi_cmd_rsp_list[1] is equal to string_length
845502e3edSganesanb    # the above condition is equal.
85c6185fa8SGeorge Keishing    # suppose if string_length and ipmi_cmd_rsp_list[1] not matches then
86c6185fa8SGeorge Keishing    # it will fails.
875502e3edSganesanb    ${rsp_length}=  Get Length  ${ipmi_cmd_rsp_list[2:]}
885502e3edSganesanb    ${string_length}=  Get Response Length In Hex  ${rsp_length}
895502e3edSganesanb    Run Keyword And Continue On Failure
905502e3edSganesanb    ...  Should Be Equal As Strings  ${ipmi_cmd_rsp_list[1]}  ${string_length}
915502e3edSganesanb    ...  msg=Id string length in ipmi response is showing wrongly
925502e3edSganesanb
935502e3edSganesanb    # Verify get dcmi management controller identifier string command response
945502e3edSganesanb    # and the bytes used for Set DCMI MCID string.
955502e3edSganesanb    ${set_dcmi_mcid_cmd}=
965502e3edSganesanb    ...  convert_prefix_hex_list_to_non_prefix_hex_list  ${string_hex_list}
975502e3edSganesanb    Run Keyword And Continue On Failure
985502e3edSganesanb    ...  Lists Should Be Equal  ${ipmi_cmd_rsp_list[2:]}  ${set_dcmi_mcid_cmd}
995502e3edSganesanb    ...  msg=Bytes given in dcmi set mcid command and string bytes got from dcmi get mcid command are not same
1005502e3edSganesanb
1015502e3edSganesanb    # Verify Hostname of cat /etc/hostname and get dcmi management controller identifier string command.
1025502e3edSganesanb    ${bytes_list}=  Get Hostname From BMC Console
1035502e3edSganesanb    Run Keyword And Continue On Failure
1045502e3edSganesanb    ...  Lists Should Be Equal  ${ipmi_cmd_rsp_list[2:]}  ${bytes_list}
1055502e3edSganesanb    ...  msg=Bytes got from dcmi get mcid command and hostname from "cat /etc/os-release" command is not same.
1065502e3edSganesanb
1075502e3edSganesanb*** Keywords ***
1085502e3edSganesanbGet Default MCID
1095502e3edSganesanb    [Documentation]  Get default mcid.
1105502e3edSganesanb
1115502e3edSganesanb    ${default_mcid}=  Get DCMI Management Controller Identifier String
1125502e3edSganesanb    Set Test Variable  ${default_mcid}
1135502e3edSganesanb
1145502e3edSganesanbSet Default MCID
1155502e3edSganesanb    [Documentation]  Set default mcid.
1165502e3edSganesanb
1175502e3edSganesanb    @{ipmi_cmd_rsp_list}=  Split String  ${default_mcid}
1185502e3edSganesanb    ${number_of_bytes_to_write}=  Set Variable  ${ipmi_cmd_rsp_list[1]}
1195502e3edSganesanb    ${bytes_in_int}=  Convert To Integer  ${number_of_bytes_to_write}  16
1205502e3edSganesanb    ${bytes_to_write}=  Evaluate  ${bytes_in_int} + 1
1215502e3edSganesanb    ${no_of_bytes_to_write}=  Get Response Length In Hex  ${bytes_to_write}
1225502e3edSganesanb    @{tmp_lst}=  Create List
1235502e3edSganesanb    FOR  ${bytes}  IN  @{ipmi_cmd_rsp_list[2:]}
1245502e3edSganesanb      Append To List  ${tmp_lst}  0x${bytes}
1255502e3edSganesanb    END
1265502e3edSganesanb    ${default_hex}=  Catenate  @{tmp_lst}
1275502e3edSganesanb
1285502e3edSganesanb    ${cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['SET']}
1295502e3edSganesanb    ...  0x${no_of_bytes_to_write} ${default_hex}
1305502e3edSganesanb    Run External IPMI Raw Command  ${cmd}
1315502e3edSganesanb
1325502e3edSganesanbGet DCMI Management Controller Identifier String
1335502e3edSganesanb    [Documentation]  Get DCMI MCID String.
1345502e3edSganesanb
1355502e3edSganesanb    ${mcid_get_cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['GET']}
136e44a601bSKManimozhi123    ${resp}=  Run IPMI Command  ${mcid_get_cmd}
1378bd0130fSWilson Suen    ${resp}=  Strip String  ${resp}  mode=right  characters=${SPACE}00\n
1385502e3edSganesanb
139409df05dSGeorge Keishing    RETURN  ${resp}
1405502e3edSganesanb
1415502e3edSganesanbSet DCMI Management Controller Identifier String
1425502e3edSganesanb    [Documentation]  Set DCMI MCID String.
1435502e3edSganesanb
1445502e3edSganesanb    # 16 bytes maximum as per dcmi spec
1455502e3edSganesanb    ${random_int}=  Evaluate  random.randint(1, 15)  modules=random
1465502e3edSganesanb    ${random_string}=  Generate Random String  ${random_int}
1475502e3edSganesanb    ${string_hex_list}=  convert_name_into_bytes_with_prefix  ${random_string}
1485502e3edSganesanb    ${random_hex}=  Catenate  @{string_hex_list}
1495502e3edSganesanb    ${number_of_random_string}=  Evaluate  ${random_int} + 1
1505502e3edSganesanb    ${number_of_bytes_to_write}=  Get Response Length In Hex  ${number_of_random_string}
1515502e3edSganesanb
1525502e3edSganesanb    ${mcid_set_cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['SET']}
1535502e3edSganesanb    ...  0x${number_of_bytes_to_write} ${random_hex} 0x00
1545502e3edSganesanb    ${resp}=  Run External IPMI Raw Command  ${mcid_set_cmd}
1555502e3edSganesanb
1565502e3edSganesanb    Set Test Variable  ${string_hex_list}
1575502e3edSganesanb    Set Test Variable  ${random_int}
1585502e3edSganesanb    Set Test Variable  ${number_of_bytes_to_write}
1595502e3edSganesanb
160409df05dSGeorge Keishing    RETURN  ${resp}
1615502e3edSganesanb
1625502e3edSganesanbGet Hostname From BMC Console
1635502e3edSganesanb    [Documentation]  Get hostname.
1645502e3edSganesanb
1655502e3edSganesanb    ${cmd}=  Catenate  cat ${hostname_file_path}
1665502e3edSganesanb    ${bmc_hostname}=  BMC Execute Command  ${cmd}
1675502e3edSganesanb    ${name}=  Convert To List  ${bmc_hostname}
1685502e3edSganesanb    ${hostname_bytes}=  convert_name_into_bytes_without_prefix  ${name[0]}
1695502e3edSganesanb
170409df05dSGeorge Keishing    RETURN  ${hostname_bytes}
1715502e3edSganesanb
1725502e3edSganesanbGet Response Length In Hex
1735502e3edSganesanb    [Documentation]  Get response length in hex.
1745502e3edSganesanb    [Arguments]  ${resp_length}
1755502e3edSganesanb
1765502e3edSganesanb    ${length}=  Convert To Hex  ${resp_length}
1775502e3edSganesanb    ${length_1}=  Get Length  ${length}
1785502e3edSganesanb    ${length_2}=  Set Variable IF
1795502e3edSganesanb    ...  '${length_1}' == '1'  0${length}
1805502e3edSganesanb    ...  '${length_1}' != '1'  ${length}
1815502e3edSganesanb    ${resp_length_3}=  Convert To Lower Case  ${length_2}
1825502e3edSganesanb
183409df05dSGeorge Keishing    RETURN  ${resp_length_3}
184