summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/common/include/test/drivers/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/common/include/test/drivers/utils.h')
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/utils.h76
1 files changed, 36 insertions, 40 deletions
diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h
index 7be7dd5400..8a703108c3 100644
--- a/zephyr/test/drivers/common/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/common/include/test/drivers/utils.h
@@ -6,21 +6,20 @@
#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_
#define ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
+#include <stddef.h>
+#include <string.h>
+
#include "charger.h"
+#include "lpc.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "extpower.h"
#include "host_command.h"
-#include "lpc.h"
#include "power.h"
#include "usbc/utils.h"
-#include <stddef.h>
-#include <string.h>
-
-#include <zephyr/drivers/emul.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-
/**
* @brief Helper macro for EMUL_GET_USBC_BINDING. If @p usbc_id has the same
* port number as @p port, then struct emul* for @p chip phandle is
@@ -72,11 +71,21 @@ void test_set_chipset_to_power_level(enum power_state new_state);
/** @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__)
+
/**
* Run an ACPI read to the specified address.
*
* This function assumes a successful ACPI read process and will make a
- * call to the zassert_* API. A failure here will fail the calling test.
+ * call to the zassume_* API. A failure here will skip the calling test.
*
* @param acpi_addr Address to query
* @return Byte read
@@ -87,7 +96,7 @@ uint8_t acpi_read(uint8_t acpi_addr);
* Run an ACPI write to the specified address.
*
* This function assumes a successful ACPI write process and will make a
- * call to the zassert_* API. A failure here will fail the calling test.
+ * call to the zassume_* API. A failure here will skip the calling test.
*
* @param acpi_addr Address to write
* @param write_byte Byte to write to address
@@ -98,7 +107,7 @@ void acpi_write(uint8_t acpi_addr, uint8_t write_byte);
* Run the host command to gather our EC feature flags.
*
* This function assumes a successful host command processing and will make a
- * call to the zassert_* API. A failure here will fail the calling test.
+ * call to the zassume_* API. A failure here will abort the calling test.
*
* @return The result of the host command
*/
@@ -108,7 +117,7 @@ static inline struct ec_response_get_features host_cmd_get_features(void)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_FEATURES, 0, response);
- zassert_ok(host_command_process(&args), "Failed to get features");
+ zassume_ok(host_command_process(&args), "Failed to get features");
return response;
}
@@ -116,7 +125,7 @@ static inline struct ec_response_get_features host_cmd_get_features(void)
* 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 zassert_* API. A failure here will fail the calling test.
+ * 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.
@@ -131,7 +140,7 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassume_ok(host_command_process(&args),
"Failed to get charge state for chgnum %d", chgnum);
return response;
}
@@ -140,7 +149,7 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum)
* 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 zassert_* API. A failure here will fail the calling test.
+ * 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.
@@ -152,7 +161,7 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port)
struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
EC_CMD_USB_PD_POWER_INFO, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassume_ok(host_command_process(&args),
"Failed to get power info for port %d", port);
return response;
}
@@ -161,7 +170,7 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port)
* 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 zassert_* API. A failure here will fail the calling test.
+ * 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.
@@ -173,7 +182,7 @@ static inline struct ec_response_typec_status host_cmd_typec_status(int port)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassume_ok(host_command_process(&args),
"Failed to get Type-C state for port %d", port);
return response;
}
@@ -186,7 +195,7 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_USB_PD_CONTROL, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassume_ok(host_command_process(&args),
"Failed to process usb_pd_control_swap for port %d, swap %d",
port, swap);
return response;
@@ -196,7 +205,7 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
* Run the host command to suspend/resume PD ports
*
* This function assumes a successful host command processing and will make a
- * call to the zassert_* API. A failure here will fail the calling test.
+ * call to the zassume_* API. A failure here will skip the calling test.
*
* @param port The USB port to operate on
* @param cmd The sub-command to run
@@ -207,7 +216,7 @@ static inline void host_cmd_pd_control(int port, enum ec_pd_control_cmd cmd)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassume_ok(host_command_process(&args),
"Failed to process pd_control for port %d, cmd %d", port,
cmd);
}
@@ -231,7 +240,7 @@ host_cmd_charge_control(enum ec_charge_control_mode mode,
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, 2, response, params);
- zassert_ok(host_command_process(&args),
+ zassume_ok(host_command_process(&args),
"Failed to get charge control values");
return response;
@@ -251,7 +260,7 @@ enum ec_status host_cmd_host_event(enum ec_host_event_action action,
/**
* @brief Call the host command MOTION_SENSE with the dump sub-command
*
- * Note: this function uses the zassert_ API. It will fail the test if the host
+ * 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
@@ -540,15 +549,6 @@ void host_cmd_typec_control_clear_events(int port, uint32_t events);
*/
void host_cmd_typec_control_bist_share_mode(int port, int enable);
-/**
- * Run the host command to control PD port behavior, with the sub-command of
- * TYPEC_CONTROL_COMMAND_SEND_VDM_REQ
- *
- * @param port The USB-C port number
- * @param vdm_req VDM request data
- */
-void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req);
-
struct host_events_ctx {
host_event_t lpc_host_events;
host_event_t lpc_host_event_mask[LPC_HOST_EVENT_COUNT];
@@ -580,7 +580,7 @@ void host_events_restore(struct host_events_ctx *host_events_ctx);
* If enabled, the device _should_ begin charging.
*
* This function assumes a successful gpio emulator call and will make a call
- * to the zassert_* API. A failure here will fail the calling test.
+ * to the zassume_* API. A failure here will abort the calling test.
*
* This function sleeps to wait for the GPIO interrupt to take place.
*
@@ -591,14 +591,10 @@ static inline void set_ac_enabled(bool enabled)
const struct device *acok_dev =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_ACOK_OD_NODE, gpios));
- zassert_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled),
+ zassume_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled),
NULL);
- /*
- * b/253284635 - Sleep for a full second past the debounce time
- * to ensure the power button debounce logic runs.
- */
- k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1000));
- zassert_equal(enabled, extpower_is_present(), NULL);
+ k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1));
+ zassume_equal(enabled, extpower_is_present(), NULL);
}
/**