From: Ivan Grokhotkov Date: Wed, 18 Oct 2017 13:09:53 +0000 (+0800) Subject: unit tests: fix warnings, build with -Werror X-Git-Tag: v3.1-dev~148^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90bbcbcdc0bb0da058bafdea8cede6f3f540501a;p=esp-idf unit tests: fix warnings, build with -Werror - libsodium: silence warnings - unit tests: fix warnings - spiram: fix warnings - ringbuf test: enable by default, reduce delays --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index adcfdb6a46..ea5c5981bc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -121,6 +121,8 @@ build_esp_idf_tests: - cd tools/unit-test-app - make help # make sure kconfig tools are built in single process - 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 - python tools/UnitTestParser.py diff --git a/components/esp32/spiram.c b/components/esp32/spiram.c index 55e97859fc..d07444a921 100644 --- a/components/esp32/spiram.c +++ b/components/esp32/spiram.c @@ -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); if (!dma_heap) return ESP_ERR_NO_MEM; 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() diff --git a/components/esp32/test/component.mk b/components/esp32/test/component.mk index 745f8cb796..76f6f71328 100644 --- a/components/esp32/test/component.mk +++ b/components/esp32/test/component.mk @@ -12,4 +12,4 @@ test_tjpgd.o: test_tjpgd_logo.h test_tjpgd_logo.h: $(COMPONENT_PATH)/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 diff --git a/components/esp32/test/test_fastbus.c b/components/esp32/test/test_fastbus.c index 2b58c725b0..dc5e5b312d 100644 --- a/components/esp32/test/test_fastbus.c +++ b/components/esp32/test/test_fastbus.c @@ -104,7 +104,7 @@ TEST_CASE("Fast I/O bus test", "[hw][ignore]") 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_DATA3_U, FUNC_SD_DATA3_U1TXD); diff --git a/components/esp32/test/test_intr_alloc.c b/components/esp32/test/test_intr_alloc.c index 23d9504d12..2eef456a56 100644 --- a/components/esp32/test/test_intr_alloc.c +++ b/components/esp32/test/test_intr_alloc.c @@ -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); TEST_ESP_OK(r); //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 ); //assign shared then r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler2, &ctx, &handle2); diff --git a/components/freertos/test/test_freertos.c b/components/freertos/test/test_freertos.c index 745e31a9a0..1f9b159d06 100644 --- a/components/freertos/test/test_freertos.c +++ b/components/freertos/test/test_freertos.c @@ -164,7 +164,7 @@ static void uartRxInit(xQueueHandle q) { 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_U0TXD_U, FUNC_U0TXD_U0TXD); diff --git a/components/freertos/test/test_ringbuf.c b/components/freertos/test/test_ringbuf.c index ac2e88fe5c..84e1159992 100644 --- a/components/freertos/test/test_ringbuf.c +++ b/components/freertos/test/test_ringbuf.c @@ -2,7 +2,7 @@ Test for multicore FreeRTOS ringbuffer. */ -#include +#include #include #include "rom/ets_sys.h" @@ -16,11 +16,8 @@ #include "soc/uart_reg.h" #include "soc/dport_reg.h" #include "soc/io_mux_reg.h" +#include "esp_intr_alloc.h" -#include -#include - -void ets_isr_unmask(uint32_t unmask); static RingbufHandle_t rb; typedef enum { @@ -32,6 +29,8 @@ typedef enum { static volatile testtype_t testtype; +intr_handle_t s_intr_handle; + static void task1(void *arg) { testtype_t oldtest; @@ -50,14 +49,14 @@ static void task1(void *arg) printf("Test %d: Timeout on send!\n", (int)testtype); } if (testtype == TST_MOSTLYEMPTY) { - vTaskDelay(1000 / portTICK_PERIOD_MS); + vTaskDelay(300 / portTICK_PERIOD_MS); } } //Send NULL event to stop other side. r = xRingbufferSend(rb, NULL, 0, 10000 / portTICK_PERIOD_MS); } 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); } if (testtype == TST_MOSTLYFILLED) { - vTaskDelay(1000 / portTICK_PERIOD_MS); + vTaskDelay(300 / portTICK_PERIOD_MS); } } } 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() { - uint32_t reg_val; - 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); + WRITE_PERI_REG(UART_CONF1_REG(0), 1 << UART_RXFIFO_FULL_THRHD_S); 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); - printf("Enabling int %d\n", ETS_UART0_INUM); - 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); + ESP_ERROR_CHECK(esp_intr_alloc(ETS_UART0_INTR_SOURCE, 0, &uartIsrHdl, NULL, &s_intr_handle)); +} +static void uartRxDeinit() +{ + esp_intr_free(s_intr_handle); } static void testRingbuffer(int type) @@ -166,31 +157,32 @@ static void testRingbuffer(int type) testtype = TST_MOSTLYFILLED; - xTaskCreatePinnedToCore(task1 , "tskone" , 2048, NULL, 3, &th[0], 0); - xTaskCreatePinnedToCore(task2 , "tsktwo" , 2048, NULL, 3, &th[1], 0); + xTaskCreatePinnedToCore(task1, "tskone", 2048, NULL, 3, &th[0], 0); + xTaskCreatePinnedToCore(task2, "tsktwo", 2048, NULL, 3, &th[1], 0); uartRxInit(); 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"); - 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"); testtype = TST_MOSTLYEMPTY; - vTaskDelay(15000 / portTICK_PERIOD_MS); + vTaskDelay(5000 / portTICK_PERIOD_MS); //Shut down all the tasks for (i = 0; i < 2; i++) { vTaskDelete(th[i]); } - xt_ints_off(1 << ETS_UART0_INUM); + vRingbufferDelete(rb); + uartRxDeinit(); } // 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); } -TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos][ignore]") +TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos]") { testRingbuffer(1); } diff --git a/components/heap/test/test_heap_trace.c b/components/heap/test/test_heap_trace.c index 31b6f58824..ccec5daf7c 100644 --- a/components/heap/test/test_heap_trace.c +++ b/components/heap/test/test_heap_trace.c @@ -8,13 +8,14 @@ #include #include #include -#include "esp_heap_trace.h" #include "sdkconfig.h" #include "unity.h" #ifdef CONFIG_HEAP_TRACING // only compile in heap tracing tests if tracing is enabled +#include "esp_heap_trace.h" + TEST_CASE("heap trace leak check", "[heap]") { heap_trace_record_t recs[8]; diff --git a/components/libsodium/test/component.mk b/components/libsodium/test/component.mk index 6e7c3bc7a9..75a54ae814 100644 --- a/components/libsodium/test/component.mk +++ b/components/libsodium/test/component.mk @@ -25,9 +25,10 @@ COMPONENT_OBJS := test_sodium.o # Run each test case from test_sodium.c as CASENAME_xmain(). define sodium_testcase -# this generates 'warning "main" redefined' warnings at -# runtime. Only solution involves patching libsodium's cmptest.h +# This would generate 'warning "main" redefined' warnings at runtime, which are +# 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: CPPFLAGS+=-Wp,-w ote: COMPONENT_OBJS += $(LS_TESTDIR)/$(1).o endef diff --git a/tools/unit-test-app/components/unity/unity_platform.c b/tools/unit-test-app/components/unity/unity_platform.c index 7b96ae4f34..f1c792e327 100644 --- a/tools/unit-test-app/components/unity/unity_platform.c +++ b/tools/unit-test-app/components/unity/unity_platform.c @@ -10,9 +10,12 @@ #include "esp_log.h" #include "soc/cpu.h" #include "esp_heap_caps.h" -#include "esp_heap_trace.h" #include "test_utils.h" +#ifdef CONFIG_HEAP_TRACING +#include "esp_heap_trace.h" +#endif + #define unity_printf ets_printf // Pointers to the head and tail of linked list of test description structs: