Skip to content

Commit

Permalink
tests: power_mgmt: Add test for PM_DEVICE_SYSTEM_MANAGED
Browse files Browse the repository at this point in the history
Add a new test that disables PM_DEVICE_SYSTEM_MANAGED, since this
option is enabled by default.

Signed-off-by: Flavio Ceolin <[email protected]>
  • Loading branch information
Flavio Ceolin committed Mar 22, 2024
1 parent d365c1d commit 8286e64
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
7 changes: 7 additions & 0 deletions tests/subsys/pm/power_mgmt/no-device-pm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_ZTEST=y
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_PM_POLICY_CUSTOM=y
CONFIG_PM_DEVICE_SYSTEM_MANAGED=n
CONFIG_MP_MAX_NUM_CPUS=1
15 changes: 14 additions & 1 deletion tests/subsys/pm/power_mgmt/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)

enum pm_device_state device_power_state;

#ifndef CONFIG_PM_DEVICE_SYSTEM_MANAGED
/* Devices shouldn't have changed state because system managed
* device power management is not enabled.
**/
pm_device_state_get(device_a, &device_power_state);
zassert_true(device_power_state == PM_DEVICE_STATE_ACTIVE,
NULL);

pm_device_state_get(device_c, &device_power_state);
zassert_true(device_power_state == PM_DEVICE_STATE_ACTIVE,
NULL);
#else
/* If testing device order this function does not need to anything */
if (testing_device_order) {
return;
Expand Down Expand Up @@ -213,6 +225,7 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)
*/
zassert_false(state == PM_STATE_ACTIVE,
"Entering low power state with a wrong parameter");
#endif
}

void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
Expand Down Expand Up @@ -261,7 +274,7 @@ static void notify_pm_state_entry(enum pm_state state)
zassert_equal(state, PM_STATE_SUSPEND_TO_IDLE);

pm_device_state_get(device_dummy, &device_power_state);
if (testing_device_runtime) {
if (testing_device_runtime || !IS_ENABLED(CONFIG_PM_DEVICE_SYSTEM_MANAGED)) {
/* If device runtime is enable, the device should still be
* active
*/
Expand Down
10 changes: 7 additions & 3 deletions tests/subsys/pm/power_mgmt/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
common:
platform_allow: native_sim
tags: pm
tests:
pm.system:
platform_allow: native_sim
tags: pm
pm.system: {}
pm.system.no.device.pm:
extra_args:
- OVERLAY_CONFIG="no-device-pm.conf"

0 comments on commit 8286e64

Please sign in to comment.