unit tests: fix warnings, build with -Werror

- libsodium: silence warnings
- unit tests: fix warnings
- spiram: fix warnings
- ringbuf test: enable by default, reduce delays
This commit is contained in:
Ivan Grokhotkov 2017-10-18 21:09:53 +08:00
parent b52e3fae64
commit 90bbcbcdc0
10 changed files with 38 additions and 39 deletions

View file

@ -121,6 +121,8 @@ build_esp_idf_tests:
- cd tools/unit-test-app - cd tools/unit-test-app
- make help # make sure kconfig tools are built in single process - make help # make sure kconfig tools are built in single process
- make ut-clean-all-configs - make ut-clean-all-configs
- export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations"
- export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
- make ut-build-all-configs TESTS_ALL=1 - make ut-build-all-configs TESTS_ALL=1
- python tools/UnitTestParser.py - python tools/UnitTestParser.py

View file

@ -141,7 +141,7 @@ esp_err_t esp_spiram_reserve_dma_pool(size_t size) {
dma_heap=heap_caps_malloc(size, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); dma_heap=heap_caps_malloc(size, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
if (!dma_heap) return ESP_ERR_NO_MEM; if (!dma_heap) return ESP_ERR_NO_MEM;
uint32_t caps[]={MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL, 0, MALLOC_CAP_8BIT|MALLOC_CAP_32BIT}; uint32_t caps[]={MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL, 0, MALLOC_CAP_8BIT|MALLOC_CAP_32BIT};
return heap_caps_add_region_with_caps(caps, dma_heap, dma_heap+size-1); return heap_caps_add_region_with_caps(caps, (intptr_t) dma_heap, (intptr_t) dma_heap+size-1);
} }
size_t esp_spiram_get_size() size_t esp_spiram_get_size()

View file

@ -12,4 +12,4 @@ test_tjpgd.o: test_tjpgd_logo.h
test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg
$(summary) XXD logo.jpg $(summary) XXD logo.jpg
$(Q) cd $(COMPONENT_PATH); xxd -i logo.jpg $(COMPONENT_BUILD_DIR)/test_tjpgd_logo.h cd $(COMPONENT_PATH); xxd -i logo.jpg $(COMPONENT_BUILD_DIR)/test_tjpgd_logo.h

View file

@ -104,7 +104,7 @@ TEST_CASE("Fast I/O bus test", "[hw][ignore]")
TEST_ASSERT(0); TEST_ASSERT(0);
} }
PIN_PULLUP_DIS(PERIPHS_IO_MUX_SD_DATA3_U); gpio_pullup_dis(10);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, FUNC_SD_DATA2_U1RXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, FUNC_SD_DATA2_U1RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, FUNC_SD_DATA3_U1TXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, FUNC_SD_DATA3_U1TXD);

View file

@ -274,7 +274,7 @@ TEST_CASE("allocate 2 handlers for a same source and remove the later one","[esp
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler1, &ctx, &handle1); r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler1, &ctx, &handle1);
TEST_ESP_OK(r); TEST_ESP_OK(r);
//try an invalid assign first //try an invalid assign first
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, NULL, int_handler2, NULL, &handle2); r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, 0, int_handler2, NULL, &handle2);
TEST_ASSERT_EQUAL_INT(r, ESP_ERR_NOT_FOUND ); TEST_ASSERT_EQUAL_INT(r, ESP_ERR_NOT_FOUND );
//assign shared then //assign shared then
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler2, &ctx, &handle2); r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler2, &ctx, &handle2);

View file

@ -164,7 +164,7 @@ static void uartRxInit(xQueueHandle q)
{ {
uint32_t reg_val; uint32_t reg_val;
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); gpio_pullup_dis(1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);

View file

@ -2,7 +2,7 @@
Test for multicore FreeRTOS ringbuffer. Test for multicore FreeRTOS ringbuffer.
*/ */
#include <esp_types.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "rom/ets_sys.h" #include "rom/ets_sys.h"
@ -16,11 +16,8 @@
#include "soc/uart_reg.h" #include "soc/uart_reg.h"
#include "soc/dport_reg.h" #include "soc/dport_reg.h"
#include "soc/io_mux_reg.h" #include "soc/io_mux_reg.h"
#include "esp_intr_alloc.h"
#include <string.h>
#include <stdio.h>
void ets_isr_unmask(uint32_t unmask);
static RingbufHandle_t rb; static RingbufHandle_t rb;
typedef enum { typedef enum {
@ -32,6 +29,8 @@ typedef enum {
static volatile testtype_t testtype; static volatile testtype_t testtype;
intr_handle_t s_intr_handle;
static void task1(void *arg) static void task1(void *arg)
{ {
testtype_t oldtest; testtype_t oldtest;
@ -50,14 +49,14 @@ static void task1(void *arg)
printf("Test %d: Timeout on send!\n", (int)testtype); printf("Test %d: Timeout on send!\n", (int)testtype);
} }
if (testtype == TST_MOSTLYEMPTY) { if (testtype == TST_MOSTLYEMPTY) {
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(300 / portTICK_PERIOD_MS);
} }
} }
//Send NULL event to stop other side. //Send NULL event to stop other side.
r = xRingbufferSend(rb, NULL, 0, 10000 / portTICK_PERIOD_MS); r = xRingbufferSend(rb, NULL, 0, 10000 / portTICK_PERIOD_MS);
} }
while (oldtest == testtype) { while (oldtest == testtype) {
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(300 / portTICK_PERIOD_MS);
} }
} }
} }
@ -85,12 +84,12 @@ static void task2(void *arg)
vRingbufferReturnItem(rb, buf); vRingbufferReturnItem(rb, buf);
} }
if (testtype == TST_MOSTLYFILLED) { if (testtype == TST_MOSTLYFILLED) {
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(300 / portTICK_PERIOD_MS);
} }
} }
} }
while (oldtest == testtype) { while (oldtest == testtype) {
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(300 / portTICK_PERIOD_MS);
} }
} }
} }
@ -138,24 +137,16 @@ static void uartIsrHdl(void *arg)
static void uartRxInit() static void uartRxInit()
{ {
uint32_t reg_val; WRITE_PERI_REG(UART_CONF1_REG(0), 1 << UART_RXFIFO_FULL_THRHD_S);
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
// reg_val = READ_PERI_REG(UART_CONF1(0));
reg_val = (1 << UART_RXFIFO_FULL_THRHD_S);
WRITE_PERI_REG(UART_CONF1_REG(0), reg_val);
CLEAR_PERI_REG_MASK(UART_INT_ENA_REG(0), UART_TXFIFO_EMPTY_INT_ENA | UART_RXFIFO_TOUT_INT_ENA); CLEAR_PERI_REG_MASK(UART_INT_ENA_REG(0), UART_TXFIFO_EMPTY_INT_ENA | UART_RXFIFO_TOUT_INT_ENA);
SET_PERI_REG_MASK(UART_INT_ENA_REG(0), UART_RXFIFO_FULL_INT_ENA); SET_PERI_REG_MASK(UART_INT_ENA_REG(0), UART_RXFIFO_FULL_INT_ENA);
printf("Enabling int %d\n", ETS_UART0_INUM); ESP_ERROR_CHECK(esp_intr_alloc(ETS_UART0_INTR_SOURCE, 0, &uartIsrHdl, NULL, &s_intr_handle));
DPORT_REG_SET_FIELD(DPORT_PRO_UART_INTR_MAP_REG, DPORT_PRO_UART_INTR_MAP, ETS_UART0_INUM); }
DPORT_REG_SET_FIELD(DPORT_PRO_UART1_INTR_MAP_REG, DPORT_PRO_UART1_INTR_MAP, ETS_UART0_INUM);
xt_set_interrupt_handler(ETS_UART0_INUM, uartIsrHdl, NULL);
xt_ints_on(1 << ETS_UART0_INUM);
static void uartRxDeinit()
{
esp_intr_free(s_intr_handle);
} }
static void testRingbuffer(int type) static void testRingbuffer(int type)
@ -166,31 +157,32 @@ static void testRingbuffer(int type)
testtype = TST_MOSTLYFILLED; testtype = TST_MOSTLYFILLED;
xTaskCreatePinnedToCore(task1 , "tskone" , 2048, NULL, 3, &th[0], 0); xTaskCreatePinnedToCore(task1, "tskone", 2048, NULL, 3, &th[0], 0);
xTaskCreatePinnedToCore(task2 , "tsktwo" , 2048, NULL, 3, &th[1], 0); xTaskCreatePinnedToCore(task2, "tsktwo", 2048, NULL, 3, &th[1], 0);
uartRxInit(); uartRxInit();
printf("Press 'r' to read an event in isr, any other key to write one.\n"); printf("Press 'r' to read an event in isr, any other key to write one.\n");
printf("Test: mostlyfilled; putting 10 items in ringbuff ASAP, reading 1 a second\n"); printf("Test: mostlyfilled; putting 10 items in ringbuff ASAP, reading 1 a second\n");
vTaskDelay(15000 / portTICK_PERIOD_MS); vTaskDelay(5000 / portTICK_PERIOD_MS);
printf("Test: mostlyempty; putting 10 items in ringbuff @ 1/sec, reading as fast as possible\n"); printf("Test: mostlyempty; putting 10 items in ringbuff @ 1/sec, reading as fast as possible\n");
testtype = TST_MOSTLYEMPTY; testtype = TST_MOSTLYEMPTY;
vTaskDelay(15000 / portTICK_PERIOD_MS); vTaskDelay(5000 / portTICK_PERIOD_MS);
//Shut down all the tasks //Shut down all the tasks
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
vTaskDelete(th[i]); vTaskDelete(th[i]);
} }
xt_ints_off(1 << ETS_UART0_INUM); vRingbufferDelete(rb);
uartRxDeinit();
} }
// TODO: split this thing into separate orthogonal tests // TODO: split this thing into separate orthogonal tests
TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos][ignore]") TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos]")
{ {
testRingbuffer(0); testRingbuffer(0);
} }
TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos][ignore]") TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos]")
{ {
testRingbuffer(1); testRingbuffer(1);
} }

View file

@ -8,13 +8,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "esp_heap_trace.h"
#include "sdkconfig.h" #include "sdkconfig.h"
#include "unity.h" #include "unity.h"
#ifdef CONFIG_HEAP_TRACING #ifdef CONFIG_HEAP_TRACING
// only compile in heap tracing tests if tracing is enabled // only compile in heap tracing tests if tracing is enabled
#include "esp_heap_trace.h"
TEST_CASE("heap trace leak check", "[heap]") TEST_CASE("heap trace leak check", "[heap]")
{ {
heap_trace_record_t recs[8]; heap_trace_record_t recs[8];

View file

@ -25,9 +25,10 @@ COMPONENT_OBJS := test_sodium.o
# Run each test case from test_sodium.c as CASENAME_xmain(). # Run each test case from test_sodium.c as CASENAME_xmain().
define sodium_testcase define sodium_testcase
# this generates 'warning "main" redefined' warnings at # This would generate 'warning "main" redefined' warnings at runtime, which are
# runtime. Only solution involves patching libsodium's cmptest.h # silenced here. Only other solution involves patching libsodium's cmptest.h.
$(LS_TESTDIR)/$(1).o: CFLAGS+=-Dxmain=$(1)_xmain -Dmain=$(1)_main $(LS_TESTDIR)/$(1).o: CFLAGS+=-Dxmain=$(1)_xmain -Dmain=$(1)_main
$(LS_TESTDIR)/$(1).o: CPPFLAGS+=-Wp,-w
ote: ote:
COMPONENT_OBJS += $(LS_TESTDIR)/$(1).o COMPONENT_OBJS += $(LS_TESTDIR)/$(1).o
endef endef

View file

@ -10,9 +10,12 @@
#include "esp_log.h" #include "esp_log.h"
#include "soc/cpu.h" #include "soc/cpu.h"
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
#include "esp_heap_trace.h"
#include "test_utils.h" #include "test_utils.h"
#ifdef CONFIG_HEAP_TRACING
#include "esp_heap_trace.h"
#endif
#define unity_printf ets_printf #define unity_printf ets_printf
// Pointers to the head and tail of linked list of test description structs: // Pointers to the head and tail of linked list of test description structs: