diff options
author | Caveh Jalali <caveh@chromium.org> | 2023-01-11 17:55:09 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-16 00:46:34 +0000 |
commit | 654c7f10f0447d04cdafee9ea19f887f964d8940 (patch) | |
tree | c86673bfc91c80cf1eb1df29fe30b1e15a317afa /zephyr/test/drivers/default | |
parent | 0893963bfd157ad6310266381b921b8f007ef31d (diff) | |
download | chrome-ec-654c7f10f0447d04cdafee9ea19f887f964d8940.tar.gz |
zephyr/test: Update tests to use EC CMD API
This refactors the unit tests to use the EC host command API. Calls to
the generic host_command_process(...) are replaced with type-checked
host command API calls that perform the same operation.
BRANCH=none
BUG=b:258110734
TEST='./twister -v -T zephyr/test' passes
Change-Id: I1b925a04271dd50c3c7c0a3481cd30ba762b1561
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4172828
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/test/drivers/default')
-rw-r--r-- | zephyr/test/drivers/default/src/espi.c | 92 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/i2c.c | 47 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/i2c_passthru.c | 37 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/lid_switch.c | 12 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/locate_chip.c | 22 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/power_common.c | 62 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/uart_hostcmd.c | 18 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/usb_mux.c | 15 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/vboot_hash.c | 30 | ||||
-rw-r--r-- | zephyr/test/drivers/default/src/vstore.c | 23 |
10 files changed, 138 insertions, 220 deletions
diff --git a/zephyr/test/drivers/default/src/espi.c b/zephyr/test/drivers/default/src/espi.c index d81718d422..86428d4ba6 100644 --- a/zephyr/test/drivers/default/src/espi.c +++ b/zephyr/test/drivers/default/src/espi.c @@ -36,11 +36,9 @@ static void espi_after(void *state) ZTEST_USER(espi, test_host_command_get_protocol_info) { struct ec_response_get_protocol_info response; - struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE( - EC_CMD_GET_PROTOCOL_INFO, 0, response); + struct host_cmd_handler_args args; - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_get_protocol_info(&args, &response)); zassert_equal(args.response_size, sizeof(response)); zassert_equal(response.protocol_versions, BIT(3)); zassert_equal(response.max_request_packet_size, EC_LPC_HOST_PACKET_SIZE, @@ -55,12 +53,9 @@ ZTEST_USER(espi, test_host_command_usb_pd_power_info) /* Only test we've enabled the command */ struct ec_response_usb_pd_power_info response; struct ec_params_usb_pd_power_info params = { .port = PORT }; - struct host_cmd_handler_args args = BUILD_HOST_COMMAND( - EC_CMD_USB_PD_POWER_INFO, 0, response, params); + struct host_cmd_handler_args args; - args.params = ¶ms; - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_usb_pd_power_info(&args, ¶ms, &response)); zassert_equal(args.response_size, sizeof(response)); } @@ -69,11 +64,9 @@ ZTEST_USER(espi, test_host_command_typec_status) /* Only test we've enabled the command */ 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); + struct host_cmd_handler_args args; - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_typec_status(&args, ¶ms, &response)); zassert_equal(args.response_size, sizeof(response)); } @@ -85,20 +78,17 @@ ZTEST_USER(espi, test_host_command_gpio_get_v0) }; struct ec_response_gpio_get response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 0, response, p); + struct host_cmd_handler_args args; set_ac_enabled(true); - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_gpio_get(&args, &p, &response)); zassert_equal(args.response_size, sizeof(response)); zassert_true(response.val); set_ac_enabled(false); - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_gpio_get(&args, &p, &response)); zassert_equal(args.response_size, sizeof(response)); zassert_false(response.val); } @@ -114,21 +104,18 @@ ZTEST_USER(espi, test_host_command_gpio_get_v1_get_by_name) }; struct ec_response_gpio_get_v1 response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, p); + struct host_cmd_handler_args args; set_ac_enabled(true); - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response)); zassert_equal(args.response_size, sizeof(response.get_value_by_name), NULL); zassert_true(response.get_info.val); set_ac_enabled(false); - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response)); zassert_equal(args.response_size, sizeof(response.get_value_by_name), NULL); zassert_false(response.get_info.val); @@ -141,11 +128,9 @@ ZTEST_USER(espi, test_host_command_gpio_get_v1_get_count) }; struct ec_response_gpio_get_v1 response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, p); + struct host_cmd_handler_args args; - zassert_ok(host_command_process(&args), NULL); - zassert_ok(args.result, NULL); + zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response), NULL); zassert_equal(args.response_size, sizeof(response.get_count), NULL); zassert_equal(response.get_count.val, GPIO_COUNT, NULL); } @@ -161,21 +146,18 @@ ZTEST_USER(espi, test_host_command_gpio_get_v1_get_info) }; struct ec_response_gpio_get_v1 response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, p); + struct host_cmd_handler_args args; set_ac_enabled(true); - zassert_ok(host_command_process(&args), NULL); - zassert_ok(args.result, NULL); + zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response), NULL); zassert_equal(args.response_size, sizeof(response), NULL); zassert_ok(strcmp(response.get_info.name, AC_OK_OD_GPIO_NAME), NULL); zassert_true(response.get_info.val, NULL); set_ac_enabled(false); - zassert_ok(host_command_process(&args), NULL); - zassert_ok(args.result, NULL); + zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response), NULL); zassert_equal(args.response_size, sizeof(response), NULL); zassert_ok(strcmp(response.get_info.name, AC_OK_OD_GPIO_NAME), NULL); zassert_false(response.get_info.val, NULL); @@ -192,18 +174,15 @@ ZTEST_USER(espi, test_host_command_gpio_set) .val = 0, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, p); - /* Force value to 1 to see change */ zassert_ok(gpio_pin_set_dt(gp, 1), NULL); - zassert_ok(host_command_process(&args), NULL); + zassert_ok(ec_cmd_gpio_set(NULL, &p), NULL); zassert_equal(gpio_pin_get_dt(gp), p.val, NULL); p.val = 1; - zassert_ok(host_command_process(&args), NULL); + zassert_ok(ec_cmd_gpio_set(NULL, &p), NULL); zassert_equal(gpio_pin_get_dt(gp), p.val, NULL); } @@ -211,10 +190,9 @@ ZTEST(espi, test_hc_gpio_get_v0_invalid_name) { struct ec_response_gpio_get response; struct ec_params_gpio_get params = { .name = "INVALID_GPIO_NAME" }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 0, response, params); - zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL); + zassert_equal(EC_RES_ERROR, ec_cmd_gpio_get(NULL, ¶ms, &response), + NULL); } ZTEST(espi, test_hc_gpio_get_v1_get_by_name_invalid_name) @@ -224,10 +202,9 @@ ZTEST(espi, test_hc_gpio_get_v1_get_by_name_invalid_name) .subcmd = EC_GPIO_GET_BY_NAME, .get_value_by_name.name = "INVALID_GPIO_NAME", }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, params); - zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL); + zassert_equal(EC_RES_ERROR, + ec_cmd_gpio_get_v1(NULL, ¶ms, &response), NULL); } ZTEST(espi, test_hc_gpio_get_v1_get_info_invalid_index) @@ -237,10 +214,9 @@ ZTEST(espi, test_hc_gpio_get_v1_get_info_invalid_index) .subcmd = EC_GPIO_GET_INFO, .get_info.index = GPIO_COUNT, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, params); - zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL); + zassert_equal(EC_RES_ERROR, + ec_cmd_gpio_get_v1(NULL, ¶ms, &response), NULL); } ZTEST(espi, test_hc_gpio_get_v1_invalid_subcmd) @@ -249,20 +225,17 @@ ZTEST(espi, test_hc_gpio_get_v1_invalid_subcmd) struct ec_params_gpio_get_v1 params = { .subcmd = EC_CMD_GPIO_GET, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, params); - zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args), NULL); + zassert_equal(EC_RES_INVALID_PARAM, + ec_cmd_gpio_get_v1(NULL, ¶ms, &response), NULL); } /* EC_CMD_GET_FEATURES */ ZTEST_USER(espi, test_host_command_ec_cmd_get_features) { struct ec_response_get_features response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_FEATURES, 0, response); - int rv = host_command_process(&args); + int rv = ec_cmd_get_features(NULL, &response); zassert_equal(rv, EC_RES_SUCCESS, "Expected %d, but got %d", EC_RES_SUCCESS, rv); @@ -285,11 +258,10 @@ ZTEST_USER(espi, test_host_command_ec_cmd_get_features) ZTEST(espi, test_hc_gpio_set_system_is_locked) { struct ec_params_gpio_set params; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, params); system_is_locked_fake.return_val = 1; - zassert_equal(EC_RES_ACCESS_DENIED, host_command_process(&args), NULL); + zassert_equal(EC_RES_ACCESS_DENIED, ec_cmd_gpio_set(NULL, ¶ms), + NULL); } ZTEST(espi, test_hc_gpio_set_invalid_gpio_name) @@ -298,10 +270,8 @@ ZTEST(espi, test_hc_gpio_set_invalid_gpio_name) .name = "", .val = 0, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, params); - zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL); + zassert_equal(EC_RES_ERROR, ec_cmd_gpio_set(NULL, ¶ms), NULL); } ZTEST_SUITE(espi, drivers_predicate_post_main, NULL, espi_before, espi_after, diff --git a/zephyr/test/drivers/default/src/i2c.c b/zephyr/test/drivers/default/src/i2c.c index ca27fedbb2..b171f7dab9 100644 --- a/zephyr/test/drivers/default/src/i2c.c +++ b/zephyr/test/drivers/default/src/i2c.c @@ -18,18 +18,15 @@ ZTEST_USER(i2c, test_i2c_set_speed_success) .port = I2C_PORT_USB_C0, .cmd = EC_I2C_CONTROL_GET_SPEED, }; - struct host_cmd_handler_args get_args = - BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, get_params); + struct host_cmd_handler_args get_args; struct ec_params_i2c_control set_params = { .port = I2C_PORT_USB_C0, .cmd = EC_I2C_CONTROL_SET_SPEED, }; - struct host_cmd_handler_args set_args = - BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, set_params); + struct host_cmd_handler_args set_args; /* Get the speed: 100. */ - zassert_ok(host_command_process(&get_args), NULL); - zassert_ok(get_args.result, NULL); + zassert_ok(ec_cmd_i2c_control(&get_args, &get_params, &response), NULL); zassert_equal(get_args.response_size, sizeof(response), NULL); zassert_equal(response.cmd_response.speed_khz, 100, "response.cmd_response.speed_khz = %d", @@ -37,16 +34,14 @@ ZTEST_USER(i2c, test_i2c_set_speed_success) /* Set the speed to 400. */ set_params.cmd_params.speed_khz = 400; - zassert_ok(host_command_process(&set_args), NULL); - zassert_ok(set_args.result, NULL); + zassert_ok(ec_cmd_i2c_control(&set_args, &set_params, &response), NULL); zassert_equal(set_args.response_size, sizeof(response), NULL); zassert_equal(response.cmd_response.speed_khz, 100, "response.cmd_response.speed_khz = %d", response.cmd_response.speed_khz); /* Get the speed to verify. */ - zassert_ok(host_command_process(&get_args), NULL); - zassert_ok(get_args.result, NULL); + zassert_ok(ec_cmd_i2c_control(&get_args, &get_params, &response), NULL); zassert_equal(get_args.response_size, sizeof(response), NULL); zassert_equal(response.cmd_response.speed_khz, 400, "response.cmd_response.speed_khz = %d", @@ -54,16 +49,14 @@ ZTEST_USER(i2c, test_i2c_set_speed_success) /* Set the speed to 1000. */ set_params.cmd_params.speed_khz = 1000; - zassert_ok(host_command_process(&set_args), NULL); - zassert_ok(set_args.result, NULL); + zassert_ok(ec_cmd_i2c_control(&set_args, &set_params, &response), NULL); zassert_equal(set_args.response_size, sizeof(response), NULL); zassert_equal(response.cmd_response.speed_khz, 400, "response.cmd_response.speed_khz = %d", response.cmd_response.speed_khz); /* Get the speed to verify. */ - zassert_ok(host_command_process(&get_args), NULL); - zassert_ok(get_args.result, NULL); + zassert_ok(ec_cmd_i2c_control(&get_args, &get_params, &response), NULL); zassert_equal(get_args.response_size, sizeof(response), NULL); zassert_equal(response.cmd_response.speed_khz, 1000, "response.cmd_response.speed_khz = %d", @@ -71,8 +64,7 @@ ZTEST_USER(i2c, test_i2c_set_speed_success) /* Set the speed back to 100. */ set_params.cmd_params.speed_khz = 100; - zassert_ok(host_command_process(&set_args), NULL); - zassert_ok(set_args.result, NULL); + zassert_ok(ec_cmd_i2c_control(&set_args, &set_params, &response), NULL); zassert_equal(set_args.response_size, sizeof(response), NULL); zassert_equal(response.cmd_response.speed_khz, 1000, "response.cmd_response.speed_khz = %d", @@ -87,11 +79,10 @@ ZTEST_USER(i2c, test_i2c_set_speed_not_dynamic) .cmd = EC_I2C_CONTROL_SET_SPEED, .cmd_params.speed_khz = 400, }; - struct host_cmd_handler_args set_args = - BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, set_params); /* Set the speed to 400 on a bus which doesn't support dynamic-speed. */ - zassert_equal(EC_RES_ERROR, host_command_process(&set_args), NULL); + zassert_equal(EC_RES_ERROR, + ec_cmd_i2c_control(NULL, &set_params, &response), NULL); } ZTEST_USER(i2c, test_i2c_control_wrong_port) @@ -101,12 +92,10 @@ ZTEST_USER(i2c, test_i2c_control_wrong_port) .port = 10, .cmd = EC_I2C_CONTROL_GET_SPEED, }; - struct host_cmd_handler_args get_args = - BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, get_params); /* Set the .port=10, which is not defined. */ - zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&get_args), - NULL); + zassert_equal(EC_RES_INVALID_PARAM, + ec_cmd_i2c_control(NULL, &get_params, &response), NULL); } ZTEST_USER(i2c, test_i2c_control_wrong_cmd) @@ -116,12 +105,10 @@ ZTEST_USER(i2c, test_i2c_control_wrong_cmd) .port = I2C_PORT_USB_C0, .cmd = 10, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, params); /* Call the .cmd=10, which is not defined. */ - zassert_equal(EC_RES_INVALID_COMMAND, host_command_process(&args), - NULL); + zassert_equal(EC_RES_INVALID_COMMAND, + ec_cmd_i2c_control(NULL, ¶ms, &response), NULL); } ZTEST_USER(i2c, test_i2c_set_speed_wrong_freq) @@ -132,12 +119,10 @@ ZTEST_USER(i2c, test_i2c_set_speed_wrong_freq) .cmd = EC_I2C_CONTROL_SET_SPEED, .cmd_params.speed_khz = 123, }; - struct host_cmd_handler_args set_args = - BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, set_params); /* Set the speed to 123 KHz (an invalid speed). */ - zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&set_args), - NULL); + zassert_equal(EC_RES_INVALID_PARAM, + ec_cmd_i2c_control(NULL, &set_params, &response), NULL); } static void i2c_freq_reset(void) diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c index afefc4b553..21726ea8f6 100644 --- a/zephyr/test/drivers/default/src/i2c_passthru.c +++ b/zephyr/test/drivers/default/src/i2c_passthru.c @@ -112,37 +112,39 @@ ZTEST_USER(i2c_passthru, test_passthru_protect) .port = I2C_PORT_SENSOR, .subcmd = EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE, }; - struct host_cmd_handler_args enable_args = BUILD_HOST_COMMAND_PARAMS( - EC_CMD_I2C_PASSTHRU_PROTECT, 0, enable_params); /* Check the protect status: 0 (unprotected) */ - zassert_ok(host_command_process(&status_args), NULL); - zassert_ok(status_args.result, NULL); + zassert_ok(ec_cmd_i2c_passthru_protect(&status_args, &status_params, + &response), + NULL); zassert_equal(status_args.response_size, sizeof(response), NULL); zassert_equal(response.status, 0, "response.status = %d", response.status); /* Protect the bus */ - zassert_ok(host_command_process(&enable_args), NULL); - zassert_ok(enable_args.result, NULL); + zassert_ok(ec_cmd_i2c_passthru_protect(NULL, &enable_params, &response), + NULL); /* Check the protect status: 1 (protected) */ - zassert_ok(host_command_process(&status_args), NULL); - zassert_ok(status_args.result, NULL); + zassert_ok(ec_cmd_i2c_passthru_protect(&status_args, &status_params, + &response), + NULL); zassert_equal(status_args.response_size, sizeof(response), NULL); zassert_equal(response.status, 1, "response.status = %d", response.status); /* Error case: wrong subcmd */ status_params.subcmd = 10; - zassert_equal(host_command_process(&status_args), + zassert_equal(ec_cmd_i2c_passthru_protect(NULL, &status_params, + &response), EC_RES_INVALID_COMMAND, NULL); status_params.subcmd = EC_CMD_I2C_PASSTHRU_PROTECT_STATUS; /* Error case: wrong port */ status_params.port = 10; - zassert_equal(host_command_process(&status_args), EC_RES_INVALID_PARAM, - NULL); + zassert_equal(ec_cmd_i2c_passthru_protect(NULL, &status_params, + &response), + EC_RES_INVALID_PARAM, NULL); status_params.port = I2C_PORT_SENSOR; /* Error case: response size not enough */ @@ -164,8 +166,7 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs) .port = I2C_PORT_SENSOR, .subcmd = EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE_TCPCS, }; - struct host_cmd_handler_args enable_args = BUILD_HOST_COMMAND_PARAMS( - EC_CMD_I2C_PASSTHRU_PROTECT, 0, enable_params); + struct ec_response_i2c_passthru_protect enable_response; uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)); uint8_t *out_data; uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) + @@ -182,8 +183,9 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs) system_is_locked_fake.return_val = false; /* Protect the all TCPC buses */ - zassert_ok(host_command_process(&enable_args), NULL); - zassert_ok(enable_args.result, NULL); + zassert_ok(ec_cmd_i2c_passthru_protect(NULL, &enable_params, + &enable_response), + NULL); passthru_params->port = I2C_PORT_USB_C0; passthru_params->num_msgs = 2; @@ -211,8 +213,9 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs) system_is_locked_fake.return_val = true; /* Protect the all TCPC buses */ - zassert_ok(host_command_process(&enable_args), NULL); - zassert_ok(enable_args.result, NULL); + zassert_ok(ec_cmd_i2c_passthru_protect(NULL, &enable_params, + &enable_response), + NULL); zassert_equal(host_command_process(&passthru_args), EC_RES_ACCESS_DENIED); diff --git a/zephyr/test/drivers/default/src/lid_switch.c b/zephyr/test/drivers/default/src/lid_switch.c index 744701d40c..f71e590d62 100644 --- a/zephyr/test/drivers/default/src/lid_switch.c +++ b/zephyr/test/drivers/default/src/lid_switch.c @@ -60,17 +60,12 @@ static void lid_switch_after(void *unused) struct ec_params_force_lid_open params = { .enabled = 0, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_FORCE_LID_OPEN, 0, params); int res; - res = host_command_process(&args); + res = ec_cmd_force_lid_open(NULL, ¶ms); if (res) TC_ERROR("host_command_process() failed (%d)\n", res); - if (args.result) - TC_ERROR("args.result != 0 (%d != 0)\n", args.result); - res = emul_lid_open(); if (res) TC_ERROR("emul_lid_open() failed (%d)\n", res); @@ -287,16 +282,13 @@ ZTEST(lid_switch, test_hc_force_lid_open) struct ec_params_force_lid_open params = { .enabled = 1, }; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_FORCE_LID_OPEN, 0, params); /* Start closed. */ zassert_ok(emul_lid_close()); k_sleep(K_MSEC(100)); zassert_equal(lid_is_open(), 0); - zassert_ok(host_command_process(&args)); - zassert_ok(args.result); + zassert_ok(ec_cmd_force_lid_open(NULL, ¶ms)); k_sleep(K_MSEC(100)); zassert_equal(lid_is_open(), 1); } diff --git a/zephyr/test/drivers/default/src/locate_chip.c b/zephyr/test/drivers/default/src/locate_chip.c index c54031c5df..5efaa439f3 100644 --- a/zephyr/test/drivers/default/src/locate_chip.c +++ b/zephyr/test/drivers/default/src/locate_chip.c @@ -20,13 +20,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_tcpc) int ret; struct ec_params_locate_chip p; struct ec_response_locate_chip r; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p); p.type = EC_CHIP_TYPE_TCPC; p.index = 0; - ret = host_command_process(&args); + ret = ec_cmd_locate_chip(NULL, &p, &r); zassert_equal(ret, EC_RES_SUCCESS, "Unexpected return value: %d", ret); zassert_equal(r.bus_type, EC_BUS_TYPE_I2C, "Unexpected bus_type: %d", @@ -39,7 +37,7 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_tcpc) p.type = EC_CHIP_TYPE_TCPC; p.index = 1; - ret = host_command_process(&args); + ret = ec_cmd_locate_chip(NULL, &p, &r); zassert_equal(ret, EC_RES_SUCCESS, "Unexpected return value: %d", ret); zassert_equal(r.bus_type, EC_BUS_TYPE_I2C, "Unexpected bus_type: %d", @@ -58,13 +56,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_tcpc_overflow) int ret; struct ec_params_locate_chip p; struct ec_response_locate_chip r; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p); p.type = EC_CHIP_TYPE_TCPC; p.index = 10; - ret = host_command_process(&args); + ret = ec_cmd_locate_chip(NULL, &p, &r); zassert_equal(ret, EC_RES_OVERFLOW, "Unexpected return value: %d", ret); } @@ -77,13 +73,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_eeprom) int ret; struct ec_params_locate_chip p; struct ec_response_locate_chip r; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p); p.type = EC_CHIP_TYPE_CBI_EEPROM; p.index = 0; - ret = host_command_process(&args); + ret = ec_cmd_locate_chip(NULL, &p, &r); zassert_equal(ret, EC_RES_SUCCESS, "Unexpected return value: %d", ret); zassert_equal(r.bus_type, EC_BUS_TYPE_I2C, "Unexpected bus_type: %d", @@ -102,13 +96,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_eeprom_overflow) int ret; struct ec_params_locate_chip p; struct ec_response_locate_chip r; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p); p.type = EC_CHIP_TYPE_CBI_EEPROM; p.index = 1; - ret = host_command_process(&args); + ret = ec_cmd_locate_chip(NULL, &p, &r); zassert_equal(ret, EC_RES_OVERFLOW, "Unexpected return value: %d", ret); } @@ -121,11 +113,9 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_invalid) int ret; struct ec_params_locate_chip p; struct ec_response_locate_chip r; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p); p.type = EC_CHIP_TYPE_COUNT; - ret = host_command_process(&args); + ret = ec_cmd_locate_chip(NULL, &p, &r); zassert_equal(ret, EC_RES_INVALID_PARAM, "Unexpected return value: %d", ret); diff --git a/zephyr/test/drivers/default/src/power_common.c b/zephyr/test/drivers/default/src/power_common.c index 2b8ba4ac88..58ca3977f9 100644 --- a/zephyr/test/drivers/default/src/power_common.c +++ b/zephyr/test/drivers/default/src/power_common.c @@ -247,13 +247,6 @@ ZTEST(power_common_no_tasks, test_power_exit_hard_off) ZTEST(power_common_no_tasks, test_power_reboot_ap_at_g3) { struct ec_params_reboot_ap_on_g3_v1 params; - struct host_cmd_handler_args args = { - .command = EC_CMD_REBOOT_AP_ON_G3, - .version = 0, - .send_response = stub_send_response_callback, - .params = ¶ms, - .params_size = sizeof(params), - }; int delay_ms; int64_t before_time; @@ -269,7 +262,7 @@ ZTEST(power_common_no_tasks, test_power_reboot_ap_at_g3) zassert_equal(POWER_S0, power_get_state()); /* Test version 0 (no delay argument) */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_reboot_ap_on_g3(NULL)); /* Go to G3 and check if reboot is triggered */ power_set_state(POWER_G3); @@ -277,10 +270,9 @@ ZTEST(power_common_no_tasks, test_power_reboot_ap_at_g3) zassert_equal(POWER_G3S5, power_get_state()); /* Test version 1 (with delay argument) */ - args.version = 1; delay_ms = 3000; params.reboot_ap_at_g3_delay = delay_ms / 1000; /* in seconds */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_reboot_ap_on_g3_v1(NULL, ¶ms)); /* Go to G3 and check if reboot is triggered after delay */ power_set_state(POWER_G3); @@ -295,8 +287,6 @@ ZTEST(power_common, test_power_hc_smart_discharge) { struct ec_response_smart_discharge response; struct ec_params_smart_discharge params; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_SMART_DISCHARGE, 0, response, params); const struct emul *emul = EMUL_DT_GET(BATTERY_NODE); struct i2c_common_emul_data *common_data = emul_smart_battery_get_i2c_common_data(emul); @@ -311,7 +301,8 @@ ZTEST(power_common, test_power_hc_smart_discharge) /* Test fail when battery capacity is not available */ i2c_common_emul_set_read_fail_reg(common_data, SB_FULL_CHARGE_CAPACITY); - zassert_equal(EC_RES_UNAVAILABLE, host_command_process(&args)); + zassert_equal(EC_RES_UNAVAILABLE, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); i2c_common_emul_set_read_fail_reg(common_data, I2C_COMMON_EMUL_NO_FAIL_REG); @@ -319,13 +310,15 @@ ZTEST(power_common, test_power_hc_smart_discharge) params.drate.hibern = 10; params.drate.cutoff = 100; /* Test fail on higher discahrge in hibernation than cutoff */ - zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args)); + zassert_equal(EC_RES_INVALID_PARAM, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); /* Setup discharge rates */ params.drate.hibern = 10; params.drate.cutoff = 0; /* Test fail on only one discharge rate set to 0 */ - zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args)); + zassert_equal(EC_RES_INVALID_PARAM, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); /* Setup correct parameters */ hours_to_zero = 1000; @@ -341,7 +334,8 @@ ZTEST(power_common, test_power_hc_smart_discharge) params.hours_to_zero = hours_to_zero; /* Test if correct values are set */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); zassert_equal(hibern_drate, response.drate.hibern); zassert_equal(cutoff_drate, response.drate.cutoff); zassert_equal(hours_to_zero, response.hours_to_zero); @@ -360,7 +354,8 @@ ZTEST(power_common, test_power_hc_smart_discharge) cutoff_cap = cutoff_drate * hours_to_zero / 1000; /* Test that command doesn't change drate but apply new hours to zero */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); zassert_equal(hibern_drate, response.drate.hibern); zassert_equal(cutoff_drate, response.drate.cutoff); zassert_equal(hours_to_zero, response.hours_to_zero); @@ -374,7 +369,8 @@ ZTEST(power_common, test_power_hc_smart_discharge) params.flags = 0; /* Test that command doesn't change drate and dzone */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); zassert_equal(hibern_drate, response.drate.hibern); zassert_equal(cutoff_drate, response.drate.cutoff); zassert_equal(hours_to_zero, response.hours_to_zero); @@ -390,8 +386,6 @@ ZTEST(power_common, test_power_board_system_is_idle) { struct ec_response_smart_discharge response; struct ec_params_smart_discharge params; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_SMART_DISCHARGE, 0, response, params); struct sbat_emul_bat_data *bat; const struct emul *emul = EMUL_DT_GET(BATTERY_NODE); struct i2c_common_emul_data *common_data = @@ -408,7 +402,8 @@ ZTEST(power_common, test_power_board_system_is_idle) params.hours_to_zero = 1000; /* h */ params.flags = EC_SMART_DISCHARGE_FLAGS_SET; /* Set stay-up and cutoff zones */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); /* Test shutdown ignore is send when target time is in future */ target = 1125; @@ -508,8 +503,6 @@ static void setup_hibernation_delay(void *state) { struct ec_response_smart_discharge response; struct ec_params_smart_discharge params; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_SMART_DISCHARGE, 0, response, params); struct sbat_emul_bat_data *bat; const struct emul *emul = EMUL_DT_GET(BATTERY_NODE); ARG_UNUSED(state); @@ -521,7 +514,8 @@ static void setup_hibernation_delay(void *state) params.drate.cutoff = 10; /* uA */ params.hours_to_zero = 10000; /* h */ params.flags = EC_SMART_DISCHARGE_FLAGS_SET; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_smart_discharge(NULL, ¶ms, &response)); /* * Make sure that battery is in safe zone in good condition to * not trigger hibernate in charge_state_v2.c @@ -543,8 +537,6 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) { struct ec_response_hibernation_delay response; struct ec_params_hibernation_delay params; - struct host_cmd_handler_args args = BUILD_HOST_COMMAND( - EC_CMD_HIBERNATION_DELAY, 0, response, params); uint32_t h_delay; int sleep_time; @@ -559,7 +551,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) /* Set hibernate delay */ h_delay = 9; params.seconds = h_delay; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_hibernation_delay(NULL, ¶ms, &response)); zassert_equal(0, response.time_g3, "Time from last G3 enter %d != 0", response.time_g3); @@ -578,7 +571,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) /* Get hibernate delay */ params.seconds = 0; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_hibernation_delay(NULL, ¶ms, &response)); zassert_equal(sleep_time, response.time_g3, "Time from last G3 enter %d != %d", response.time_g3, @@ -597,7 +591,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) /* Get hibernate delay */ params.seconds = 0; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_hibernation_delay(NULL, ¶ms, &response)); zassert_equal(h_delay, response.time_g3, "Time from last G3 enter %d != %d", response.time_g3, @@ -616,7 +611,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) /* Get hibernate delay */ params.seconds = 0; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_hibernation_delay(NULL, ¶ms, &response)); /* After hibernation, remaining time shouldn't be negative */ zassert_equal(0, response.time_remaining, "Time to hibernation %d != 0", @@ -633,7 +629,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) /* Get hibernate delay */ params.seconds = 0; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_hibernation_delay(NULL, ¶ms, &response)); zassert_equal(0, response.time_g3, "Time from last G3 enter %d should be 0 on AC", @@ -650,7 +647,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay) /* Get hibernate delay */ params.seconds = 0; - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_hibernation_delay(NULL, ¶ms, &response)); zassert_equal(0, response.time_g3, "Time from last G3 enter %d should be 0 on state != G3", diff --git a/zephyr/test/drivers/default/src/uart_hostcmd.c b/zephyr/test/drivers/default/src/uart_hostcmd.c index 907dba929f..5e45d98980 100644 --- a/zephyr/test/drivers/default/src/uart_hostcmd.c +++ b/zephyr/test/drivers/default/src/uart_hostcmd.c @@ -28,11 +28,9 @@ static void setup_snapshots_and_messages(void *unused) char response[1024]; struct host_cmd_handler_args read_args = BUILD_HOST_COMMAND_RESPONSE(EC_CMD_CONSOLE_READ, 0, response); - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND_SIMPLE(EC_CMD_CONSOLE_SNAPSHOT, 0); /* Set first snapshot before first message */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL)); cputs(CC_COMMAND, msg1); /* Read everything from buffer */ @@ -44,7 +42,7 @@ static void setup_snapshots_and_messages(void *unused) } while (read_args.response_size != 0); /* Set second snapshot after first message */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL)); cputs(CC_COMMAND, msg2); } @@ -60,8 +58,6 @@ static void test_uart_hc_read_next(int ver) struct ec_params_console_read_v1 params; struct host_cmd_handler_args read_args = BUILD_HOST_COMMAND_RESPONSE(EC_CMD_CONSOLE_READ, ver, response); - struct host_cmd_handler_args snap_args = - BUILD_HOST_COMMAND_SIMPLE(EC_CMD_CONSOLE_SNAPSHOT, 0); char *msg1_start; char *msg2_start; char *msg3_start; @@ -90,7 +86,7 @@ static void test_uart_hc_read_next(int ver) msg1_start); /* Set new snapshot which should include message 2 */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL)); read_args.response_size = 0; zassert_equal(EC_RES_SUCCESS, host_command_process(&read_args)); @@ -123,7 +119,7 @@ static void test_uart_hc_read_next(int ver) read_args.response_size); /* Set new snapshot which should include message 3 */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL)); read_args.response_size = 0; zassert_equal(EC_RES_SUCCESS, host_command_process(&read_args)); @@ -163,8 +159,6 @@ ZTEST_USER(uart_hostcmd, test_uart_hc_read_recent_v1) struct ec_params_console_read_v1 params; struct host_cmd_handler_args read_args = BUILD_HOST_COMMAND(EC_CMD_CONSOLE_READ, 1, response, params); - struct host_cmd_handler_args snap_args = - BUILD_HOST_COMMAND_SIMPLE(EC_CMD_CONSOLE_SNAPSHOT, 0); params.subcmd = CONSOLE_READ_RECENT; @@ -183,7 +177,7 @@ ZTEST_USER(uart_hostcmd, test_uart_hc_read_recent_v1) response); /* Set new snapshot after second message */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL)); /* Only message between two last snapshots should be read */ read_args.response_size = 0; @@ -210,7 +204,7 @@ ZTEST_USER(uart_hostcmd, test_uart_hc_read_recent_v1) read_args.response_size); /* Set new snapshot */ - zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args)); + zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL)); /* This time only third message should be read */ read_args.response_size = 0; diff --git a/zephyr/test/drivers/default/src/usb_mux.c b/zephyr/test/drivers/default/src/usb_mux.c index 0e89cf2398..cad47c75a7 100644 --- a/zephyr/test/drivers/default/src/usb_mux.c +++ b/zephyr/test/drivers/default/src/usb_mux.c @@ -819,13 +819,13 @@ ZTEST(usb_init_mux, test_usb_mux_hc_mux_info) { struct ec_response_usb_pd_mux_info response; struct ec_params_usb_pd_mux_info params; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_USB_PD_MUX_INFO, 0, response, params); + struct host_cmd_handler_args args; mux_state_t exp_mode; /* Test invalid port parameter */ params.port = 5; - zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args)); + zassert_equal(EC_RES_INVALID_PARAM, + ec_cmd_usb_pd_mux_info(NULL, ¶ms, &response)); /* Set correct port for rest of the test */ params.port = USBC_PORT_C1; @@ -833,13 +833,15 @@ ZTEST(usb_init_mux, test_usb_mux_hc_mux_info) /* Test error on getting mux mode */ set_proxy_get_mux_state_seq(USB_PD_MUX_USB_ENABLED); proxy_get_fake.return_val = EC_ERROR_UNKNOWN; - zassert_equal(EC_RES_ERROR, host_command_process(&args)); + zassert_equal(EC_RES_ERROR, + ec_cmd_usb_pd_mux_info(NULL, ¶ms, &response)); /* Test getting mux mode */ reset_proxy_fakes(); exp_mode = USB_PD_MUX_USB_ENABLED; set_proxy_get_mux_state_seq(exp_mode); - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_usb_pd_mux_info(&args, ¶ms, &response)); zassert_equal(args.response_size, sizeof(response)); zassert_equal(exp_mode, response.flags, "mode is 0x%x (!= 0x%x)", response.flags, exp_mode); @@ -850,7 +852,8 @@ ZTEST(usb_init_mux, test_usb_mux_hc_mux_info) exp_mode = USB_PD_MUX_USB_ENABLED | USB_PD_MUX_HPD_LVL | USB_PD_MUX_HPD_IRQ; set_proxy_get_mux_state_seq(exp_mode); - zassert_equal(EC_RES_SUCCESS, host_command_process(&args)); + zassert_equal(EC_RES_SUCCESS, + ec_cmd_usb_pd_mux_info(&args, ¶ms, &response)); zassert_equal(args.response_size, sizeof(response)); zassert_equal(exp_mode, response.flags, "mode is 0x%x (!= 0x%x)", response.flags, exp_mode); diff --git a/zephyr/test/drivers/default/src/vboot_hash.c b/zephyr/test/drivers/default/src/vboot_hash.c index 61d4260a23..101fc2f6dc 100644 --- a/zephyr/test/drivers/default/src/vboot_hash.c +++ b/zephyr/test/drivers/default/src/vboot_hash.c @@ -21,36 +21,29 @@ ZTEST_USER(vboot_hash, test_hostcmd_abort) .offset = EC_VBOOT_HASH_OFFSET_RO, .size = 0, }; - struct host_cmd_handler_args start_args = BUILD_HOST_COMMAND( - EC_CMD_VBOOT_HASH, 0, response, start_params); + struct host_cmd_handler_args start_args; struct ec_params_vboot_hash abort_params = { .cmd = EC_VBOOT_HASH_ABORT, }; - struct host_cmd_handler_args abort_args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_VBOOT_HASH, 0, abort_params); struct ec_params_vboot_hash get_params = { .cmd = EC_VBOOT_HASH_GET, }; - struct host_cmd_handler_args get_args = - BUILD_HOST_COMMAND(EC_CMD_VBOOT_HASH, 0, response, get_params); + struct host_cmd_handler_args get_args; /* Start hashing. The command doesn't wait to finish. */ - zassert_ok(host_command_process(&start_args)); - zassert_ok(start_args.result); + zassert_ok(ec_cmd_vboot_hash(&start_args, &start_params, &response)); zassert_equal(start_args.response_size, sizeof(response)); zassert_equal(response.status, EC_VBOOT_HASH_STATUS_BUSY, "response.status = %d", response.status); /* Abort it immediately */ - zassert_ok(host_command_process(&abort_args)); - zassert_ok(abort_args.result); + zassert_ok(ec_cmd_vboot_hash(NULL, &abort_params, &response)); /* Give it a bit time. The abort is being processed in the background */ k_msleep(20); /* Get the hash result. Should be NONE. */ - zassert_ok(host_command_process(&get_args)); - zassert_ok(get_args.result); + zassert_ok(ec_cmd_vboot_hash(&get_args, &get_params, &response)); zassert_equal(get_args.response_size, sizeof(response)); zassert_equal(response.status, EC_VBOOT_HASH_STATUS_NONE, "response.status = %d", response.status); @@ -65,12 +58,10 @@ ZTEST_USER(vboot_hash, test_hostcmd_recalc) .offset = EC_VBOOT_HASH_OFFSET_RO, .size = 0, }; - struct host_cmd_handler_args recalc_args = BUILD_HOST_COMMAND( - EC_CMD_VBOOT_HASH, 0, response, recalc_params); + struct host_cmd_handler_args recalc_args; /* Recalculate the hash. The command waits to finish. */ - zassert_ok(host_command_process(&recalc_args)); - zassert_ok(recalc_args.result); + zassert_ok(ec_cmd_vboot_hash(&recalc_args, &recalc_params, &response)); zassert_equal(recalc_args.response_size, sizeof(response)); zassert_equal(response.status, EC_VBOOT_HASH_STATUS_DONE, "response.status = %d", response.status); @@ -88,12 +79,11 @@ ZTEST_USER(vboot_hash, test_hostcmd_hash_arbitrary_size) /* arbitrary size */ .size = 0x12345, }; - struct host_cmd_handler_args recalc_args = BUILD_HOST_COMMAND( - EC_CMD_VBOOT_HASH, 0, response, recalc_params); + struct host_cmd_handler_args recalc_args; /* Recalculate the hash. The command waits to finish. */ - zassert_ok(host_command_process(&recalc_args), NULL); - zassert_ok(recalc_args.result, NULL); + zassert_ok(ec_cmd_vboot_hash(&recalc_args, &recalc_params, &response), + NULL); zassert_equal(recalc_args.response_size, sizeof(response), NULL); zassert_equal(response.status, EC_VBOOT_HASH_STATUS_DONE, "response.status = %d", response.status); diff --git a/zephyr/test/drivers/default/src/vstore.c b/zephyr/test/drivers/default/src/vstore.c index 923d14ff00..876655f66a 100644 --- a/zephyr/test/drivers/default/src/vstore.c +++ b/zephyr/test/drivers/default/src/vstore.c @@ -58,11 +58,10 @@ ZTEST_USER(vstore, test_vstore_read_bad_slot) .slot = CONFIG_VSTORE_SLOT_COUNT, }; struct ec_response_vstore_read response; - struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_VSTORE_READ, 0, response, params); - zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, - "Failed to fail on invalid slot %d", params.slot); + zassert_equal(ec_cmd_vstore_read(NULL, ¶ms, &response), + EC_RES_INVALID_PARAM, "Failed to fail on invalid slot %d", + params.slot); } ZTEST_USER(vstore, test_vstore_write_bad_slot) @@ -84,8 +83,6 @@ static void do_vstore_write_read(unsigned int slot) .slot = slot, /* .data is set up below */ }; - struct host_cmd_handler_args write_args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_VSTORE_WRITE, 0, write_params); struct ec_params_vstore_read read_params = { .slot = slot, }; @@ -101,8 +98,7 @@ static void do_vstore_write_read(unsigned int slot) write_params.data[i] = i + 1; /* Write to a slot */ - zassert_ok(host_command_process(&write_args), NULL); - zassert_ok(write_args.result, NULL); + zassert_ok(ec_cmd_vstore_write(NULL, &write_params), NULL); /* Check that it is now locked */ zassert_ok(host_command_process(&info_args), NULL); @@ -121,7 +117,8 @@ static void do_vstore_write_read(unsigned int slot) EC_VSTORE_SLOT_SIZE, "response.data did not match"); /* Try to write to it again */ - zassert_equal(host_command_process(&write_args), EC_RES_ACCESS_DENIED, + zassert_equal(ec_cmd_vstore_write(NULL, &write_params), + EC_RES_ACCESS_DENIED, "Failed to fail on writing locked slot %d", write_params.slot); @@ -144,8 +141,7 @@ static void do_vstore_write_read(unsigned int slot) /* Clear locks and try the write again, this time with zero bytes */ vstore_clear_lock(); memset(write_params.data, '\0', EC_VSTORE_SLOT_SIZE); - zassert_ok(host_command_process(&write_args), NULL); - zassert_ok(write_args.result, NULL); + zassert_ok(ec_cmd_vstore_write(NULL, &write_params), NULL); /* Check that it is now locked */ zassert_ok(host_command_process(&info_args), NULL); @@ -182,8 +178,6 @@ ZTEST_USER(vstore, test_vstore_state) .slot = 0, /* .data is set up below */ }; - struct host_cmd_handler_args write_args = - BUILD_HOST_COMMAND_PARAMS(EC_CMD_VSTORE_WRITE, 0, write_params); struct ec_params_reboot_ec reboot_params = { .cmd = EC_REBOOT_JUMP_RW, @@ -203,8 +197,7 @@ ZTEST_USER(vstore, test_vstore_state) write_params.data[i] = i + 1; /* Write to a slot */ - zassert_ok(host_command_process(&write_args), NULL); - zassert_ok(write_args.result, NULL); + zassert_ok(ec_cmd_vstore_write(NULL, &write_params), NULL); /* Set up so we get back to this test on a reboot */ if (!setjmp(env)) { |