From 5847e0afd2315f485796c37c8df5b95b8944187d Mon Sep 17 00:00:00 2001 From: Felipe Neves Date: Fri, 3 Apr 2020 16:57:57 -0300 Subject: [PATCH] freertos/test: fix overflow on accumulator used on scheduling time test --- .../test/test_freertos_scheduling_time.c | 16 +++++++++++----- components/idf_test/include/idf_performance.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/components/freertos/test/test_freertos_scheduling_time.c b/components/freertos/test/test_freertos_scheduling_time.c index 1670f520e7..7e3a783684 100644 --- a/components/freertos/test/test_freertos_scheduling_time.c +++ b/components/freertos/test/test_freertos_scheduling_time.c @@ -11,6 +11,8 @@ #include "soc/cpu.h" #include "test_utils.h" +#define NUMBER_OF_ITERATIONS 10 + typedef struct { SemaphoreHandle_t end_sema; uint32_t before_sched; @@ -31,14 +33,18 @@ static void test_task_1(void *arg) { static void test_task_2(void *arg) { test_context_t *context = (test_context_t *)arg; - uint32_t accumulator = 0; + uint64_t accumulator = 0; - for(int i = 0; i < 10000; i++) { + vTaskPrioritySet(NULL, CONFIG_UNITY_FREERTOS_PRIORITY + 1); + vTaskPrioritySet(context->t1_handle, CONFIG_UNITY_FREERTOS_PRIORITY + 1); + vPortYield(); + + for(int i = 0; i < NUMBER_OF_ITERATIONS; i++) { accumulator += (portGET_RUN_TIME_COUNTER_VALUE() - context->before_sched); vPortYield(); } - context->cycles_to_sched = accumulator / 10000; + context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS; vTaskDelete(context->t1_handle); xSemaphoreGive(context->end_sema); vTaskDelete(NULL); @@ -55,8 +61,8 @@ TEST_CASE("scheduling time test", "[freertos]") xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,1); xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,1); #else - xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,0); - xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,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); #endif BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY); diff --git a/components/idf_test/include/idf_performance.h b/components/idf_test/include/idf_performance.h index 9de9d9ceb4..23d2477b7f 100644 --- a/components/idf_test/include/idf_performance.h +++ b/components/idf_test/include/idf_performance.h @@ -92,5 +92,5 @@ //time to perform the task selection plus context switch (from task) #ifndef IDF_PERFORMANCE_MAX_SCHEDULING_TIME -#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 1500 +#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 2000 #endif