| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 1 | *** Settings *** | 
|  | 2 |  | 
|  | 3 | Documentation    Module to test dcmi get temperature reading functionality. | 
|  | 4 | Resource         ../../lib/ipmi_client.robot | 
|  | 5 | Resource         ../../lib/openbmc_ffdc.robot | 
|  | 6 | Resource         ../../lib/bmc_network_utils.robot | 
|  | 7 | Resource         ../../lib/boot_utils.robot | 
|  | 8 | Variables        ../../data/ipmi_raw_cmd_table.py | 
|  | 9 | Variables        ../../data/dcmi_raw_cmd_table.py | 
|  | 10 | Variables        ../../data/ipmi_variable.py | 
|  | 11 | Library          ../../lib/bmc_network_utils.py | 
|  | 12 | Library          ../../lib/ipmi_utils.py | 
|  | 13 | Library          ../../lib/utilities.py | 
|  | 14 | Library          JSONLibrary | 
|  | 15 |  | 
|  | 16 | Suite Setup  Suite Setup Execution | 
|  | 17 |  | 
| Matt Fischer | 6fb70d9 | 2023-10-24 19:06:33 -0600 | [diff] [blame] | 18 | Test Tags       DCMI_Get_Temperature_Reading | 
| George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 19 |  | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 20 | *** Variables *** | 
| George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 21 |  | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 22 | ${config_file_name}             dcmi_sensors.json | 
|  | 23 | ${dcmi_sensors_info_json_file}  /usr/share/ipmi-providers/${config_file_name} | 
|  | 24 | ${client_config_file_path}      ${EXEC_DIR}/${config_file_name} | 
|  | 25 | &{dcmi_sensor_uri} | 
|  | 26 |  | 
|  | 27 | *** Test Cases *** | 
| Sridevi Ramesh | 34f0bf0 | 2025-07-24 09:31:26 -0500 | [diff] [blame] | 28 |  | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 29 | Verify Get Temperature Reading Command For Inlet Temperature Sensor | 
|  | 30 | [Documentation]  Verify IPMI Get Temperature Reading command for inlet temperature sensor. | 
|  | 31 | [Tags]  Verify_Get_Temperature_Reading_Command_For_Inlet_Temperature_Sensor | 
|  | 32 |  | 
|  | 33 | ${cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][0]} | 
|  | 34 | ...  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][1]} 0x00 0x00 | 
| ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 35 | ${ipmi_resp}=  Run IPMI Command  ${cmd} | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 36 | Verify Reading With IPMI  ${ipmi_resp}  ${1}  inlet | 
|  | 37 | # Verify Temperature Reading With Dbus URI  ${ipmi_resp}  inlet  ${1} | 
|  | 38 |  | 
|  | 39 | Verify Get Temperature Reading Command For CPU 0 Temperature Sensor | 
|  | 40 | [Documentation]  Verify IPMI Get Temperature Reading command for cpu0 temperature sensor. | 
|  | 41 | [Tags]  Verify_Get_Temperature_Reading_Command_For_CPU_0_Temperature_Sensor | 
|  | 42 |  | 
|  | 43 | ${cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][0]} | 
|  | 44 | ...  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][2]} 0x00 0x00 | 
| ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 45 | ${ipmi_resp}=  Run IPMI Command  ${cmd} | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 46 | Verify Reading With IPMI  ${ipmi_resp}  ${1}  cpu | 
|  | 47 | # Verify Temperature Reading With Dbus URI  ${ipmi_resp}  cpu  ${1} | 
|  | 48 |  | 
|  | 49 | Verify Get Temperature Reading Command For CPU 1 Temperature Sensor | 
|  | 50 | [Documentation]  Verify IPMI Get Temperature Reading command for cpu1 temperature sensor. | 
|  | 51 | [Tags]  Verify_Get_Temperature_Reading_Command_For_CPU_1_Temperature_Sensor | 
|  | 52 |  | 
|  | 53 | ${cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][0]} | 
|  | 54 | ...  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][2]} 0x00 0x00 | 
| ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 55 | ${ipmi_resp}=  Run IPMI Command  ${cmd} | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 56 | Verify Reading With IPMI  ${ipmi_resp}  ${2}  cpu | 
|  | 57 | # Verify Temperature Reading With Dbus URI  ${ipmi_resp}  cpu  ${2} | 
|  | 58 |  | 
|  | 59 | Verify Get Temperature Reading Command For Baseboard Temperature Sensor | 
|  | 60 | [Documentation]  Verify IPMI Get Temperature Reading command for baseboard temperature sensor. | 
|  | 61 | [Tags]  Verify_Get_Temperature_Reading_Command_For_Baseboard_Temperature_Sensor | 
|  | 62 |  | 
|  | 63 | ${cmd}=  Catenate  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][0]} | 
|  | 64 | ...  ${DCMI_RAW_CMD['DCMI']['GET_TEMPERATURE_READING'][3]} 0x00 0x00 | 
| ishwaryamathim | 372cd86 | 2023-11-14 18:12:23 +0000 | [diff] [blame] | 65 | ${ipmi_resp}=  Run IPMI Command  ${cmd} | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 66 | Verify Reading With IPMI  ${ipmi_resp}  ${1}  baseboard | 
|  | 67 | # Verify Temperature Reading With Dbus URI  ${ipmi_resp}  baseboard  ${1} | 
|  | 68 |  | 
|  | 69 | *** Keywords *** | 
|  | 70 | Suite Setup Execution | 
|  | 71 | [Documentation]  Get dcmi sensors uri from config file. | 
|  | 72 |  | 
|  | 73 | IPMI Power On  stack_mode=skip  quiet=1 | 
|  | 74 |  | 
|  | 75 | # Get this file to client machine /usr/share/ipmi-providers/dcmi_sensors.json | 
|  | 76 | scp.Open Connection | 
|  | 77 | ...  ${OPENBMC_HOST}  username=${OPENBMC_USERNAME}  password=${OPENBMC_PASSWORD}  port=${SSH_PORT} | 
|  | 78 | scp.Get File  ${dcmi_sensors_info_json_file}  ${EXEC_DIR} | 
|  | 79 | scp.Close Connection | 
|  | 80 |  | 
|  | 81 | ${config_file}=  OperatingSystem.Get File  ${client_config_file_path} | 
|  | 82 | ${config_file_response}=  Evaluate  json.loads('''${config_file}''')  json | 
|  | 83 |  | 
|  | 84 | ${remove_configuration_file}=  Catenate  rm -rf ${client_config_file_path} | 
|  | 85 | ${rc}  ${output}=  Shell Cmd  ${remove_configuration_file} | 
|  | 86 |  | 
|  | 87 | FOR  ${key}  ${value}  IN  &{config_file_response} | 
|  | 88 | &{tmp}=  Create Dictionary | 
|  | 89 | FOR  ${response}  IN  @{value} | 
|  | 90 | ${sensor_dbus}=  Get From Dictionary  ${response}  dbus | 
|  | 91 | ${instance}=  Get From Dictionary  ${response}  instance | 
|  | 92 | Set To Dictionary  ${tmp}  ${instance}  ${sensor_dbus} | 
|  | 93 | END | 
|  | 94 | Set To Dictionary  ${dcmi_sensor_uri}  ${key}  ${tmp} | 
|  | 95 | END | 
|  | 96 |  | 
|  | 97 | Verify Temperature Reading With Dbus URI | 
|  | 98 | [Documentation]  Verify temperature from ipmi response and json file. | 
|  | 99 | [Arguments]  ${ipmi_resp}  ${key}  ${instance} | 
|  | 100 |  | 
|  | 101 | # Description of argument(s): | 
|  | 102 | # ipmi_resp         IPMI command response. | 
|  | 103 | # key               Entity ID description i.e inlet, cpu, baseboard. | 
|  | 104 | # instance          instance number 1, 2, .. | 
|  | 105 |  | 
|  | 106 | ${dbus_uris}=  Get From Dictionary  ${dcmi_sensor_uri}  ${key} | 
|  | 107 | ${dbus_uri}=  Get From Dictionary  ${dbus_uris}  ${instance} | 
|  | 108 |  | 
|  | 109 | ${get_reading_value}=  Set Variable If | 
|  | 110 | ...  '${instance}' == '1'  ${3} | 
|  | 111 | ...  '${instance}' == '2'  ${5} | 
|  | 112 |  | 
|  | 113 | ${ipmi_resp_list}=  Split String  ${ipmi_resp} | 
|  | 114 | ${temperature_reading}=  Get From List  ${ipmi_resp_list}  ${get_reading_value} | 
|  | 115 | ${temp_reading}=  Convert To Integer  ${temperature_reading}  16 | 
|  | 116 | ${busctl_cmd}=  Catenate  busctl introspect xyz.openbmc_project.HwmonTempSensor ${dbus_uri} | 
|  | 117 | ${busctl_cmd_resp}=  BMC Execute Command  ${busctl_cmd} | 
|  | 118 | ${current_temp_value_from_dbus}=  Get Regexp Matches  ${busctl_cmd_resp[0]} | 
|  | 119 | ...  \\.Value\\s+property\\s+d\\s+(\\S+)\\s  1 | 
|  | 120 |  | 
|  | 121 | ${min_value}=  Evaluate  ${temp_reading} - 1 | 
|  | 122 | ${max_value}=  Evaluate  ${temp_reading} + 1 | 
|  | 123 |  | 
|  | 124 | Check Reading Value In D-Bus | 
|  | 125 | [Documentation]  Verify temperature from ipmi response and json file. | 
|  | 126 | [Arguments]  ${key}  ${instance}  ${dcmi_reading_value} | 
|  | 127 |  | 
|  | 128 | # Description of argument(s): | 
| Sridevi Ramesh | 34f0bf0 | 2025-07-24 09:31:26 -0500 | [diff] [blame] | 129 | # key                 Entity ID description i.e inlet, cpu, baseboard. | 
|  | 130 | # instance            instance number 1, 2, .. | 
|  | 131 | # dcmi_reading_value  DCMI reading value. | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 132 |  | 
|  | 133 | ${dbus_uris}=  Get From Dictionary  ${dcmi_sensor_uri}  ${key} | 
|  | 134 | ${dbus_uri}=  Get From Dictionary  ${dbus_uris}  ${instance} | 
|  | 135 |  | 
|  | 136 | ${busctl_cmd}=  Catenate  busctl introspect xyz.openbmc_project.HwmonTempSensor ${dbus_uri} | 
|  | 137 | ${busctl_cmd_resp}=  BMC Execute Command  ${busctl_cmd} | 
|  | 138 | ${current_temp_value_from_dbus}=  Get Regexp Matches  ${busctl_cmd_resp[0]} | 
|  | 139 | ...  \\.Value\\s+property\\s+d\\s+(\\S+)\\s  1 | 
| George Keishing | 923c9df | 2025-05-14 18:14:01 +0530 | [diff] [blame] | 140 |  | 
|  | 141 | IF  '${current_temp_value_from_dbus[0]}' == 'nan' and '${dcmi_reading_value}' == '0' | 
|  | 142 | Fail  msg=sensor reading value is not present. | 
|  | 143 | END | 
|  | 144 |  | 
|  | 145 | IF  '${current_temp_value_from_dbus[0]}' != 'nan' and '${dcmi_reading_value}' == '0' | 
|  | 146 | Fail  msg=sensor reading value is showing as 0 in dcmi get temperature raw command. | 
|  | 147 | END | 
|  | 148 |  | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 149 | ${dbus_reading_value}=  Set Variable  .${current_temp_value_from_dbus[0].split(".")[1].strip()} | 
|  | 150 | ${status}=  Run Keyword And Return Status  Should Be True  ${dbus_reading_value} > .499 | 
| George Keishing | 923c9df | 2025-05-14 18:14:01 +0530 | [diff] [blame] | 151 |  | 
|  | 152 | IF  ${status} == False | 
|  | 153 | Fail  msg=sensor reading value is showing wrongly in dcmi get temperature raw command. | 
|  | 154 | END | 
|  | 155 |  | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 156 | ${dbus_reading_value}=  Set Variable  ${current_temp_value_from_dbus[0].split(".")[0].strip()} | 
|  | 157 | Should Be Equal  ${dcmi_reading_value}  ${dbus_reading_value} | 
|  | 158 | ...  msg=sensor reading value is showing wrongly in dcmi get temperature raw command. | 
|  | 159 |  | 
|  | 160 | Verify Reading With IPMI | 
|  | 161 | [Documentation]  Verify temperature reading with ipmi command. | 
|  | 162 | [Arguments]  ${ipmi_resp}  ${instance}  ${key} | 
|  | 163 |  | 
|  | 164 | # Description of argument(s): | 
|  | 165 | # ipmi_resp         IPMI command response. | 
|  | 166 | # instance          instance number 1, 2, .. | 
|  | 167 | # key               Entity ID description i.e inlet, cpu, baseboard. | 
|  | 168 |  | 
|  | 169 | ${get_reading_value}=  Set Variable If | 
|  | 170 | ...  '${instance}' == '1'  ${3} | 
|  | 171 | ...  '${instance}' == '2'  ${5} | 
|  | 172 |  | 
|  | 173 | ${ipmi_resp_list}=  Split String  ${ipmi_resp} | 
|  | 174 | ${temperature_reading}=  Get From List  ${ipmi_resp_list}  ${get_reading_value} | 
|  | 175 | ${dcmi_reading}=  Convert To Integer  ${temperature_reading}  16 | 
| George Keishing | 923c9df | 2025-05-14 18:14:01 +0530 | [diff] [blame] | 176 | IF  '${dcmi_reading}' == '0' | 
|  | 177 | Check Reading Value In D-Bus  ${key}  ${instance}  ${dcmi_reading} | 
|  | 178 | END | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 179 | ${dcmi_temp_reading}=  Convert To String  ${dcmi_reading} | 
|  | 180 | ${ipmi_sensor_cmd_resp}=  Get IPMI Sensor Reading  ${key}  ${instance} | 
|  | 181 | ${ipmi_sensor_cmd_resp_list}=  Split String  ${ipmi_sensor_cmd_resp}  | | 
|  | 182 | ${ipmi_temp_reading}=  Set Variable  ${ipmi_sensor_cmd_resp_list[1].strip().split(".")[0]} | 
|  | 183 | ${reading_status}=  Run Keyword And Return Status  Should Be Equal | 
|  | 184 | ...  ${dcmi_temp_reading}  ${ipmi_temp_reading} | 
| George Keishing | 923c9df | 2025-05-14 18:14:01 +0530 | [diff] [blame] | 185 | IF  ${reading_status} == False | 
|  | 186 | Check Reading Value In D-Bus  ${key}  ${instance}  ${dcmi_temp_reading} | 
|  | 187 | END | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 188 |  | 
|  | 189 | Get IPMI Sensor Reading | 
|  | 190 | [Documentation]  Return ipmi sensor reading. | 
|  | 191 | [Arguments]  ${key}  ${instance} | 
|  | 192 |  | 
|  | 193 | # Description of argument(s): | 
|  | 194 | # instance          Entity ID description i.e inlet, cpu, baseboard. | 
|  | 195 | # index             Selecting the corresponding sensor dbus uri from list. | 
|  | 196 |  | 
|  | 197 | ${dbus_uris}=  Get From Dictionary  ${dcmi_sensor_uri}  ${key} | 
|  | 198 | ${dbus_uri}=  Get From Dictionary  ${dbus_uris}  ${instance} | 
|  | 199 | ${sensor_name}=  Set Variable  ${dbus_uri.split('/')[-1]} | 
|  | 200 |  | 
| ishwaryamathim | deb9b39 | 2023-11-10 07:21:21 +0000 | [diff] [blame] | 201 | ${sensor_format}=  Run IPMI Standard Command  sensor | 
|  | 202 | ${sensor_name_status}=  Run Keyword And Return Status  Should Contain | 
|  | 203 | ...  ${sensor_format}  _ | 
|  | 204 |  | 
| George Keishing | 923c9df | 2025-05-14 18:14:01 +0530 | [diff] [blame] | 205 | ${replaced_str}=  Replace String  ${sensor_name}  _  ${SPACE} | 
|  | 206 | ${sensor_name}=  Set Variable If  ${sensor_name_status} == True | 
|  | 207 | ...  ${sensor_name_dbus} | 
|  | 208 | ...  ${replaced_str} | 
| ishwaryamathim | deb9b39 | 2023-11-10 07:21:21 +0000 | [diff] [blame] | 209 |  | 
| ganesanb | a016f3f | 2022-12-13 13:56:34 +0000 | [diff] [blame] | 210 | ${ret}=  Run External IPMI Standard Command  sensor | grep -i "${sensor_name}" | 
|  | 211 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 212 | RETURN  ${ret} |