From ae1389afd94e1a1343a3f660be06f055dae58a46 Mon Sep 17 00:00:00 2001 From: Sachin Parekh Date: Mon, 25 Mar 2019 16:15:02 +0530 Subject: [PATCH] unit-test-app: freertos_compliance config added Signed-off-by: Sachin Parekh --- .gitlab-ci.yml | 98 ++++++++++++++++++- components/driver/test/test_spi_master.c | 3 + components/freertos/Kconfig | 3 +- .../freertos/include/freertos/portmacro.h | 50 +++++++--- components/freertos/test/test_spinlocks.c | 4 +- .../unit-test-app/configs/freertos_compliance | 2 + 6 files changed, 142 insertions(+), 18 deletions(-) create mode 100644 tools/unit-test-app/configs/freertos_compliance diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 191745b780..d0a50037cf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1491,6 +1491,12 @@ UT_006_03: - UT_T1_GPIO UT_006_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_GPIO + +UT_006_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1516,6 +1522,12 @@ UT_007_03: - UT_T1_PCNT UT_007_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_PCNT + +UT_007_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1541,6 +1553,12 @@ UT_008_03: - UT_T1_LEDC UT_008_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_LEDC + +UT_008_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1566,6 +1584,12 @@ UT_009_03: - UT_T2_RS485 UT_009_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T2_RS485 + +UT_009_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1591,6 +1615,12 @@ UT_010_03: - UT_T1_RMT UT_010_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_RMT + +UT_010_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1669,6 +1699,12 @@ UT_013_03: - Example_SPI_Multi_device UT_013_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - Example_SPI_Multi_device + +UT_013_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1694,6 +1730,12 @@ UT_014_03: - UT_T2_I2C UT_014_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T2_I2C + +UT_014_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1719,6 +1761,12 @@ UT_015_03: - UT_T1_MCPWM UT_015_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_MCPWM + +UT_015_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1744,6 +1792,12 @@ UT_016_03: - UT_T1_I2S UT_016_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_I2S + +UT_016_05: <<: *unit_test_template tags: - ESP32_IDF @@ -1773,9 +1827,15 @@ UT_017_04: tags: - ESP32_IDF - UT_T2_1 - - psram UT_017_05: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T2_1 + - psram + +UT_017_06: <<: *unit_test_template tags: - ESP32_IDF @@ -1788,6 +1848,42 @@ UT_601_01: - ESP32_IDF - UT_T1_1 +UT_601_02: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + +UT_601_03: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + +UT_601_04: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + +UT_601_05: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + +UT_601_06: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + +UT_601_07: + <<: *unit_test_template + tags: + - ESP32_IDF + - UT_T1_1 + IT_001_01: <<: *test_template tags: diff --git a/components/driver/test/test_spi_master.c b/components/driver/test/test_spi_master.c index 6c54f5b012..d2542c0624 100644 --- a/components/driver/test/test_spi_master.c +++ b/components/driver/test/test_spi_master.c @@ -909,6 +909,9 @@ 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]; diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 7eeec02b93..777ca7b604 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -430,7 +430,8 @@ menu "FreeRTOS" bool "Tests compliance with Vanilla FreeRTOS port*_CRITICAL calls" default n help - If enabled, context of port*_CRITICAL calls (ISR or Non-ISR) would be checked to be in compliance with Vanilla FreeRTOS. + If enabled, context of port*_CRITICAL calls (ISR or Non-ISR) + would be checked to be in compliance with Vanilla FreeRTOS. e.g Calling port*_CRITICAL from ISR context would cause assert failure endmenu diff --git a/components/freertos/include/freertos/portmacro.h b/components/freertos/include/freertos/portmacro.h index 4072b65b43..7fd94d5a0b 100644 --- a/components/freertos/include/freertos/portmacro.h +++ b/components/freertos/include/freertos/portmacro.h @@ -213,14 +213,25 @@ void vTaskExitCritical( portMUX_TYPE *mux, const char *function, int line ); #ifdef CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE /* Calling port*_CRITICAL from ISR context would cause an assert failure. * If the parent function is called from both ISR and Non-ISR context then call port*_CRITICAL_SAFE - **/ -#define portENTER_CRITICAL(mux) do { \ - configASSERT(!xPortInIsrContext()); \ - vTaskEnterCritical(mux, __FUNCTION__, __LINE__); \ + */ +#define portENTER_CRITICAL(mux) do { \ + if(!xPortInIsrContext()) { \ + vTaskEnterCritical(mux, __FUNCTION__, __LINE__); \ + } else { \ + ets_printf("%s:%d (%s)- port*_CRITICAL called from ISR context!\n", __FILE__, __LINE__, \ + __FUNCTION__); \ + abort(); \ + } \ } while(0) -#define portEXIT_CRITICAL(mux) do { \ - configASSERT(!xPortInIsrContext()); \ - vTaskExitCritical(mux, __FUNCTION__, __LINE__); \ + +#define portEXIT_CRITICAL(mux) do { \ + if(!xPortInIsrContext()) { \ + vTaskExitCritical(mux, __FUNCTION__, __LINE__); \ + } else { \ + ets_printf("%s:%d (%s)- port*_CRITICAL called from ISR context!\n", __FILE__, __LINE__, \ + __FUNCTION__); \ + abort(); \ + } \ } while(0) #else #define portENTER_CRITICAL(mux) vTaskEnterCritical(mux, __FUNCTION__, __LINE__) @@ -247,14 +258,25 @@ void vPortCPUReleaseMutex(portMUX_TYPE *mux); #ifdef CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE /* Calling port*_CRITICAL from ISR context would cause an assert failure. * If the parent function is called from both ISR and Non-ISR context then call port*_CRITICAL_SAFE - **/ -#define portENTER_CRITICAL(mux) do { \ - configASSERT(!xPortInIsrContext()); \ - vTaskEnterCritical(mux); \ + */ +#define portENTER_CRITICAL(mux) do { \ + if(!xPortInIsrContext()) { \ + vTaskEnterCritical(mux); \ + } else { \ + ets_printf("%s:%d (%s)- port*_CRITICAL called from ISR context!\n", __FILE__, __LINE__, \ + __FUNCTION__); \ + abort(); \ + } \ } while(0) -#define portEXIT_CRITICAL(mux) do { \ - configASSERT(!xPortInIsrContext()); \ - vTaskExitCritical(mux); \ + +#define portEXIT_CRITICAL(mux) do { \ + if(!xPortInIsrContext()) { \ + vTaskExitCritical(mux); \ + } else { \ + ets_printf("%s:%d (%s)- port*_CRITICAL called from ISR context!\n", __FILE__, __LINE__, \ + __FUNCTION__); \ + abort(); \ + } \ } while(0) #else #define portENTER_CRITICAL(mux) vTaskEnterCritical(mux) diff --git a/components/freertos/test/test_spinlocks.c b/components/freertos/test/test_spinlocks.c index 7703b11753..59be39edde 100644 --- a/components/freertos/test/test_spinlocks.c +++ b/components/freertos/test/test_spinlocks.c @@ -40,8 +40,8 @@ TEST_CASE("portMUX spinlocks (no contention)", "[freertos]") BENCHMARK_START(); for (int i = 0; i < REPEAT_OPS; i++) { - portENTER_CRITICAL(&mux); - portEXIT_CRITICAL(&mux); + portENTER_CRITICAL_ISR(&mux); + portEXIT_CRITICAL_ISR(&mux); } BENCHMARK_END("no contention lock"); diff --git a/tools/unit-test-app/configs/freertos_compliance b/tools/unit-test-app/configs/freertos_compliance new file mode 100644 index 0000000000..2d7a6202c2 --- /dev/null +++ b/tools/unit-test-app/configs/freertos_compliance @@ -0,0 +1,2 @@ +TEST_COMPONENTS=driver esp32 spi_flash +CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE=y