Skip to content

Commit 90bbcbc

Browse files
committed
unit tests: fix warnings, build with -Werror
- libsodium: silence warnings - unit tests: fix warnings - spiram: fix warnings - ringbuf test: enable by default, reduce delays
1 parent b52e3fa commit 90bbcbc

File tree

10 files changed

+38
-39
lines changed

10 files changed

+38
-39
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ build_esp_idf_tests:
121121
- cd tools/unit-test-app
122122
- make help # make sure kconfig tools are built in single process
123123
- make ut-clean-all-configs
124+
- export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations"
125+
- export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
124126
- make ut-build-all-configs TESTS_ALL=1
125127
- python tools/UnitTestParser.py
126128

components/esp32/spiram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ esp_err_t esp_spiram_reserve_dma_pool(size_t size) {
141141
dma_heap=heap_caps_malloc(size, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
142142
if (!dma_heap) return ESP_ERR_NO_MEM;
143143
uint32_t caps[]={MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL, 0, MALLOC_CAP_8BIT|MALLOC_CAP_32BIT};
144-
return heap_caps_add_region_with_caps(caps, dma_heap, dma_heap+size-1);
144+
return heap_caps_add_region_with_caps(caps, (intptr_t) dma_heap, (intptr_t) dma_heap+size-1);
145145
}
146146

147147
size_t esp_spiram_get_size()

components/esp32/test/component.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ test_tjpgd.o: test_tjpgd_logo.h
1212

1313
test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg
1414
$(summary) XXD logo.jpg
15-
$(Q) cd $(COMPONENT_PATH); xxd -i logo.jpg $(COMPONENT_BUILD_DIR)/test_tjpgd_logo.h
15+
cd $(COMPONENT_PATH); xxd -i logo.jpg $(COMPONENT_BUILD_DIR)/test_tjpgd_logo.h

components/esp32/test/test_fastbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ TEST_CASE("Fast I/O bus test", "[hw][ignore]")
104104
TEST_ASSERT(0);
105105
}
106106

107-
PIN_PULLUP_DIS(PERIPHS_IO_MUX_SD_DATA3_U);
107+
gpio_pullup_dis(10);
108108
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, FUNC_SD_DATA2_U1RXD);
109109
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, FUNC_SD_DATA3_U1TXD);
110110

components/esp32/test/test_intr_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ TEST_CASE("allocate 2 handlers for a same source and remove the later one","[esp
274274
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler1, &ctx, &handle1);
275275
TEST_ESP_OK(r);
276276
//try an invalid assign first
277-
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, NULL, int_handler2, NULL, &handle2);
277+
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, 0, int_handler2, NULL, &handle2);
278278
TEST_ASSERT_EQUAL_INT(r, ESP_ERR_NOT_FOUND );
279279
//assign shared then
280280
r=esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, int_handler2, &ctx, &handle2);

components/freertos/test/test_freertos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void uartRxInit(xQueueHandle q)
164164
{
165165
uint32_t reg_val;
166166

167-
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
167+
gpio_pullup_dis(1);
168168
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
169169
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
170170

components/freertos/test/test_ringbuf.c

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Test for multicore FreeRTOS ringbuffer.
33
*/
44

5-
#include <esp_types.h>
5+
#include <string.h>
66
#include <stdio.h>
77
#include "rom/ets_sys.h"
88

@@ -16,11 +16,8 @@
1616
#include "soc/uart_reg.h"
1717
#include "soc/dport_reg.h"
1818
#include "soc/io_mux_reg.h"
19+
#include "esp_intr_alloc.h"
1920

20-
#include <string.h>
21-
#include <stdio.h>
22-
23-
void ets_isr_unmask(uint32_t unmask);
2421

2522
static RingbufHandle_t rb;
2623
typedef enum {
@@ -32,6 +29,8 @@ typedef enum {
3229

3330
static volatile testtype_t testtype;
3431

32+
intr_handle_t s_intr_handle;
33+
3534
static void task1(void *arg)
3635
{
3736
testtype_t oldtest;
@@ -50,14 +49,14 @@ static void task1(void *arg)
5049
printf("Test %d: Timeout on send!\n", (int)testtype);
5150
}
5251
if (testtype == TST_MOSTLYEMPTY) {
53-
vTaskDelay(1000 / portTICK_PERIOD_MS);
52+
vTaskDelay(300 / portTICK_PERIOD_MS);
5453
}
5554
}
5655
//Send NULL event to stop other side.
5756
r = xRingbufferSend(rb, NULL, 0, 10000 / portTICK_PERIOD_MS);
5857
}
5958
while (oldtest == testtype) {
60-
vTaskDelay(1000 / portTICK_PERIOD_MS);
59+
vTaskDelay(300 / portTICK_PERIOD_MS);
6160
}
6261
}
6362
}
@@ -85,12 +84,12 @@ static void task2(void *arg)
8584
vRingbufferReturnItem(rb, buf);
8685
}
8786
if (testtype == TST_MOSTLYFILLED) {
88-
vTaskDelay(1000 / portTICK_PERIOD_MS);
87+
vTaskDelay(300 / portTICK_PERIOD_MS);
8988
}
9089
}
9190
}
9291
while (oldtest == testtype) {
93-
vTaskDelay(1000 / portTICK_PERIOD_MS);
92+
vTaskDelay(300 / portTICK_PERIOD_MS);
9493
}
9594
}
9695
}
@@ -138,24 +137,16 @@ static void uartIsrHdl(void *arg)
138137

139138
static void uartRxInit()
140139
{
141-
uint32_t reg_val;
142-
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
143-
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
144-
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
145-
146-
// reg_val = READ_PERI_REG(UART_CONF1(0));
147-
reg_val = (1 << UART_RXFIFO_FULL_THRHD_S);
148-
WRITE_PERI_REG(UART_CONF1_REG(0), reg_val);
140+
WRITE_PERI_REG(UART_CONF1_REG(0), 1 << UART_RXFIFO_FULL_THRHD_S);
149141
CLEAR_PERI_REG_MASK(UART_INT_ENA_REG(0), UART_TXFIFO_EMPTY_INT_ENA | UART_RXFIFO_TOUT_INT_ENA);
150142
SET_PERI_REG_MASK(UART_INT_ENA_REG(0), UART_RXFIFO_FULL_INT_ENA);
151143

152-
printf("Enabling int %d\n", ETS_UART0_INUM);
153-
DPORT_REG_SET_FIELD(DPORT_PRO_UART_INTR_MAP_REG, DPORT_PRO_UART_INTR_MAP, ETS_UART0_INUM);
154-
DPORT_REG_SET_FIELD(DPORT_PRO_UART1_INTR_MAP_REG, DPORT_PRO_UART1_INTR_MAP, ETS_UART0_INUM);
155-
156-
xt_set_interrupt_handler(ETS_UART0_INUM, uartIsrHdl, NULL);
157-
xt_ints_on(1 << ETS_UART0_INUM);
144+
ESP_ERROR_CHECK(esp_intr_alloc(ETS_UART0_INTR_SOURCE, 0, &uartIsrHdl, NULL, &s_intr_handle));
145+
}
158146

147+
static void uartRxDeinit()
148+
{
149+
esp_intr_free(s_intr_handle);
159150
}
160151

161152
static void testRingbuffer(int type)
@@ -166,31 +157,32 @@ static void testRingbuffer(int type)
166157

167158
testtype = TST_MOSTLYFILLED;
168159

169-
xTaskCreatePinnedToCore(task1 , "tskone" , 2048, NULL, 3, &th[0], 0);
170-
xTaskCreatePinnedToCore(task2 , "tsktwo" , 2048, NULL, 3, &th[1], 0);
160+
xTaskCreatePinnedToCore(task1, "tskone", 2048, NULL, 3, &th[0], 0);
161+
xTaskCreatePinnedToCore(task2, "tsktwo", 2048, NULL, 3, &th[1], 0);
171162
uartRxInit();
172163

173164
printf("Press 'r' to read an event in isr, any other key to write one.\n");
174165
printf("Test: mostlyfilled; putting 10 items in ringbuff ASAP, reading 1 a second\n");
175-
vTaskDelay(15000 / portTICK_PERIOD_MS);
166+
vTaskDelay(5000 / portTICK_PERIOD_MS);
176167
printf("Test: mostlyempty; putting 10 items in ringbuff @ 1/sec, reading as fast as possible\n");
177168
testtype = TST_MOSTLYEMPTY;
178-
vTaskDelay(15000 / portTICK_PERIOD_MS);
169+
vTaskDelay(5000 / portTICK_PERIOD_MS);
179170

180171
//Shut down all the tasks
181172
for (i = 0; i < 2; i++) {
182173
vTaskDelete(th[i]);
183174
}
184-
xt_ints_off(1 << ETS_UART0_INUM);
175+
vRingbufferDelete(rb);
176+
uartRxDeinit();
185177
}
186178

187179
// TODO: split this thing into separate orthogonal tests
188-
TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos][ignore]")
180+
TEST_CASE("FreeRTOS ringbuffer test, no splitting items", "[freertos]")
189181
{
190182
testRingbuffer(0);
191183
}
192184

193-
TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos][ignore]")
185+
TEST_CASE("FreeRTOS ringbuffer test, w/ splitting items", "[freertos]")
194186
{
195187
testRingbuffer(1);
196188
}

components/heap/test/test_heap_trace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
#include <stdio.h>
99
#include <stdlib.h>
1010
#include <string.h>
11-
#include "esp_heap_trace.h"
1211
#include "sdkconfig.h"
1312
#include "unity.h"
1413

1514
#ifdef CONFIG_HEAP_TRACING
1615
// only compile in heap tracing tests if tracing is enabled
1716

17+
#include "esp_heap_trace.h"
18+
1819
TEST_CASE("heap trace leak check", "[heap]")
1920
{
2021
heap_trace_record_t recs[8];

components/libsodium/test/component.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ COMPONENT_OBJS := test_sodium.o
2525
# Run each test case from test_sodium.c as CASENAME_xmain().
2626

2727
define sodium_testcase
28-
# this generates 'warning "main" redefined' warnings at
29-
# runtime. Only solution involves patching libsodium's cmptest.h
28+
# This would generate 'warning "main" redefined' warnings at runtime, which are
29+
# silenced here. Only other solution involves patching libsodium's cmptest.h.
3030
$(LS_TESTDIR)/$(1).o: CFLAGS+=-Dxmain=$(1)_xmain -Dmain=$(1)_main
31+
$(LS_TESTDIR)/$(1).o: CPPFLAGS+=-Wp,-w
3132
ote:
3233
COMPONENT_OBJS += $(LS_TESTDIR)/$(1).o
3334
endef

tools/unit-test-app/components/unity/unity_platform.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
#include "esp_log.h"
1111
#include "soc/cpu.h"
1212
#include "esp_heap_caps.h"
13-
#include "esp_heap_trace.h"
1413
#include "test_utils.h"
1514

15+
#ifdef CONFIG_HEAP_TRACING
16+
#include "esp_heap_trace.h"
17+
#endif
18+
1619
#define unity_printf ets_printf
1720

1821
// Pointers to the head and tail of linked list of test description structs:

0 commit comments

Comments
 (0)