tests: pm: initialize devices at compile time and fix ready checks
Initialize tests devices a,c at compile time. Also fix ready check (was wrongly checking for NULL). Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
e8b79e5b34
commit
d520029900
|
@ -9,10 +9,8 @@
|
|||
#include <zephyr/pm/pm.h>
|
||||
#include <zephyr/pm/device.h>
|
||||
|
||||
#define DEV_NAME DT_NODELABEL(gpio0)
|
||||
|
||||
|
||||
static const struct device *dev;
|
||||
static const struct device *const dev =
|
||||
DEVICE_DT_GET(DT_NODELABEL(gpio0));
|
||||
static uint8_t sleep_count;
|
||||
|
||||
|
||||
|
@ -80,8 +78,7 @@ ZTEST(wakeup_device_1cpu, test_wakeup_device_api)
|
|||
{
|
||||
bool ret = false;
|
||||
|
||||
dev = DEVICE_DT_GET(DEV_NAME);
|
||||
zassert_not_null(dev, "Failed to get device");
|
||||
zassert_true(device_is_ready(dev), "Device not ready");
|
||||
|
||||
ret = pm_device_wakeup_is_capable(dev);
|
||||
zassert_true(ret, "Device not marked as capable");
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
#define TEST_DEVA DT_NODELABEL(test_dev_a)
|
||||
#define TEST_DEVB DT_NODELABEL(test_dev_b)
|
||||
|
||||
static const struct device *domain, *deva, *devb, *devc;
|
||||
static const struct device *const domain = DEVICE_DT_GET(TEST_DOMAIN);
|
||||
static const struct device *const deva = DEVICE_DT_GET(TEST_DEVA);
|
||||
static const struct device *const devb = DEVICE_DT_GET(TEST_DEVB);
|
||||
static const struct device *devc;
|
||||
static int testing_domain_on_notitication;
|
||||
static int testing_domain_off_notitication;
|
||||
|
||||
|
@ -125,9 +128,6 @@ ZTEST(power_domain_1cpu, test_power_domain_device_runtime)
|
|||
int ret;
|
||||
enum pm_device_state state;
|
||||
|
||||
domain = DEVICE_DT_GET(TEST_DOMAIN);
|
||||
deva = DEVICE_DT_GET(TEST_DEVA);
|
||||
devb = DEVICE_DT_GET(TEST_DEVB);
|
||||
devc = DEVICE_GET(devc);
|
||||
|
||||
pm_device_init_suspended(domain);
|
||||
|
|
|
@ -31,9 +31,10 @@ static bool testing_device_lock;
|
|||
static const struct device *device_dummy;
|
||||
static struct dummy_driver_api *api;
|
||||
|
||||
static const struct device *device_a;
|
||||
static const struct device *device_c;
|
||||
|
||||
static const struct device *const device_a =
|
||||
DEVICE_DT_GET(DT_INST(0, test_device_pm));
|
||||
static const struct device *const device_c =
|
||||
DEVICE_DT_GET(DT_INST(2, test_device_pm));
|
||||
|
||||
/*
|
||||
* According with the initialization level, devices A, B and C are
|
||||
|
@ -375,11 +376,8 @@ ZTEST(power_management_1cpu, test_power_state_notification)
|
|||
|
||||
ZTEST(power_management_1cpu, test_device_order)
|
||||
{
|
||||
device_a = DEVICE_DT_GET(DT_INST(0, test_device_pm));
|
||||
zassert_not_null(device_a, "Failed to get device");
|
||||
|
||||
device_c = DEVICE_DT_GET(DT_INST(2, test_device_pm));
|
||||
zassert_not_null(device_c, "Failed to get device");
|
||||
zassert_true(device_is_ready(device_a), "device a not ready");
|
||||
zassert_true(device_is_ready(device_c), "device c not ready");
|
||||
|
||||
testing_device_order = true;
|
||||
enter_low_power = true;
|
||||
|
|
Loading…
Reference in a new issue