diff options
Diffstat (limited to 'zephyr/test/drivers/isl923x')
-rw-r--r-- | zephyr/test/drivers/isl923x/CMakeLists.txt | 23 | ||||
-rw-r--r-- | zephyr/test/drivers/isl923x/src/charge_ramp_hw.c | 23 | ||||
-rw-r--r-- | zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c | 34 |
3 files changed, 35 insertions, 45 deletions
diff --git a/zephyr/test/drivers/isl923x/CMakeLists.txt b/zephyr/test/drivers/isl923x/CMakeLists.txt index 36a97589c1..734742c6b6 100644 --- a/zephyr/test/drivers/isl923x/CMakeLists.txt +++ b/zephyr/test/drivers/isl923x/CMakeLists.txt @@ -1,22 +1,9 @@ -# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Create library name based on current directory -zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name) - -# Create interface library -zephyr_interface_library_named(${lib_name}) - -# Add include paths -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") - # Add source files -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON - "${CMAKE_CURRENT_SOURCE_DIR}/src/console_cmd_amon_bmon.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_RAMP_HW - "${CMAKE_CURRENT_SOURCE_DIR}/src/charge_ramp_hw.c") - -# Link in the library -zephyr_library_link_libraries(${lib_name}) +target_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON + app PRIVATE src/console_cmd_amon_bmon.c) +target_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_RAMP_HW + app PRIVATE src/charge_ramp_hw.c) diff --git a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c index c1ae9ce240..c814b75de9 100644 --- a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c +++ b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c @@ -1,10 +1,9 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - -#include <ztest.h> +#include <zephyr/ztest.h> #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" @@ -14,10 +13,10 @@ #include "test/drivers/test_state.h" #define CHARGER_NUM get_charger_num(&isl923x_drv) -#define ISL923X_EMUL emul_get_binding(DT_LABEL(DT_NODELABEL(isl923x_emul))) +#define ISL923X_EMUL EMUL_DT_GET(DT_NODELABEL(isl923x_emul)) -ZTEST_SUITE(charge_ramp_hw, drivers_predicate_post_main, NULL, NULL, - NULL, NULL); +ZTEST_SUITE(charge_ramp_hw, drivers_predicate_post_main, NULL, NULL, NULL, + NULL); ZTEST(charge_ramp_hw, test_charge_ramp_hw_ramp) { @@ -33,20 +32,20 @@ ZTEST(charge_ramp_hw, test_charge_ramp_hw_ramp) ZTEST(charge_ramp_hw, test_charge_ramp_hw_ramp_read_fail_reg0) { - const struct emul *isl923x_emul = ISL923X_EMUL; - struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + struct i2c_common_emul_data *common_data = + emul_isl923x_get_i2c_common_data(ISL923X_EMUL); - i2c_common_emul_set_read_fail_reg(i2c_emul, ISL923X_REG_CONTROL0); + i2c_common_emul_set_read_fail_reg(common_data, ISL923X_REG_CONTROL0); zassert_equal(EC_ERROR_INVAL, isl923x_drv.set_hw_ramp(CHARGER_NUM, 1), NULL); } ZTEST(charge_ramp_hw, test_charge_ramp_hw_ramp_read_fail_acl1) { - const struct emul *isl923x_emul = ISL923X_EMUL; - struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + struct i2c_common_emul_data *common_data = + emul_isl923x_get_i2c_common_data(ISL923X_EMUL); - i2c_common_emul_set_read_fail_reg(i2c_emul, + i2c_common_emul_set_read_fail_reg(common_data, ISL923X_REG_ADAPTER_CURRENT_LIMIT1); zassert_equal(0, isl923x_drv.ramp_get_current_limit(CHARGER_NUM), NULL); } diff --git a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c index bdbdd083ba..9246bf5b6b 100644 --- a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c +++ b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -6,7 +6,7 @@ #include <zephyr/drivers/adc.h> #include <zephyr/drivers/adc/adc_emul.h> #include <zephyr/shell/shell.h> -#include <ztest.h> +#include <zephyr/ztest.h> #include "adc.h" #include "console.h" @@ -21,7 +21,7 @@ #define ADC_DEVICE_NODE DT_NODELABEL(adc0) #define CHARGER_NUM get_charger_num(&isl923x_drv) -#define ISL923X_EMUL emul_get_binding(DT_LABEL(DT_NODELABEL(isl923x_emul))) +#define ISL923X_EMUL EMUL_DT_GET(DT_NODELABEL(isl923x_emul)) ZTEST_SUITE(console_cmd_amon_bmon, drivers_predicate_post_main, NULL, NULL, NULL, NULL); @@ -60,13 +60,14 @@ ZTEST(console_cmd_amon_bmon, test_isl923x_amonbmon_get_input_current) } ZTEST(console_cmd_amon_bmon, - test_isl923x_amonbmon_get_input_current_read_fail_req1) + test_isl923x_amonbmon_get_input_current_read_fail_req1) { const struct emul *isl923x_emul = ISL923X_EMUL; - struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + struct i2c_common_emul_data *common_data = + emul_isl923x_get_i2c_common_data(isl923x_emul); int current_milli_amps; - i2c_common_emul_set_read_fail_reg(i2c_emul, ISL923X_REG_CONTROL1); + i2c_common_emul_set_read_fail_reg(common_data, ISL923X_REG_CONTROL1); zassert_equal(EC_ERROR_INVAL, isl923x_drv.get_input_current(CHARGER_NUM, ¤t_milli_amps), @@ -76,13 +77,14 @@ ZTEST(console_cmd_amon_bmon, } ZTEST(console_cmd_amon_bmon, - test_isl923x_amonbmon_get_input_current_read_fail_req3) + test_isl923x_amonbmon_get_input_current_read_fail_req3) { const struct emul *isl923x_emul = ISL923X_EMUL; - struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + struct i2c_common_emul_data *common_data = + emul_isl923x_get_i2c_common_data(isl923x_emul); int current_milli_amps; - i2c_common_emul_set_read_fail_reg(i2c_emul, ISL9238_REG_CONTROL3); + i2c_common_emul_set_read_fail_reg(common_data, ISL9238_REG_CONTROL3); zassert_equal(EC_ERROR_INVAL, isl923x_drv.get_input_current(CHARGER_NUM, ¤t_milli_amps), @@ -90,13 +92,14 @@ ZTEST(console_cmd_amon_bmon, } ZTEST(console_cmd_amon_bmon, - test_isl923x_amonbmon_get_input_current_write_fail_req1) + test_isl923x_amonbmon_get_input_current_write_fail_req1) { const struct emul *isl923x_emul = ISL923X_EMUL; - struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + struct i2c_common_emul_data *common_data = + emul_isl923x_get_i2c_common_data(isl923x_emul); int current_milli_amps; - i2c_common_emul_set_write_fail_reg(i2c_emul, ISL923X_REG_CONTROL1); + i2c_common_emul_set_write_fail_reg(common_data, ISL923X_REG_CONTROL1); zassert_equal(EC_ERROR_INVAL, isl923x_drv.get_input_current(CHARGER_NUM, ¤t_milli_amps), @@ -104,13 +107,14 @@ ZTEST(console_cmd_amon_bmon, } ZTEST(console_cmd_amon_bmon, - test_isl923x_amonbmon_get_input_current_write_fail_req3) + test_isl923x_amonbmon_get_input_current_write_fail_req3) { const struct emul *isl923x_emul = ISL923X_EMUL; - struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul); + struct i2c_common_emul_data *common_data = + emul_isl923x_get_i2c_common_data(isl923x_emul); int current_milli_amps; - i2c_common_emul_set_write_fail_reg(i2c_emul, ISL9238_REG_CONTROL3); + i2c_common_emul_set_write_fail_reg(common_data, ISL9238_REG_CONTROL3); zassert_equal(EC_ERROR_INVAL, isl923x_drv.get_input_current(CHARGER_NUM, ¤t_milli_amps), |