mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 23:54:33 +02:00
Merge branch 'bugfix/test_fp_switch' into 'master'
esp32: use semaphore in FP switch test, raise worker task priority See merge request espressif/esp-idf!7526
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include "soc/cpu.h"
|
#include "soc/cpu.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ TEST_CASE("test FP sqrt", "[fp]")
|
|||||||
|
|
||||||
struct TestFPState {
|
struct TestFPState {
|
||||||
int fail;
|
int fail;
|
||||||
int done;
|
SemaphoreHandle_t done;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int testFpIter = 100000;
|
static const int testFpIter = 100000;
|
||||||
@@ -175,22 +176,25 @@ static void tskTestFP(void *pvParameters)
|
|||||||
printf("%s: i=%d y=%f eps=%f\r\n", __func__, i, y, eps);
|
printf("%s: i=%d y=%f eps=%f\r\n", __func__, i, y, eps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state->done++;
|
TEST_ASSERT(xSemaphoreGive(state->done));
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("context switch saves FP registers", "[fp]")
|
TEST_CASE("context switch saves FP registers", "[fp]")
|
||||||
{
|
{
|
||||||
struct TestFPState state;
|
struct TestFPState state = {
|
||||||
state.done = 0;
|
.done = xSemaphoreCreateCounting(4, 0)
|
||||||
state.fail = 0;
|
};
|
||||||
xTaskCreatePinnedToCore(tskTestFP, "tsk1", 2048, &state, 3, NULL, 0);
|
TEST_ASSERT_NOT_NULL(state.done);
|
||||||
xTaskCreatePinnedToCore(tskTestFP, "tsk2", 2048, &state, 3, NULL, 0);
|
const int prio = UNITY_FREERTOS_PRIORITY + 1;
|
||||||
xTaskCreatePinnedToCore(tskTestFP, "tsk3", 2048, &state, 3, NULL, portNUM_PROCESSORS - 1);
|
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk1", 2048, &state, prio, NULL, 0));
|
||||||
xTaskCreatePinnedToCore(tskTestFP, "tsk4", 2048, &state, 3, NULL, 0);
|
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk2", 2048, &state, prio, NULL, 0));
|
||||||
while (state.done != 4) {
|
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk3", 2048, &state, prio, NULL, portNUM_PROCESSORS - 1));
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
TEST_ASSERT(xTaskCreatePinnedToCore(tskTestFP, "tsk4", 2048, &state, prio, NULL, 0));
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
TEST_ASSERT(xSemaphoreTake(state.done, pdMS_TO_TICKS(5000)));
|
||||||
}
|
}
|
||||||
|
vSemaphoreDelete(state.done);
|
||||||
if (state.fail) {
|
if (state.fail) {
|
||||||
const int total = testFpIter * 4;
|
const int total = testFpIter * 4;
|
||||||
printf("Failed: %d, total: %d\r\n", state.fail, total);
|
printf("Failed: %d, total: %d\r\n", state.fail, total);
|
||||||
|
Reference in New Issue
Block a user