tests: power_mgmt: Add test for PM_DEVICE_SYSTEM_MANAGED

Add a new test that disables PM_DEVICE_SYSTEM_MANAGED, since this
option is enabled by default.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2024-01-28 18:49:55 +00:00 committed by Anas Nashif
commit 1359eb9308
3 changed files with 28 additions and 4 deletions

View file

@ -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

View file

@ -177,6 +177,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;
@ -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)
@ -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
*/

View file

@ -1,4 +1,8 @@
tests:
pm.system:
common:
platform_allow: native_sim
tags: pm
tests:
pm.system: {}
pm.system.no.device.pm:
extra_args:
- OVERLAY_CONFIG="no-device-pm.conf"