18a17c49cSchithrag*** Settings ***
28a17c49cSchithragDocumentation       This suite tests IPMI Payload in OpenBMC.
38a17c49cSchithrag...                 This script verifies Get Device ID IPMI command.
48a17c49cSchithrag...
58a17c49cSchithrag...                 Response data validated for each and every byte,
68a17c49cSchithrag...                 with respect to expected response.
78a17c49cSchithrag...
88a17c49cSchithrag...                 Following data validated in response bytes :
98a17c49cSchithrag...                 Device ID, Device Revision, Firmware Revision 1 & 2,
108a17c49cSchithrag...                 IPMI Version, Manufacture ID, Product ID,
118a17c49cSchithrag...                 Auxiliary Firmware Revision Information
128a17c49cSchithrag...
138a17c49cSchithrag...                 Request Data for Get Device ID defined under,
148a17c49cSchithrag...                       - data/ipmi_raw_cmd_table.py
158a17c49cSchithrag
168a17c49cSchithrag
17d0c4b800SganesanbResource            ../lib/ipmi_client.robot
18d0c4b800SganesanbResource            ../lib/openbmc_ffdc.robot
198a17c49cSchithragLibrary             Collections
208a17c49cSchithragLibrary             ../lib/ipmi_utils.py
218a17c49cSchithragLibrary             ../lib/var_funcs.py
228a17c49cSchithragVariables           ../data/ipmi_raw_cmd_table.py
238a17c49cSchithrag
24*6fb70d98SMatt FischerTest Tags          IPMI_Device_ID
258a17c49cSchithrag
268a17c49cSchithrag*** Test Cases ***
278a17c49cSchithrag
288a17c49cSchithragGet Device ID Via IPMI
298a17c49cSchithrag    [Documentation]  Verify Get Device ID using IPMI and check whether a response is received.
308a17c49cSchithrag    [Tags]  Get_Device_ID_Via_IPMI
318a17c49cSchithrag
328a17c49cSchithrag    # Verify Get Device ID.
33372cd862Sishwaryamathim    ${resp}=  Run IPMI Command
348a17c49cSchithrag    ...  ${IPMI_RAW_CMD['Device ID']['Get'][0]}
358a17c49cSchithrag    Should Not Contain  ${resp}  ${IPMI_RAW_CMD['Device ID']['Get'][1]}
368a17c49cSchithrag
378a17c49cSchithrag
388a17c49cSchithragVerify Get Device ID With Invalid Data Request
398a17c49cSchithrag    [Documentation]  Verify Get Device ID with invalid data request via IPMI.
408a17c49cSchithrag    [Tags]  Verify_Get_Device_ID_With_Invalid_Data_Request
418a17c49cSchithrag
428a17c49cSchithrag    # Run IPMI Get Device ID command with invalid request data byte.
438a17c49cSchithrag    ${resp}=  Run Keyword and Expect Error  *Request data length invalid*
44372cd862Sishwaryamathim    ...  Run IPMI Command  ${IPMI_RAW_CMD['Device ID']['Get'][0]} 0x00
458a17c49cSchithrag    # Verify error code in 'rsp='.
468a17c49cSchithrag    Should Contain  ${resp}  ${IPMI_RAW_CMD['Device ID']['Get'][2]}
478a17c49cSchithrag
488a17c49cSchithrag
498a17c49cSchithragVerify Device ID Response Data Via IPMI
508a17c49cSchithrag    [Documentation]  Verify Get Device ID response data bytes using IPMI.
518a17c49cSchithrag    [Tags]  Verify_Device_ID_Response_Data_Via_IPMI
528a17c49cSchithrag
538a17c49cSchithrag    # Get Device ID IPMI command.
54372cd862Sishwaryamathim    ${resp}=  Run IPMI Command
558a17c49cSchithrag    ...  ${IPMI_RAW_CMD['Device ID']['Get'][0]}
568a17c49cSchithrag
578a17c49cSchithrag    # Split each and every byte and form list.
588a17c49cSchithrag    ${resp}=  Split String  ${resp}
598a17c49cSchithrag
608a17c49cSchithrag    # Checking Device ID.
618a17c49cSchithrag    Run Keyword And Continue On Failure  Should Not Be Equal  ${resp[0]}  00
628a17c49cSchithrag    ...  msg=Device ID cannot be Unspecified
638a17c49cSchithrag
648a17c49cSchithrag    # Verify Device Revision.
658a17c49cSchithrag    ${device_rev}=  Set Variable  ${resp[1]}
668a17c49cSchithrag    ${device_rev}=  Convert To Binary  ${device_rev}  base=16
678a17c49cSchithrag    ${device_rev}=  Zfill Data  ${device_rev}  8
688a17c49cSchithrag    # Comparing the reserved bits from Device Revision.
698a17c49cSchithrag    Run Keyword And Continue On Failure  Should Be Equal As Strings  ${device_rev[1:4]}  000
708a17c49cSchithrag
718a17c49cSchithrag    # Get version details from /etc/os-release.
728a17c49cSchithrag    ${os_release}=  Get BMC OS Release Details
73bd187d2bSganesanb    ${version}=  Get Bmc Major Minor Version  ${os_release['version']}
748a17c49cSchithrag
758a17c49cSchithrag    # Verify Firmware Revision 1.
768a17c49cSchithrag    ${firmware_rev1}=  Set Variable  ${version[0]}
77bd187d2bSganesanb    ${ipmi_rsp_firmware_rev1}=  Convert To Integer  ${resp[2]}  base=16
78bd187d2bSganesanb    Run Keyword And Continue On Failure  Should Be Equal As Integers
79bd187d2bSganesanb    ...  ${ipmi_rsp_firmware_rev1}  ${firmware_rev1}
808a17c49cSchithrag
818a17c49cSchithrag    # Verify Firmware Revision 2.
828a17c49cSchithrag    ${firmware_rev2}=  Set Variable  ${version[1]}
83bd187d2bSganesanb    ${ipmi_rsp_firmware_rev2}=  Convert To Integer  ${resp[3]}  base=16
84bd187d2bSganesanb    Run Keyword And Continue On Failure  Should Be Equal As Integers
85bd187d2bSganesanb    ...  ${ipmi_rsp_firmware_rev2}  ${firmware_rev2}
868a17c49cSchithrag
878a17c49cSchithrag    # Verify IPMI Version.
888a17c49cSchithrag    Run Keyword And Continue On Failure  Should Be Equal  ${resp[4]}  02
898a17c49cSchithrag
908a17c49cSchithrag    # Verify Manufacture ID.
918a17c49cSchithrag    ${manufacture_id}=  Set Variable  ${resp[6:9]}
928a17c49cSchithrag    ${manufacture_id}=  Evaluate  "".join(${manufacture_id})
938a17c49cSchithrag    ${manufacture_data}=  Convert To Binary  ${manufacture_id}  base=16
948a17c49cSchithrag    # Manufacure ID has Most significant four bits - reserved (0000b)
958a17c49cSchithrag    Run Keyword And Continue On Failure  Should Be Equal  ${manufacture_data[-5:-1]}  0000
968a17c49cSchithrag
978a17c49cSchithrag    # Verify Product ID.
988a17c49cSchithrag    ${product_id}=  Set Variable  ${resp[9:11]}
998a17c49cSchithrag    ${product_id}=  Evaluate   "".join(${product_id})
1008a17c49cSchithrag    Run Keyword And Continue On Failure  Should Not Be Equal  ${product_id}  0000
1018a17c49cSchithrag    ...  msg=Product ID cannot be Zero
1028a17c49cSchithrag
1038a17c49cSchithrag    # Get Auxiliary Firmware Revision Information from IPMI response.
1048a17c49cSchithrag    ${auxiliary_rev_version}=  Set Variable  ${resp[11:]}
1058a17c49cSchithrag    Reverse List  ${auxiliary_rev_version}
1068a17c49cSchithrag    ${auxiliary_rev_version}=  Evaluate  "".join(${auxiliary_rev_version})
1078a17c49cSchithrag    ${auxiliary_rev_version}=  Convert To Integer  ${auxiliary_rev_version}  16
1088a17c49cSchithrag
1098a17c49cSchithrag    # Compare both IPMI aux version and dev_id.json aux version.
1108a17c49cSchithrag    ${dev_id_data}=  Get Device Info From BMC
1118a17c49cSchithrag    ${aux_info}=  Get From Dictionary  ${dev_id_data}  aux
1128a17c49cSchithrag    Run Keyword And Continue On Failure  Should Be Equal  ${aux_info}  ${auxiliary_rev_version}
1138a17c49cSchithrag
1148a17c49cSchithrag
1158a17c49cSchithrag*** Keywords ***
1168a17c49cSchithrag
1178a17c49cSchithragGet BMC OS Release Details
1188a17c49cSchithrag    [Documentation]  To get the release details from bmc etc/os-release.
1198a17c49cSchithrag
1208a17c49cSchithrag    # The BMC OS Release information will be,
1218a17c49cSchithrag    # for example,
1228a17c49cSchithrag    # ID=openbmc-phosphor
1238a17c49cSchithrag    # NAME="ADCD EFG BMC (OpenBMC     Project Reference Distro)"
1248a17c49cSchithrag    # VERSION="2.9.1-2719"
1258a17c49cSchithrag    # VERSION_ID=2.9.1-2719-xxxxxxxx
1268a17c49cSchithrag    # PRETTY_NAME="ABCD EFG BMC (OpenBMC     Project Reference Distro) 2.9.1-2719"
1278a17c49cSchithrag    # BUILD_ID="xxxxxxxxxx"
1288a17c49cSchithrag    # OPENBMC_TARGET_MACHINE="efg"
1298a17c49cSchithrag
1308a17c49cSchithrag    ${os_release}=  Get BMC Release Info
1318a17c49cSchithrag    ${os_release}=  Convert To Dictionary  ${os_release}
1328a17c49cSchithrag
133409df05dSGeorge Keishing    RETURN  ${os_release}
1348a17c49cSchithrag
1358a17c49cSchithrag
1368a17c49cSchithragGet Device Info From BMC
1378a17c49cSchithrag    [Documentation]  To get the device information from BMC.
1388a17c49cSchithrag
1398a17c49cSchithrag    # Get Device ID information from BMC.
1408a17c49cSchithrag    ${data}=  Bmc Execute Command   cat /usr/share/ipmi-providers/dev_id.json
1418a17c49cSchithrag    ${data}=  Convert To List  ${data}
1428a17c49cSchithrag
1438a17c49cSchithrag    # Fetching dictionary from the response.
1448a17c49cSchithrag    ${info}=  Set Variable  ${data[0]}
1458a17c49cSchithrag    ${info}=  Evaluate  dict(${info})
1468a17c49cSchithrag
147409df05dSGeorge Keishing    RETURN  ${info}
148