1*** Settings ***
2
3Documentation    Module to test PLDM platform commands.
4
5Library           ../lib/pldm_utils.py
6Variables         ../data/pldm_variables.py
7Resource          ../lib/openbmc_ffdc.robot
8Resource          ../lib/bmc_redfish_resource.robot
9Resource          ../lib/boot_utils.robot
10
11Test Setup        Printn
12Test Teardown     FFDC On Test Case Fail
13Suite Teardown    Pldmtool Platform Suite Cleanup
14
15*** Test Cases ***
16Verify GetPDR
17    [Documentation]  Verify GetPDR (Platform Descpritor Record) response message.
18    [Tags]  Verify_GetPDR
19
20    ${record_handle}=  Set Variable  ${1}
21    # Note: Record handle count is unknown and it is dynamic in nature.
22    #       Assuming there are 100 record handle.
23    FOR   ${i}  IN RANGE  100
24       ${next_record_handle}=  Run Keyword  Verify GetPDR For Record Handle  ${record_handle}
25       Exit For Loop If  ${next_record_handle} == 0
26       ${record_handle}=  Set Variable  ${next_record_handle}
27    END
28
29Verify SetStateEffecterStates
30    [Documentation]  Verify set state effecter states response message.
31    [Tags]  Verify_SetStateEffecterStates
32    [Template]  Verify SetStateEffecterStates For Effecter States
33
34    # EffecterHandle  Count  EffecterStates (effecterID effecterState)
35
36    '1'              '1'    '1 1'  # (effecterState -> 1 -> 'Boot Not Active')
37    '1'              '1'    '1 2'  # (effecterState -> 2 -> 'Boot Completed')
38    '2'              '1'    '1 9'  # (effecterState -> 9 -> 'System Power is in soft off mode')
39    '3'              '1'    '1 6'  # (effecterState -> 6 -> 'Graceful Restart Requested')
40
41*** Keywords ***
42
43Verify GetPDR For Record Handle
44    [Documentation]  Verify GetPDR (Platform Descpritor Record) for given input
45    ...              record handle and return next record handle.
46    [Arguments]  ${record_handle}
47
48    # Description of argument(s):
49    # ${record_handle}  Record handle.
50    #                   e.g. '1' is record handle 'Boot Progress' (196).
51    #                        '2' is record handle 'System Power State (260)'.
52    #                        '3' is record handle 'Software Termination Status (129)'.
53
54    # pldm_output:
55    # [responseCount]:                               29
56    # [recordHandle]:                                1
57    # [PDRHeaderVersion]:                            1
58    # [PDRType]:                                     11
59    # [recordChangeNumber]:                          0
60    # [dataLength]:                                  19
61    # [PLDMTerminusHandle]:                          0
62    # [effecterID]:                                  1
63    # [entityType]:                                  33
64    # [entityInstanceNumber]:                        0
65    # [containerID]:                                 0
66    # [effecterSemanticID]:                          0
67    # [effecterInit]:                                0
68    # [effecterDescriptionPDR]:                      false
69    # [compositeEffecterCount]:                      1
70    # [stateSetID]:                                  196
71    # [possibleStatesSize]:                          1
72    # [possibleStates]:                              6
73
74    ${pldm_cmd}=  Evaluate  $CMD_GETPDR % ${record_handle}
75    ${pldm_output}=  Pldmtool  ${pldm_cmd}
76    Rprint Vars  pldm_output
77    # Note: Output of GetPDR type 'PLDM_NUMERIC_EFFECTER_PDR' has dynamic content
78    #       hence just checking pdrtype only
79    #       GetPDR type 'PLDM_STATE_SENSOR_PDR' Dev implementation is still in progress
80    #       TODO: Verify output of GetPDR type 'PLDM_STATE_SENSOR_PDR'
81    Run Keyword If  ${pldm_output['pdrtype']} == ${PLDM_PDR_TYPES['PLDM_STATE_EFFECTER_PDR']}
82    ...  Log To Console  "Found PDR Type - PLDM_STATE_EFFECTER_PDR"
83    ...  ELSE IF  ${pldm_output['pdrtype']} == ${PLDM_PDR_TYPES['PLDM_PDR_FRU_RECORD_SET']}
84    ...  Valid Dict  pldm_output  valid_values=${RESPONSE_DICT_GETPDR_FRURECORDSETIDENTIFIER}
85    ...  ELSE IF  ${pldm_output['pdrtype']} == ${PLDM_PDR_TYPES['PLDM_PDR_ENTITY_ASSOCIATION']}
86    ...  Valid Dict  pldm_output  valid_values=${RESPONSE_DICT_GETPDR_PDRENTITYASSOCIATION}
87    ...  ELSE IF  ${pldm_output['pdrtype']} == ${PLDM_PDR_TYPES['PLDM_NUMERIC_EFFECTER_PDR']}
88    ...  Log To Console  "Found PDR Type - PLDM_NUMERIC_EFFECTER_PDR"
89    ...  ELSE IF  ${pldm_output['pdrtype']} == ${PLDM_PDR_TYPES['PLDM_STATE_SENSOR_PDR']}
90    ...  Log To Console  "Found PDR Type - PLDM_STATE_SENSOR_PDR"
91    ...  ELSE  Fail  msg="Unknown PDR Type is received"
92
93    Should be equal as strings  ${pldm_output['recordhandle']}  ${record_handle}
94    [Return]  ${pldm_output['nextrecordhandle']}
95
96Verify SetStateEffecterStates For Effecter States
97    [Documentation]  Verify set state effecter states for given input effecter states.
98    [Arguments]  ${effecter_handle}  ${count}  ${effecter_states}
99
100    # Description of argument(s):
101    # ${effecter_handle}   A handle that is used to identify and access the effecter (e.g. '1').
102    #                      e.g. '1' is effecter handle 'Boot Progress'.
103    #                           '2' is effecter handle 'System Power State'.
104    # ${count}             The number of individual sets of effecter information (e.g. '1').
105    # ${effecter_states}   (effecterID effecterState).
106    #                      e.g. '1 1'.
107
108    # Example output:
109    # [SetStateEffecterStates ]: SUCCESS
110
111    ${pldm_cmd}=  Evaluate  $CMD_SETSTATEEFFECTERSTATES % (${effecter_handle}, ${count}, ${effecter_states})
112    ${pldm_output}=  Pldmtool  ${pldm_cmd}
113    Rprint Vars  pldm_output
114    Valid Value  pldm_output['setstateeffecterstates']  ['SUCCESS']
115
116Pldmtool Platform Suite Cleanup
117    [Documentation]    Reset BMC at suite cleanup.
118
119    Redfish.Login
120    Redfish Hard Power Off
121    Redfish Power On
122    Redfish.Logout
123