tests: Add PM control to dummy_driver
Add the pm_control fn to the dummy_driver so the full PM API is tested. This change also bypasses all PM APIs if the device driver doesn't support PM. Signed-off-by: Keith Short <keithshort@google.com>
This commit is contained in:
parent
a94c2bc78b
commit
0bfde7bc5d
2 changed files with 18 additions and 10 deletions
|
@ -32,11 +32,16 @@ int dummy_init(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dummy_pm_control(const struct device *dev, enum pm_device_action action)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cond INTERNAL_HIDDEN
|
* @cond INTERNAL_HIDDEN
|
||||||
*/
|
*/
|
||||||
DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, &dummy_init,
|
DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, dummy_init,
|
||||||
NULL, NULL, NULL, POST_KERNEL,
|
dummy_pm_control, NULL, NULL, POST_KERNEL,
|
||||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs);
|
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -293,11 +293,18 @@ void test_dummy_device_pm(void)
|
||||||
{
|
{
|
||||||
const struct device *dev;
|
const struct device *dev;
|
||||||
int busy, ret;
|
int busy, ret;
|
||||||
enum pm_device_state device_power_state = PM_DEVICE_STATE_SUSPENDED;
|
enum pm_device_state device_power_state;
|
||||||
|
|
||||||
dev = device_get_binding(DUMMY_PORT_2);
|
dev = device_get_binding(DUMMY_PORT_2);
|
||||||
zassert_false((dev == NULL), NULL);
|
zassert_false((dev == NULL), NULL);
|
||||||
|
|
||||||
|
ret = pm_device_state_get(dev, &device_power_state);
|
||||||
|
if (ret == -ENOSYS) {
|
||||||
|
TC_PRINT("Power management not supported on device");
|
||||||
|
ztest_test_skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
busy = pm_device_is_any_busy();
|
busy = pm_device_is_any_busy();
|
||||||
zassert_true((busy == 0), NULL);
|
zassert_true((busy == 0), NULL);
|
||||||
|
|
||||||
|
@ -320,15 +327,11 @@ void test_dummy_device_pm(void)
|
||||||
|
|
||||||
/* Set device state to PM_DEVICE_STATE_ACTIVE */
|
/* Set device state to PM_DEVICE_STATE_ACTIVE */
|
||||||
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
ret = pm_device_state_set(dev, PM_DEVICE_STATE_ACTIVE);
|
||||||
if (ret == -ENOSYS) {
|
|
||||||
TC_PRINT("Power management not supported on device");
|
|
||||||
ztest_test_skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
zassert_true((ret == 0),
|
zassert_true((ret == 0) || (ret == -EALREADY),
|
||||||
"Unable to set active state to device");
|
"Unable to set active state to device");
|
||||||
|
|
||||||
|
device_power_state = PM_DEVICE_STATE_SUSPENDED;
|
||||||
ret = pm_device_state_get(dev, &device_power_state);
|
ret = pm_device_state_get(dev, &device_power_state);
|
||||||
zassert_true((ret == 0),
|
zassert_true((ret == 0),
|
||||||
"Unable to get active state to device");
|
"Unable to get active state to device");
|
||||||
|
@ -343,7 +346,7 @@ void test_dummy_device_pm(void)
|
||||||
ret = pm_device_state_get(dev, &device_power_state);
|
ret = pm_device_state_get(dev, &device_power_state);
|
||||||
zassert_true((ret == 0),
|
zassert_true((ret == 0),
|
||||||
"Unable to get suspend state to device");
|
"Unable to get suspend state to device");
|
||||||
zassert_true((device_power_state == PM_DEVICE_STATE_ACTIVE),
|
zassert_true((device_power_state == PM_DEVICE_STATE_SUSPENDED),
|
||||||
"Error power status");
|
"Error power status");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue