diff options
author | Al Semjonovs <asemjonovs@google.com> | 2022-11-22 15:41:26 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-29 19:52:04 +0000 |
commit | f67381c09cbea0089fd618712aa1d2fbb0e01d7c (patch) | |
tree | 5f3dc2659d615e709b1cea1b4beb769f2200cede | |
parent | 01be95eee0d625e4b8a194f6664d2bae20765355 (diff) | |
download | chrome-ec-f67381c09cbea0089fd618712aa1d2fbb0e01d7c.tar.gz |
zephyr: test pd_log_recv_vdm
Validate log is captured
BUG=None
BRANCH=NONE
TEST=./twister -T zephyr/test/drivers
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
Change-Id: Ic8edb5994bf3a6f12a9fb7a2d222d98813c7d3f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049885
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/pd_log.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/zephyr/test/drivers/host_cmd/src/pd_log.c b/zephyr/test/drivers/host_cmd/src/pd_log.c index 6b5ffc197d..819f020890 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_log.c +++ b/zephyr/test/drivers/host_cmd/src/pd_log.c @@ -7,6 +7,7 @@ #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> @@ -20,6 +21,14 @@ #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. @@ -120,7 +129,7 @@ ZTEST_USER_F(pd_log, test_mcu_connect) ZTEST_USER_F(pd_log, test_read_log_entry) { - uint8_t response_buffer[sizeof(struct ec_response_pd_log) + 16]; + uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE]; struct ec_response_pd_log *response = (struct ec_response_pd_log *)response_buffer; struct host_cmd_handler_args args = @@ -133,3 +142,25 @@ 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); +} |