mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(freertos): Updated unstable FreeRTOS unit tests
This commit fixes some flaky FreeRTOS unit tests.
This commit is contained in:
parent
33dec4175a
commit
68dbbf339d
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -75,7 +75,7 @@ static void yield_task2(void *arg)
|
|||||||
|
|
||||||
/* Wait for the other task to run for the test to begin */
|
/* Wait for the other task to run for the test to begin */
|
||||||
while (!task_sequence_ready) {
|
while (!task_sequence_ready) {
|
||||||
taskYIELD();
|
vTaskDelay(10);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Store task_id in the sequence array */
|
/* Store task_id in the sequence array */
|
||||||
@ -272,7 +272,7 @@ static void test_critical_task2(void *arg)
|
|||||||
|
|
||||||
/* Wait for the other task to run for the test to begin */
|
/* Wait for the other task to run for the test to begin */
|
||||||
while (!task_sequence_ready) {
|
while (!task_sequence_ready) {
|
||||||
taskYIELD();
|
vTaskDelay(10);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Store task_id in the sequence array */
|
/* Store task_id in the sequence array */
|
||||||
@ -474,7 +474,7 @@ static void other_core_task2(void *arg)
|
|||||||
|
|
||||||
/* Wait for the other task to run for the test to begin */
|
/* Wait for the other task to run for the test to begin */
|
||||||
while (!task_sequence_ready) {
|
while (!task_sequence_ready) {
|
||||||
taskYIELD();
|
vTaskDelay(10);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Store task_id in the sequence array */
|
/* Store task_id in the sequence array */
|
||||||
@ -594,7 +594,7 @@ static void other_core_critical_task2(void *arg)
|
|||||||
|
|
||||||
/* Wait for the other task to run for the test to begin */
|
/* Wait for the other task to run for the test to begin */
|
||||||
while (!task_sequence_ready) {
|
while (!task_sequence_ready) {
|
||||||
taskYIELD();
|
vTaskDelay(10);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Store task_id in the sequence array */
|
/* Store task_id in the sequence array */
|
||||||
|
@ -31,7 +31,7 @@ static void test_task_1(void *arg)
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
context->before_sched = esp_cpu_get_cycle_count();
|
context->before_sched = esp_cpu_get_cycle_count();
|
||||||
vPortYield();
|
taskYIELD();
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
@ -44,11 +44,11 @@ static void test_task_2(void *arg)
|
|||||||
|
|
||||||
vTaskPrioritySet(NULL, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
|
vTaskPrioritySet(NULL, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
|
||||||
vTaskPrioritySet(context->t1_handle, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
|
vTaskPrioritySet(context->t1_handle, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
|
||||||
vPortYield();
|
taskYIELD();
|
||||||
|
|
||||||
for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
|
for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
|
||||||
accumulator += (esp_cpu_get_cycle_count() - context->before_sched);
|
accumulator += (esp_cpu_get_cycle_count() - context->before_sched);
|
||||||
vPortYield();
|
taskYIELD();
|
||||||
}
|
}
|
||||||
|
|
||||||
context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS;
|
context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS;
|
||||||
@ -65,8 +65,8 @@ TEST_CASE("scheduling time test", "[freertos]")
|
|||||||
TEST_ASSERT(context.end_sema != NULL);
|
TEST_ASSERT(context.end_sema != NULL);
|
||||||
|
|
||||||
#if !CONFIG_FREERTOS_UNICORE
|
#if !CONFIG_FREERTOS_UNICORE
|
||||||
xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, 1, &context.t1_handle, 1);
|
xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle, 1);
|
||||||
xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, 1, NULL, 1);
|
xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL, 1);
|
||||||
#else
|
#else
|
||||||
xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle, 0);
|
xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle, 0);
|
||||||
xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL, 0);
|
xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL, 0);
|
||||||
@ -75,4 +75,7 @@ TEST_CASE("scheduling time test", "[freertos]")
|
|||||||
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);
|
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);
|
||||||
TEST_ASSERT_EQUAL_HEX32(pdTRUE, result);
|
TEST_ASSERT_EQUAL_HEX32(pdTRUE, result);
|
||||||
TEST_PERFORMANCE_LESS_THAN(SCHEDULING_TIME, "%"PRIu32" cycles", context.cycles_to_sched);
|
TEST_PERFORMANCE_LESS_THAN(SCHEDULING_TIME, "%"PRIu32" cycles", context.cycles_to_sched);
|
||||||
|
|
||||||
|
/* Cleanup */
|
||||||
|
vSemaphoreDelete(context.end_sema);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ TEST_CASE("portMUX spinlocks (no contention)", "[freertos]")
|
|||||||
}
|
}
|
||||||
BENCHMARK_END("no contention lock");
|
BENCHMARK_END("no contention lock");
|
||||||
|
|
||||||
#ifdef CONFIG_FREERTOS_UNICORE
|
#if CONFIG_FREERTOS_UNICORE
|
||||||
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
|
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
|
||||||
#else
|
#else
|
||||||
#if CONFIG_SPIRAM
|
#if CONFIG_SPIRAM
|
||||||
@ -76,6 +76,16 @@ TEST_CASE("portMUX recursive locks (no contention)", "[freertos]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BENCHMARK_END("no contention recursive");
|
BENCHMARK_END("no contention recursive");
|
||||||
|
|
||||||
|
#if CONFIG_FREERTOS_UNICORE
|
||||||
|
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
|
||||||
|
#else
|
||||||
|
#if CONFIG_SPIRAM
|
||||||
|
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
|
||||||
|
#else
|
||||||
|
TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user