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 | |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 14 | Force Tags DCMI_Asset_Tag |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 15 | |
| 16 | *** Test Cases *** |
| 17 | |
| 18 | Set Asset Tag With Valid String Length |
| 19 | [Documentation] Set asset tag with valid string length and verify. |
| 20 | [Tags] Set_Asset_Tag_With_Valid_String_Length |
| 21 | # Allowed MAX characters length for asset tag name is 63. |
| 22 | ${random_string}= Generate Random String 63 |
| 23 | Run Keyword Run IPMI Standard Command dcmi set_asset_tag ${random_string} |
| 24 | |
| 25 | ${asset_tag}= Run Keyword Run IPMI Standard Command dcmi asset_tag |
| 26 | Should Contain ${asset_tag} ${random_string} |
| 27 | |
| 28 | |
| 29 | Set Asset Tag With Invalid String Length |
| 30 | [Documentation] Verify error while setting invalid asset tag via IPMI. |
| 31 | [Tags] Set_Asset_Tag_With_Invalid_String_Length |
| 32 | # Any string more than 63 character is invalid for asset tag. |
| 33 | ${random_string}= Generate Random String 64 |
| 34 | |
ishwaryamathim | 6d7d165 | 2023-11-09 14:20:17 +0000 | [diff] [blame] | 35 | ${resp}= Run IPMI Standard Command |
| 36 | ... dcmi set_asset_tag ${random_string} fail_on_err=0 |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 37 | Should Contain ${resp} Parameter out of range ignore_case=True |
| 38 | |
| 39 | |
| 40 | Set Asset Tag With IPMI And Verify With Redfish |
| 41 | [Documentation] Set valid asset tag via IPMI and verify using Redfish. |
| 42 | [Tags] Set_Asset_Tag_With_IPMI_And_Verify_With_Redfish |
| 43 | |
| 44 | ${random_string}= Generate Random String 63 |
| 45 | Run Keyword Run IPMI Standard Command dcmi set_asset_tag ${random_string} |
| 46 | |
| 47 | ${asset_tag}= Redfish.Get Attribute ${SYSTEM_BASE_URI} AssetTag |
| 48 | Valid Value asset_tag ['${random_string}'] |
| 49 | |
| 50 | |
| 51 | Set Asset Tag With Valid String Length Via DCMI Command |
| 52 | [Documentation] Set asset tag with valid string length and verify. |
| 53 | [Tags] Set_Asset_Tag_With_Valid_String_Length_Via_DCMI_Command |
| 54 | |
| 55 | ${cmd_resp}= Set Valid Asset Tag |
| 56 | @{cmd_resp_list}= Split String ${cmd_resp} |
| 57 | Run Keyword And Continue On Failure |
| 58 | ... Valid Value cmd_resp_list[1] valid_values=['${number_of_bytes_to_write}'] |
| 59 | Validate Asset Tag Via Raw Command |
| 60 | |
| 61 | |
| 62 | Set Asset Tag With Invalid String Length Via DCMI Command |
| 63 | [Documentation] Set asset tag with invalid string length and verify. |
| 64 | [Tags] Set_Asset_Tag_With_Invalid_String_Length_Via_DCMI_Command |
| 65 | |
manimozhik | 066f164 | 2023-11-09 07:22:18 +0000 | [diff] [blame] | 66 | ${random_string}= Generate Random String ${17} |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 67 | ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string} |
| 68 | ${random_hex}= Catenate @{string_hex_list} |
manimozhik | 066f164 | 2023-11-09 07:22:18 +0000 | [diff] [blame] | 69 | ${number_of_bytes_to_write}= Get Response Length In Hex ${17} |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 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 * |
ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 73 | ... Run IPMI Command ${cmd} |
George Keishing | 8bd8125 | 2023-11-03 00:32:01 +0530 | [diff] [blame] | 74 | Should Contain ${resp} rsp=0xc9): Parameter out of range: ignore_case=True |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 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 |
manimozhik | 066f164 | 2023-11-09 07:22:18 +0000 | [diff] [blame] | 94 | ${random_int}= Evaluate random.randint(1, 17) modules=random |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 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} |
manimozhik | 066f164 | 2023-11-09 07:22:18 +0000 | [diff] [blame] | 98 | ${number_of_bytes_to_write}= Get Response Length In Hex ${random_int} |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 99 | |
| 100 | ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][1]} 0x${number_of_bytes_to_write} ${random_hex} |
ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 101 | ${ret}= Run IPMI Command ${cmd} |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 102 | |
| 103 | Set Test Variable ${string_hex_list} |
| 104 | Set Test Variable ${random_string} |
| 105 | Set Test Variable ${number_of_bytes_to_write} |
| 106 | |
| 107 | [Return] ${ret} |
| 108 | |
| 109 | Get Raw Asset Tag |
| 110 | [Documentation] Get asset tag command in raw command. |
| 111 | |
| 112 | ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][0]} 0x${number_of_bytes_to_write} |
ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 113 | ${ret}= Run IPMI Command ${cmd} |
ganesanb | db74ad2 | 2023-05-01 15:47:53 +0000 | [diff] [blame] | 114 | |
| 115 | [Return] ${ret} |
| 116 | |
| 117 | Validate Asset Tag Via Raw Command |
| 118 | [Documentation] Validate asset tag via raw cmd. |
| 119 | |
| 120 | ${cmd_resp}= Get Raw Asset Tag |
| 121 | @{resp_list}= Split String ${cmd_resp} |
| 122 | Run Keyword And Continue On Failure |
| 123 | ... Valid Value resp_list[1] valid_values=['${number_of_bytes_to_write}'] |
| 124 | ${data_list}= convert_prefix_hex_list_to_non_prefix_hex_list ${string_hex_list} |
| 125 | Lists Should Be Equal ${data_list} ${resp_list[2:]} |
| 126 | ... msg=Get asset tag command response is showing wrong response ${data_list}. |
| 127 | |
| 128 | Get Response Length In Hex |
| 129 | [Documentation] Get response length in hex. |
| 130 | [Arguments] ${resp_length} |
| 131 | |
| 132 | ${length}= Convert To Hex ${resp_length} |
| 133 | ${length_1}= Get Length ${length} |
| 134 | ${length_2}= Set Variable IF |
| 135 | ... '${length_1}' == '1' 0${length} |
| 136 | ... '${length_1}' != '1' ${length} |
| 137 | ${ret}= Convert To Lower Case ${length_2} |
| 138 | |
| 139 | [Return] ${ret} |