From 738c56e84a0ff3b71ffb72d33883541fe5c15c1a Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Fri, 23 Nov 2018 08:07:59 +0100 Subject: [PATCH] Fix VFS_OPEN_WRITE_CLOSE_TIME unit test issue Closes idf/esp-idf#44 --- components/idf_test/include/idf_performance.h | 4 ++-- components/vfs/test/CMakeLists.txt | 4 +++- components/vfs/test/component.mk | 2 ++ components/vfs/test/linker.lf | 6 ++++++ components/vfs/test/test_vfs_fd.c | 4 +++- 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 components/vfs/test/linker.lf diff --git a/components/idf_test/include/idf_performance.h b/components/idf_test/include/idf_performance.h index 3e7c841d7..0ba430e76 100644 --- a/components/idf_test/include/idf_performance.h +++ b/components/idf_test/include/idf_performance.h @@ -12,8 +12,8 @@ #define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_POLLING_NO_DMA 15 /* Due to code size & linker layout differences interacting with cache, VFS microbenchmark currently runs slower with PSRAM enabled. */ -#define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME 50000 -#define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME_PSRAM 40000 +#define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME 20000 +#define IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME_PSRAM 25000 // throughput performance by iperf #define IDF_PERFORMANCE_MIN_TCP_RX_THROUGHPUT 50 #define IDF_PERFORMANCE_MIN_TCP_TX_THROUGHPUT 40 diff --git a/components/vfs/test/CMakeLists.txt b/components/vfs/test/CMakeLists.txt index b3a707332..e67c253d0 100644 --- a/components/vfs/test/CMakeLists.txt +++ b/components/vfs/test/CMakeLists.txt @@ -3,4 +3,6 @@ set(COMPONENT_ADD_INCLUDEDIRS ".") set(COMPONENT_REQUIRES unity test_utils vfs fatfs spiffs) -register_component() \ No newline at end of file +set(COMPONENT_ADD_LDFRAGMENTS linker.lf) + +register_component() diff --git a/components/vfs/test/component.mk b/components/vfs/test/component.mk index ce464a212..5650ced1e 100644 --- a/components/vfs/test/component.mk +++ b/components/vfs/test/component.mk @@ -1 +1,3 @@ COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive + +COMPONENT_ADD_LDFRAGMENTS += linker.lf diff --git a/components/vfs/test/linker.lf b/components/vfs/test/linker.lf new file mode 100644 index 000000000..b623fc56b --- /dev/null +++ b/components/vfs/test/linker.lf @@ -0,0 +1,6 @@ +[mapping] +archive: libvfs.a +entries: + vfs:esp_vfs_open (noflash) + vfs:esp_vfs_write (noflash) + vfs:esp_vfs_close (noflash) diff --git a/components/vfs/test/test_vfs_fd.c b/components/vfs/test/test_vfs_fd.c index ff2c22e91..8dea92794 100644 --- a/components/vfs/test/test_vfs_fd.c +++ b/components/vfs/test/test_vfs_fd.c @@ -227,7 +227,7 @@ static int time_test_vfs_close(int fd) return 1; } -int time_test_vfs_write(int fd, const void *data, size_t size) +static int time_test_vfs_write(int fd, const void *data, size_t size) { return size; } @@ -255,6 +255,8 @@ TEST_CASE("Open & write & close through VFS passes performance test", "[vfs]") TEST_ASSERT_NOT_EQUAL(close(fd), -1); } + // esp_vfs_open, esp_vfs_write and esp_vfs_close need to be in IRAM for performance test to pass + const int64_t time_diff_us = esp_timer_get_time() - begin; const int ns_per_iter = (int) (time_diff_us * 1000 / iter_count); TEST_ESP_OK( esp_vfs_unregister(VFS_PREF1) );