From 782480313edcbc96cb62590f87e240bbc8aa3149 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sun, 15 May 2022 11:20:05 +1000 Subject: [PATCH] tests: pm: device_runtime: test PM unsupported behaviour Test the behaviour of the PM device_runtime API on devices that do not support power management. Signed-off-by: Jordan Yates --- tests/subsys/pm/device_runtime_api/src/main.c | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/subsys/pm/device_runtime_api/src/main.c b/tests/subsys/pm/device_runtime_api/src/main.c index c17cff65189..64287c00d67 100644 --- a/tests/subsys/pm/device_runtime_api/src/main.c +++ b/tests/subsys/pm/device_runtime_api/src/main.c @@ -217,6 +217,25 @@ static void test_api(void) zassert_equal(ret, 0, NULL); } +static int pm_unsupported_init(const struct device *dev) +{ + return 0; +} + +DEVICE_DEFINE(pm_unsupported_device, "PM Unsupported", pm_unsupported_init, + NULL, NULL, NULL, APPLICATION, 0, NULL); + +static void test_unsupported(void) +{ + const struct device *dev = DEVICE_GET(pm_unsupported_device); + + zassert_false(pm_device_runtime_is_enabled(dev), ""); + zassert_equal(pm_device_runtime_enable(dev), -ENOTSUP, ""); + zassert_equal(pm_device_runtime_disable(dev), -ENOTSUP, ""); + zassert_equal(pm_device_runtime_get(dev), -ENOTSUP, ""); + zassert_equal(pm_device_runtime_put(dev), -ENOTSUP, ""); +} + void test_main(void) { dev = device_get_binding("test_driver"); @@ -225,6 +244,7 @@ void test_main(void) ztest_test_suite(device_runtime_api, ztest_unit_test_setup_teardown(test_api, test_api_setup, - test_api_teardown)); + test_api_teardown), + ztest_unit_test(test_unsupported)); ztest_run_test_suite(device_runtime_api); }