mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 21:54:33 +02:00
ipc: Mitigates and speeds up some ipc tests
Test ipc_isr two tasks use IPC function calls Test multiple ipc_calls Closes IDFCI-1638
This commit is contained in:
@@ -84,19 +84,25 @@ TEST_CASE("Test ipc_task works with the priority of the caller's task", "[ipc]")
|
|||||||
static void test_func2_ipc(void *arg)
|
static void test_func2_ipc(void *arg)
|
||||||
{
|
{
|
||||||
int callers_priority = *(int *)arg;
|
int callers_priority = *(int *)arg;
|
||||||
esp_rom_delay_us(1000000 + xPortGetCoreID() * 100);
|
esp_rom_delay_us(10000 + xPortGetCoreID() * 100);
|
||||||
UBaseType_t priority = uxTaskPriorityGet(NULL);
|
UBaseType_t priority = uxTaskPriorityGet(NULL);
|
||||||
esp_rom_printf("test_func2_ipc: [callers_priority = %d, priority = %d, cpu = %d]\n", callers_priority, priority, xPortGetCoreID());
|
esp_rom_printf("test_func2_ipc: [callers_priority = %d, priority = %d, cpu = %d]\n", callers_priority, priority, xPortGetCoreID());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void task(void *sema)
|
typedef struct {
|
||||||
|
SemaphoreHandle_t start;
|
||||||
|
SemaphoreHandle_t done;
|
||||||
|
} test_semaphore_args_t;
|
||||||
|
|
||||||
|
static void task(void *semaphore_args)
|
||||||
{
|
{
|
||||||
|
test_semaphore_args_t* test_semaphore = (test_semaphore_args_t*) semaphore_args;
|
||||||
int priority = uxTaskPriorityGet(NULL);
|
int priority = uxTaskPriorityGet(NULL);
|
||||||
ESP_LOGI("task", "start [priority = %d, cpu = %d]", priority, xPortGetCoreID());
|
ESP_LOGI("task", "start [priority = %d, cpu = %d]", priority, xPortGetCoreID());
|
||||||
xSemaphoreTake(*(SemaphoreHandle_t *)sema, portMAX_DELAY);
|
xSemaphoreTake(test_semaphore->start, portMAX_DELAY);
|
||||||
esp_ipc_call_blocking(!xPortGetCoreID(), test_func2_ipc, &priority);
|
esp_ipc_call_blocking(!xPortGetCoreID(), test_func2_ipc, &priority);
|
||||||
xSemaphoreGive(*(SemaphoreHandle_t *)sema);
|
|
||||||
ESP_LOGI("task", "finish [priority = %d, cpu = %d]", priority, xPortGetCoreID());
|
ESP_LOGI("task", "finish [priority = %d, cpu = %d]", priority, xPortGetCoreID());
|
||||||
|
xSemaphoreGive(test_semaphore->done);
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,28 +111,27 @@ TEST_CASE("Test multiple ipc_calls", "[ipc]")
|
|||||||
const int max_tasks = 5;
|
const int max_tasks = 5;
|
||||||
UBaseType_t priority = uxTaskPriorityGet(NULL);
|
UBaseType_t priority = uxTaskPriorityGet(NULL);
|
||||||
ESP_LOGI("test", "priority = %d, cpu = %d", priority, xPortGetCoreID());
|
ESP_LOGI("test", "priority = %d, cpu = %d", priority, xPortGetCoreID());
|
||||||
SemaphoreHandle_t sema_ipc_done[max_tasks * portNUM_PROCESSORS];
|
test_semaphore_args_t test_semaphore[max_tasks * portNUM_PROCESSORS];
|
||||||
|
|
||||||
for (int task_num = 0; task_num < max_tasks; ++task_num) {
|
for (int task_num = 0; task_num < max_tasks; ++task_num) {
|
||||||
++priority;
|
++priority;
|
||||||
ESP_LOGI("test", "task prio = %d", priority);
|
ESP_LOGI("test", "task prio = %d", priority);
|
||||||
for (int cpu_num = 0; cpu_num < portNUM_PROCESSORS; ++cpu_num) {
|
for (int cpu_num = 0; cpu_num < portNUM_PROCESSORS; ++cpu_num) {
|
||||||
sema_ipc_done[task_num * 2 + cpu_num] = xSemaphoreCreateBinary();
|
unsigned i = task_num * 2 + cpu_num;
|
||||||
xTaskCreatePinnedToCore(task, "task", 4096, &sema_ipc_done[task_num * 2 + cpu_num], priority, NULL, cpu_num);
|
test_semaphore[i].start = xSemaphoreCreateBinary();
|
||||||
|
test_semaphore[i].done = xSemaphoreCreateBinary();
|
||||||
|
xTaskCreatePinnedToCore(task, "task", 4096, &test_semaphore[i], priority, NULL, cpu_num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int task_num = 0; task_num < max_tasks; ++task_num) {
|
for (int i = 0; i < max_tasks * portNUM_PROCESSORS; ++i) {
|
||||||
for (int cpu_num = 0; cpu_num < portNUM_PROCESSORS; ++cpu_num) {
|
xSemaphoreGive(test_semaphore[i].start);
|
||||||
xSemaphoreGive(sema_ipc_done[task_num * 2 + cpu_num]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int task_num = 0; task_num < max_tasks; ++task_num) {
|
for (int i = 0; i < max_tasks * portNUM_PROCESSORS; ++i) {
|
||||||
for (int cpu_num = 0; cpu_num < portNUM_PROCESSORS; ++cpu_num) {
|
xSemaphoreTake(test_semaphore[i].done, portMAX_DELAY);
|
||||||
xSemaphoreTake(sema_ipc_done[task_num * 2 + cpu_num], portMAX_DELAY);
|
vSemaphoreDelete(test_semaphore[i].done);
|
||||||
vSemaphoreDelete(sema_ipc_done[task_num * 2 + cpu_num]);
|
vSemaphoreDelete(test_semaphore[i].start);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ESP_IPC_USES_CALLERS_PRIORITY */
|
#endif /* CONFIG_ESP_IPC_USES_CALLERS_PRIORITY */
|
||||||
|
@@ -75,7 +75,7 @@ static void task_asm(void *arg)
|
|||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
printf("task_asm counter = %d\n", counter);
|
printf("task_asm counter = %d\n", counter);
|
||||||
TEST_ASSERT_GREATER_THAN(1000000, counter);
|
TEST_ASSERT_GREATER_THAN(10000, counter);
|
||||||
xSemaphoreGive(*sema);
|
xSemaphoreGive(*sema);
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ TEST_CASE("Test ipc_isr two tasks use IPC function calls", "[ipc]")
|
|||||||
printf("Test start\n");
|
printf("Test start\n");
|
||||||
xTaskCreatePinnedToCore(task_asm, "task_asm", 2048, &exit_sema[0], UNITY_FREERTOS_PRIORITY - 1, NULL, 0);
|
xTaskCreatePinnedToCore(task_asm, "task_asm", 2048, &exit_sema[0], UNITY_FREERTOS_PRIORITY - 1, NULL, 0);
|
||||||
xTaskCreatePinnedToCore(task_asm, "task_asm", 2048, &exit_sema[1], UNITY_FREERTOS_PRIORITY - 1, NULL, 1);
|
xTaskCreatePinnedToCore(task_asm, "task_asm", 2048, &exit_sema[1], UNITY_FREERTOS_PRIORITY - 1, NULL, 1);
|
||||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
s_stop = true;
|
s_stop = true;
|
||||||
xSemaphoreTake(exit_sema[0], portMAX_DELAY);
|
xSemaphoreTake(exit_sema[0], portMAX_DELAY);
|
||||||
xSemaphoreTake(exit_sema[1], portMAX_DELAY);
|
xSemaphoreTake(exit_sema[1], portMAX_DELAY);
|
||||||
|
Reference in New Issue
Block a user