summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c')
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c187
1 files changed, 94 insertions, 93 deletions
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 6d0a386d6e..b0ba438bbb 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,39 +5,30 @@
/* 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 void
+static enum ec_status
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);
- 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);
+ return host_command_process(&args);
}
-static void host_event_set_wake_mask_helper(uint32_t mask)
+static enum ec_status 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);
- 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);
+ return host_command_process(&args);
}
/**
@@ -45,13 +36,17 @@ static void host_event_set_wake_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_wake_mask_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ 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);
+ }
}
/**
@@ -59,16 +54,24 @@ 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)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- host_event_get_wake_mask_helper(&result);
+ 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;
+ }
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event wake mask is not clear");
- host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL);
+ zassert_ok(host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
host_event_get_wake_mask_helper(&result);
@@ -78,38 +81,25 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- host_event_set_wake_mask_helper(0);
-#else
- ztest_test_skip();
-#endif
+ zassert_ok(host_event_set_wake_mask_helper(0));
}
-static void
+static enum ec_status
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);
- 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);
+ return host_command_process(&args);
}
-static void host_event_set_smi_mask_helper(uint32_t mask)
+static enum ec_status 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);
- 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);
+ return host_command_process(&args);
}
/**
@@ -117,13 +107,18 @@ static void host_event_set_smi_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_smi_mask_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ 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;
+ }
}
/**
@@ -131,42 +126,43 @@ 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)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- host_event_get_smi_mask_helper(&result);
+ 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;
+ }
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SMI mask is not clear");
- host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL);
+ zassert_ok(host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
- host_event_get_smi_mask_helper(&result);
+ zassert_ok(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 */
- host_event_set_smi_mask_helper(0);
-#else
- ztest_test_skip();
-#endif
+ zassert_ok(host_event_set_smi_mask_helper(0));
}
-static void host_event_get_b_helper(struct ec_response_host_event_mask *r)
+static enum ec_status
+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);
- 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);
+ return host_command_process(&args);
}
/**
@@ -174,41 +170,36 @@ static void host_event_get_b_helper(struct ec_response_host_event_mask *r)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_b)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_b_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ 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;
+ }
}
-static void
+static enum ec_status
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);
- 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);
+ return host_command_process(&args);
}
-static void host_event_set_sci_mask_helper(uint32_t mask)
+static enum ec_status 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);
- 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);
+ return host_command_process(&args);
}
/**
@@ -216,13 +207,18 @@ static void host_event_set_sci_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_sci_mask_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ 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;
+ }
}
/**
@@ -230,27 +226,32 @@ 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)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- host_event_get_sci_mask_helper(&result);
+ 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;
+ }
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SCI mask is not clear");
- host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL);
+ zassert_ok(host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
- host_event_get_sci_mask_helper(&result);
+ zassert_ok(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 */
- host_event_set_sci_mask_helper(0);
-#else
- ztest_test_skip();
-#endif
+ zassert_ok(host_event_set_sci_mask_helper(0));
}