1*** Settings ***
2
3Documentation    Test firmware boot side switch using pldmtool.
4
5# Test Procedure:
6# 1. Power off the host or post firmware is updated.
7# 2. Check the firmware boot side ( login to BMC and execute )
8#    Example:
9#    pldmtool bios GetBIOSAttributeCurrentValueByHandle -a fw_boot_side
10#
11#    It should return response either Temp or Perm
12# 3. Set the firmware boot side to Temp or Perm accordingly
13#    Example:
14#    pldmtool bios SetBIOSAttributeCurrentValue -a fw_boot_side -d Temp
15#
16# 4. Power on
17# 5. BMC take reset during power on ( expected )
18# 6. Check the system booted to Runtime
19# 7. Verify the boot side is still same which was set.
20
21Library          Collections
22Library          ../lib/tftp_update_utils.py
23Resource         ../lib/bmc_redfish_resource.robot
24Resource         ../lib/openbmc_ffdc.robot
25
26Test Setup       Printn
27Test Teardown    FFDC On Test Case Fail
28
29Force Tags       Firmware_Boot_Side
30
31*** Variables ***
32
33# By default 2, to ensure, it performs both Perm and Temp side switch and boot.
34${LOOP_COUNT}     2
35
36# This dictionary is for Temp -> Perm or vice versa in the test code.
37&{FW_BOOT_SIDE_DICT}  Perm=Temp  Temp=Perm
38
39*** Test Cases ***
40
41Test Firmware Boot Side Using Pldmtool
42    [Documentation]   Power off the host , set the firmware boot side via pldmtool,
43    ...               power on the host and confirm the fw_boot_side attribute is
44    ...               still set.
45    [Tags]  Test_Firmware_Boot_Side_Using_Pldmtool
46    [Template]  Firmware Side Switch Power On Loop
47
48    # iteration
49    ${LOOP_COUNT}
50
51
52*** Keywords ***
53
54Firmware Side Switch Power On Loop
55    [Documentation]   Number of iteration, test should perform switch side and boot.
56    [Arguments]  ${iteration}
57
58    # Description of argument(s):
59    # iteration      Number of switch it needs to perform.
60
61    FOR  ${count}  IN RANGE  0  ${iteration}
62        Print Timen  The Current Loop Count is ${count} of ${iteration}
63
64        # Get the current system state before BMC reset.
65        ${state}=  Get Pre Reboot State
66
67        Redfish Power Off  stack_mode=skip
68
69        ${cur_boot_side}=  PLDM Get BIOS Attribute  fw_boot_side
70        Print Timen  Current BIOS attribute fw_boot_side: ${cur_boot_side}
71
72        ${next_boot_side}=  Set Variable  ${FW_BOOT_SIDE_DICT["${cur_boot_side["CurrentValue"]}"]}
73        Print Timen  Set BIOS attribute fw_boot_side: ${next_boot_side}
74        PLDM Set BIOS Attribute  fw_boot_side  ${next_boot_side}
75
76        ${cur_boot_side}=  PLDM Get BIOS Attribute  fw_boot_side
77        Print Timen   Next boot will apply BIOS attribute fw_boot_side: ${cur_boot_side}
78
79        Print Timen  Perform power on operation and expect BMC to take reset.
80        Redfish Power Operation  On
81        Print Timen  Wait for the BMC to take reset and come back online.
82        Wait For Reboot  start_boot_seconds=${state['epoch_seconds']}  wait_state_check=0
83
84        Print Timen  BMC rebooted, wait for host to boot to Runtime.
85        # Post BMC reset, host should auto power on back to runtime.
86        Wait Until Keyword Succeeds  10 min  20 sec  Is Boot Progress Runtime Matched
87
88        # Verify the system is booting up with the new fw_boot_side set.
89        ${cur_boot_side}=  PLDM Get BIOS Attribute  fw_boot_side
90        Should Be Equal As Strings  ${cur_boot_side["CurrentValue"]}  ${next_boot_side}
91        Print Timen  Current: ${cur_boot_side["CurrentValue"]} and set side: ${next_boot_side} are same.
92    END
93
94
95Is Boot Progress Runtime Matched
96    [Documentation]  Get BootProgress state and expect boot state mismatch.
97
98    # Match any of the BootProgress state SystemHardwareInitializationComplete|OSBootStarted|OSRunning
99    ${boot_progress}  ${host_state}=  Redfish Get Boot Progress
100    Should Contain Any  ${boot_progress}  SystemHardwareInitializationComplete  OSBootStarted  OSRunning
101