diff --git a/components/driver/test/test_spi_master.c b/components/driver/test/test_spi_master.c index 8dba1ee44..e6b426f9d 100644 --- a/components/driver/test/test_spi_master.c +++ b/components/driver/test/test_spi_master.c @@ -939,6 +939,9 @@ TEST_CASE("SPI master variable dummy test", "[spi]") /******************************************************************************** * Test SPI transaction interval ********************************************************************************/ +//Disabled since the check in portENTER_CRITICAL in esp_intr_enable/disable increase the delay +#ifndef CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE + #define RECORD_TIME_PREPARE() uint32_t __t1, __t2 #define RECORD_TIME_START() do {__t1 = xthal_get_ccount();}while(0) #define RECORD_TIME_END(p_time) do{__t2 = xthal_get_ccount(); *p_time = (__t2-__t1);}while(0) @@ -997,9 +1000,6 @@ static IRAM_ATTR void spi_transmit_polling_measure(spi_device_handle_t spi, spi_ TEST_CASE("spi_speed","[spi]") { -#ifdef CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE - return; -#endif uint32_t t_flight; //to get rid of the influence of randomly interrupts, we measured the performance by median value uint32_t t_flight_sorted[TEST_TIMES]; @@ -1025,7 +1025,7 @@ TEST_CASE("spi_speed","[spi]") for (int i = 0; i < TEST_TIMES; i++) { ESP_LOGI(TAG, "%.2lf", GET_US_BY_CCOUNT(t_flight_sorted[i])); } - TEST_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_NO_POLLING, "%d us", (int)GET_US_BY_CCOUNT(t_flight_sorted[(TEST_TIMES+1)/2])); + TEST_TARGET_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_NO_POLLING, "%d us", (int)GET_US_BY_CCOUNT(t_flight_sorted[(TEST_TIMES+1)/2])); //acquire the bus to send polling transactions faster ret = spi_device_acquire_bus(spi, portMAX_DELAY); @@ -1058,7 +1058,7 @@ TEST_CASE("spi_speed","[spi]") for (int i = 0; i < TEST_TIMES; i++) { ESP_LOGI(TAG, "%.2lf", GET_US_BY_CCOUNT(t_flight_sorted[i])); } - TEST_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_NO_POLLING_NO_DMA, "%d us", (int)GET_US_BY_CCOUNT(t_flight_sorted[(TEST_TIMES+1)/2])); + TEST_TARGET_PERFORMANCE_LESS_THAN(SPI_PER_TRANS_NO_POLLING_NO_DMA, "%d us", (int)GET_US_BY_CCOUNT(t_flight_sorted[(TEST_TIMES+1)/2])); //acquire the bus to send polling transactions faster ret = spi_device_acquire_bus(spi, portMAX_DELAY); @@ -1078,6 +1078,7 @@ TEST_CASE("spi_speed","[spi]") spi_device_release_bus(spi); master_free_device_bus(spi); } +#endif typedef struct { spi_device_handle_t handle; diff --git a/components/idf_test/include/idf_performance.h b/components/idf_test/include/idf_performance.h index 19ee6b0fe..55c523e37 100644 --- a/components/idf_test/include/idf_performance.h +++ b/components/idf_test/include/idf_performance.h @@ -6,10 +6,17 @@ #define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM 300 #define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE 130 #define IDF_PERFORMANCE_MAX_ESP_TIMER_GET_TIME_PER_CALL 1000 -#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_NO_POLLING 30 -#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_NO_POLLING_NO_DMA 27 + +#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_NO_POLLING_ESP32 30 +#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_NO_POLLING_NO_DMA_ESP32 27 + +#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_NO_POLLING_ESP32S2 32 +#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_NO_POLLING_NO_DMA_ESP32S2 30 + #define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_POLLING 15 #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 20000 diff --git a/tools/unit-test-app/components/test_utils/include/test_utils.h b/tools/unit-test-app/components/test_utils/include/test_utils.h index f9901bb9c..d01e45cdc 100644 --- a/tools/unit-test-app/components/test_utils/include/test_utils.h +++ b/tools/unit-test-app/components/test_utils/include/test_utils.h @@ -26,16 +26,37 @@ /* These macros should only be used with ESP-IDF. * To use performance check, we need to first define pass standard in idf_performance.h. */ + +//macros call this to expand an argument instead of directly converting into str +#define PERFORMANCE_STR(s) #s +//macros call this to contact strings after expanding them +#define PERFORMANCE_CON(a, b) _PERFORMANCE_CON(a, b) +#define _PERFORMANCE_CON(a, b) a##b + #define TEST_PERFORMANCE_LESS_THAN(name, value_fmt, value) do { \ - printf("[Performance]["#name"]: "value_fmt"\n", value); \ - TEST_ASSERT(value < IDF_PERFORMANCE_MAX_##name); \ + printf("[Performance]["PERFORMANCE_STR(name)"]: "value_fmt"\n", value); \ + TEST_ASSERT(value < PERFORMANCE_CON(IDF_PERFORMANCE_MAX_, name)); \ } while(0) #define TEST_PERFORMANCE_GREATER_THAN(name, value_fmt, value) do { \ - printf("[Performance]["#name"]: "value_fmt"\n", value); \ - TEST_ASSERT(value > IDF_PERFORMANCE_MIN_##name); \ + printf("[Performance]["PERFORMANCE_STR(name)"]: "value_fmt"\n", value); \ + TEST_ASSERT(value > PERFORMANCE_CON(IDF_PERFORMANCE_MIN_, name)); \ } while(0) +//Add more targets here, and corresponding performance requirements for that target in idf_performance.h +#ifdef CONFIG_IDF_TARGET_ESP32 +#define PERFORMANCE_TARGET_SUFFIX _ESP32 +#elif CONFIG_IDF_TARGET_ESP32S2BETA +#define PERFORMANCE_TARGET_SUFFIX _ESP32S2 +#else +#error target surfix not defined! +#endif + + +#define TEST_TARGET_PERFORMANCE_LESS_THAN(name, value_fmt, value) TEST_PERFORMANCE_LESS_THAN(PERFORMANCE_CON(name, PERFORMANCE_TARGET_SUFFIX), value_fmt, value) + +#define TEST_TARGET_PERFORMANCE_GREATER_THAN(name, value_fmt, value) TEST_PERFORMANCE_GREATER_THAN(PERFORMANCE_CON(name, PERFORMANCE_TARGET_SUFFIX), value_fmt, value) + /* @brief macro to print IDF performance * @param mode : performance item name. a string pointer.