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}  240
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  raw ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][0]}
39    Sleep  ${host_reboot_time}
40
41    Verify POST Code Response Length  ${resp}
42
43Test Get BIOS POST Code via IPMI Raw Command With Host Powered Off
44    [Documentation]  Get BIOS POST Code via IPMI raw command after power off.
45    [Tags]  Test_Get_BIOS_POST_Code_via_IPMI_Raw_Command_With_Host_Powered_Off
46
47    ${resp}=  Run IPMI Standard Command  chassis power off
48    Sleep  ${power_state_change}
49    Should Contain  ${resp}  Chassis Power Control: Down/Off
50
51    ${resp}=  Run IPMI Standard Command  raw ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][0]}
52    Should Contain  ${resp}  ${IPMI_RAW_CMD['BIOS_POST_Code']['Get'][3]}
53
54*** Keywords ***
55
56Verify Host PowerOn Via IPMI
57    [Documentation]   Verify host power on operation using external IPMI command.
58    [Tags]  Verify_Host_PowerOn_Via_IPMI
59
60    IPMI Power On  stack_mode=skip  quiet=1
61    ${ipmi_state}=  Get Host State Via External IPMI
62    Valid Value  ipmi_state  ['on']
63
64
65Verify POST Code Response Length
66    [Documentation]  Verify the BIOS POST Code response byte length.
67    [Tags]  Verify_POST_Code_Response_Length
68    [Arguments]  ${resp}
69
70    # Description of argument(s):
71    # resp                          The complete response bytes from
72    #                               Get BIOS POST Code command returned
73    #                               in one string.
74
75    @{resp_bytes}=  Split String  ${resp}
76    ${string_length}=  Get Length  ${resp_bytes}
77
78    # Convert response byte length to integer.
79    ${value}=  Get Slice From List  ${resp_bytes}   2   4
80    Reverse List   ${value}
81    ${byte_length_string}=  Evaluate   "".join(${value})
82    ${byte_length_integer}=  Convert To Integer  ${byte_length_string}  16
83    ${true_length}=  Evaluate  (${string_length} - 4)
84
85    Should Be Equal  ${true_length}  ${byte_length_integer}
86
87