]> granicus.if.org Git - esp-idf/commitdiff
test: spiram: fix and enable test cases for default configuration
authorMahavir Jain <mahavir@espressif.com>
Mon, 19 Nov 2018 16:50:52 +0000 (22:20 +0530)
committerMahavir Jain <mahavir@espressif.com>
Mon, 19 Nov 2018 17:10:14 +0000 (22:40 +0530)
components/esp32/test/test_spiram_cache_flush.c

index a99f7226dbee771b100c3a1266541f11f0ffc30c..964ccde33d50eed2b1d672a25c1037b34ee48b27 100644 (file)
@@ -24,11 +24,15 @@ This code tests the interaction between PSRAM and SPI flash routines.
 #include "esp_partition.h"
 #include "test_utils.h"
 
+#if CONFIG_SPIRAM_SUPPORT
 
-#if CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MEMMAP
+#if CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC
+#define USE_CAPS_ALLOC 1
+#endif // CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC
 
 #define TSTSZ (16*1024)
 
+#if !CONFIG_FREERTOS_UNICORE
 
 volatile static int res[2], err[2];
 
@@ -51,11 +55,11 @@ void tstMem(void *arg) {
 }
 
 
-TEST_CASE("Spiram cache flush on mmap", "[spiram][ignore]")
+TEST_CASE("Spiram cache flush on mmap", "[spiram]")
 {
     void *mem[2];
     res[0]=0; res[1]=0;
-#if CONFIG_SPIRAM_USE_CAPS_ALLOC
+#if USE_CAPS_ALLOC
     printf("Allocating SPI RAM chunk...\n");
     mem[0]=heap_caps_malloc(TSTSZ, MALLOC_CAP_SPIRAM);
     mem[1]=heap_caps_malloc(TSTSZ, MALLOC_CAP_SPIRAM);
@@ -71,7 +75,6 @@ TEST_CASE("Spiram cache flush on mmap", "[spiram][ignore]")
     xTaskCreatePinnedToCore(tstMem  , "tskone"  , 2048, mem[0], 3, &th[0], 0);
     xTaskCreatePinnedToCore(tstMem  , "tsktwo"  , 2048, mem[1], 3, &th[1], 1);
 
-    const esp_partition_t* part = get_test_data_partition();
     for (int l=0; l<10; l++) {
         for (int p=0; p<4096*1024; p+=65536) {
             const void *out;
@@ -79,14 +82,13 @@ TEST_CASE("Spiram cache flush on mmap", "[spiram][ignore]")
             spi_flash_mmap(p, 65536, SPI_FLASH_MMAP_DATA, &out, &h);
             spi_flash_munmap(h);
         }
-        printf("%d/10\n", l);
     }
 
     printf("Checked memory %d and %d times. Errors: %d and %d\n", res[0], res[1], err[0], err[1]);
 
     vTaskDelete(th[0]);
     vTaskDelete(th[1]);
-#if CONFIG_SPIRAM_USE_CAPS_ALLOC
+#if USE_CAPS_ALLOC
     free(mem[0]);
     free(mem[1]);
 #endif
@@ -97,11 +99,11 @@ TEST_CASE("Spiram cache flush on mmap", "[spiram][ignore]")
 
 #define CYCLES 1024
 
-TEST_CASE("Spiram cache flush on write/read", "[spiram][ignore]")
+TEST_CASE("Spiram cache flush on write/read", "[spiram]")
 {
     void *mem[2];
     res[0]=0; res[1]=0;
-#if CONFIG_SPIRAM_USE_CAPS_ALLOC
+#if USE_CAPS_ALLOC
     printf("Allocating SPI RAM chunk...\n");
     mem[0]=heap_caps_malloc(TSTSZ, MALLOC_CAP_SPIRAM);
     mem[1]=heap_caps_malloc(TSTSZ, MALLOC_CAP_SPIRAM);
@@ -127,7 +129,6 @@ TEST_CASE("Spiram cache flush on write/read", "[spiram][ignore]")
     spi_flash_mmap_handle_t handle;
     esp_partition_mmap(part, 0, 512, SPI_FLASH_MMAP_DATA, &out, &handle);
     for (int i=0; i<CYCLES; i++) {
-        printf("%d/%d\n", i, CYCLES);
         esp_partition_write(part, 0, buf, 512);
         esp_partition_read(part, 0, buf, 512);
         vTaskDelay(1);
@@ -138,15 +139,16 @@ TEST_CASE("Spiram cache flush on write/read", "[spiram][ignore]")
 
     vTaskDelete(th[0]);
     vTaskDelete(th[1]);
-#if CONFIG_SPIRAM_USE_CAPS_ALLOC
+#if USE_CAPS_ALLOC
     free(mem[0]);
     free(mem[1]);
 #endif
 }
+#endif // !CONFIG_FREERTOS_UNICORE
 
-IRAM_ATTR TEST_CASE("Spiram memcmp weirdness at 80MHz", "[spiram][ignore]") {
+IRAM_ATTR TEST_CASE("Spiram memcmp weirdness at 80MHz", "[spiram]") {
     char *mem1=malloc(0x10000);
-#if CONFIG_SPIRAM_USE_CAPS_ALLOC
+#if USE_CAPS_ALLOC
     char *mem2=heap_caps_malloc(0x10000, MALLOC_CAP_SPIRAM);
 #else
     char *mem2=(void*)0x3f800000;
@@ -173,11 +175,11 @@ IRAM_ATTR TEST_CASE("Spiram memcmp weirdness at 80MHz", "[spiram][ignore]") {
             }
         }
     }
-}
-
-
-#endif  //CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MEMMAP
-
-
 
+    free(mem1);
+#if USE_CAPS_ALLOC
+    free(mem2);
+#endif
+}
 
+#endif // CONFIG_SPIRAM_SUPPORT