summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/host_cmd
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/host_cmd')
-rw-r--r--zephyr/test/drivers/host_cmd/CMakeLists.txt1
-rw-r--r--zephyr/test/drivers/host_cmd/src/adc.c8
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_cut_off.c6
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_display_soc.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_v2.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/charge_manager.c48
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_cmd_versions.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_panic_info.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c8
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_command.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands.c3
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c187
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_request_expected_size.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c3
-rw-r--r--zephyr/test/drivers/host_cmd/src/motion_sense.c16
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_chip_info.c12
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_control.c30
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_log.c39
-rw-r--r--zephyr/test/drivers/host_cmd/src/tablet_mode.c111
-rw-r--r--zephyr/test/drivers/host_cmd/src/usb_pd_control.c10
-rw-r--r--zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c6
22 files changed, 156 insertions, 360 deletions
diff --git a/zephyr/test/drivers/host_cmd/CMakeLists.txt b/zephyr/test/drivers/host_cmd/CMakeLists.txt
index 14733253c3..d1567ec635 100644
--- a/zephyr/test/drivers/host_cmd/CMakeLists.txt
+++ b/zephyr/test/drivers/host_cmd/CMakeLists.txt
@@ -21,7 +21,6 @@ target_sources(app PRIVATE
src/pd_chip_info.c
src/pd_control.c
src/pd_log.c
- src/tablet_mode.c
src/usb_pd_control.c
src/usb_pd_host_cmd.c
)
diff --git a/zephyr/test/drivers/host_cmd/src/adc.c b/zephyr/test/drivers/host_cmd/src/adc.c
index f283ef17d5..6b2bef1165 100644
--- a/zephyr/test/drivers/host_cmd/src/adc.c
+++ b/zephyr/test/drivers/host_cmd/src/adc.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
+#include <zephyr/drivers/emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
#include "adc.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/drivers/emul.h>
-#include <zephyr/fff.h>
-#include <zephyr/ztest.h>
-
FAKE_VALUE_FUNC(int, adc_read_channel, enum adc_channel);
ZTEST(hc_adc, normal_path)
diff --git a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
index 019362f3c8..ed9d96481d 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
@@ -3,6 +3,9 @@
* found in the LICENSE file.
*/
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
#include "battery.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_smart_battery.h"
@@ -11,9 +14,6 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/drivers/emul.h>
-#include <zephyr/ztest.h>
-
struct host_cmd_battery_cut_off_fixture {
const struct emul *emul;
struct i2c_common_emul_data *i2c_emul;
diff --git a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
index 6af3d35043..029551a49b 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "battery.h"
#include "charge_state.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST_USER(battery_display_soc, happy_path)
{
const uint32_t full_charge_as_tenths =
diff --git a/zephyr/test/drivers/host_cmd/src/battery_v2.c b/zephyr/test/drivers/host_cmd/src/battery_v2.c
index a6fab89b8c..3e0ac969f9 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_v2.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_v2.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "battery.h"
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST(host_cmd_battery_v2, test_get_static__invalid_index)
{
struct ec_response_battery_static_info response;
diff --git a/zephyr/test/drivers/host_cmd/src/charge_manager.c b/zephyr/test/drivers/host_cmd/src/charge_manager.c
index 6bbf7a3ae3..7298b8e135 100644
--- a/zephyr/test/drivers/host_cmd/src/charge_manager.c
+++ b/zephyr/test/drivers/host_cmd/src/charge_manager.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "charge_manager.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST_USER(charge_manager, test_port_count)
{
struct ec_response_charge_port_count response = { 0 };
@@ -44,49 +44,5 @@ ZTEST_USER(charge_manager, test_port_override__0_from_off)
zassert_ok(host_command_process(&args));
}
-ZTEST_USER(charge_manager, test_charge_state_get_debug_params)
-{
- struct ec_params_charge_state params = {
- .cmd = CHARGE_STATE_CMD_GET_PARAM,
- };
- struct ec_response_charge_state response = { 0 };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params);
-
- /* Check that the following get commands work on these debug parameters.
- * The values being asserted are the default values when nothing is
- * plugged in. This should be enough since the test only needs to verify
- * that the command gets the current value. Tests that verify the
- * charging behavior exist elsewhere (under
- * default/src/integration/usbc).
- */
- params.get_param.param = CS_PARAM_DEBUG_CTL_MODE;
- zassert_ok(host_command_process(&args));
- zassert_equal(0, response.get_param.value);
-
- params.get_param.param = CS_PARAM_DEBUG_MANUAL_CURRENT;
- zassert_ok(host_command_process(&args));
- zassert_equal(0xffffffff, response.get_param.value);
-
- params.get_param.param = CS_PARAM_DEBUG_MANUAL_VOLTAGE;
- zassert_ok(host_command_process(&args));
- zassert_equal(0xffffffff, response.get_param.value);
-
- params.get_param.param = CS_PARAM_DEBUG_SEEMS_DEAD;
- zassert_ok(host_command_process(&args));
- zassert_equal(0, response.get_param.value);
-
- params.get_param.param = CS_PARAM_DEBUG_SEEMS_DISCONNECTED;
- zassert_ok(host_command_process(&args));
- zassert_equal(0, response.get_param.value);
-
- params.get_param.param = CS_PARAM_DEBUG_BATT_REMOVED;
- zassert_ok(host_command_process(&args));
- zassert_equal(0, response.get_param.value);
-
- params.get_param.param = CS_PARAM_DEBUG_MAX;
- zassert_equal(EC_ERROR_INVAL, host_command_process(&args));
-}
-
ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
diff --git a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
index 0fa7ab3770..b935b69e46 100644
--- a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
+++ b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "battery.h"
#include "charge_state.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST_USER(hc_get_cmd_versions, test_v0__both_versions)
{
struct ec_params_get_cmd_versions params = {
diff --git a/zephyr/test/drivers/host_cmd/src/get_panic_info.c b/zephyr/test/drivers/host_cmd/src/get_panic_info.c
index 85d5fdd6f2..bdb19d9a98 100644
--- a/zephyr/test/drivers/host_cmd/src/get_panic_info.c
+++ b/zephyr/test/drivers/host_cmd/src/get_panic_info.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "host_command.h"
#include "panic.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
struct host_cmd_get_panic_info_fixture {
struct panic_data saved_pdata;
};
diff --git a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
index 2d9410232d..907329f8a1 100644
--- a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
+++ b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
ZTEST_USER(host_cmd_get_pd_port_caps, test_good_index)
{
struct ec_params_get_pd_port_caps params = { .port = 0 };
@@ -50,7 +50,7 @@ static void host_cmd_get_pd_port_caps_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassert_true(board_get_usb_pd_port_count() > 0,
+ zassume_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
}
diff --git a/zephyr/test/drivers/host_cmd/src/host_command.c b/zephyr/test/drivers/host_cmd/src/host_command.c
index a9f0fcb941..49e41acc89 100644
--- a/zephyr/test/drivers/host_cmd/src/host_command.c
+++ b/zephyr/test/drivers/host_cmd/src/host_command.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST(host_cmd_host_commands, get_command_versions__v1)
{
struct ec_response_get_cmd_versions response;
diff --git a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
index f4bf956e9b..9d29aeb7de 100644
--- a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
+++ b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST_USER(hc_test_protocol, test_echo_max_buffer_size)
{
struct ec_params_test_protocol params = {
diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands.c b/zephyr/test/drivers/host_cmd/src/host_event_commands.c
index 8e7fff0fe2..c2f7e72045 100644
--- a/zephyr/test/drivers/host_cmd/src/host_event_commands.c
+++ b/zephyr/test/drivers/host_cmd/src/host_event_commands.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/ztest.h>
-
struct host_cmd_host_event_commands_fixture {
struct host_events_ctx ctx;
};
diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
index b0ba438bbb..6d0a386d6e 100644
--- a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
+++ b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
@@ -5,30 +5,39 @@
/* Tests for deprecated EC_CMD_HOST_EVENT_* commands */
+#include <zephyr/ztest.h>
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/ztest.h>
-
#define HOST_EVENT_TEST_MASK_VAL EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)
-static enum ec_status
+static void
host_event_get_wake_mask_helper(struct ec_response_host_event_mask *r)
{
+ enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_WAKE_MASK, 0, *r);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_GET_WAKE_MASK always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
-static enum ec_status host_event_set_wake_mask_helper(uint32_t mask)
+static void host_event_set_wake_mask_helper(uint32_t mask)
{
+ enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_WAKE_MASK, 0, params);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_SET_WAKE_MASK always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
/**
@@ -36,17 +45,13 @@ static enum ec_status host_event_set_wake_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
- rv = host_event_get_wake_mask_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- }
+ host_event_get_wake_mask_helper(&result);
+#else
+ ztest_test_skip();
+#endif
}
/**
@@ -54,24 +59,16 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- rv = host_event_get_wake_mask_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- return;
- }
+ host_event_get_wake_mask_helper(&result);
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event wake mask is not clear");
- zassert_ok(host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL));
+ host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL);
/* Verify the mask changed */
host_event_get_wake_mask_helper(&result);
@@ -81,25 +78,38 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- zassert_ok(host_event_set_wake_mask_helper(0));
+ host_event_set_wake_mask_helper(0);
+#else
+ ztest_test_skip();
+#endif
}
-static enum ec_status
+static void
host_event_get_smi_mask_helper(struct ec_response_host_event_mask *r)
{
+ enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_SMI_MASK, 0, *r);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_GET_SMI_MASK always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
-static enum ec_status host_event_set_smi_mask_helper(uint32_t mask)
+static void host_event_set_smi_mask_helper(uint32_t mask)
{
+ enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_SMI_MASK, 0, params);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_SET_SMI_MASK always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
/**
@@ -107,18 +117,13 @@ static enum ec_status host_event_set_smi_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
- rv = host_event_get_smi_mask_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- return;
- }
+ host_event_get_smi_mask_helper(&result);
+#else
+ ztest_test_skip();
+#endif
}
/**
@@ -126,43 +131,42 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- rv = host_event_get_smi_mask_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- return;
- }
+ host_event_get_smi_mask_helper(&result);
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SMI mask is not clear");
- zassert_ok(host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL));
+ host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL);
/* Verify the mask changed */
- zassert_ok(host_event_get_smi_mask_helper(&result));
+ host_event_get_smi_mask_helper(&result);
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SMI mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- zassert_ok(host_event_set_smi_mask_helper(0));
+ host_event_set_smi_mask_helper(0);
+#else
+ ztest_test_skip();
+#endif
}
-static enum ec_status
-host_event_get_b_helper(struct ec_response_host_event_mask *r)
+static void host_event_get_b_helper(struct ec_response_host_event_mask *r)
{
+ enum ec_status ret_val;
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_HOST_EVENT_GET_B, 0, *r);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_GET_B always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
/**
@@ -170,36 +174,41 @@ host_event_get_b_helper(struct ec_response_host_event_mask *r)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_b)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
- rv = host_event_get_b_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- return;
- }
+ host_event_get_b_helper(&result);
+#else
+ ztest_test_skip();
+#endif
}
-static enum ec_status
+static void
host_event_get_sci_mask_helper(struct ec_response_host_event_mask *r)
{
+ enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_SCI_MASK, 0, *r);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_GET_SCI_MASK always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
-static enum ec_status host_event_set_sci_mask_helper(uint32_t mask)
+static void host_event_set_sci_mask_helper(uint32_t mask)
{
+ enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_SCI_MASK, 0, params);
- return host_command_process(&args);
+ ret_val = host_command_process(&args);
+
+ /* EC_CMD_HOST_EVENT_SET_SCI_MASK always returns success */
+ zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
+ EC_RES_SUCCESS, ret_val);
}
/**
@@ -207,18 +216,13 @@ static enum ec_status host_event_set_sci_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
- rv = host_event_get_sci_mask_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- return;
- }
+ host_event_get_sci_mask_helper(&result);
+#else
+ ztest_test_skip();
+#endif
}
/**
@@ -226,32 +230,27 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_sci_mask)
{
- enum ec_status rv;
+#ifdef CONFIG_HOSTCMD_X86
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- rv = host_event_get_sci_mask_helper(&result);
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
- } else {
- zassert_equal(EC_RES_INVALID_COMMAND, rv,
- "Expected %d, returned %d",
- EC_RES_INVALID_COMMAND, rv);
- return;
- }
+ host_event_get_sci_mask_helper(&result);
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SCI mask is not clear");
- zassert_ok(host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL));
+ host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL);
/* Verify the mask changed */
- zassert_ok(host_event_get_sci_mask_helper(&result));
+ host_event_get_sci_mask_helper(&result);
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SCI mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- zassert_ok(host_event_set_sci_mask_helper(0));
+ host_event_set_sci_mask_helper(0);
+#else
+ ztest_test_skip();
+#endif
}
diff --git a/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c b/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c
index 19fdd9ea4a..30ff8c11b2 100644
--- a/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c
+++ b/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
+
#include "host_command.h"
#include "test/drivers/test_state.h"
-#include <zephyr/ztest.h>
-
ZTEST(host_request_expected_size, test_mismatched_host_request_version)
{
const struct ec_host_request request = {
diff --git a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
index e77230cfaf..4c74a48ab4 100644
--- a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
+++ b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
+#include <zephyr/ztest.h>
#include "include/keyboard_mkbp.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/ztest.h>
-
struct keyboard_mkbp_commands_fixture {
struct ec_mkbp_config config;
};
diff --git a/zephyr/test/drivers/host_cmd/src/motion_sense.c b/zephyr/test/drivers/host_cmd/src/motion_sense.c
index 919baf7219..371ca4ae11 100644
--- a/zephyr/test/drivers/host_cmd/src/motion_sense.c
+++ b/zephyr/test/drivers/host_cmd/src/motion_sense.c
@@ -3,6 +3,10 @@
* found in the LICENSE file.
*/
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#include "atomic.h"
#include "console.h"
#include "driver/accel_bma2x2.h"
@@ -13,10 +17,6 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
FAKE_VALUE_FUNC(int, mock_set_range, struct motion_sensor_t *, int, int);
FAKE_VALUE_FUNC(int, mock_set_offset, const struct motion_sensor_t *,
const int16_t *, int16_t);
@@ -72,7 +72,7 @@ static void host_cmd_motion_sense_before(void *fixture)
RESET_FAKE(mock_perform_calib);
FFF_RESET_HISTORY();
- zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinit 0"));
+ zassume_ok(shell_execute_cmd(get_ec_shell(), "accelinit 0"));
atomic_clear(&motion_sensors[0].flush_pending);
motion_sensors[0].config[SENSOR_CONFIG_AP].odr = 0;
@@ -305,7 +305,7 @@ ZTEST_USER(host_cmd_motion_sense, test_odr_get)
{
struct ec_response_motion_sense response;
- zassert_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0],
+ zassume_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0],
1000000, false),
NULL);
zassert_ok(host_cmd_motion_sense_odr(/*sensor_num=*/0,
@@ -322,7 +322,7 @@ ZTEST_USER(host_cmd_motion_sense, test_odr_set)
{
struct ec_response_motion_sense response;
- zassert_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 0,
+ zassume_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 0,
false),
NULL);
zassert_ok(host_cmd_motion_sense_odr(/*sensor_num=*/0,
@@ -774,7 +774,7 @@ ZTEST(host_cmd_motion_sense, test_int_enable)
host_cmd_motion_sense_int_enable(2, &response), NULL);
/* Make sure we start off disabled */
- zassert_ok(host_cmd_motion_sense_int_enable(0, &response));
+ zassume_ok(host_cmd_motion_sense_int_enable(0, &response));
/* Test enable */
zassert_ok(host_cmd_motion_sense_int_enable(1, &response));
diff --git a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
index c04e74810a..95e2339899 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#define TEST_PORT USBC_PORT_C0
#define BAD_PORT 65
@@ -20,7 +20,7 @@ static enum ec_status run_pd_chip_info(int port,
{
struct ec_params_pd_chip_info params = { .port = port, .live = true };
struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, *resp, params);
+ BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, resp, params);
return host_command_process(&args);
}
@@ -41,7 +41,7 @@ ZTEST_USER(host_cmd_pd_chip_info, test_bad_index)
{
struct ec_response_pd_chip_info_v1 response;
- zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
+ zassume_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
zassert_equal(run_pd_chip_info(BAD_PORT, &response),
EC_RES_INVALID_PARAM,
@@ -53,7 +53,7 @@ static void host_cmd_pd_chip_info_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassert_true(board_get_usb_pd_port_count() > 0,
+ zassume_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
/* Set the system into S0, since the AP would drive these commands */
diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c
index a881a8e0ea..e8de27f6ce 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_control.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#define TEST_PORT USBC_PORT_C0
#define BAD_PORT 82
@@ -23,7 +23,7 @@ ZTEST_USER(host_cmd_pd_control, test_bad_index)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
- zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
+ zassume_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
"Failed to fail pd_control for port %d", params.chip);
@@ -47,7 +47,7 @@ ZTEST_USER(host_cmd_pd_control, test_pd_reset_resume)
* the only HC return which would cover this is a state string, which
* could be brittle.
*/
- zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
+ zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
host_cmd_pd_control(TEST_PORT, PD_RESET);
@@ -76,7 +76,7 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume)
* the only HC return which would cover this is a state string, which
* could be brittle.
*/
- zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
+ zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
host_cmd_pd_control(TEST_PORT, PD_SUSPEND);
@@ -93,20 +93,6 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume)
zassert_true(pd_is_port_enabled(TEST_PORT), "Port failed to resume");
}
-ZTEST_USER(host_cmd_pd_control, test_suspend_low_battery)
-{
- struct ec_params_pd_control params = { .chip = TEST_PORT,
- .subcmd = PD_SUSPEND };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
-
- /* Suspending the port for firmware update should fail at critical low
- * battery.
- */
- test_set_battery_level(1);
- zassert_equal(host_command_process(&args), EC_RES_BUSY);
-}
-
ZTEST_USER(host_cmd_pd_control, test_control_disable)
{
struct ec_params_pd_control params = { .chip = TEST_PORT,
@@ -131,7 +117,7 @@ static void host_cmd_pd_control_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassert_true(board_get_usb_pd_port_count() > 0,
+ zassume_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
/* Set the system into S0, since the AP would drive these commands */
diff --git a/zephyr/test/drivers/host_cmd/src/pd_log.c b/zephyr/test/drivers/host_cmd/src/pd_log.c
index 819f020890..a6022d8bb1 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_log.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_log.c
@@ -3,14 +3,13 @@
* found in the LICENSE file.
*/
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#include "event_log.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "usb_pd.h"
-#include "util.h"
-
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
/**
* @brief This is the maximum size of a single log entry.
@@ -21,14 +20,6 @@
#define MAX_EVENT_LOG_ENTRY_SIZE (sizeof(struct event_log_entry) + 16)
/**
- * @brief This is the maximum size of a response pd log entry.
- *
- * Each entry must contain some common data + up to 16 bytes of additional type
- * specific data.
- */
-#define MAX_RESPONSE_PD_LOG_ENTRY_SIZE (sizeof(struct ec_response_pd_log) + 16)
-
-/**
* @brief The size of the PD log entry data
*
* Logs from the PD include an additional 8 bytes of data to be sent to the AP.
@@ -129,7 +120,7 @@ ZTEST_USER_F(pd_log, test_mcu_connect)
ZTEST_USER_F(pd_log, test_read_log_entry)
{
- uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE];
+ uint8_t response_buffer[sizeof(struct ec_response_pd_log) + 16];
struct ec_response_pd_log *response =
(struct ec_response_pd_log *)response_buffer;
struct host_cmd_handler_args args =
@@ -142,25 +133,3 @@ ZTEST_USER_F(pd_log, test_read_log_entry)
zassert_equal(sizeof(struct event_log_entry), args.response_size, NULL);
zassert_equal(PD_EVENT_NO_ENTRY, response->type, NULL);
}
-
-ZTEST_USER_F(pd_log, test_log_recv_vdm)
-{
- uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE];
- uint32_t *payload = (uint32_t *)response_buffer;
- struct ec_response_pd_log *response =
- (struct ec_response_pd_log *)&payload[1];
-
- memset(response_buffer, 0, sizeof(response_buffer));
- payload[0] |= VDO_SRC_RESPONDER;
- response->type = PD_EVENT_MCU_CONNECT;
- response->size_port = 8;
- int cnt = DIV_ROUND_UP(response->size_port, sizeof(uint32_t)) + 2;
-
- pd_log_recv_vdm(0, cnt, payload);
-
- (void)log_dequeue_event(&fixture->log_entry);
-
- zassert_equal(response->type, fixture->log_entry.type,
- "type=%d, received=%d", response->type,
- fixture->log_entry.type);
-}
diff --git a/zephyr/test/drivers/host_cmd/src/tablet_mode.c b/zephyr/test/drivers/host_cmd/src/tablet_mode.c
deleted file mode 100644
index a84faa035f..0000000000
--- a/zephyr/test/drivers/host_cmd/src/tablet_mode.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* 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 "emul/emul_common_i2c.h"
-#include "emul/emul_smart_battery.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "tablet_mode.h"
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
-
-#include <zephyr/drivers/emul.h>
-#include <zephyr/ztest.h>
-
-struct host_cmd_tablet_mode_fixture {
- const struct emul *emul;
- struct i2c_common_emul_data *i2c_emul;
-};
-
-static void host_cmd_tablet_mode_before(void *f)
-{
- ARG_UNUSED(f);
- tablet_reset();
-}
-
-static void host_cmd_tablet_mode_after(void *f)
-{
- ARG_UNUSED(f);
- tablet_reset();
-}
-
-ZTEST_SUITE(host_cmd_tablet_mode, drivers_predicate_post_main, NULL,
- host_cmd_tablet_mode_before, host_cmd_tablet_mode_after, NULL);
-
-/* Test tablet mode can be enabled with a host command. */
-ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_on)
-{
- int rv;
- struct ec_params_set_tablet_mode params = {
- .tablet_mode = TABLET_MODE_FORCE_TABLET
- };
-
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
- zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
- rv);
- /* Return 1 if in tablet mode, 0 otherwise */
- rv = tablet_get_mode();
- zassert_equal(rv, 1, "unexpected tablet mode: %d", rv);
-}
-
-/* Test tablet mode can be disabled with a host command. */
-ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_off)
-{
- int rv;
- struct ec_params_set_tablet_mode params = {
- .tablet_mode = TABLET_MODE_FORCE_CLAMSHELL
- };
-
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
- zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
- rv);
- /* Return 1 if in tablet mode, 0 otherwise */
- rv = tablet_get_mode();
- zassert_equal(rv, 0, "unexpected tablet mode: %d", rv);
-}
-
-/* Test tablet mode can be reset with a host command. */
-ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_reset)
-{
- int rv;
- struct ec_params_set_tablet_mode params = {
- .tablet_mode = TABLET_MODE_DEFAULT
- };
-
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
- zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
- rv);
- /* Return 1 if in tablet mode, 0 otherwise */
- rv = tablet_get_mode();
- zassert_equal(rv, 0, "unexpected tablet mode: %d", rv);
-}
-
-/* Test tablet mode can handle invalid host command parameters. */
-ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_invalid_parameter)
-{
- int rv;
- struct ec_params_set_tablet_mode params = {
- .tablet_mode = 0xEE /* Sufficiently random, bad value.*/
- };
-
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
- zassert_equal(EC_RES_INVALID_PARAM, rv,
- "Expected EC_RES_INVALID_PARAM, but got %d", rv);
- /* Return 1 if in tablet mode, 0 otherwise */
- rv = tablet_get_mode();
- zassert_equal(rv, 0, "unexpected tablet mode: %d", rv);
-}
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
index f926c2b7ca..c439141da9 100644
--- a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
@@ -3,6 +3,9 @@
* found in the LICENSE file.
*/
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#include "console.h"
#include "ec_commands.h"
#include "emul/emul_isl923x.h"
@@ -13,9 +16,6 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#define TEST_PORT USBC_PORT_C0
#define BAD_PORT 42
@@ -99,7 +99,7 @@ ZTEST_USER(host_cmd_usb_pd_control, test_bad_index)
{
struct ec_response_usb_pd_control_v2 response;
- zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
+ zassume_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
zassert_equal(run_usb_pd_control(BAD_PORT, &response),
EC_RES_INVALID_PARAM,
@@ -130,7 +130,7 @@ static void host_cmd_usb_pd_control_before(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassert_true(board_get_usb_pd_port_count() > 0,
+ zassume_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
/* Set the system into S0, since the AP would drive these commands */
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
index d95461f274..3afc90760a 100644
--- a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
+++ b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "usb_pd.h"
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
ZTEST_USER(usb_pd_host_cmd, test_hc_pd_host_event_status)
{
struct ec_response_host_event_status response;