blob: 3456afd6ec06ba74cd3ff906b399cde13b972d1a [file] [log] [blame]
ganesanbdb74ad22023-05-01 15:47:53 +00001*** Settings ***
2
3Documentation Module to test dcmi asset tag functionality.
4Resource ../../lib/ipmi_client.robot
5Resource ../../lib/openbmc_ffdc.robot
6Library ../../lib/gen_robot_valid.py
7Library ../../lib/utils.py
8Variables ../../data/dcmi_raw_cmd_table.py
9
10Suite Setup Redfish.Login
11Suite Teardown Redfish.Logout
12Test Teardown FFDC On Test Case Fail
13
George Keishing87dc4422023-10-20 12:56:30 +053014Force Tags DCMI_Asset_Tag
ganesanbdb74ad22023-05-01 15:47:53 +000015
16*** Test Cases ***
17
18Set 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
29Set 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
35 ${resp}= Run Keyword And Expect Error * Run IPMI Standard Command
36 ... dcmi set_asset_tag ${random_string}
37 Should Contain ${resp} Parameter out of range ignore_case=True
38
39
40Set 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
51Set 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
62Set 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
66 ${random_string}= Generate Random String ${16}
67 ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string}
68 ${random_hex}= Catenate @{string_hex_list}
69 ${number_of_random_string}= Evaluate ${16} + 1
70 ${number_of_bytes_to_write}= Get Response Length In Hex ${number_of_random_string}
71
72 ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][1]} 0x${number_of_bytes_to_write} ${random_hex}
73 ${resp}= Run Keyword And Expect Error *
74 ... Run External IPMI Raw Command ${cmd}
75 Should Contain ${resp} resp=0xc9): Parameter out of range: ignore_case=True
76
77
78Set Valid Asset Tag With DCMI And Verify With Redfish
79 [Documentation] Set valid asset tag via IPMI and verify using Redfish.
80 [Tags] Set_Valid_Asset_Tag_With_DCMI_And_Verify_With_Redfish
81
82 ${cmd_resp}= Set Valid Asset Tag
83 @{cmd_resp_list}= Split String ${cmd_resp}
84 Run Keyword And Continue On Failure
85 ... Valid Value cmd_resp_list[1] valid_values=['${number_of_bytes_to_write}']
86
87 ${asset_tag}= Redfish.Get Attribute ${SYSTEM_BASE_URI} AssetTag
88 Valid Value asset_tag ['${random_string}']
89
90*** Keywords ***
91Set Valid Asset Tag
92 [Documentation] Set valid length asset tag.
93
94 # 16 bytes maximum as per dcmi spec
95 ${random_int}= Evaluate random.randint(1, 15) modules=random
96 ${random_string}= Generate Random String ${random_int}
97 ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string}
98 ${random_hex}= Catenate @{string_hex_list}
99 ${number_of_random_string}= Evaluate ${random_int} + 1
100 ${number_of_bytes_to_write}= Get Response Length In Hex ${number_of_random_string}
101
102 ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][1]} 0x${number_of_bytes_to_write} ${random_hex}
103 ${ret}= Run External IPMI Raw Command ${cmd}
104
105 Set Test Variable ${string_hex_list}
106 Set Test Variable ${random_string}
107 Set Test Variable ${number_of_bytes_to_write}
108
109 [Return] ${ret}
110
111Get Raw Asset Tag
112 [Documentation] Get asset tag command in raw command.
113
114 ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['Asset_Tag'][0]} 0x${number_of_bytes_to_write}
115 ${ret}= Run External IPMI Raw Command ${cmd}
116
117 [Return] ${ret}
118
119Validate Asset Tag Via Raw Command
120 [Documentation] Validate asset tag via raw cmd.
121
122 ${cmd_resp}= Get Raw Asset Tag
123 @{resp_list}= Split String ${cmd_resp}
124 Run Keyword And Continue On Failure
125 ... Valid Value resp_list[1] valid_values=['${number_of_bytes_to_write}']
126 ${data_list}= convert_prefix_hex_list_to_non_prefix_hex_list ${string_hex_list}
127 Lists Should Be Equal ${data_list} ${resp_list[2:]}
128 ... msg=Get asset tag command response is showing wrong response ${data_list}.
129
130Get Response Length In Hex
131 [Documentation] Get response length in hex.
132 [Arguments] ${resp_length}
133
134 ${length}= Convert To Hex ${resp_length}
135 ${length_1}= Get Length ${length}
136 ${length_2}= Set Variable IF
137 ... '${length_1}' == '1' 0${length}
138 ... '${length_1}' != '1' ${length}
139 ${ret}= Convert To Lower Case ${length_2}
140
141 [Return] ${ret}