From 974eef0d1056e43debaa74004a705474a0e57416 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 28 Mar 2022 21:35:07 -0600 Subject: zephyr: test: move include files to scoped directory The include path was getting too cluttered. In some cases seeing an include for "utils.h" and "util.h". These were difficult to understand, follow, and ensure uniqueness. Move all the test specific headers to their own path. BRANCH=none BUG=none TEST=zmake test test-drivers Signed-off-by: Yuval Peress Change-Id: Iab5e4d470321edb356c8b30f94c79b2ce1f38866 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3556801 Reviewed-by: Jack Rosenthal --- zephyr/test/drivers/include/charger_utils.h | 30 -- zephyr/test/drivers/include/stubs.h | 31 --- zephyr/test/drivers/include/tcpci_test_common.h | 192 ------------- .../drivers/include/test/drivers/charger_utils.h | 30 ++ zephyr/test/drivers/include/test/drivers/stubs.h | 31 +++ .../include/test/drivers/tcpci_test_common.h | 192 +++++++++++++ .../test/drivers/include/test/drivers/test_mocks.h | 107 +++++++ .../test/drivers/include/test/drivers/test_state.h | 17 ++ zephyr/test/drivers/include/test/drivers/utils.h | 309 +++++++++++++++++++++ zephyr/test/drivers/include/test_mocks.h | 107 ------- zephyr/test/drivers/include/test_state.h | 17 -- zephyr/test/drivers/include/utils.h | 309 --------------------- zephyr/test/drivers/isl923x/src/charge_ramp_hw.c | 4 +- .../drivers/isl923x/src/console_cmd_amon_bmon.c | 6 +- zephyr/test/drivers/src/battery.c | 2 +- zephyr/test/drivers/src/bb_retimer.c | 6 +- zephyr/test/drivers/src/bc12.c | 4 +- zephyr/test/drivers/src/bma2x2.c | 2 +- zephyr/test/drivers/src/bmi160.c | 4 +- zephyr/test/drivers/src/bmi260.c | 4 +- zephyr/test/drivers/src/charge_manager.c | 2 +- .../test/drivers/src/console_cmd/charge_manager.c | 4 +- zephyr/test/drivers/src/console_cmd/charge_state.c | 4 +- zephyr/test/drivers/src/cros_cbi.c | 2 +- zephyr/test/drivers/src/espi.c | 2 +- zephyr/test/drivers/src/gpio.c | 4 +- zephyr/test/drivers/src/host_cmd/motion_sense.c | 4 +- zephyr/test/drivers/src/i2c_passthru.c | 2 +- zephyr/test/drivers/src/integration/usbc/usb.c | 6 +- .../src/integration/usbc/usb_20v_3a_pd_charger.c | 4 +- .../src/integration/usbc/usb_5v_3a_pd_sink.c | 4 +- .../src/integration/usbc/usb_5v_3a_pd_source.c | 4 +- .../drivers/src/integration/usbc/usb_alt_mode.c | 6 +- .../src/integration/usbc/usb_attach_src_snk.c | 6 +- zephyr/test/drivers/src/isl923x.c | 6 +- zephyr/test/drivers/src/keyboard_scan.c | 2 +- zephyr/test/drivers/src/lid_switch.c | 2 +- zephyr/test/drivers/src/lis2dw12.c | 2 +- zephyr/test/drivers/src/ln9310.c | 2 +- zephyr/test/drivers/src/main.c | 2 +- .../test/drivers/src/motion_sense/motion_sense.c | 2 +- zephyr/test/drivers/src/panic.c | 4 +- zephyr/test/drivers/src/power_common.c | 6 +- zephyr/test/drivers/src/ppc_sn5s330.c | 4 +- zephyr/test/drivers/src/ppc_syv682c.c | 4 +- zephyr/test/drivers/src/ps8xxx.c | 6 +- zephyr/test/drivers/src/smart.c | 2 +- zephyr/test/drivers/src/stm_mems_common.c | 2 +- zephyr/test/drivers/src/stubs.c | 2 +- zephyr/test/drivers/src/tcpci.c | 6 +- zephyr/test/drivers/src/tcpci_test_common.c | 2 +- zephyr/test/drivers/src/tcs3400.c | 2 +- zephyr/test/drivers/src/temp_sensor.c | 2 +- zephyr/test/drivers/src/test_mocks.c | 2 +- zephyr/test/drivers/src/thermistor.c | 2 +- zephyr/test/drivers/src/usb_mux.c | 6 +- zephyr/test/drivers/src/usb_pd_host_cmd.c | 2 +- zephyr/test/drivers/src/utils.c | 4 +- zephyr/test/drivers/src/vboot_hash.c | 2 +- zephyr/test/drivers/src/watchdog.c | 4 +- 60 files changed, 770 insertions(+), 770 deletions(-) delete mode 100644 zephyr/test/drivers/include/charger_utils.h delete mode 100644 zephyr/test/drivers/include/stubs.h delete mode 100644 zephyr/test/drivers/include/tcpci_test_common.h create mode 100644 zephyr/test/drivers/include/test/drivers/charger_utils.h create mode 100644 zephyr/test/drivers/include/test/drivers/stubs.h create mode 100644 zephyr/test/drivers/include/test/drivers/tcpci_test_common.h create mode 100644 zephyr/test/drivers/include/test/drivers/test_mocks.h create mode 100644 zephyr/test/drivers/include/test/drivers/test_state.h create mode 100644 zephyr/test/drivers/include/test/drivers/utils.h delete mode 100644 zephyr/test/drivers/include/test_mocks.h delete mode 100644 zephyr/test/drivers/include/test_state.h delete mode 100644 zephyr/test/drivers/include/utils.h diff --git a/zephyr/test/drivers/include/charger_utils.h b/zephyr/test/drivers/include/charger_utils.h deleted file mode 100644 index 1712a5a384..0000000000 --- a/zephyr/test/drivers/include/charger_utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_CHARGER_UTILS_H_ -#define ZEPHYR_TEST_DRIVERS_INCLUDE_CHARGER_UTILS_H_ - -#include "charger.h" - -/** - * @brief Get the index of the charger in chg_chips - * - * @param charger Pointer to the charger driver. - * @return The index of the charger if found - * @return board_get_charger_chip_count() if not found - */ -static inline uint8_t get_charger_num(const struct charger_drv *charger) -{ - const uint8_t chip_count = board_get_charger_chip_count(); - uint8_t chip; - - for (chip = 0; chip < chip_count; ++chip) { - if (chg_chips[chip].drv == charger) - return chip; - } - return chip; -} - -#endif /* ZEPHYR_TEST_DRIVERS_INCLUDE_CHARGER_UTILS_H_ */ diff --git a/zephyr/test/drivers/include/stubs.h b/zephyr/test/drivers/include/stubs.h deleted file mode 100644 index 2e03142d72..0000000000 --- a/zephyr/test/drivers/include/stubs.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __TEST_DRIVERS_STUBS_H -#define __TEST_DRIVERS_STUBS_H - -#include "fff.h" -#include "power.h" - -enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; - -/* Structure used by usb_mux test. It is part of usb_muxes chain. */ -extern struct usb_mux usbc1_virtual_usb_mux; - -/** - * @brief Set product ID that should be returned by board_get_ps8xxx_product_id - * - * @param product_id ID of PS8xxx product which is emulated - */ -void board_set_ps8xxx_product_id(uint16_t product_id); - -/* Declare fake function to allow tests to examine calls to this function */ -DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); - -void sys_arch_reboot(int type); - -/* Declare GPIO_TEST interrupt handler */ -void gpio_test_interrupt(enum gpio_signal signal); -#endif /* __TEST_DRIVERS_STUBS_H */ diff --git a/zephyr/test/drivers/include/tcpci_test_common.h b/zephyr/test/drivers/include/tcpci_test_common.h deleted file mode 100644 index e39738a9d5..0000000000 --- a/zephyr/test/drivers/include/tcpci_test_common.h +++ /dev/null @@ -1,192 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __TCPCI_TEST_COMMON_H -#define __TCPCI_TEST_COMMON_H - -#include "stubs.h" - -/** - * @brief Check TCPC register value using zassert API - * - * @param emul Pointer to TCPCI emulator - * @param reg TCPC register address to check - * @param exp_val Expected value of register - * @param line Line number to print in case of failure - */ -void check_tcpci_reg_f(const struct emul *emul, int reg, uint16_t exp_val, - int line); -#define check_tcpci_reg(emul, reg, exp_val) \ - check_tcpci_reg_f((emul), (reg), (exp_val), __LINE__) - -/** - * @brief Check TCPC register value with mask using zassert API - * - * @param emul Pointer to TCPCI emulator - * @param reg TCPC register address to check - * @param exp_val Expected value of register - * @param mask Bits that are checked - * @param line Line number to print in case of failure - */ -void check_tcpci_reg_with_mask_f(const struct emul *emul, int reg, - uint16_t exp_val, uint16_t mask, int line); -#define check_tcpci_reg_with_mask(emul, reg, exp_val, mask) \ - check_tcpci_reg_with_mask_f((emul), (reg), (exp_val), (mask), __LINE__) - -/** - * @brief Test TCPCI init and vbus level callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_init(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI release callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_release(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI get cc callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_get_cc(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI set cc callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_set_cc(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI set polarity callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_set_polarity(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI set vconn callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_set_vconn(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI set msg header callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_set_msg_header(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI rx and sop prime enable callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_set_rx_detect(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI get raw message from TCPC callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_get_rx_message_raw(const struct emul *emul, - enum usbc_port port); - -/** - * @brief Test TCPCI transmitting message from TCPC callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_transmit(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI alert callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_alert(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI alert RX message callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_alert_rx_message(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI auto discharge on disconnect callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_auto_discharge(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI drp toggle callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_drp_toggle(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI get chip info callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_get_chip_info(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI enter low power mode callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_low_power_mode(const struct emul *emul, enum usbc_port port); - -/** - * @brief Test TCPCI set bist test mode callback - * - * @param emul Pointer to TCPCI emulator - * @param port Select USBC port that will be used to obtain tcpm_drv from - * tcpc_config - */ -void test_tcpci_set_bist_mode(const struct emul *emul, enum usbc_port port); - -#endif /* __TCPCI_TEST_COMMON_H */ diff --git a/zephyr/test/drivers/include/test/drivers/charger_utils.h b/zephyr/test/drivers/include/test/drivers/charger_utils.h new file mode 100644 index 0000000000..1712a5a384 --- /dev/null +++ b/zephyr/test/drivers/include/test/drivers/charger_utils.h @@ -0,0 +1,30 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_CHARGER_UTILS_H_ +#define ZEPHYR_TEST_DRIVERS_INCLUDE_CHARGER_UTILS_H_ + +#include "charger.h" + +/** + * @brief Get the index of the charger in chg_chips + * + * @param charger Pointer to the charger driver. + * @return The index of the charger if found + * @return board_get_charger_chip_count() if not found + */ +static inline uint8_t get_charger_num(const struct charger_drv *charger) +{ + const uint8_t chip_count = board_get_charger_chip_count(); + uint8_t chip; + + for (chip = 0; chip < chip_count; ++chip) { + if (chg_chips[chip].drv == charger) + return chip; + } + return chip; +} + +#endif /* ZEPHYR_TEST_DRIVERS_INCLUDE_CHARGER_UTILS_H_ */ diff --git a/zephyr/test/drivers/include/test/drivers/stubs.h b/zephyr/test/drivers/include/test/drivers/stubs.h new file mode 100644 index 0000000000..2e03142d72 --- /dev/null +++ b/zephyr/test/drivers/include/test/drivers/stubs.h @@ -0,0 +1,31 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __TEST_DRIVERS_STUBS_H +#define __TEST_DRIVERS_STUBS_H + +#include "fff.h" +#include "power.h" + +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; + +/* Structure used by usb_mux test. It is part of usb_muxes chain. */ +extern struct usb_mux usbc1_virtual_usb_mux; + +/** + * @brief Set product ID that should be returned by board_get_ps8xxx_product_id + * + * @param product_id ID of PS8xxx product which is emulated + */ +void board_set_ps8xxx_product_id(uint16_t product_id); + +/* Declare fake function to allow tests to examine calls to this function */ +DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); + +void sys_arch_reboot(int type); + +/* Declare GPIO_TEST interrupt handler */ +void gpio_test_interrupt(enum gpio_signal signal); +#endif /* __TEST_DRIVERS_STUBS_H */ diff --git a/zephyr/test/drivers/include/test/drivers/tcpci_test_common.h b/zephyr/test/drivers/include/test/drivers/tcpci_test_common.h new file mode 100644 index 0000000000..e39738a9d5 --- /dev/null +++ b/zephyr/test/drivers/include/test/drivers/tcpci_test_common.h @@ -0,0 +1,192 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __TCPCI_TEST_COMMON_H +#define __TCPCI_TEST_COMMON_H + +#include "stubs.h" + +/** + * @brief Check TCPC register value using zassert API + * + * @param emul Pointer to TCPCI emulator + * @param reg TCPC register address to check + * @param exp_val Expected value of register + * @param line Line number to print in case of failure + */ +void check_tcpci_reg_f(const struct emul *emul, int reg, uint16_t exp_val, + int line); +#define check_tcpci_reg(emul, reg, exp_val) \ + check_tcpci_reg_f((emul), (reg), (exp_val), __LINE__) + +/** + * @brief Check TCPC register value with mask using zassert API + * + * @param emul Pointer to TCPCI emulator + * @param reg TCPC register address to check + * @param exp_val Expected value of register + * @param mask Bits that are checked + * @param line Line number to print in case of failure + */ +void check_tcpci_reg_with_mask_f(const struct emul *emul, int reg, + uint16_t exp_val, uint16_t mask, int line); +#define check_tcpci_reg_with_mask(emul, reg, exp_val, mask) \ + check_tcpci_reg_with_mask_f((emul), (reg), (exp_val), (mask), __LINE__) + +/** + * @brief Test TCPCI init and vbus level callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_init(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI release callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_release(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI get cc callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_get_cc(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI set cc callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_set_cc(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI set polarity callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_set_polarity(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI set vconn callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_set_vconn(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI set msg header callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_set_msg_header(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI rx and sop prime enable callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_set_rx_detect(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI get raw message from TCPC callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_get_rx_message_raw(const struct emul *emul, + enum usbc_port port); + +/** + * @brief Test TCPCI transmitting message from TCPC callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_transmit(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI alert callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_alert(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI alert RX message callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_alert_rx_message(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI auto discharge on disconnect callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_auto_discharge(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI drp toggle callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_drp_toggle(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI get chip info callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_get_chip_info(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI enter low power mode callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_low_power_mode(const struct emul *emul, enum usbc_port port); + +/** + * @brief Test TCPCI set bist test mode callback + * + * @param emul Pointer to TCPCI emulator + * @param port Select USBC port that will be used to obtain tcpm_drv from + * tcpc_config + */ +void test_tcpci_set_bist_mode(const struct emul *emul, enum usbc_port port); + +#endif /* __TCPCI_TEST_COMMON_H */ diff --git a/zephyr/test/drivers/include/test/drivers/test_mocks.h b/zephyr/test/drivers/include/test/drivers/test_mocks.h new file mode 100644 index 0000000000..f29cce97cc --- /dev/null +++ b/zephyr/test/drivers/include/test/drivers/test_mocks.h @@ -0,0 +1,107 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/* + * Convenience macros + */ + +/** + * @brief Helper macro for inspecting the argument history of a given + * fake. Counts number of times the fake was called with a given + * argument. + * @param FAKE - FFF-provided fake structure (no pointers). + * @param ARG_NUM - Zero-based index of the argument to compare. + * @param VAL - Expression the argument must equal. + * @return Returns the number of times a call was made to the fake + * where the argument `ARG_NUM` equals `VAL`. + */ +#define MOCK_COUNT_CALLS_WITH_ARG_VALUE(FAKE, ARG_NUM, VAL) \ + ({ \ + int count = 0; \ + for (int i = 0; i < (FAKE).call_count; i++) { \ + if ((FAKE).arg##ARG_NUM##_history[i] == (VAL)) { \ + count++; \ + } \ + } \ + count; \ + }) + +/** + * @brief Helper macro for asserting that a certain register write occurred. + * Used when wrapping an I2C emulator mock write function in FFF. Prints + * useful error messages when the assertion fails. + * @param FAKE - name of the fake whose arg history to insepct. Do not include + * '_fake' at the end. + * @param CALL_NUM - Index in to the call history that this write should have + * occurred at. Zero based. + * @param EXPECTED_REG - The register address that was supposed to be written. + * @param EXPECTED_VAL - The 8-bit value that was supposed to be written, or + * `MOCK_IGNORE_VALUE` to suppress this check. + */ +#define MOCK_ASSERT_I2C_WRITE(FAKE, CALL_NUM, EXPECTED_REG, EXPECTED_VAL) \ + do { \ + zassert_true((CALL_NUM) < FAKE##_fake.call_count, \ + "Call #%d did not occur (%d I2C writes total)", \ + (CALL_NUM), FAKE##_fake.call_count); \ + zassert_equal( \ + FAKE##_fake.arg1_history[(CALL_NUM)], (EXPECTED_REG), \ + "Expected I2C write #%d to register 0x%02x (" \ + #EXPECTED_REG ") but wrote to reg 0x%02x", \ + (CALL_NUM), (EXPECTED_REG), \ + FAKE##_fake.arg1_history[(CALL_NUM)]); \ + if ((EXPECTED_VAL) != MOCK_IGNORE_VALUE) { \ + zassert_equal( \ + FAKE##_fake.arg2_history[(CALL_NUM)], \ + (EXPECTED_VAL), \ + "Expected I2C write #%d to register 0x%02x (" \ + #EXPECTED_REG ") to write 0x%02x (" \ + #EXPECTED_VAL ") but wrote 0x%02x", \ + (CALL_NUM), (EXPECTED_REG), (EXPECTED_VAL), \ + FAKE##_fake.arg2_history[(CALL_NUM)]); \ + } \ + } while (0) + +/** @brief Value to pass to MOCK_ASSERT_I2C_WRITE to ignore the actual value + * written. + */ +#define MOCK_IGNORE_VALUE (-1) + +/** + * @brief Helper macro for asserting that a certain register read occurred. + * Used when wrapping an I2C emulator mock read function in FFF. Prints + * useful error messages when the assertion fails. + * @param FAKE - name of the fake whose arg history to insepct. Do not include + * '_fake' at the end. + * @param CALL_NUM - Index in to the call history that this write should have + * occurred at. Zero based. + * @param EXPECTED_REG - The register address that was supposed to be read + * from. + */ +#define MOCK_ASSERT_I2C_READ(FAKE, CALL_NUM, EXPECTED_REG) \ + do { \ + zassert_true((CALL_NUM) < FAKE##_fake.call_count, \ + "Call #%d did not occur (%d I2C reads total)", \ + (CALL_NUM), FAKE##_fake.call_count); \ + zassert_equal( \ + FAKE##_fake.arg1_history[(CALL_NUM)], (EXPECTED_REG), \ + "Expected I2C read #%d from register 0x%02x (" \ + #EXPECTED_REG ") but read from reg 0x%02x", \ + (CALL_NUM), (EXPECTED_REG), \ + FAKE##_fake.arg1_history[(CALL_NUM)]); \ + } while (0) + +/* + * Mock declarations + */ + +/* Mocks for common/init_rom.c */ +DECLARE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int); +DECLARE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int); +DECLARE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int); + +/* Mocks for common/system.c */ +DECLARE_FAKE_VALUE_FUNC(int, system_jumped_late); diff --git a/zephyr/test/drivers/include/test/drivers/test_state.h b/zephyr/test/drivers/include/test/drivers/test_state.h new file mode 100644 index 0000000000..fe8b3e8ffc --- /dev/null +++ b/zephyr/test/drivers/include/test/drivers/test_state.h @@ -0,0 +1,17 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ +#define ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ + +struct test_state { + bool ec_app_main_run; +}; + +bool drivers_predicate_pre_main(const void *state); + +bool drivers_predicate_post_main(const void *state); + +#endif /* ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ */ diff --git a/zephyr/test/drivers/include/test/drivers/utils.h b/zephyr/test/drivers/include/test/drivers/utils.h new file mode 100644 index 0000000000..6d5d0c33bf --- /dev/null +++ b/zephyr/test/drivers/include/test/drivers/utils.h @@ -0,0 +1,309 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ +#define ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ + +#include +#include +#include + +#include "charger.h" +#include "emul/tcpc/emul_tcpci_partner_src.h" +#include "extpower.h" +#include "host_command.h" + +/** @brief Set chipset to S0 state. Call all necessary hooks. */ +void test_set_chipset_to_s0(void); + +/** @brief Set chipset to G3 state. Call all necessary hooks. */ +void test_set_chipset_to_g3(void); + +/* + * TODO(b/217755888): Implement ztest assume API upstream + */ + +/** + * @brief Assume that this function call won't be reached + * @param msg Optional message to print if the assumption fails + */ +#define zassume_unreachable(msg, ...) zassert_unreachable(msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a cond is true + * @param cond Condition to check + * @param msg Optional message to print if the assumption fails + */ +#define zassume_true(cond, msg, ...) zassert_true(cond, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a cond is false + * @param cond Condition to check + * @param msg Optional message to print if the assumption fails + */ +#define zassume_false(cond, msg, ...) zassert_false(cond, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a cond is 0 (success) + * @param cond Condition to check + * @param msg Optional message to print if the assumption fails + */ +#define zassume_ok(cond, msg, ...) zassert_ok(cond, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a ptr is NULL + * @param ptr Pointer to compare + * @param msg Optional message to print if the assumption fails + */ +#define zassume_is_null(ptr, msg, ...) zassert_is_null(ptr, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a ptr is not NULL + * @param ptr Pointer to compare + * @param msg Optional message to print if the assumption fails + */ +#define zassume_not_null(ptr, msg, ...) \ + zassert_not_null(ptr, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a a equals @a b + * + * @a a and @a b won't be converted and will be compared directly. + * + * @param a Value to compare + * @param b Value to compare + * @param msg Optional message to print if the assumption fails + */ +#define zassume_equal(a, b, msg, ...) zassert_equal(a, b, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a a does not equal @a b + * + * @a a and @a b won't be converted and will be compared directly. + * + * @param a Value to compare + * @param b Value to compare + * @param msg Optional message to print if the assumption fails + */ +#define zassume_not_equal(a, b, msg, ...) \ + zassert_not_equal(a, b, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a a equals @a b + * + * @a a and @a b will be converted to `void *` before comparing. + * + * @param a Value to compare + * @param b Value to compare + * @param msg Optional message to print if the assumption fails + */ +#define zassume_equal_ptr(a, b, msg, ...) \ + zassert_equal_ptr(a, b, msg, ##__VA_ARGS__) + +/** + * @brief Assume that @a a is within @a b with delta @a d + * + * @param a Value to compare + * @param b Value to compare + * @param d Delta + * @param msg Optional message to print if the assumption fails + */ +#define zassume_within(a, b, d, msg, ...) \ + zassert_within(a, b, d, msg, ##__VA_ARGS__) + +/** + * @brief Assume that 2 memory buffers have the same contents + * + * This macro calls the final memory comparison assumption macro. + * Using double expansion allows providing some arguments by macros that + * would expand to more than one values (ANSI-C99 defines that all the macro + * arguments have to be expanded before macro call). + * + * @param ... Arguments, see @ref zassume_mem_equal__ + * for real arguments accepted. + */ +#define zassume_mem_equal(...) zassert_mem_equal(##__VA_ARGS__) + +/** + * Run the host command to get the charge state for a given charger number. + * + * This function assumes a successful host command processing and will make a + * call to the zassume_* API. A failure here will abort the calling test. + * + * @param chgnum The charger number to query. + * @return The result of the query. + */ +static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum) +{ + struct ec_params_charge_state params = { + .chgnum = chgnum, + .cmd = CHARGE_STATE_CMD_GET_STATE, + }; + struct ec_response_charge_state response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params); + + zassume_ok(host_command_process(&args), + "Failed to get charge state for chgnum %d", chgnum); + return response; +} + +/** + * Run the host command to get the USB PD power info for a given port. + * + * This function assumes a successful host command processing and will make a + * call to the zassume_* API. A failure here will abort the calling test. + * + * @param port The USB port to get info from. + * @return The result of the query. + */ +static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port) +{ + struct ec_params_usb_pd_power_info params = { .port = port }; + struct ec_response_usb_pd_power_info response; + struct host_cmd_handler_args args = BUILD_HOST_COMMAND( + EC_CMD_USB_PD_POWER_INFO, 0, response, params); + + zassume_ok(host_command_process(&args), + "Failed to get power info for port %d", port); + return response; +} + +/** + * Run the host command to get the Type-C status information for a given port. + * + * This function assumes a successful host command processing and will make a + * call to the zassume_* API. A failure here will abort the calling test. + * + * @param port The USB port to get info from. + * @return The result of the query. + */ +static inline struct ec_response_typec_status host_cmd_typec_status(int port) +{ + struct ec_params_typec_status params = { .port = port }; + struct ec_response_typec_status response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params); + + zassume_ok(host_command_process(&args), + "Failed to get Type-C state for port %d", port); + return response; +} + +/** + * Run the host command to get the charge state. + * + * @return The result of the query. + */ +static inline struct ec_response_charge_control +host_cmd_get_charge_control(void) +{ + struct ec_params_charge_control params = { + .cmd = EC_CHARGE_CONTROL_CMD_GET + }; + struct ec_response_charge_control response; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, 2, response, params); + + zassume_ok(host_command_process(&args), + "Failed to get charge control values"); + + return response; +} + +/** + * @brief Call the host command MOTION_SENSE with the dump sub-command + * + * Note: this function uses the zassume_ API. It will skip the test if the host + * command fails. + * + * @param max_sensor_count The maximum number of sensor data objects to populate + * in the response object. + * @param response Pointer to the response object to fill. + */ +void host_cmd_motion_sense_dump(int max_sensor_count, + struct ec_response_motion_sense *response); + +/** + * Run the host command to get the PD discovery responses. + * + * @param port The USB-C port number + * @param partner_type SOP, SOP', or SOP'' + * @param response Destination buffer for command response; + * should hold struct ec_response_typec_discovery and + * enough struct svid_mode_info for expected response. + * @param response_size Number of bytes in response + */ +void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type, + void *response, size_t response_size); + +#define GPIO_ACOK_OD_NODE DT_NODELABEL(gpio_acok_od) +#define GPIO_ACOK_OD_PIN DT_GPIO_PIN(GPIO_ACOK_OD_NODE, gpios) + +/** + * Set whether or not AC is enabled. + * + * If enabled, the device _should_ begin charging. + * + * This function assumes a successful gpio emulator call and will make a call + * to the zassume_* API. A failure here will abort the calling test. + * + * This function sleeps to wait for the GPIO interrupt to take place. + * + * @param enabled Whether or not to enable AC. + */ +static inline void set_ac_enabled(bool enabled) +{ + const struct device *acok_dev = + DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_ACOK_OD_NODE, gpios)); + + zassume_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled), + NULL); + k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1)); + zassume_equal(enabled, extpower_is_present(), NULL); +} + +/** + * @brief Connect a power source to a given port. + * + * Note: this is function currently only supports an ISL923X charger chip. + * + * @param src Pointer to the emulated source + * @param pdo_index The index of the PDO object within the src to use + * @param tcpci_emul The TCPCI emulator that the source will connect to + * @param charger_emul The charger chip emulator + */ +void connect_source_to_port(struct tcpci_src_emul *src, int pdo_index, + const struct emul *tcpci_emul, + const struct emul *charger_emul); + +/** + * @brief Disconnect a power source from a given port. + * + * Note: this is function currently only supports an ISL923X charger chip. + * + * @param tcpci_emul The TCPCI emulator that will be disconnected + * @param charger_emul The charger chip emulator + */ +void disconnect_source_from_port(const struct emul *tcpci_emul, + const struct emul *charger_emul); + +/** + * @brief Allocate memory for a test pourpose + * + * @param bytes Number of bytes to allocate + * + * @return Pointer to valid memory or NULL + */ +void *test_malloc(size_t bytes); + +/** + * @brief Free memory allocated by @ref test_malloc + * + * @param mem Pointer to the memory + */ +void test_free(void *mem); + +#endif /* ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ */ diff --git a/zephyr/test/drivers/include/test_mocks.h b/zephyr/test/drivers/include/test_mocks.h deleted file mode 100644 index f29cce97cc..0000000000 --- a/zephyr/test/drivers/include/test_mocks.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/* - * Convenience macros - */ - -/** - * @brief Helper macro for inspecting the argument history of a given - * fake. Counts number of times the fake was called with a given - * argument. - * @param FAKE - FFF-provided fake structure (no pointers). - * @param ARG_NUM - Zero-based index of the argument to compare. - * @param VAL - Expression the argument must equal. - * @return Returns the number of times a call was made to the fake - * where the argument `ARG_NUM` equals `VAL`. - */ -#define MOCK_COUNT_CALLS_WITH_ARG_VALUE(FAKE, ARG_NUM, VAL) \ - ({ \ - int count = 0; \ - for (int i = 0; i < (FAKE).call_count; i++) { \ - if ((FAKE).arg##ARG_NUM##_history[i] == (VAL)) { \ - count++; \ - } \ - } \ - count; \ - }) - -/** - * @brief Helper macro for asserting that a certain register write occurred. - * Used when wrapping an I2C emulator mock write function in FFF. Prints - * useful error messages when the assertion fails. - * @param FAKE - name of the fake whose arg history to insepct. Do not include - * '_fake' at the end. - * @param CALL_NUM - Index in to the call history that this write should have - * occurred at. Zero based. - * @param EXPECTED_REG - The register address that was supposed to be written. - * @param EXPECTED_VAL - The 8-bit value that was supposed to be written, or - * `MOCK_IGNORE_VALUE` to suppress this check. - */ -#define MOCK_ASSERT_I2C_WRITE(FAKE, CALL_NUM, EXPECTED_REG, EXPECTED_VAL) \ - do { \ - zassert_true((CALL_NUM) < FAKE##_fake.call_count, \ - "Call #%d did not occur (%d I2C writes total)", \ - (CALL_NUM), FAKE##_fake.call_count); \ - zassert_equal( \ - FAKE##_fake.arg1_history[(CALL_NUM)], (EXPECTED_REG), \ - "Expected I2C write #%d to register 0x%02x (" \ - #EXPECTED_REG ") but wrote to reg 0x%02x", \ - (CALL_NUM), (EXPECTED_REG), \ - FAKE##_fake.arg1_history[(CALL_NUM)]); \ - if ((EXPECTED_VAL) != MOCK_IGNORE_VALUE) { \ - zassert_equal( \ - FAKE##_fake.arg2_history[(CALL_NUM)], \ - (EXPECTED_VAL), \ - "Expected I2C write #%d to register 0x%02x (" \ - #EXPECTED_REG ") to write 0x%02x (" \ - #EXPECTED_VAL ") but wrote 0x%02x", \ - (CALL_NUM), (EXPECTED_REG), (EXPECTED_VAL), \ - FAKE##_fake.arg2_history[(CALL_NUM)]); \ - } \ - } while (0) - -/** @brief Value to pass to MOCK_ASSERT_I2C_WRITE to ignore the actual value - * written. - */ -#define MOCK_IGNORE_VALUE (-1) - -/** - * @brief Helper macro for asserting that a certain register read occurred. - * Used when wrapping an I2C emulator mock read function in FFF. Prints - * useful error messages when the assertion fails. - * @param FAKE - name of the fake whose arg history to insepct. Do not include - * '_fake' at the end. - * @param CALL_NUM - Index in to the call history that this write should have - * occurred at. Zero based. - * @param EXPECTED_REG - The register address that was supposed to be read - * from. - */ -#define MOCK_ASSERT_I2C_READ(FAKE, CALL_NUM, EXPECTED_REG) \ - do { \ - zassert_true((CALL_NUM) < FAKE##_fake.call_count, \ - "Call #%d did not occur (%d I2C reads total)", \ - (CALL_NUM), FAKE##_fake.call_count); \ - zassert_equal( \ - FAKE##_fake.arg1_history[(CALL_NUM)], (EXPECTED_REG), \ - "Expected I2C read #%d from register 0x%02x (" \ - #EXPECTED_REG ") but read from reg 0x%02x", \ - (CALL_NUM), (EXPECTED_REG), \ - FAKE##_fake.arg1_history[(CALL_NUM)]); \ - } while (0) - -/* - * Mock declarations - */ - -/* Mocks for common/init_rom.c */ -DECLARE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int); -DECLARE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int); -DECLARE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int); - -/* Mocks for common/system.c */ -DECLARE_FAKE_VALUE_FUNC(int, system_jumped_late); diff --git a/zephyr/test/drivers/include/test_state.h b/zephyr/test/drivers/include/test_state.h deleted file mode 100644 index fe8b3e8ffc..0000000000 --- a/zephyr/test/drivers/include/test_state.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ -#define ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ - -struct test_state { - bool ec_app_main_run; -}; - -bool drivers_predicate_pre_main(const void *state); - -bool drivers_predicate_post_main(const void *state); - -#endif /* ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ */ diff --git a/zephyr/test/drivers/include/utils.h b/zephyr/test/drivers/include/utils.h deleted file mode 100644 index 6d5d0c33bf..0000000000 --- a/zephyr/test/drivers/include/utils.h +++ /dev/null @@ -1,309 +0,0 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ -#define ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ - -#include -#include -#include - -#include "charger.h" -#include "emul/tcpc/emul_tcpci_partner_src.h" -#include "extpower.h" -#include "host_command.h" - -/** @brief Set chipset to S0 state. Call all necessary hooks. */ -void test_set_chipset_to_s0(void); - -/** @brief Set chipset to G3 state. Call all necessary hooks. */ -void test_set_chipset_to_g3(void); - -/* - * TODO(b/217755888): Implement ztest assume API upstream - */ - -/** - * @brief Assume that this function call won't be reached - * @param msg Optional message to print if the assumption fails - */ -#define zassume_unreachable(msg, ...) zassert_unreachable(msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a cond is true - * @param cond Condition to check - * @param msg Optional message to print if the assumption fails - */ -#define zassume_true(cond, msg, ...) zassert_true(cond, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a cond is false - * @param cond Condition to check - * @param msg Optional message to print if the assumption fails - */ -#define zassume_false(cond, msg, ...) zassert_false(cond, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a cond is 0 (success) - * @param cond Condition to check - * @param msg Optional message to print if the assumption fails - */ -#define zassume_ok(cond, msg, ...) zassert_ok(cond, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a ptr is NULL - * @param ptr Pointer to compare - * @param msg Optional message to print if the assumption fails - */ -#define zassume_is_null(ptr, msg, ...) zassert_is_null(ptr, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a ptr is not NULL - * @param ptr Pointer to compare - * @param msg Optional message to print if the assumption fails - */ -#define zassume_not_null(ptr, msg, ...) \ - zassert_not_null(ptr, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a a equals @a b - * - * @a a and @a b won't be converted and will be compared directly. - * - * @param a Value to compare - * @param b Value to compare - * @param msg Optional message to print if the assumption fails - */ -#define zassume_equal(a, b, msg, ...) zassert_equal(a, b, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a a does not equal @a b - * - * @a a and @a b won't be converted and will be compared directly. - * - * @param a Value to compare - * @param b Value to compare - * @param msg Optional message to print if the assumption fails - */ -#define zassume_not_equal(a, b, msg, ...) \ - zassert_not_equal(a, b, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a a equals @a b - * - * @a a and @a b will be converted to `void *` before comparing. - * - * @param a Value to compare - * @param b Value to compare - * @param msg Optional message to print if the assumption fails - */ -#define zassume_equal_ptr(a, b, msg, ...) \ - zassert_equal_ptr(a, b, msg, ##__VA_ARGS__) - -/** - * @brief Assume that @a a is within @a b with delta @a d - * - * @param a Value to compare - * @param b Value to compare - * @param d Delta - * @param msg Optional message to print if the assumption fails - */ -#define zassume_within(a, b, d, msg, ...) \ - zassert_within(a, b, d, msg, ##__VA_ARGS__) - -/** - * @brief Assume that 2 memory buffers have the same contents - * - * This macro calls the final memory comparison assumption macro. - * Using double expansion allows providing some arguments by macros that - * would expand to more than one values (ANSI-C99 defines that all the macro - * arguments have to be expanded before macro call). - * - * @param ... Arguments, see @ref zassume_mem_equal__ - * for real arguments accepted. - */ -#define zassume_mem_equal(...) zassert_mem_equal(##__VA_ARGS__) - -/** - * Run the host command to get the charge state for a given charger number. - * - * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. - * - * @param chgnum The charger number to query. - * @return The result of the query. - */ -static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum) -{ - struct ec_params_charge_state params = { - .chgnum = chgnum, - .cmd = CHARGE_STATE_CMD_GET_STATE, - }; - struct ec_response_charge_state response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params); - - zassume_ok(host_command_process(&args), - "Failed to get charge state for chgnum %d", chgnum); - return response; -} - -/** - * Run the host command to get the USB PD power info for a given port. - * - * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. - * - * @param port The USB port to get info from. - * @return The result of the query. - */ -static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port) -{ - struct ec_params_usb_pd_power_info params = { .port = port }; - struct ec_response_usb_pd_power_info response; - struct host_cmd_handler_args args = BUILD_HOST_COMMAND( - EC_CMD_USB_PD_POWER_INFO, 0, response, params); - - zassume_ok(host_command_process(&args), - "Failed to get power info for port %d", port); - return response; -} - -/** - * Run the host command to get the Type-C status information for a given port. - * - * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. - * - * @param port The USB port to get info from. - * @return The result of the query. - */ -static inline struct ec_response_typec_status host_cmd_typec_status(int port) -{ - struct ec_params_typec_status params = { .port = port }; - struct ec_response_typec_status response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params); - - zassume_ok(host_command_process(&args), - "Failed to get Type-C state for port %d", port); - return response; -} - -/** - * Run the host command to get the charge state. - * - * @return The result of the query. - */ -static inline struct ec_response_charge_control -host_cmd_get_charge_control(void) -{ - struct ec_params_charge_control params = { - .cmd = EC_CHARGE_CONTROL_CMD_GET - }; - struct ec_response_charge_control response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, 2, response, params); - - zassume_ok(host_command_process(&args), - "Failed to get charge control values"); - - return response; -} - -/** - * @brief Call the host command MOTION_SENSE with the dump sub-command - * - * Note: this function uses the zassume_ API. It will skip the test if the host - * command fails. - * - * @param max_sensor_count The maximum number of sensor data objects to populate - * in the response object. - * @param response Pointer to the response object to fill. - */ -void host_cmd_motion_sense_dump(int max_sensor_count, - struct ec_response_motion_sense *response); - -/** - * Run the host command to get the PD discovery responses. - * - * @param port The USB-C port number - * @param partner_type SOP, SOP', or SOP'' - * @param response Destination buffer for command response; - * should hold struct ec_response_typec_discovery and - * enough struct svid_mode_info for expected response. - * @param response_size Number of bytes in response - */ -void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type, - void *response, size_t response_size); - -#define GPIO_ACOK_OD_NODE DT_NODELABEL(gpio_acok_od) -#define GPIO_ACOK_OD_PIN DT_GPIO_PIN(GPIO_ACOK_OD_NODE, gpios) - -/** - * Set whether or not AC is enabled. - * - * If enabled, the device _should_ begin charging. - * - * This function assumes a successful gpio emulator call and will make a call - * to the zassume_* API. A failure here will abort the calling test. - * - * This function sleeps to wait for the GPIO interrupt to take place. - * - * @param enabled Whether or not to enable AC. - */ -static inline void set_ac_enabled(bool enabled) -{ - const struct device *acok_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_ACOK_OD_NODE, gpios)); - - zassume_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled), - NULL); - k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1)); - zassume_equal(enabled, extpower_is_present(), NULL); -} - -/** - * @brief Connect a power source to a given port. - * - * Note: this is function currently only supports an ISL923X charger chip. - * - * @param src Pointer to the emulated source - * @param pdo_index The index of the PDO object within the src to use - * @param tcpci_emul The TCPCI emulator that the source will connect to - * @param charger_emul The charger chip emulator - */ -void connect_source_to_port(struct tcpci_src_emul *src, int pdo_index, - const struct emul *tcpci_emul, - const struct emul *charger_emul); - -/** - * @brief Disconnect a power source from a given port. - * - * Note: this is function currently only supports an ISL923X charger chip. - * - * @param tcpci_emul The TCPCI emulator that will be disconnected - * @param charger_emul The charger chip emulator - */ -void disconnect_source_from_port(const struct emul *tcpci_emul, - const struct emul *charger_emul); - -/** - * @brief Allocate memory for a test pourpose - * - * @param bytes Number of bytes to allocate - * - * @return Pointer to valid memory or NULL - */ -void *test_malloc(size_t bytes); - -/** - * @brief Free memory allocated by @ref test_malloc - * - * @param mem Pointer to the memory - */ -void test_free(void *mem); - -#endif /* ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ */ diff --git a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c index a405fab963..c1ae9ce240 100644 --- a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c +++ b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c @@ -6,12 +6,12 @@ #include -#include "charger_utils.h" #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" #include "emul/emul_common_i2c.h" #include "emul/emul_isl923x.h" -#include "test_state.h" +#include "test/drivers/charger_utils.h" +#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))) 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 fd78209e13..b70d67a750 100644 --- a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c +++ b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c @@ -10,14 +10,14 @@ #include "adc.h" #include "console.h" -#include "charger_utils.h" #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" #include "ec_commands.h" #include "emul/emul_common_i2c.h" #include "emul/emul_isl923x.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/charger_utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #define ADC_DEVICE_NODE DT_NODELABEL(adc0) #define CHARGER_NUM get_charger_num(&isl923x_drv) diff --git a/zephyr/test/drivers/src/battery.c b/zephyr/test/drivers/src/battery.c index c9c49e1ae8..71d45ac6af 100644 --- a/zephyr/test/drivers/src/battery.c +++ b/zephyr/test/drivers/src/battery.c @@ -9,7 +9,7 @@ #include #include "battery.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) diff --git a/zephyr/test/drivers/src/bb_retimer.c b/zephyr/test/drivers/src/bb_retimer.c index 84d8a4a836..82a50f5049 100644 --- a/zephyr/test/drivers/src/bb_retimer.c +++ b/zephyr/test/drivers/src/bb_retimer.c @@ -14,14 +14,14 @@ #include "emul/emul_common_i2c.h" #include "hooks.h" #include "i2c.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "usb_prl_sm.h" #include "usb_tc_sm.h" #include "chipset.h" #include "driver/retimer/bb_retimer.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #define GPIO_USB_C1_LS_EN_PATH DT_PATH(named_gpios, usb_c1_ls_en) #define GPIO_USB_C1_LS_EN_PORT DT_GPIO_PIN(GPIO_USB_C1_LS_EN_PATH, gpios) diff --git a/zephyr/test/drivers/src/bc12.c b/zephyr/test/drivers/src/bc12.c index 088785aa18..df65d2f7a4 100644 --- a/zephyr/test/drivers/src/bc12.c +++ b/zephyr/test/drivers/src/bc12.c @@ -14,8 +14,8 @@ #include "usb_charge.h" #include "battery.h" #include "extpower.h" -#include "stubs.h" -#include "test_state.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" #include LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG); diff --git a/zephyr/test/drivers/src/bma2x2.c b/zephyr/test/drivers/src/bma2x2.c index 8a19e42267..4277ed1245 100644 --- a/zephyr/test/drivers/src/bma2x2.c +++ b/zephyr/test/drivers/src/bma2x2.c @@ -14,7 +14,7 @@ #include "accelgyro.h" #include "motion_sense.h" #include "driver/accel_bma2x2.h" -#include "test_state.h" +#include "test/drivers/test_state.h" /** How accurate comparision of vectors should be. */ #define V_EPS 8 diff --git a/zephyr/test/drivers/src/bmi160.c b/zephyr/test/drivers/src/bmi160.c index 73cd33b2eb..5578b4a796 100644 --- a/zephyr/test/drivers/src/bmi160.c +++ b/zephyr/test/drivers/src/bmi160.c @@ -10,12 +10,12 @@ #include "i2c.h" #include "emul/emul_bmi.h" #include "emul/emul_common_i2c.h" -#include "test_mocks.h" +#include "test/drivers/test_mocks.h" #include "motion_sense_fifo.h" #include "driver/accelgyro_bmi160.h" #include "driver/accelgyro_bmi_common.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define BMI_ORD DT_DEP_ORD(DT_NODELABEL(accel_bmi160)) #define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_accel)) diff --git a/zephyr/test/drivers/src/bmi260.c b/zephyr/test/drivers/src/bmi260.c index 98be6a2d65..0146b37fe6 100644 --- a/zephyr/test/drivers/src/bmi260.c +++ b/zephyr/test/drivers/src/bmi260.c @@ -15,8 +15,8 @@ #include "motion_sense_fifo.h" #include "driver/accelgyro_bmi260.h" #include "driver/accelgyro_bmi_common.h" -#include "test_mocks.h" -#include "test_state.h" +#include "test/drivers/test_mocks.h" +#include "test/drivers/test_state.h" #define BMI_ORD DT_DEP_ORD(DT_NODELABEL(accel_bmi260)) #define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi260_accel)) diff --git a/zephyr/test/drivers/src/charge_manager.c b/zephyr/test/drivers/src/charge_manager.c index 6a3c842493..13668924fd 100644 --- a/zephyr/test/drivers/src/charge_manager.c +++ b/zephyr/test/drivers/src/charge_manager.c @@ -7,7 +7,7 @@ #include "charge_manager.h" #include "ec_commands.h" -#include "test_state.h" +#include "test/drivers/test_state.h" ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/src/console_cmd/charge_manager.c b/zephyr/test/drivers/src/console_cmd/charge_manager.c index cf33e4125f..8d66c4a7b8 100644 --- a/zephyr/test/drivers/src/console_cmd/charge_manager.c +++ b/zephyr/test/drivers/src/console_cmd/charge_manager.c @@ -11,8 +11,8 @@ #include "emul/emul_isl923x.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "tcpm/tcpci.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" static void connect_sink_to_port(const struct emul *charger_emul, const struct emul *tcpci_emul, diff --git a/zephyr/test/drivers/src/console_cmd/charge_state.c b/zephyr/test/drivers/src/console_cmd/charge_state.c index 7715a84b9e..0b9378cbb7 100644 --- a/zephyr/test/drivers/src/console_cmd/charge_state.c +++ b/zephyr/test/drivers/src/console_cmd/charge_state.c @@ -10,8 +10,8 @@ #include "charge_state_v2.h" #include "console.h" #include "ec_commands.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" ZTEST_USER(console_cmd_charge_state, test_idle_too_few_args) { diff --git a/zephyr/test/drivers/src/cros_cbi.c b/zephyr/test/drivers/src/cros_cbi.c index 37094e1a49..9acd6741ed 100644 --- a/zephyr/test/drivers/src/cros_cbi.c +++ b/zephyr/test/drivers/src/cros_cbi.c @@ -7,7 +7,7 @@ #include #include "cros_cbi.h" -#include "test_state.h" +#include "test/drivers/test_state.h" ZTEST(cros_cbi, test_check_match) { diff --git a/zephyr/test/drivers/src/espi.c b/zephyr/test/drivers/src/espi.c index 5b89ebdf10..f8293b4591 100644 --- a/zephyr/test/drivers/src/espi.c +++ b/zephyr/test/drivers/src/espi.c @@ -8,7 +8,7 @@ #include "ec_commands.h" #include "host_command.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define PORT 0 diff --git a/zephyr/test/drivers/src/gpio.c b/zephyr/test/drivers/src/gpio.c index 0edb389a3e..8e8b166092 100644 --- a/zephyr/test/drivers/src/gpio.c +++ b/zephyr/test/drivers/src/gpio.c @@ -20,9 +20,9 @@ #include "gpio.h" #include "gpio/gpio.h" #include "gpio/gpio_int.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "util.h" -#include "test_state.h" +#include "test/drivers/test_state.h" extern bool gpio_test_interrupt_triggered; /** diff --git a/zephyr/test/drivers/src/host_cmd/motion_sense.c b/zephyr/test/drivers/src/host_cmd/motion_sense.c index 46a3540ad0..3e4c8e0336 100644 --- a/zephyr/test/drivers/src/host_cmd/motion_sense.c +++ b/zephyr/test/drivers/src/host_cmd/motion_sense.c @@ -6,8 +6,8 @@ #include #include "motion_sense.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" /** * Get the size needed for a struct ec_response_motion_sense diff --git a/zephyr/test/drivers/src/i2c_passthru.c b/zephyr/test/drivers/src/i2c_passthru.c index fa8445d516..98bc181d84 100644 --- a/zephyr/test/drivers/src/i2c_passthru.c +++ b/zephyr/test/drivers/src/i2c_passthru.c @@ -8,7 +8,7 @@ #include "ec_commands.h" #include "host_command.h" -#include "test_state.h" +#include "test/drivers/test_state.h" ZTEST_USER(i2c_passthru, test_read_without_write) { diff --git a/zephyr/test/drivers/src/integration/usbc/usb.c b/zephyr/test/drivers/src/integration/usbc/usb.c index 229b17e73c..3c2898b363 100644 --- a/zephyr/test/drivers/src/integration/usbc/usb.c +++ b/zephyr/test/drivers/src/integration/usbc/usb.c @@ -19,11 +19,11 @@ #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" #include "test/usb_pe.h" -#include "utils.h" -#include "test_state.h" +#include "test/drivers/utils.h" +#include "test/drivers/test_state.h" #define TCPCI_EMUL_LABEL DT_NODELABEL(tcpci_emul) #define TCPCI_EMUL_LABEL2 DT_NODELABEL(tcpci_ps8xxx_emul) diff --git a/zephyr/test/drivers/src/integration/usbc/usb_20v_3a_pd_charger.c b/zephyr/test/drivers/src/integration/usbc/usb_20v_3a_pd_charger.c index b089d6c902..78029dd3ff 100644 --- a/zephyr/test/drivers/src/integration/usbc/usb_20v_3a_pd_charger.c +++ b/zephyr/test/drivers/src/integration/usbc/usb_20v_3a_pd_charger.c @@ -9,8 +9,8 @@ #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci_partner_src.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "usb_pd.h" #define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery)) diff --git a/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_sink.c b/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_sink.c index d28a23d99e..9541f20dd3 100644 --- a/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_sink.c +++ b/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_sink.c @@ -11,8 +11,8 @@ #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "tcpm/tcpci.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "usb_pd.h" struct usb_attach_5v_3a_pd_sink_fixture { diff --git a/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_source.c index 39c6d208bf..970870950c 100644 --- a/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_source.c +++ b/zephyr/test/drivers/src/integration/usbc/usb_5v_3a_pd_source.c @@ -9,8 +9,8 @@ #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci_partner_src.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "usb_pd.h" #define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery)) diff --git a/zephyr/test/drivers/src/integration/usbc/usb_alt_mode.c b/zephyr/test/drivers/src/integration/usbc/usb_alt_mode.c index 3cbb306698..abef3f0b78 100644 --- a/zephyr/test/drivers/src/integration/usbc/usb_alt_mode.c +++ b/zephyr/test/drivers/src/integration/usbc/usb_alt_mode.c @@ -15,10 +15,10 @@ #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "host_command.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "utils.h" -#include "test_state.h" +#include "test/drivers/utils.h" +#include "test/drivers/test_state.h" struct usbc_alt_mode_fixture { const struct emul *tcpci_emul; diff --git a/zephyr/test/drivers/src/integration/usbc/usb_attach_src_snk.c b/zephyr/test/drivers/src/integration/usbc/usb_attach_src_snk.c index 319e52eb4b..4ed9dcb8d1 100644 --- a/zephyr/test/drivers/src/integration/usbc/usb_attach_src_snk.c +++ b/zephyr/test/drivers/src/integration/usbc/usb_attach_src_snk.c @@ -17,11 +17,11 @@ #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" #include "test/usb_pe.h" -#include "utils.h" -#include "test_state.h" +#include "test/drivers/utils.h" +#include "test/drivers/test_state.h" #define SNK_PORT USBC_PORT_C0 #define SRC_PORT USBC_PORT_C1 diff --git a/zephyr/test/drivers/src/isl923x.c b/zephyr/test/drivers/src/isl923x.c index 82bfd25032..667d05f57b 100644 --- a/zephyr/test/drivers/src/isl923x.c +++ b/zephyr/test/drivers/src/isl923x.c @@ -9,14 +9,14 @@ #include "battery.h" #include "battery_smart.h" -#include "charger_utils.h" +#include "test/drivers/charger_utils.h" #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" #include "emul/emul_common_i2c.h" #include "emul/emul_isl923x.h" #include "system.h" -#include "test_mocks.h" -#include "test_state.h" +#include "test/drivers/test_mocks.h" +#include "test/drivers/test_state.h" BUILD_ASSERT(CONFIG_CHARGER_SENSE_RESISTOR == 10 || CONFIG_CHARGER_SENSE_RESISTOR == 5); diff --git a/zephyr/test/drivers/src/keyboard_scan.c b/zephyr/test/drivers/src/keyboard_scan.c index 8977a4e495..6d438c2b76 100644 --- a/zephyr/test/drivers/src/keyboard_scan.c +++ b/zephyr/test/drivers/src/keyboard_scan.c @@ -8,7 +8,7 @@ #include #include -#include "test_state.h" +#include "test/drivers/test_state.h" int emulate_keystate(int row, int col, int pressed) { diff --git a/zephyr/test/drivers/src/lid_switch.c b/zephyr/test/drivers/src/lid_switch.c index d3727d926c..c4794741fb 100644 --- a/zephyr/test/drivers/src/lid_switch.c +++ b/zephyr/test/drivers/src/lid_switch.c @@ -11,7 +11,7 @@ #include #include -#include "test_state.h" +#include "test/drivers/test_state.h" #include "ec_commands.h" #include "host_command.h" diff --git a/zephyr/test/drivers/src/lis2dw12.c b/zephyr/test/drivers/src/lis2dw12.c index 96c0389585..07faee0427 100644 --- a/zephyr/test/drivers/src/lis2dw12.c +++ b/zephyr/test/drivers/src/lis2dw12.c @@ -8,7 +8,7 @@ #include "driver/accel_lis2dw12.h" #include "emul/emul_common_i2c.h" #include "emul/emul_lis2dw12.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define LIS2DW12_NODELABEL DT_NODELABEL(ms_lis2dw12_accel) #define LIS2DW12_SENSOR_ID SENSOR_ID(LIS2DW12_NODELABEL) diff --git a/zephyr/test/drivers/src/ln9310.c b/zephyr/test/drivers/src/ln9310.c index 6eb13eabfb..9ff018fdba 100644 --- a/zephyr/test/drivers/src/ln9310.c +++ b/zephyr/test/drivers/src/ln9310.c @@ -13,7 +13,7 @@ #include "emul/emul_ln9310.h" #include "emul/emul_common_i2c.h" #include "timer.h" -#include "test_state.h" +#include "test/drivers/test_state.h" /* * TODO(b/201420132): Implement approach for tests to immediately schedule work diff --git a/zephyr/test/drivers/src/main.c b/zephyr/test/drivers/src/main.c index b3bb18a4be..062d8224bd 100644 --- a/zephyr/test/drivers/src/main.c +++ b/zephyr/test/drivers/src/main.c @@ -6,7 +6,7 @@ #include #include #include "ec_app_main.h" -#include "test_state.h" +#include "test/drivers/test_state.h" bool drivers_predicate_pre_main(const void *state) { diff --git a/zephyr/test/drivers/src/motion_sense/motion_sense.c b/zephyr/test/drivers/src/motion_sense/motion_sense.c index 606440b5c5..5b6839bbae 100644 --- a/zephyr/test/drivers/src/motion_sense/motion_sense.c +++ b/zephyr/test/drivers/src/motion_sense/motion_sense.c @@ -6,7 +6,7 @@ #include #include "motion_sense.h" -#include "test_state.h" +#include "test/drivers/test_state.h" ZTEST_SUITE(motion_sense, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/src/panic.c b/zephyr/test/drivers/src/panic.c index 664b12b87a..3dba6e0cfd 100644 --- a/zephyr/test/drivers/src/panic.c +++ b/zephyr/test/drivers/src/panic.c @@ -17,8 +17,8 @@ #include "common.h" #include "ec_tasks.h" #include "panic.h" -#include "stubs.h" -#include "test_state.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" /** * @brief Test Suite: Verifies panic functionality. diff --git a/zephyr/test/drivers/src/power_common.c b/zephyr/test/drivers/src/power_common.c index e5eace0155..59e8db1f45 100644 --- a/zephyr/test/drivers/src/power_common.c +++ b/zephyr/test/drivers/src/power_common.c @@ -15,17 +15,17 @@ #include "hooks.h" #include "host_command.h" #include "power.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "task.h" #include "ec_tasks.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #include "emul/emul_common_i2c.h" #include "emul/emul_smart_battery.h" #include "battery.h" #include "battery_smart.h" -#include "utils.h" +#include "test/drivers/utils.h" #define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery)) diff --git a/zephyr/test/drivers/src/ppc_sn5s330.c b/zephyr/test/drivers/src/ppc_sn5s330.c index e0317cacf6..e7db47d5d5 100644 --- a/zephyr/test/drivers/src/ppc_sn5s330.c +++ b/zephyr/test/drivers/src/ppc_sn5s330.c @@ -15,8 +15,8 @@ #include "emul/emul_common_i2c.h" #include "emul/emul_sn5s330.h" #include "usbc_ppc.h" -#include "test_mocks.h" -#include "test_state.h" +#include "test/drivers/test_mocks.h" +#include "test/drivers/test_state.h" /** This must match the index of the sn5s330 in ppc_chips[] */ #define SN5S330_PORT 0 diff --git a/zephyr/test/drivers/src/ppc_syv682c.c b/zephyr/test/drivers/src/ppc_syv682c.c index 0d1b315628..4e257c8dee 100644 --- a/zephyr/test/drivers/src/ppc_syv682c.c +++ b/zephyr/test/drivers/src/ppc_syv682c.c @@ -12,10 +12,10 @@ #include "emul/emul_syv682x.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "syv682x.h" #include "timer.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #include "usbc_ppc.h" #define SYV682X_ORD DT_DEP_ORD(DT_NODELABEL(syv682x_emul)) diff --git a/zephyr/test/drivers/src/ps8xxx.c b/zephyr/test/drivers/src/ps8xxx.c index f4d7e33e76..b30d9ef0c3 100644 --- a/zephyr/test/drivers/src/ps8xxx.c +++ b/zephyr/test/drivers/src/ps8xxx.c @@ -12,13 +12,13 @@ #include "emul/tcpc/emul_ps8xxx.h" #include "timer.h" #include "i2c.h" -#include "stubs.h" -#include "tcpci_test_common.h" +#include "test/drivers/stubs.h" +#include "test/drivers/tcpci_test_common.h" #include "tcpm/tcpci.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/ps8xxx_public.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define PS8XXX_EMUL_LABEL DT_LABEL(DT_NODELABEL(ps8xxx_emul)) diff --git a/zephyr/test/drivers/src/smart.c b/zephyr/test/drivers/src/smart.c index efcc8ae003..f80563a40f 100644 --- a/zephyr/test/drivers/src/smart.c +++ b/zephyr/test/drivers/src/smart.c @@ -16,7 +16,7 @@ #include "battery.h" #include "battery_smart.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery)) diff --git a/zephyr/test/drivers/src/stm_mems_common.c b/zephyr/test/drivers/src/stm_mems_common.c index 19d3e0f43d..358c20ee3d 100644 --- a/zephyr/test/drivers/src/stm_mems_common.c +++ b/zephyr/test/drivers/src/stm_mems_common.c @@ -13,7 +13,7 @@ #include "emul/emul_common_i2c.h" #include "emul/i2c_mock.h" #include "i2c/i2c.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define MOCK_EMUL emul_get_binding(DT_LABEL(DT_NODELABEL(i2c_mock))) diff --git a/zephyr/test/drivers/src/stubs.c b/zephyr/test/drivers/src/stubs.c index 5c66a9d13f..b38bd1fd4e 100644 --- a/zephyr/test/drivers/src/stubs.c +++ b/zephyr/test/drivers/src/stubs.c @@ -19,7 +19,7 @@ #include "ppc/sn5s330_public.h" #include "ppc/syv682x_public.h" #include "retimer/bb_retimer_public.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" #include "usb_mux.h" diff --git a/zephyr/test/drivers/src/tcpci.c b/zephyr/test/drivers/src/tcpci.c index b6eab298cc..972f9fd326 100644 --- a/zephyr/test/drivers/src/tcpci.c +++ b/zephyr/test/drivers/src/tcpci.c @@ -14,11 +14,11 @@ #include "emul/tcpc/emul_tcpci.h" #include "hooks.h" #include "i2c.h" -#include "stubs.h" -#include "tcpci_test_common.h" +#include "test/drivers/stubs.h" +#include "test/drivers/tcpci_test_common.h" #include "tcpm/tcpci.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define EMUL_LABEL DT_NODELABEL(tcpci_emul) diff --git a/zephyr/test/drivers/src/tcpci_test_common.c b/zephyr/test/drivers/src/tcpci_test_common.c index 9b0ebffcaa..41b0c2db99 100644 --- a/zephyr/test/drivers/src/tcpci_test_common.c +++ b/zephyr/test/drivers/src/tcpci_test_common.c @@ -9,7 +9,7 @@ #include "common.h" #include "emul/emul_common_i2c.h" #include "emul/tcpc/emul_tcpci.h" -#include "tcpci_test_common.h" +#include "test/drivers/tcpci_test_common.h" #include "tcpm/tcpci.h" diff --git a/zephyr/test/drivers/src/tcs3400.c b/zephyr/test/drivers/src/tcs3400.c index 58b4f05608..8b29259244 100644 --- a/zephyr/test/drivers/src/tcs3400.c +++ b/zephyr/test/drivers/src/tcs3400.c @@ -14,7 +14,7 @@ #include "motion_sense.h" #include "motion_sense_fifo.h" #include "driver/als_tcs3400.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define TCS_ORD DT_DEP_ORD(DT_NODELABEL(tcs_emul)) #define TCS_CLR_SENSOR_ID SENSOR_ID(DT_NODELABEL(tcs3400_clear)) diff --git a/zephyr/test/drivers/src/temp_sensor.c b/zephyr/test/drivers/src/temp_sensor.c index acb2f1ac60..c9469476e1 100644 --- a/zephyr/test/drivers/src/temp_sensor.c +++ b/zephyr/test/drivers/src/temp_sensor.c @@ -15,7 +15,7 @@ #include "common.h" #include "temp_sensor.h" #include "temp_sensor/temp_sensor.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok) #define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios) diff --git a/zephyr/test/drivers/src/test_mocks.c b/zephyr/test/drivers/src/test_mocks.c index 99629374dd..f8bbb1a6c1 100644 --- a/zephyr/test/drivers/src/test_mocks.c +++ b/zephyr/test/drivers/src/test_mocks.c @@ -5,7 +5,7 @@ #include -#include "test_mocks.h" +#include "test/drivers/test_mocks.h" DEFINE_FFF_GLOBALS; diff --git a/zephyr/test/drivers/src/thermistor.c b/zephyr/test/drivers/src/thermistor.c index 591faa9436..49e5e02234 100644 --- a/zephyr/test/drivers/src/thermistor.c +++ b/zephyr/test/drivers/src/thermistor.c @@ -14,7 +14,7 @@ #include "common.h" #include "../driver/temp_sensor/thermistor.h" #include "temp_sensor/temp_sensor.h" -#include "test_state.h" +#include "test/drivers/test_state.h" #define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok) diff --git a/zephyr/test/drivers/src/usb_mux.c b/zephyr/test/drivers/src/usb_mux.c index 9dad48acdc..bd3024ae44 100644 --- a/zephyr/test/drivers/src/usb_mux.c +++ b/zephyr/test/drivers/src/usb_mux.c @@ -18,7 +18,7 @@ #include "hooks.h" #include "host_command.h" #include "i2c.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "task.h" #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" @@ -26,8 +26,8 @@ #include "usb_tc_sm.h" #include "usb_mux.h" -#include "test_state.h" -#include "utils.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" /** Copy of original usb_muxes[USB_PORT_C1] */ struct usb_mux usb_mux_c1; diff --git a/zephyr/test/drivers/src/usb_pd_host_cmd.c b/zephyr/test/drivers/src/usb_pd_host_cmd.c index 5f8097e7ff..a22f3387c3 100644 --- a/zephyr/test/drivers/src/usb_pd_host_cmd.c +++ b/zephyr/test/drivers/src/usb_pd_host_cmd.c @@ -8,7 +8,7 @@ #include "ec_commands.h" #include "host_command.h" -#include "test_state.h" +#include "test/drivers/test_state.h" ZTEST_USER(usb_pd_host_cmd, test_host_command_hc_pd_ports) { diff --git a/zephyr/test/drivers/src/utils.c b/zephyr/test/drivers/src/utils.c index 3021a98c90..ef2084ab07 100644 --- a/zephyr/test/drivers/src/utils.c +++ b/zephyr/test/drivers/src/utils.c @@ -15,9 +15,9 @@ #include "emul/tcpc/emul_tcpci_partner_src.h" #include "hooks.h" #include "power.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "chipset.h" -#include "utils.h" +#include "test/drivers/utils.h" #define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery)) #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) diff --git a/zephyr/test/drivers/src/vboot_hash.c b/zephyr/test/drivers/src/vboot_hash.c index 841893c61b..aabffbbe74 100644 --- a/zephyr/test/drivers/src/vboot_hash.c +++ b/zephyr/test/drivers/src/vboot_hash.c @@ -9,7 +9,7 @@ #include "ec_commands.h" #include "host_command.h" -#include "test_state.h" +#include "test/drivers/test_state.h" ZTEST_USER(vboot_hash, test_hostcmd) { diff --git a/zephyr/test/drivers/src/watchdog.c b/zephyr/test/drivers/src/watchdog.c index 86df3f14f3..acd8edc41a 100644 --- a/zephyr/test/drivers/src/watchdog.c +++ b/zephyr/test/drivers/src/watchdog.c @@ -19,9 +19,9 @@ #include "ec_tasks.h" #include "fff.h" #include "hooks.h" -#include "stubs.h" +#include "test/drivers/stubs.h" #include "watchdog.h" -#include "test_state.h" +#include "test/drivers/test_state.h" /** * @brief Default watchdog timeout plus some time for it to expire. -- cgit v1.2.1