summaryrefslogtreecommitdiff
path: root/test/cec.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /test/cec.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14388.62.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'test/cec.c')
-rw-r--r--test/cec.c131
1 files changed, 0 insertions, 131 deletions
diff --git a/test/cec.c b/test/cec.c
deleted file mode 100644
index 9377e4fcd3..0000000000
--- a/test/cec.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Copyright 2018 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Test the buffer handling of HDMI CEC
- */
-
-#include <string.h>
-
-#include "cec.h"
-#include "test_util.h"
-
-struct overflow_msg {
- struct cec_msg_transfer transfer;
- uint8_t overflow_detector;
-} overflow_msg;
-/* Ensure the overflow detector is located directly after the buffer */
-BUILD_ASSERT(offsetof(struct overflow_msg, overflow_detector) ==
- offsetof(struct cec_msg_transfer, buf) + MAX_CEC_MSG_LEN);
-
-
-struct overflow_queue {
- struct cec_rx_queue queue;
- uint8_t overflow_detector[CEC_RX_BUFFER_SIZE];
-} overflow_queue;
-/* Ensure the overflow detector is located directly after the buffer */
-BUILD_ASSERT(offsetof(struct overflow_queue, overflow_detector) ==
- offsetof(struct cec_rx_queue, buf) + CEC_RX_BUFFER_SIZE);
-
-static struct cec_rx_queue *queue;
-
-/* Tests */
-static int test_msg_overflow(void)
-{
- int i;
-
- /* Overwrite the buffer by 1 byte */
- for (i = 0; i < (MAX_CEC_MSG_LEN+1)*8; i++) {
- cec_transfer_set_bit(&overflow_msg.transfer, 1);
- cec_transfer_inc_bit(&overflow_msg.transfer);
- }
-
- /* Make sure we actually wrote the whole buffer with ones */
- for (i = 0; i < MAX_CEC_MSG_LEN; i++)
- TEST_ASSERT(overflow_msg.transfer.buf[i] == 0xff);
-
- /* Verify that the attempt to overflow the buffer did not succeed */
- TEST_ASSERT(overflow_msg.overflow_detector == 0);
-
- /* The full indicator is when byte reaches MAX_CEC_MSG_LEN */
- TEST_ASSERT(overflow_msg.transfer.byte == MAX_CEC_MSG_LEN);
-
- /* Check that the indicator stays the same if we write another byte */
- for (i = 0; i < 8; i++) {
- cec_transfer_set_bit(&overflow_msg.transfer, 1);
- cec_transfer_inc_bit(&overflow_msg.transfer);
- }
- TEST_ASSERT(overflow_msg.transfer.byte == MAX_CEC_MSG_LEN);
-
- return EC_SUCCESS;
-}
-
-
-
-static int verify_no_queue_overflow(void)
-{
- int i;
-
- for (i = 0; i < CEC_RX_BUFFER_SIZE; i++) {
- if (overflow_queue.overflow_detector[i] != 0)
- return EC_ERROR_OVERFLOW;
- }
- return EC_SUCCESS;
-}
-
-
-static void clear_queue(void)
-{
- memset(queue, 0, sizeof(struct cec_rx_queue));
-
-}
-
-static int fill_queue(uint8_t *msg, int msg_size)
-{
- int i;
-
- /*
- * Fill the queue. Every push adds the message and one extra byte for
- * the length field. The maximum data we can add is one less than
- * CEC_RX_BUFFER_SIZE since write_pointer==read_pointer is used to
- * indicate an empty buffer
- */
- clear_queue();
-
- for (i = 0; i < (CEC_RX_BUFFER_SIZE - 1)/(msg_size + 1); i++)
- TEST_ASSERT(cec_rx_queue_push(queue, msg, msg_size) == 0);
-
- /* Now the queue should be full */
- TEST_ASSERT(cec_rx_queue_push(queue, msg, msg_size) ==
- EC_ERROR_OVERFLOW);
-
- /* Verify nothing was written outside of the queue */
- TEST_ASSERT(verify_no_queue_overflow() == EC_SUCCESS);
-
- return EC_SUCCESS;
-}
-
-static int test_queue_overflow(void)
-{
- uint8_t msg[CEC_RX_BUFFER_SIZE];
-
- memset(msg, 0xff, sizeof(msg));
-
- TEST_ASSERT(fill_queue(msg, 1) == EC_SUCCESS);
- TEST_ASSERT(fill_queue(msg, 2) == EC_SUCCESS);
- TEST_ASSERT(fill_queue(msg, 3) == EC_SUCCESS);
- TEST_ASSERT(fill_queue(msg, MAX_CEC_MSG_LEN) == EC_SUCCESS);
-
- return EC_SUCCESS;
-}
-
-void run_test(int argc, char **argv)
-{
- queue = &overflow_queue.queue;
-
- RUN_TEST(test_msg_overflow);
-
- RUN_TEST(test_queue_overflow);
-
- test_print_result();
-}