Skip to content

Commit

Permalink
tests: power_mgmt: Test system-managed disabled per state
Browse files Browse the repository at this point in the history
Check that a power state that has system-managed device power
management disabled does not trigger device power management
when the system sleeps.

Signed-off-by: Flavio Ceolin <[email protected]>
  • Loading branch information
Flavio Ceolin committed May 29, 2024
1 parent 65df781 commit b49f8ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 6 additions & 1 deletion tests/subsys/pm/power_mgmt/boards/native_sim.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
compatible = "zephyr,power-state";
power-state-name = "suspend-to-idle";
};
state1: state1 {
compatible = "zephyr,power-state";
power-state-name = "standby";
zephyr,pm-device-disabled;
};
};
};

Expand All @@ -36,5 +41,5 @@
};

&cpu0 {
cpu-power-states = <&state0>;
cpu-power-states = <&state0 &state1>;
};
15 changes: 12 additions & 3 deletions tests/subsys/pm/power_mgmt/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)
set_pm = true;
zassert_equal(state, forced_state, NULL);
testing_force_state = false;

/* We have forced a state that does not trigger device power management.
* The device should still be active.
*/
pm_device_state_get(device_c, &device_power_state);
zassert_true(device_power_state == PM_DEVICE_STATE_ACTIVE);
}

/* at this point, notify_pm_state_entry() implemented in
Expand Down Expand Up @@ -244,7 +250,7 @@ const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t ticks)
{
const struct pm_state_info *cpu_states;

zassert_true(pm_state_cpu_get_all(cpu, &cpu_states) == 1,
zassert_true(pm_state_cpu_get_all(cpu, &cpu_states) == 2,
"There is no power state defined");

/* make sure this is idle thread */
Expand Down Expand Up @@ -457,8 +463,11 @@ ZTEST(power_management_1cpu, test_empty_states)

ZTEST(power_management_1cpu, test_force_state)
{
forced_state = PM_STATE_STANDBY;
bool ret = pm_state_force(0, &(struct pm_state_info) {forced_state, 0, 0});
const struct pm_state_info *cpu_states;

pm_state_cpu_get_all(0, &cpu_states);
forced_state = cpu_states[1].state;
bool ret = pm_state_force(0, &cpu_states[1]);

zassert_equal(ret, true, "Error in force state");

Expand Down

0 comments on commit b49f8ae

Please sign in to comment.