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
29*** Variables ***
30
31# By default 2, to ensure, it performs both Perm and Temp side switch and boot.
32${LOOP_COUNT}     2
33
34# This dictionary is for Temp -> Perm or vice versa in the test code.
35&{FW_BOOT_SIDE_DICT}  Perm=Temp  Temp=Perm
36
37*** Test Cases ***
38
39Test Firmware Boot Side Using Pldmtool
40    [Documentation]   Power off the host , set the firmware boot side via pldmtool,
41    ...               power on the host and confirm the fw_boot_side attribute is
42    ...               still set.
43    [Tags]  Test_Firmware_Boot_Side_Using_Pldmtool
44    [Template]  Firmware Side Switch Power On Loop
45
46    # iteration
47    ${LOOP_COUNT}
48
49
50*** Keywords ***
51
52Firmware Side Switch Power On Loop
53    [Documentation]   Number of iteration, test should perform switch side and boot.
54    [Arguments]  ${iteration}
55
56    # Description of argument(s):
57    # iteration      Number of switch it needs to perform.
58
59    FOR  ${count}  IN RANGE  0  ${iteration}
60        Print Timen  The Current Loop Count is ${count} of ${iteration}
61
62        # Get the current system state before BMC reset.
63        ${state}=  Get Pre Reboot State
64
65        Redfish Power Off  stack_mode=skip
66
67        ${cur_boot_side}=  PLDM Get BIOS Attribute  fw_boot_side
68        Print Timen  Current BIOS attribute fw_boot_side: ${cur_boot_side}
69
70        ${next_boot_side}=  Set Variable  ${FW_BOOT_SIDE_DICT["${cur_boot_side["CurrentValue"]}"]}
71        Print Timen  Set BIOS attribute fw_boot_side: ${next_boot_side}
72        PLDM Set BIOS Attribute  fw_boot_side  ${next_boot_side}
73
74        ${cur_boot_side}=  PLDM Get BIOS Attribute  fw_boot_side
75        Print Timen   Next boot will apply BIOS attribute fw_boot_side: ${cur_boot_side}
76
77        Print Timen  Perform power on operation and expect BMC to take reset.
78        Redfish Power Operation  On
79        Print Timen  Wait for the BMC to take reset and come back online.
80        Wait For Reboot  start_boot_seconds=${state['epoch_seconds']}  wait_state_check=0
81
82        Print Timen  BMC rebooted, wait for host to boot to Runtime.
83        # Post BMC reset, host should auto power on back to runtime.
84        Wait Until Keyword Succeeds  10 min  20 sec  Is Boot Progress Runtime Matched
85
86        # Verify the system is booting up with the new fw_boot_side set.
87        ${cur_boot_side}=  PLDM Get BIOS Attribute  fw_boot_side
88        Should Be Equal As Strings  ${cur_boot_side["CurrentValue"]}  ${next_boot_side}
89        Print Timen  Current: ${cur_boot_side["CurrentValue"]} and set side: ${next_boot_side} are same.
90    END
91
92
93Is Boot Progress Runtime Matched
94    [Documentation]  Get BootProgress state and expect boot state mismatch.
95
96    # Match any of the BootProgress state SystemHardwareInitializationComplete|OSBootStarted|OSRunning
97    ${boot_progress}  ${host_state}=  Redfish Get Boot Progress
98    Should Contain Any  ${boot_progress}  SystemHardwareInitializationComplete  OSBootStarted  OSRunning
99