ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Module to test dcmi asset tag functionality. |
| 4 | Resource ../../lib/ipmi_client.robot |
| 5 | Resource ../../lib/openbmc_ffdc.robot |
| 6 | Library ../../lib/gen_robot_valid.py |
| 7 | Library ../../lib/utils.py |
| 8 | Variables ../../data/dcmi_raw_cmd_table.py |
| 9 | |
| 10 | Suite Setup Redfish.Login |
| 11 | Suite Teardown Redfish.Logout |
| 12 | Test Teardown FFDC On Test Case Fail |
| 13 | |
| 14 | |
| 15 | *** Test Cases *** |
| 16 | |
| 17 | Set Asset Tag With Valid String Length |
| 18 | [Documentation] Set asset tag with valid string length and verify. |
| 19 | [Tags] Set_Asset_Tag_With_Valid_String_Length |
| 20 | # Allowed MAX characters length for asset tag name is 63. |
| 21 | ${random_string}= Generate Random String 63 |
| 22 | Run Keyword Run IPMI Standard Command dcmi set_asset_tag ${random_string} |
| 23 | |
| 24 | ${asset_tag}= Run Keyword Run IPMI Standard Command dcmi asset_tag |
| 25 | Should Contain ${asset_tag} ${random_string} |
| 26 | |
| 27 | |
| 28 | Set Asset Tag With Invalid String Length |
| 29 | [Documentation] Verify error while setting invalid asset tag via IPMI. |
| 30 | [Tags] Set_Asset_Tag_With_Invalid_String_Length |
| 31 | # Any string more than 63 character is invalid for asset tag. |
| 32 | ${random_string}= Generate Random String 64 |
| 33 | |
| 34 | ${resp}= Run Keyword And Expect Error * Run IPMI Standard Command |
| 35 | ... dcmi set_asset_tag ${random_string} |
| 36 | Should Contain ${resp} Parameter out of range ignore_case=True |
| 37 | |
| 38 | |
| 39 | Set Asset Tag With IPMI And Verify With Redfish |
| 40 | [Documentation] Set valid asset tag via IPMI and verify using Redfish. |
| 41 | [Tags] Set_Asset_Tag_With_IPMI_And_Verify_With_Redfish |
| 42 | |
| 43 | ${random_string}= Generate Random String 63 |
| 44 | Run Keyword Run IPMI Standard Command dcmi set_asset_tag ${random_string} |
| 45 | |
| 46 | ${asset_tag}= Redfish.Get Attribute ${SYSTEM_BASE_URI} AssetTag |
| 47 | Valid Value asset_tag ['${random_string}'] |
| 48 | |
| 49 | |
| 50 | Set Asset Tag With Valid String Length Via DCMI Command |
| 51 | [Documentation] Set asset tag with valid string length and verify. |
| 52 | [Tags] Set_Asset_Tag_With_Valid_String_Length_Via_DCMI_Command |
| 53 | |
| 54 | ${cmd_resp}= Set Valid Asset Tag |
| 55 | @{cmd_resp_list}= Split String ${cmd_resp} |
| 56 | Run Keyword And Continue On Failure |
| 57 | ... Valid Value cmd_resp_list[1] valid_values=['${number_of_bytes_to_write}'] |
| 58 | Validate Asset Tag Via Raw Command |
| 59 | |
| 60 | |
| 61 | Set Asset Tag With Invalid String Length Via DCMI Command |
| 62 | [Documentation] Set asset tag with invalid string length and verify. |
| 63 | [Tags] Set_Asset_Tag_With_Invalid_String_Length_Via_DCMI_Command |
| 64 | |
| 65 | ${random_string}= Generate Random String ${16} |
| 66 | ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string} |
| 67 | ${random_hex}= Catenate @{string_hex_list} |
| 68 | ${number_of_random_string}= Evaluate ${16} + 1 |
| 69 | ${number_of_bytes_to_write}= Get Response Length In Hex ${number_of_random_string} |
| 70 | |
| 71 | ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][1]} 0x${number_of_bytes_to_write} ${random_hex} |
| 72 | ${resp}= Run Keyword And Expect Error * |
| 73 | ... Run External IPMI Raw Command ${cmd} |
| 74 | Should Contain ${resp} resp=0xc9): Parameter out of range: ignore_case=True |
| 75 | |
| 76 | |
| 77 | Set Valid Asset Tag With DCMI And Verify With Redfish |
| 78 | [Documentation] Set valid asset tag via IPMI and verify using Redfish. |
| 79 | [Tags] Set_Valid_Asset_Tag_With_DCMI_And_Verify_With_Redfish |
| 80 | |
| 81 | ${cmd_resp}= Set Valid Asset Tag |
| 82 | @{cmd_resp_list}= Split String ${cmd_resp} |
| 83 | Run Keyword And Continue On Failure |
| 84 | ... Valid Value cmd_resp_list[1] valid_values=['${number_of_bytes_to_write}'] |
| 85 | |
| 86 | ${asset_tag}= Redfish.Get Attribute ${SYSTEM_BASE_URI} AssetTag |
| 87 | Valid Value asset_tag ['${random_string}'] |
| 88 | |
| 89 | *** Keywords *** |
| 90 | Set Valid Asset Tag |
| 91 | [Documentation] Set valid length asset tag. |
| 92 | |
| 93 | # 16 bytes maximum as per dcmi spec |
| 94 | ${random_int}= Evaluate random.randint(1, 15) modules=random |
| 95 | ${random_string}= Generate Random String ${random_int} |
| 96 | ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string} |
| 97 | ${random_hex}= Catenate @{string_hex_list} |
| 98 | ${number_of_random_string}= Evaluate ${random_int} + 1 |
| 99 | ${number_of_bytes_to_write}= Get Response Length In Hex ${number_of_random_string} |
| 100 | |
| 101 | ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][1]} 0x${number_of_bytes_to_write} ${random_hex} |
| 102 | ${ret}= Run External IPMI Raw Command ${cmd} |
| 103 | |
| 104 | Set Test Variable ${string_hex_list} |
| 105 | Set Test Variable ${random_string} |
| 106 | Set Test Variable ${number_of_bytes_to_write} |
| 107 | |
| 108 | [Return] ${ret} |
| 109 | |
| 110 | Get Raw Asset Tag |
| 111 | [Documentation] Get asset tag command in raw command. |
| 112 | |
| 113 | ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][0]} 0x${number_of_bytes_to_write} |
| 114 | ${ret}= Run External IPMI Raw Command ${cmd} |
| 115 | |
| 116 | [Return] ${ret} |
| 117 | |
| 118 | Validate Asset Tag Via Raw Command |
| 119 | [Documentation] Validate asset tag via raw cmd. |
| 120 | |
| 121 | ${cmd_resp}= Get Raw Asset Tag |
| 122 | @{resp_list}= Split String ${cmd_resp} |
| 123 | Run Keyword And Continue On Failure |
| 124 | ... Valid Value resp_list[1] valid_values=['${number_of_bytes_to_write}'] |
| 125 | ${data_list}= convert_prefix_hex_list_to_non_prefix_hex_list ${string_hex_list} |
| 126 | Lists Should Be Equal ${data_list} ${resp_list[2:]} |
| 127 | ... msg=Get asset tag command response is showing wrong response ${data_list}. |
| 128 | |
| 129 | Get Response Length In Hex |
| 130 | [Documentation] Get response length in hex. |
| 131 | [Arguments] ${resp_length} |
| 132 | |
| 133 | ${length}= Convert To Hex ${resp_length} |
| 134 | ${length_1}= Get Length ${length} |
| 135 | ${length_2}= Set Variable IF |
| 136 | ... '${length_1}' == '1' 0${length} |
| 137 | ... '${length_1}' != '1' ${length} |
| 138 | ${ret}= Convert To Lower Case ${length_2} |
| 139 | |
| 140 | [Return] ${ret} |