From 4f33339c1d7ef86921246ca257d21e929c0170ec Mon Sep 17 00:00:00 2001 From: Piyush Shah Date: Fri, 17 Nov 2017 17:23:43 +0530 Subject: [PATCH] test_ringbuf: Add tests for arbitrary length ring buffer This will test the ring buffer for buffer length that is not a multiple of 4 Signed-off-by: Piyush Shah --- components/freertos/test/test_ringbuf.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/components/freertos/test/test_ringbuf.c b/components/freertos/test/test_ringbuf.c index 84e1159992..6a721aae39 100644 --- a/components/freertos/test/test_ringbuf.c +++ b/components/freertos/test/test_ringbuf.c @@ -149,11 +149,16 @@ static void uartRxDeinit() esp_intr_free(s_intr_handle); } -static void testRingbuffer(int type) +static void testRingbuffer(int type, bool arbitrary) { TaskHandle_t th[2]; int i; - rb = xRingbufferCreate(32 * 3, type); + /* Arbitrary Length means buffer length which is not a multiple of 4 */ + if (arbitrary) { + rb = xRingbufferCreate(31 * 3, type); + } else { + rb = xRingbufferCreate(32 * 3, type); + } testtype = TST_MOSTLYFILLED; @@ -179,12 +184,22 @@ static void testRingbuffer(int type) // TODO: split this thing into separate orthogonal tests TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos]") { - testRingbuffer(0); + testRingbuffer(0, false); } TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos]") { - testRingbuffer(1); + testRingbuffer(1, false); +} + +TEST_CASE("FreeRTOS ringbuffer test, no splitting items, arbitrary length buffer", "[freertos]") +{ + testRingbuffer(0, true); +} + +TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items, arbitrary length buffer", "[freertos]") +{ + testRingbuffer(1, true); }