1*** Settings ***
2
3Documentation    Module to test IPMI Get BIOS POST Code Command.
4Resource         ../lib/ipmi_client.robot
5Resource         ../lib/boot_utils.robot
6Library          ../lib/ipmi_utils.py
7Variables        ../data/ipmi_raw_cmd_table.py
8
9*** Variables ***
10${power_state_change}  10
11${host_reboot_time}  360
12
13*** Test Cases ***
14
15IPMI Chassis Status On
16    [Documentation]  This test case verfies system power on status
17    ...               using IPMI Get Chassis status command.
18    [Tags]  IPMI_Chassis_Status_On
19
20    # Check the chassis status.
21    Verify Host PowerOn Via IPMI
22    ${resp}=  Run IPMI Standard Command  chassis power status
23    Should Be Equal As Strings  '${resp}'  'Chassis Power is on'
24
25Test Get BIOS POST Code via IPMI Raw Command
26    [Documentation]  Get BIOS POST Code via IPMI raw command.
27    [Tags]  Test_Get_BIOS_POST_Code_via_IPMI_Raw_Command
28
29    ${resp}=  Run IPMI Standard Command  raw ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][0]}
30    Sleep  10
31
32    Verify POST Code Response Length  ${resp}
33
34Test Get BIOS POST Code via IPMI Raw Command After Power Cycle
35    [Documentation]  Get BIOS POST Code via IPMI raw command after power cycle.
36    [Tags]  Test_Get_BIOS_POST_Code_via_IPMI_Raw_Command_After_Power_Cycle
37
38    ${resp}=  Run IPMI Standard Command  chassis power cycle
39    Sleep  ${power_state_change}
40    Should Contain  ${resp}  Chassis Power Control: Cycle
41    sleep  ${host_reboot_time}
42    ${ipmi_state}=  Get Host State Via External IPMI
43    Valid Value  ipmi_state  ['on']
44
45    ${resp}=  Run IPMI Standard Command  raw ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][0]}
46    Sleep  ${host_reboot_time}
47
48    Verify POST Code Response Length  ${resp}
49
50Test Get BIOS POST Code via IPMI Raw Command With Host Powered Off
51    [Documentation]  Get BIOS POST Code via IPMI raw command after power off.
52    [Tags]  Test_Get_BIOS_POST_Code_via_IPMI_Raw_Command_With_Host_Powered_Off
53
54    ${resp}=  Run IPMI Standard Command  chassis power off
55    Sleep  ${power_state_change}
56    Should Contain  ${resp}  Chassis Power Control: Down/Off
57
58    ${resp}=  Run IPMI Standard Command  raw ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][0]}  fail_on_err=0
59    Should Contain  ${resp}  ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][3]}
60
61    # Turn host back on.
62    IPMI Power On  stack_mode=skip  quiet=1
63    Verify Host PowerOn Via IPMI
64    ${resp}=  Run IPMI Standard Command  chassis power status
65    Should Be Equal As Strings  '${resp}'  'Chassis Power is on'
66
67*** Keywords ***
68
69Verify Host PowerOn Via IPMI
70    [Documentation]   Verify host power on operation using external IPMI command.
71    [Tags]  Verify_Host_PowerOn_Via_IPMI
72
73    IPMI Power On  stack_mode=skip  quiet=1
74    ${ipmi_state}=  Get Host State Via External IPMI
75    Valid Value  ipmi_state  ['on']
76
77
78Verify POST Code Response Length
79    [Documentation]  Verify the BIOS POST Code response byte length.
80    [Tags]  Verify_POST_Code_Response_Length
81    [Arguments]  ${resp}
82
83    # Description of argument(s):
84    # resp                          The complete response bytes from
85    #                               Get BIOS POST Code command returned
86    #                               in one string.
87
88    @{resp_bytes}=  Split String  ${resp}
89    ${string_length}=  Get Length  ${resp_bytes}
90
91    # Convert response byte length to integer.
92    ${value}=  Get Slice From List  ${resp_bytes}   2   4
93    Reverse List   ${value}
94    ${byte_length_string}=  Evaluate   "".join(${value})
95    ${byte_length_integer}=  Convert To Integer  ${byte_length_string}  16
96    ${true_length}=  Evaluate  (${string_length} - 4)
97
98    Should Be Equal  ${true_length}  ${byte_length_integer}
99
100