diff options
Diffstat (limited to 'zephyr/test/drivers/include')
-rw-r--r-- | zephyr/test/drivers/include/gpio_map.h | 18 | ||||
-rw-r--r-- | zephyr/test/drivers/include/stubs.h | 15 | ||||
-rw-r--r-- | zephyr/test/drivers/include/test_mocks.h | 26 |
3 files changed, 50 insertions, 9 deletions
diff --git a/zephyr/test/drivers/include/gpio_map.h b/zephyr/test/drivers/include/gpio_map.h index 5253b0155a..1255348a61 100644 --- a/zephyr/test/drivers/include/gpio_map.h +++ b/zephyr/test/drivers/include/gpio_map.h @@ -17,13 +17,17 @@ * Note we only need to create aliases for GPIOs that are referenced in common * platform/ec code. */ -#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_PG_EC_DSW_PWROK +#define GPIO_TEMP_SENSOR_POWER GPIO_PG_EC_DSW_PWROK -#define EC_CROS_GPIO_INTERRUPTS \ - GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \ - GPIO_INT(GPIO_USB_C0_TCPC_INT_ODL, GPIO_INT_EDGE_FALLING, \ - tcpc_alert_event) \ - GPIO_INT(GPIO_USB_C1_TCPC_INT_ODL, GPIO_INT_EDGE_FALLING, \ - tcpc_alert_event) +#define EC_CROS_GPIO_INTERRUPTS \ + GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \ + GPIO_INT(GPIO_USB_C0_TCPC_INT_ODL, GPIO_INT_EDGE_FALLING, \ + tcpc_alert_event) \ + GPIO_INT(GPIO_USB_C1_TCPC_INT_ODL, GPIO_INT_EDGE_FALLING, \ + tcpc_alert_event) \ + GPIO_INT(GPIO_USB_C0_PPC_INT_ODL, GPIO_INT_EDGE_FALLING, ppc_alert) \ + GPIO_INT(GPIO_USB_C1_PPC_INT_ODL, GPIO_INT_EDGE_FALLING, ppc_alert) \ + GPIO_INT(GPIO_SWITCHCAP_PG_INT_L, GPIO_INT_EDGE_FALLING, \ + ln9310_interrupt) \ #endif /* __ZEPHYR_GPIO_MAP_H */ diff --git a/zephyr/test/drivers/include/stubs.h b/zephyr/test/drivers/include/stubs.h index 448d6c883b..af32a988c6 100644 --- a/zephyr/test/drivers/include/stubs.h +++ b/zephyr/test/drivers/include/stubs.h @@ -6,6 +6,7 @@ #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 }; @@ -13,7 +14,16 @@ 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; -void set_mock_power_state(enum power_state state); +/** + * @brief Set state which should be returned by power_handle_state() and wake + * chipset task to immediately change state + * + * @param force If true @p state will be used as return for power_handle_state() + * and will wake up chipset task. If false argument of + * power_handle_state() will be used as return value + * @param state Power state to use when @p force is true + */ +void force_power_state(bool force, enum power_state state); /** * @brief Set product ID that should be returned by board_get_ps8xxx_product_id @@ -22,4 +32,7 @@ void set_mock_power_state(enum power_state state); */ 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); + #endif /* __TEST_DRIVERS_STUBS_H */ diff --git a/zephyr/test/drivers/include/test_mocks.h b/zephyr/test/drivers/include/test_mocks.h index fe63eea0d3..3630df083f 100644 --- a/zephyr/test/drivers/include/test_mocks.h +++ b/zephyr/test/drivers/include/test_mocks.h @@ -53,7 +53,7 @@ #EXPECTED_REG ") but wrote to reg 0x%02x", \ (CALL_NUM), (EXPECTED_REG), \ FAKE##_fake.arg1_history[(CALL_NUM)]); \ - if (EXPECTED_VAL != MOCK_IGNORE_VALUE) { \ + if ((EXPECTED_VAL) != MOCK_IGNORE_VALUE) { \ zassert_equal( \ FAKE##_fake.arg2_history[(CALL_NUM)], \ (EXPECTED_VAL), \ @@ -70,6 +70,30 @@ */ #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 */ |