]> granicus.if.org Git - esp-idf/commitdiff
unit test: adapt tests to single core configuration
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 18 Sep 2017 06:49:23 +0000 (14:49 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 19 Oct 2017 13:35:21 +0000 (21:35 +0800)
components/esp32/test/test_delay.c
components/esp32/test/test_fp.c
components/fatfs/test/test_fatfs_common.c
components/freertos/test/test_freertos_isinisrcontext.c
components/freertos/test/test_newlib_reent.c
components/freertos/test/test_preemption.c
components/freertos/test/test_spinlocks.c
components/newlib/test/test_time.c
components/spi_flash/test/test_spi_flash.c
components/spiffs/test/test_spiffs.c
components/wear_levelling/test/test_wl.c

index 7cecc0de759d643c5b5c08c205ed533abadc1334..b32299ec857fddd2c7b0c50564b8fdee2c9b4f82 100644 (file)
@@ -51,9 +51,11 @@ TEST_CASE("ets_delay produces correct delay on both CPUs", "[delay]")
     TEST_ASSERT( xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS) );
     TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
 
+#if portNUM_PROCESSORS == 2
     xTaskCreatePinnedToCore(test_delay_task, "", 2048, (void*) &args, 3, NULL, 1);
     TEST_ASSERT( xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS) );
     TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
+#endif
 
     ref_clock_deinit();
     vSemaphoreDelete(args.done);
@@ -72,9 +74,11 @@ TEST_CASE("vTaskDelay produces correct delay on both CPUs", "[delay]")
     TEST_ASSERT( xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS) );
     TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
 
+#if portNUM_PROCESSORS == 2
     xTaskCreatePinnedToCore(test_delay_task, "", 2048, (void*) &args, 3, NULL, 1);
     TEST_ASSERT( xSemaphoreTake(args.done, delay_ms * 2 / portTICK_PERIOD_MS) );
     TEST_ASSERT_INT32_WITHIN(1000, args.delay_us, args.result);
+#endif
 
     ref_clock_deinit();
     vSemaphoreDelete(args.done);
index 1b88e9722c1bc5d953c5a7810a8f1724449821ae..180999f9bcf1223b6140168d532c746912ce2e24 100644 (file)
@@ -180,7 +180,7 @@ TEST_CASE("context switch saves FP registers", "[fp]")
     state.fail = 0;
     xTaskCreatePinnedToCore(tskTestFP, "tsk1", 2048, &state, 3, NULL, 0);
     xTaskCreatePinnedToCore(tskTestFP, "tsk2", 2048, &state, 3, NULL, 0);
-    xTaskCreatePinnedToCore(tskTestFP, "tsk3", 2048, &state, 3, NULL, 1);
+    xTaskCreatePinnedToCore(tskTestFP, "tsk3", 2048, &state, 3, NULL, portNUM_PROCESSORS - 1);
     xTaskCreatePinnedToCore(tskTestFP, "tsk4", 2048, &state, 3, NULL, 0);
     while (state.done != 4) {
         vTaskDelay(100 / portTICK_PERIOD_MS);
index a2f35c3db7e146a9b8309bbaf5e7a3d209097eb4..ca27cdd4ba03d84b8da1364e118694e6bbd2a50e 100644 (file)
@@ -404,8 +404,10 @@ void test_fatfs_concurrent(const char* filename_prefix)
 
     printf("writing f1 and f2\n");
 
-    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, 1);
+    const int cpuid_0 = 0;
+    const int cpuid_1 = portNUM_PROCESSORS - 1;
+    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, cpuid_1);
 
     xSemaphoreTake(args1.done, portMAX_DELAY);
     printf("f1 done\n");
@@ -421,10 +423,10 @@ void test_fatfs_concurrent(const char* filename_prefix)
 
     printf("reading f1 and f2, writing f3 and f4\n");
 
-    xTaskCreatePinnedToCore(&read_write_task, "rw3", 2048, &args3, 3, NULL, 1);
-    xTaskCreatePinnedToCore(&read_write_task, "rw4", 2048, &args4, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, 1);
+    xTaskCreatePinnedToCore(&read_write_task, "rw3", 2048, &args3, 3, NULL, cpuid_1);
+    xTaskCreatePinnedToCore(&read_write_task, "rw4", 2048, &args4, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, cpuid_1);
 
     xSemaphoreTake(args1.done, portMAX_DELAY);
     printf("f1 done\n");
index a163688ccd93e8da6cc2fcfe9191a7a76df3c13c..085e60ddb0cfdf6e68b25d0635cc06f048b77ea2 100644 (file)
@@ -46,7 +46,9 @@ TEST_CASE("xPortInIsrContext test", "[freertos]")
 {
     xTaskCreatePinnedToCore(testthread, "tst" , 4096, NULL, 3, NULL, 0);
     vTaskDelay(150 / portTICK_PERIOD_MS);
+#if portNUM_PROCESSORS == 2
     xTaskCreatePinnedToCore(testthread, "tst" , 4096, NULL, 3, NULL, 1);
     vTaskDelay(150 / portTICK_PERIOD_MS);
+#endif
 }
 
index e0ec4aa458f9cd3fe1c089f7e8b1b9716597ea99..17346a6979fe9b9849f077f53a294209ee84f665 100644 (file)
@@ -50,7 +50,7 @@ TEST_CASE("Test for per-task non-reentrant tasks", "[freertos]")
     error = 0;
     xTaskCreatePinnedToCore(tskTestRand, "tsk1", 2048, (void *)100, 3, NULL, 0);
     xTaskCreatePinnedToCore(tskTestRand, "tsk2", 2048, (void *)200, 3, NULL, 0);
-    xTaskCreatePinnedToCore(tskTestRand, "tsk3", 2048, (void *)300, 3, NULL, 1);
+    xTaskCreatePinnedToCore(tskTestRand, "tsk3", 2048, (void *)300, 3, NULL, portNUM_PROCESSORS - 1);
     xTaskCreatePinnedToCore(tskTestRand, "tsk4", 2048, (void *)400, 3, NULL, 0);
     while (done != 4) {
         vTaskDelay(1000 / portTICK_PERIOD_MS);
index 83ab49bf433a0121c4bf429282c81c0e8723a6ba..62625600c4be5533a5adf72d45454572f8d38e27 100644 (file)
@@ -72,6 +72,7 @@ TEST_CASE("Yield from lower priority task, same CPU", "[freertos]")
 }
 
 
+#if portNUM_PROCESSORS == 2
 TEST_CASE("Yield from lower priority task, other CPU", "[freertos]")
 {
     uint32_t trigger_ccount, yield_ccount, now_ccount, delta;
@@ -106,3 +107,4 @@ TEST_CASE("Yield from lower priority task, other CPU", "[freertos]")
         vTaskDelete(sender_task);
     }
 }
+#endif // portNUM_PROCESSORS == 2
index 2ddbb07f855563d4ff21e7cf9e130fa80e0fccfe..68880ce93601e217a9dbfca24c4fe2890079bdc0 100644 (file)
@@ -62,6 +62,8 @@ TEST_CASE("portMUX recursive locks (no contention)", "[freertos]")
     BENCHMARK_END("no contention recursive");
 }
 
+#if portNUM_PROCESSORS == 2
+
 static volatile int shared_value;
 static portMUX_TYPE shared_mux;
 static xSemaphoreHandle done_sem;
@@ -130,4 +132,5 @@ TEST_CASE("portMUX high contention", "[freertos]")
     TEST_ASSERT_EQUAL_INT(REPEAT_OPS * TOTAL_TASKS, shared_value);
 }
 
+#endif // portNUM_PROCESSORS == 2
 
index a230a220bc1698f9ae5c9e4f48ed3ff653704a65..8cf9bc6c39c54a93a5dda7b91124c7102026b3a3 100644 (file)
@@ -11,6 +11,8 @@
 #include "sdkconfig.h"
 
 
+#if portNUM_PROCESSORS == 2
+
 // https://github.com/espressif/arduino-esp32/issues/120
 TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]")
 {
@@ -48,3 +50,4 @@ TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]")
     TEST_ASSERT_TRUE(xSemaphoreTake(done, 5000 / portTICK_RATE_MS));
 }
 
+#endif // portNUM_PROCESSORS == 2
index f3bd3dc104c66372a330438f10763c292eb23b73..e47cdf840c2312dea1719b3b4b78f8998d7b69db 100644 (file)
@@ -157,7 +157,7 @@ TEST_CASE("spi flash functions can run along with IRAM interrupts", "[spi_flash]
     timer_enable_intr(TIMER_GROUP_0, TIMER_0);
     timer_start(TIMER_GROUP_0, TIMER_0);
 
-    xTaskCreatePinnedToCore(read_task, "r", 2048, &read_arg, 3, NULL, 1);
+    xTaskCreatePinnedToCore(read_task, "r", 2048, &read_arg, 3, NULL, portNUM_PROCESSORS - 1);
     xSemaphoreTake(read_arg.done, portMAX_DELAY);
 
     timer_pause(TIMER_GROUP_0, TIMER_0);
index d60e4a54c46e21bba767917cf75c9e906bb39ca3..daf11ddc9493f83bf0cffb69c11c89efe4e419aa 100644 (file)
@@ -346,9 +346,10 @@ void test_spiffs_concurrent(const char* filename_prefix)
     read_write_test_arg_t args2 = READ_WRITE_TEST_ARG_INIT(names[1], 2);
 
     printf("writing f1 and f2\n");
-
-    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, 1);
+    const int cpuid_0 = 0;
+    const int cpuid_1 = portNUM_PROCESSORS - 1;
+    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, cpuid_1);
 
     xSemaphoreTake(args1.done, portMAX_DELAY);
     printf("f1 done\n");
@@ -364,10 +365,10 @@ void test_spiffs_concurrent(const char* filename_prefix)
 
     printf("reading f1 and f2, writing f3 and f4\n");
 
-    xTaskCreatePinnedToCore(&read_write_task, "rw3", 2048, &args3, 3, NULL, 1);
-    xTaskCreatePinnedToCore(&read_write_task, "rw4", 2048, &args4, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, 1);
+    xTaskCreatePinnedToCore(&read_write_task, "rw3", 2048, &args3, 3, NULL, cpuid_1);
+    xTaskCreatePinnedToCore(&read_write_task, "rw4", 2048, &args4, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw1", 2048, &args1, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw2", 2048, &args2, 3, NULL, cpuid_1);
 
     xSemaphoreTake(args1.done, portMAX_DELAY);
     printf("f1 done\n");
index c7d29bb1aee204efb6e6426de35569e1c22bd106..8aa3e6f4396fdea3932b8fff52ee559ee9913df3 100644 (file)
@@ -109,8 +109,10 @@ TEST_CASE("multiple tasks can access wl handle simultaneously", "[wear_levelling
     const size_t stack_size = 4096;
 
     printf("writing 1 and 2\n");
-    xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, 1);
+    const int cpuid_0 = 0;
+    const int cpuid_1 = portNUM_PROCESSORS - 1;
+    xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, cpuid_1);
 
     xSemaphoreTake(args1.done, portMAX_DELAY);
     printf("f1 done\n");
@@ -125,10 +127,10 @@ TEST_CASE("multiple tasks can access wl handle simultaneously", "[wear_levelling
     read_write_test_arg_t args4 = READ_WRITE_TEST_ARG_INIT(3 * sector_size, 4, handle, sector_size/sizeof(uint32_t));
 
     printf("reading 1 and 2, writing 3 and 4\n");
-    xTaskCreatePinnedToCore(&read_write_task, "rw3", stack_size, &args3, 3, NULL, 1);
-    xTaskCreatePinnedToCore(&read_write_task, "rw4", stack_size, &args4, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, 0);
-    xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, 1);
+    xTaskCreatePinnedToCore(&read_write_task, "rw3", stack_size, &args3, 3, NULL, cpuid_1);
+    xTaskCreatePinnedToCore(&read_write_task, "rw4", stack_size, &args4, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw1", stack_size, &args1, 3, NULL, cpuid_0);
+    xTaskCreatePinnedToCore(&read_write_task, "rw2", stack_size, &args2, 3, NULL, cpuid_1);
 
     xSemaphoreTake(args1.done, portMAX_DELAY);
     printf("f1 done\n");