diff options
Diffstat (limited to 'test/cec.c')
-rw-r--r-- | test/cec.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/test/cec.c b/test/cec.c index 3487ec1df4..64b230e509 100644 --- a/test/cec.c +++ b/test/cec.c @@ -19,16 +19,15 @@ BUILD_ASSERT(offsetof(struct overflow_msg, overflow_detector) == offsetof(struct cec_msg_transfer, buf) + MAX_CEC_MSG_LEN); -struct overflow_circbuf { - struct cec_rx_cb circbuf; - uint8_t overflow_detector[CEC_CIRCBUF_SIZE]; -} overflow_circbuf; +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_circbuf, overflow_detector) == - offsetof(struct cec_rx_cb, buf) + CEC_CIRCBUF_SIZE); +BUILD_ASSERT(offsetof(struct overflow_queue, overflow_detector) == + offsetof(struct cec_rx_queue, buf) + CEC_RX_BUFFER_SIZE); - -static struct cec_rx_cb *circbuf; +static struct cec_rx_queue *queue; /* Tests */ static int test_msg_overflow(void) @@ -37,8 +36,8 @@ static int test_msg_overflow(void) /* Overwrite the buffer by 1 byte */ for (i = 0; i < (MAX_CEC_MSG_LEN+1)*8; i++) { - msgt_set_bit(&overflow_msg.transfer, 1); - msgt_inc_bit(&overflow_msg.transfer); + 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 */ @@ -53,8 +52,8 @@ static int test_msg_overflow(void) /* Check that the indicator stays the same if we write another byte */ for (i = 0; i < 8; i++) { - msgt_set_bit(&overflow_msg.transfer, 1); - msgt_inc_bit(&overflow_msg.transfer); + 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); @@ -63,21 +62,21 @@ static int test_msg_overflow(void) -static int verify_no_circbuf_overflow(void) +static int verify_no_queue_overflow(void) { int i; - for (i = 0; i < CEC_CIRCBUF_SIZE; i++) { - if (overflow_circbuf.overflow_detector[i] != 0) + 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_circbuf(void) +static void clear_queue(void) { - memset(circbuf, 0, sizeof(struct cec_rx_cb)); + memset(queue, 0, sizeof(struct cec_rx_queue)); } @@ -88,27 +87,27 @@ static int fill_queue(uint8_t *msg, int msg_size) /* * 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_CIRCBUF_SIZE since write_pointer==read_pointer is used to + * CEC_RX_BUFFER_SIZE since write_pointer==read_pointer is used to * indicate an empty buffer */ - clear_circbuf(); + clear_queue(); - for (i = 0; i < (CEC_CIRCBUF_SIZE - 1)/(msg_size + 1); i++) - TEST_ASSERT(rx_circbuf_push(circbuf, msg, msg_size) == 0); + 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(rx_circbuf_push(circbuf, msg, msg_size) - == EC_ERROR_OVERFLOW); + 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_circbuf_overflow() == EC_SUCCESS); + TEST_ASSERT(verify_no_queue_overflow() == EC_SUCCESS); return EC_SUCCESS; } -static int test_circbuf_overflow(void) +static int test_queue_overflow(void) { - uint8_t msg[CEC_CIRCBUF_SIZE]; + uint8_t msg[CEC_RX_BUFFER_SIZE]; memset(msg, 0xff, sizeof(msg)); @@ -122,11 +121,11 @@ static int test_circbuf_overflow(void) void run_test(void) { - circbuf = &overflow_circbuf.circbuf; + queue = &overflow_queue.queue; RUN_TEST(test_msg_overflow); - RUN_TEST(test_circbuf_overflow); + RUN_TEST(test_queue_overflow); test_print_result(); } |