1 /*
2 Test for multicore FreeRTOS. This test spins up threads, fiddles with queues etc.
3 */
4
5 #include <esp_types.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 #include "freertos/FreeRTOS.h"
10 #include "freertos/task.h"
11 #include "freertos/semphr.h"
12 #include "freertos/queue.h"
13 #include "unity.h"
14
15 volatile static int done;
16 volatile static int error;
17
tskTestRand(void * pvParameters)18 static void tskTestRand(void *pvParameters)
19 {
20 int l;
21 srand(0x1234);
22 vTaskDelay((int)pvParameters / portTICK_PERIOD_MS);
23 l = rand();
24 printf("Rand1: %d\n", l);
25 if (l != 869320854) {
26 error++;
27 }
28 vTaskDelay((int)pvParameters / portTICK_PERIOD_MS);
29 l = rand();
30 printf("Rand2: %d\n", l);
31 if (l != 1148737841) {
32 error++;
33 }
34 done++;
35 vTaskDelete(NULL);
36 }
37
38
39
40 // TODO: split this thing into separate orthogonal tests
41 TEST_CASE("Test for per-task non-reentrant tasks", "[freertos]")
42 {
43 done = 0;
44 error = 0;
45 xTaskCreatePinnedToCore(tskTestRand, "tsk1", 2048, (void *)100, 3, NULL, 0);
46 xTaskCreatePinnedToCore(tskTestRand, "tsk2", 2048, (void *)200, 3, NULL, 0);
47 xTaskCreatePinnedToCore(tskTestRand, "tsk3", 2048, (void *)300, 3, NULL, portNUM_PROCESSORS - 1);
48 xTaskCreatePinnedToCore(tskTestRand, "tsk4", 2048, (void *)400, 3, NULL, 0);
49 while (done != 4) {
50 vTaskDelay(1000 / portTICK_PERIOD_MS);
51 }
52 TEST_ASSERT(error == 0);
53 }
54