tests: pm/power_mgmt: Increase test coverage
Test device API for when a device does not implement device pm. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
f966353b09
commit
7ded97ee85
2 changed files with 46 additions and 0 deletions
|
@ -20,4 +20,8 @@
|
|||
device_d: device_d {
|
||||
compatible = "test-device-pm";
|
||||
};
|
||||
|
||||
device_e: device_e {
|
||||
compatible = "test-device-pm";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -37,6 +37,19 @@ static const struct device *const device_a =
|
|||
static const struct device *const device_c =
|
||||
DEVICE_DT_GET(DT_INST(2, test_device_pm));
|
||||
|
||||
/*
|
||||
* This device does not support PM. It is used to check
|
||||
* the behavior of the PM subsystem when a device does not
|
||||
* support PM.
|
||||
*/
|
||||
static const struct device *const device_e =
|
||||
DEVICE_DT_GET(DT_INST(4, test_device_pm));
|
||||
|
||||
DEVICE_DT_DEFINE(DT_INST(4, test_device_pm), NULL,
|
||||
NULL, NULL, NULL,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
NULL);
|
||||
|
||||
/*
|
||||
* According with the initialization level, devices A, B and C are
|
||||
* initialized in the following order A -> B -> C.
|
||||
|
@ -443,6 +456,35 @@ ZTEST(power_management_1cpu, test_force_state)
|
|||
k_sleep(K_SECONDS(1U));
|
||||
}
|
||||
|
||||
ZTEST(power_management_1cpu, test_device_without_pm)
|
||||
{
|
||||
pm_device_busy_set(device_e);
|
||||
|
||||
/* Since this device does not support PM, it should not be set busy */
|
||||
zassert_false(pm_device_is_busy(device_e));
|
||||
|
||||
/* No device should be busy */
|
||||
zassert_false(pm_device_is_any_busy());
|
||||
|
||||
/* Lets ensure that nothing happens */
|
||||
pm_device_busy_clear(device_e);
|
||||
|
||||
/* Check the status. Since PM is enabled but this device does not support it.
|
||||
* It should return -ENOSYS
|
||||
*/
|
||||
zassert_equal(pm_device_state_get(device_e, NULL), -ENOSYS);
|
||||
|
||||
/* Try to forcefully change the state should also return an error */
|
||||
zassert_equal(pm_device_action_run(device_e, PM_DEVICE_ACTION_SUSPEND), -ENOSYS);
|
||||
|
||||
/* Confirming the device is powered */
|
||||
zassert_true(pm_device_is_powered(device_e));
|
||||
|
||||
/* Test wakeup functionality */
|
||||
zassert_false(pm_device_wakeup_enable(device_e, true));
|
||||
zassert_false(pm_device_wakeup_is_enabled(device_e));
|
||||
}
|
||||
|
||||
void power_management_1cpu_teardown(void *data)
|
||||
{
|
||||
pm_notifier_unregister(¬ifier);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue