Skip to content

Commit 0690eba

Browse files
committed
ci(mdns): Fix mdns host test layers with static task creation
1 parent eb4ab52 commit 0690eba

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

common_components/linux_compat/freertos/freertos_linux.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -212,6 +212,20 @@ void *pthread_task(void *params)
212212
return NULL;
213213
}
214214

215+
TaskHandle_t xTaskCreateStaticPinnedToCore( TaskFunction_t pxTaskCode,
216+
const char *const pcName,
217+
const uint32_t ulStackDepth,
218+
void *const pvParameters,
219+
UBaseType_t uxPriority,
220+
StackType_t *const puxStackBuffer,
221+
StaticTask_t *const pxTaskBuffer,
222+
const BaseType_t xCoreID )
223+
{
224+
static TaskHandle_t pvCreatedTask;
225+
xTaskCreate(pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, &pvCreatedTask);
226+
return pvCreatedTask;
227+
}
228+
215229
BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pvTaskCode,
216230
const char *const pcName,
217231
const uint32_t usStackDepth,

common_components/linux_compat/freertos/include/freertos/task.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#pragma once
77

88
#include "freertos/FreeRTOS.h"
9+
#include "esp_heap_caps.h"
910

1011
#ifdef __cplusplus
1112
extern "C" {
@@ -15,6 +16,9 @@ extern "C" {
1516
#define TaskHandle_t TaskHandle_t
1617
#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) )
1718

19+
typedef void *StackType_t;
20+
typedef void *StaticTask_t;
21+
1822
void vTaskDelay( const TickType_t xTicksToDelay );
1923

2024
void xTaskNotifyGive(TaskHandle_t task);
@@ -25,6 +29,15 @@ TaskHandle_t xTaskGetCurrentTaskHandle(void);
2529

2630
BaseType_t xTaskNotifyWait(uint32_t bits_entry_clear, uint32_t bits_exit_clear, uint32_t *value, TickType_t wait_time );
2731

32+
TaskHandle_t xTaskCreateStaticPinnedToCore( TaskFunction_t pxTaskCode,
33+
const char *const pcName,
34+
const uint32_t ulStackDepth,
35+
void *const pvParameters,
36+
UBaseType_t uxPriority,
37+
StackType_t *const puxStackBuffer,
38+
StaticTask_t *const pxTaskBuffer,
39+
const BaseType_t xCoreID );
40+
2841
BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pvTaskCode,
2942
const char *const pcName,
3043
const uint32_t usStackDepth,
@@ -81,6 +94,9 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
8194

8295
uint32_t xQueueSendToBack(QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait );
8396

97+
void *heap_caps_malloc( size_t size, uint32_t caps);
98+
void heap_caps_free( void *ptr);
99+
84100
#ifdef __cplusplus
85101
}
86102
#endif //__cplusplus

components/mdns/tests/test_afl_fuzz_host/esp32_mock.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -125,3 +125,13 @@ uint32_t esp_log_timestamp(void)
125125
{
126126
return 0;
127127
}
128+
129+
void *heap_caps_malloc(size_t size, uint32_t caps)
130+
{
131+
return malloc(size);
132+
}
133+
134+
void heap_caps_free( void *ptr)
135+
{
136+
free(ptr);
137+
}

components/mdns/tests/test_afl_fuzz_host/esp32_mock.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -38,6 +38,10 @@
3838
#define ESP_ERR_INVALID_RESPONSE 0x108
3939
#define ESP_ERR_INVALID_CRC 0x109
4040

41+
#define MDNS_TASK_MEMORY_LOG "internal RAM"
42+
#define MALLOC_CAP_8BIT (1<<2)
43+
#define MALLOC_CAP_INTERNAL (1<<11)
44+
4145
#define pdTRUE true
4246
#define pdFALSE false
4347
#define pdPASS ( pdTRUE )
@@ -62,6 +66,7 @@
6266
#define vSemaphoreDelete(s) free(s)
6367
#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U
6468
#define xTaskCreatePinnedToCore(a,b,c,d,e,f,g) *(f) = malloc(1)
69+
#define xTaskCreateStaticPinnedToCore(a,b,c,d,e,f,g,h) true
6570
#define vTaskDelay(m) usleep((m)*0)
6671
#define esp_random() (rand()%UINT32_MAX)
6772

@@ -79,7 +84,8 @@ typedef void *QueueHandle_t;
7984
typedef void *TaskHandle_t;
8085
typedef int BaseType_t;
8186
typedef uint32_t TickType_t;
82-
87+
typedef void *StackType_t;
88+
typedef void *StaticTask_t;
8389

8490
struct udp_pcb {
8591
uint8_t dummy;
@@ -132,5 +138,7 @@ esp_err_t esp_event_handler_unregister(const char *event_base, int32_t event_id,
132138
TaskHandle_t xTaskGetCurrentTaskHandle(void);
133139
void xTaskNotifyGive(TaskHandle_t task);
134140
BaseType_t xTaskNotifyWait(uint32_t bits_entry_clear, uint32_t bits_exit_clear, uint32_t *value, TickType_t wait_time );
141+
void *heap_caps_malloc(size_t size, uint32_t caps);
142+
void heap_caps_free(void *ptr);
135143

136144
#endif //_ESP32_COMPAT_H_

0 commit comments

Comments
 (0)