From 8286e6434dc10cde048701a1b5d672e83088a66c Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Sun, 28 Jan 2024 18:49:55 +0000 Subject: [PATCH] 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 --- tests/subsys/pm/power_mgmt/no-device-pm.conf | 7 +++++++ tests/subsys/pm/power_mgmt/src/main.c | 15 ++++++++++++++- tests/subsys/pm/power_mgmt/testcase.yaml | 10 +++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 tests/subsys/pm/power_mgmt/no-device-pm.conf diff --git a/tests/subsys/pm/power_mgmt/no-device-pm.conf b/tests/subsys/pm/power_mgmt/no-device-pm.conf new file mode 100644 index 000000000000000..862c4f8fa2cf885 --- /dev/null +++ b/tests/subsys/pm/power_mgmt/no-device-pm.conf @@ -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 diff --git a/tests/subsys/pm/power_mgmt/src/main.c b/tests/subsys/pm/power_mgmt/src/main.c index 3f04a673f1bc6a3..71edec7fe63fd68 100644 --- a/tests/subsys/pm/power_mgmt/src/main.c +++ b/tests/subsys/pm/power_mgmt/src/main.c @@ -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; @@ -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 */ diff --git a/tests/subsys/pm/power_mgmt/testcase.yaml b/tests/subsys/pm/power_mgmt/testcase.yaml index b51b282ea554905..8c4a1c92e3d835a 100644 --- a/tests/subsys/pm/power_mgmt/testcase.yaml +++ b/tests/subsys/pm/power_mgmt/testcase.yaml @@ -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"