From afcc8d8f6232b2cf718a606a2289f1aed1b5f4e5 Mon Sep 17 00:00:00 2001 From: dulibo1 Date: Mon, 21 Aug 2023 17:07:51 +0800 Subject: [PATCH] regulator:add testcase for regualtor register Signed-off-by: dulibo1 --- testing/drivertest/drivertest_regulator.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/testing/drivertest/drivertest_regulator.c b/testing/drivertest/drivertest_regulator.c index 17aa5c8cd..4310fdf48 100644 --- a/testing/drivertest/drivertest_regulator.c +++ b/testing/drivertest/drivertest_regulator.c @@ -194,6 +194,21 @@ static int test_regulator_resume(FAR struct regulator_dev_s *rdev) return 0; } +static void test_regulator_register(FAR void **state) +{ + FAR struct regulator_dev_s *test = NULL; + + g_fake_regulator.rdev = regulator_register(&g_fake_regulator_desc, + &g_fake_regulator_ops, + &g_fake_regulator); + assert_false(NULL == g_fake_regulator.rdev); + test = regulator_register(&g_fake_regulator_desc, + &g_fake_regulator_ops, + &g_fake_regulator); + assert_true(NULL == test); + regulator_unregister(g_fake_regulator.rdev); +} + static void test_regulator_always_on(FAR void **state) { FAR struct regulator_s *test = NULL; @@ -592,6 +607,7 @@ int main(int argc, FAR char *argv[]) { const struct CMUnitTest tests[] = { + cmocka_unit_test_prestate(test_regulator_register, NULL), cmocka_unit_test_prestate(test_regulator_always_on, NULL), cmocka_unit_test_prestate(test_regulator_supply_1, NULL), cmocka_unit_test_prestate(test_regulator_supply_2, NULL),