test: spiram: fix and enable test cases for default configuration

pull/2749/head
Mahavir Jain 2018-11-19 22:20:52 +05:30
rodzic e3956787f6
commit 62efef0444
1 zmienionych plików z 20 dodań i 18 usunięć

Wyświetl plik

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