]> granicus.if.org Git - esp-idf/commitdiff
unit tests: fix warnings, build with -Werror
authorIvan Grokhotkov <ivan@espressif.com>
Wed, 18 Oct 2017 13:09:53 +0000 (21:09 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 19 Oct 2017 13:35:23 +0000 (21:35 +0800)
- libsodium: silence warnings
- unit tests: fix warnings
- spiram: fix warnings
- ringbuf test: enable by default, reduce delays

.gitlab-ci.yml
components/esp32/spiram.c
components/esp32/test/component.mk
components/esp32/test/test_fastbus.c
components/esp32/test/test_intr_alloc.c
components/freertos/test/test_freertos.c
components/freertos/test/test_ringbuf.c
components/heap/test/test_heap_trace.c
components/libsodium/test/component.mk
tools/unit-test-app/components/unity/unity_platform.c

index adcfdb6a462e859ac4baa6ddd4fb8ed28c99f3ed..ea5c5981bcefaef1492be430512d5c490adad167 100644 (file)
@@ -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
 
index 55e97859fc1587ef71da2e29976564ad1e87c799..d07444a921222d7c96b313b7df9523a70d1ae718 100644 (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);
     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()
index 745f8cb79614136c811adad51a76fceff1f2d3bc..76f6f7132815f06b8d209c3f3b6b7a75e56d9453 100644 (file)
@@ -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
index 2b58c725b05199d7e189fe93b950b02b88070001..dc5e5b312d2963d399903305da269cf55b5082c5 100644 (file)
@@ -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);
 
index 23d9504d124679f0619a31887f498272ea9a0833..2eef456a56c3d87a6c3086c7721fa2a95654fee9 100644 (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);
     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);
index 745e31a9a03638a50cadf8917193d1382c3ed270..1f9b159d068c3d9b414e1ce97c3f8ecf890a9495 100644 (file)
@@ -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);
 
index ac2e88fe5cc329809513312d6e84494808a42df6..84e1159992e5d6855a8a4a2f9e5d51857c8714fc 100644 (file)
@@ -2,7 +2,7 @@
  Test for multicore FreeRTOS ringbuffer.
 */
 
-#include <esp_types.h>
+#include <string.h>
 #include <stdio.h>
 #include "rom/ets_sys.h"
 
 #include "soc/uart_reg.h"
 #include "soc/dport_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;
 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);
 }
index 31b6f5882421ddef1326ed04d272b7259f2b6968..ccec5daf7c45940adf834d286879d261e9161d7a 100644 (file)
@@ -8,13 +8,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#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];
index 6e7c3bc7a94086e099f4c1fde709ac58847ba89d..75a54ae8147ba47daa1f7e32204a4fb550044dc4 100644 (file)
@@ -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
index 7b96ae4f34b6911af93a5c243b0fcb73e60323c6..f1c792e327be63d862508ab9c78d0f5aa576cbcd 100644 (file)
 #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: