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
29
30Verify SetStateEffecterStates
31    [Documentation]  Verify set state effecter states response message.
32    [Tags]  Verify_SetStateEffecterStates
33    [Template]  Verify SetStateEffecterStates For Effecter States
34
35    # EffecterHandle  Count  EffecterStates (effecterID effecterState)
36
37    '1'              '1'    '1 1'  # (effecterState -> 1 -> 'Boot Not Active')
38    '1'              '1'    '1 2'  # (effecterState -> 2 -> 'Boot Completed')
39    '2'              '1'    '1 9'  # (effecterState -> 9 -> 'System Power is in soft off mode')
40    '3'              '1'    '1 6'  # (effecterState -> 6 -> 'Graceful Restart Requested')
41
42*** Keywords ***
43
44Verify GetPDR For Record Handle
45    [Documentation]  Verify GetPDR (Platform Descpritor Record) for given input
46    ...              record handle and return next record handle.
47    [Arguments]  ${record_handle}
48
49    # Description of argument(s):
50    # ${record_handle}  Record handle.
51    #                   e.g. '1' is record handle 'Boot Progress' (196).
52    #                        '2' is record handle 'System Power State (260)'.
53    #                        '3' is record handle 'Software Termination Status (129)'.
54
55    # pldm_output:
56    # [responseCount]:                               29
57    # [recordHandle]:                                1
58    # [PDRHeaderVersion]:                            1
59    # [PDRType]:                                     11
60    # [recordChangeNumber]:                          0
61    # [dataLength]:                                  19
62    # [PLDMTerminusHandle]:                          0
63    # [effecterID]:                                  1
64    # [entityType]:                                  33
65    # [entityInstanceNumber]:                        0
66    # [containerID]:                                 0
67    # [effecterSemanticID]:                          0
68    # [effecterInit]:                                0
69    # [effecterDescriptionPDR]:                      false
70    # [compositeEffecterCount]:                      1
71    # [stateSetID]:                                  196
72    # [possibleStatesSize]:                          1
73    # [possibleStates]:                              6
74
75    ${pldm_cmd}=  Evaluate  $CMD_GETPDR % ${record_handle}
76    ${pldm_output}=  Pldmtool  ${pldm_cmd}
77    Rprint Vars  pldm_output
78    # Note: Output of GetPDR type 'PLDM_NUMERIC_EFFECTER_PDR' has dynamic content
79    #       hence just checking pdrtype only
80    #       GetPDR type 'PLDM_STATE_SENSOR_PDR' Dev implementation is still in progress
81    #       TODO: Verify output of GetPDR type 'PLDM_STATE_SENSOR_PDR'
82    Run Keyword If  '${pldm_output['pdrtype']}' == '${PLDM_PDR_TYPES['PLDM_STATE_EFFECTER_PDR']}'
83    ...  Run Keywords  Log To Console  "Found PDR Type - PLDM_STATE_EFFECTER_PDR"  AND
84    ...  Valid Dict  pldm_output  valid_values=${RESPONSE_DICT_GETPDR_FRURECORDSETIDENTIFIER}
85
86    ...    ELSE IF  '${pldm_output['pdrtype']}' == '${PLDM_PDR_TYPES['PLDM_PDR_ENTITY_ASSOCIATION']}'
87    ...    Valid Dict  pldm_output  valid_values=${RESPONSE_DICT_GETPDR_PDRENTITYASSOCIATION}
88
89    ...    ELSE IF  '${pldm_output['pdrtype']}' == '${PLDM_PDR_TYPES['PLDM_STATE_SENSOR_PDR']}'
90    ...    Valid Dict  pldm_output  valid_values=${RESPONSE_DICT_GETPDR_STATESENSORPDR}
91
92    ...    ELSE IF  '${pldm_output['pdrtype']}' == '${PLDM_PDR_TYPES['PLDM_NUMERIC_EFFECTER_PDR']}'
93    ...    Log To Console  "Found PDR Type - PLDM_NUMERIC_EFFECTER_PDR"
94
95    ...    ELSE IF  '${pldm_output['pdrtype']}' == '${PLDM_PDR_TYPES['PLDM_TERMINUS_LOCATOR_PDR']}'
96    ...    Log To Console  "Found PDR Type - PLDM_TERMINUS_LOCATOR_PDR"
97
98    ...    ELSE  Fail  msg="Unknown PDR Type is received"
99
100    Should be equal as strings  ${pldm_output['recordhandle']}  ${record_handle}
101    [Return]  ${pldm_output['nextrecordhandle']}
102
103Verify SetStateEffecterStates For Effecter States
104    [Documentation]  Verify set state effecter states for given input effecter states.
105    [Arguments]  ${effecter_handle}  ${count}  ${effecter_states}
106
107    # Description of argument(s):
108    # ${effecter_handle}   A handle that is used to identify and access the effecter (e.g. '1').
109    #                      e.g. '1' is effecter handle 'Boot Progress'.
110    #                           '2' is effecter handle 'System Power State'.
111    # ${count}             The number of individual sets of effecter information (e.g. '1').
112    # ${effecter_states}   (effecterID effecterState).
113    #                      e.g. '1 1'.
114
115    # Example output:
116    # [SetStateEffecterStates ]: SUCCESS
117
118    ${pldm_cmd}=  Evaluate  $CMD_SETSTATEEFFECTERSTATES % (${effecter_handle}, ${count}, ${effecter_states})
119    ${pldm_output}=  Pldmtool  ${pldm_cmd}
120    Rprint Vars  pldm_output
121    Valid Value  pldm_output['setstateeffecterstates']  ['SUCCESS']
122
123Pldmtool Platform Suite Cleanup
124    [Documentation]    Reset BMC at suite cleanup.
125
126    Redfish.Login
127    Redfish Hard Power Off
128    Redfish Power On
129    Redfish.Logout
130