1*** Settings ***
2Documentation   This suite tests Timed Power On(TPO) feature via busctl command
3...             and verify the power status of the system.
4...
5...             System can be scheduled to Power ON at a specified time by using this feature.
6
7
8Resource        ../lib/boot_utils.robot
9Resource        ../lib/openbmc_ffdc.robot
10Resource        ../lib/bmc_redfish_resource.robot
11
12
13Suite Setup     Redfish.Login
14Suite Teardown  Redfish.Logout
15Test Setup      Test Setup Execution
16Test Teardown   Test Teardown Execution
17
18
19*** Variables ****
20
21${CMD_SET_TPO_TIME}    busctl set-property xyz.openbmc_project.State.ScheduledHostTransition
22...  /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime t
23
24${CMD_GET_TPO_TIME}    busctl get-property xyz.openbmc_project.State.ScheduledHostTransition
25...  /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime
26
27${TIMER_POWER_ON}      100
28
29
30*** Test Cases ***
31
32Set And Return Timer For Power ON
33    [Documentation]  Set time for power ON using busctl command and verify.
34    [Tags]  Set_Time_For_Power_ON
35
36    ${tpo_set_value}=  Set Timer For Power ON
37    ${new_tpo_value}=  Get Time Power ON Value
38    Should Be Equal  ${new_tpo_value}  ${tpo_set_value}
39
40
41*** Keywords ***
42
43Test Setup Execution
44    [Documentation]  Do test case setup tasks.
45
46    Open Connection And Login
47    Redfish Power Off
48
49
50Test Teardown Execution
51    [Documentation]  Do the test teardown
52
53    FFDC On Test Case Fail
54    Close All Connections
55
56
57Set Timer For Power ON
58    [Documentation]  Set the time for power ON with given value.
59
60    ${current_bmc_time}=  BMC Execute Command  date +%s
61    ${time_set}=  Evaluate  ${current_bmc_time[0]} + ${TIMER_POWER_ON}
62    BMC Execute Command  ${CMD_SET_TPO_TIME} ${time_set}
63
64    [Return]  ${time_set}
65
66
67Get Time Power ON Value
68    [Documentation]  Returns time power ON value.
69
70    ${timer_value}=  BMC Execute Command  ${CMD_GET_TPO_TIME}
71    @{return_value}=  Split String  ${timer_value[0]}
72    ${return_value}=  Evaluate  ${return_value}[1]
73
74    # BMC command returns integer value.
75    [Return]  ${return_value}
76