From bc0eac579cf6de391f70298684f68355ec65ea39 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Wed, 25 Dec 2019 18:37:02 +0800 Subject: [PATCH] ut: add DISABLED_FOR_TARGETS macros to control ut building --- components/unity/include/unity_test_runner.h | 44 +++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/components/unity/include/unity_test_runner.h b/components/unity/include/unity_test_runner.h index 8e8b5a3dae..ee092d0fbb 100644 --- a/components/unity/include/unity_test_runner.h +++ b/components/unity/include/unity_test_runner.h @@ -174,14 +174,38 @@ void unity_run_all_tests(void); void unity_run_menu(void); -#include "sdkconfig.h" -#if CONFIG_IDF_TARGET_ESP32 -#define TEST_CASE_ESP32(...) TEST_CASE(__VA_ARGS__) -#define TEST_CASE_MULTIPLE_STAGES_ESP32(...) TEST_CASE_MULTIPLE_STAGES(__VA_ARGS__) -#define TEST_CASE_MULTIPLE_DEVICES_ESP32(...) TEST_CASE_MULTIPLE_DEVICES(__VA_ARGS__) -#else -#define TEST_CASE_ESP32(...) __attribute__((unused)) static void UNITY_TEST_UID(test_func_) (void) -#define TEST_CASE_MULTIPLE_STAGES_ESP32(_, __, ...) __attribute__((unused)) static test_func UNITY_TEST_UID(test_functions)[] = {__VA_ARGS__}; -#define TEST_CASE_MULTIPLE_DEVICES_ESP32(_, __, ...) __attribute__((unused)) static test_func UNITY_TEST_UID(test_functions)[] = {__VA_ARGS__}; +#include "sdkconfig.h" //to get IDF_TARGET_xxx -#endif +#define CONFIG_IDF_TARGET_NA 0 + +/* + * This macro is to disable those tests and their callees that cannot be built or run temporarily + * (needs update or runners). + * + * Usage: + * ``` + * #if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2BETA, ESP32S2) + * TEST_CASE("only for esp32", "") + * { + * } + * #endif + * ``` + */ +#define TEMPORARY_DISABLED_FOR_TARGETS(...) (_UNITY_DFT_10(__VA_ARGS__, NA, NA, NA, NA, NA, NA, NA, NA, NA)) + +/* + * This macro is to disable those tests and their callees that is totally impossible to run on the + * specific targets. Usage same as TEMPORARY_DISABLED_FOR_TARGETS. + */ +#define DISABLED_FOR_TARGETS(...) TEMPORARY_DISABLED_FOR_TARGETS(__VA_ARGS__) + +#define _UNITY_DFT_10(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_9(__VA_ARGS__)) +#define _UNITY_DFT_9(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_8(__VA_ARGS__)) +#define _UNITY_DFT_8(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_7(__VA_ARGS__)) +#define _UNITY_DFT_7(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_6(__VA_ARGS__)) +#define _UNITY_DFT_6(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_5(__VA_ARGS__)) +#define _UNITY_DFT_5(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_4(__VA_ARGS__)) +#define _UNITY_DFT_4(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_3(__VA_ARGS__)) +#define _UNITY_DFT_3(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_2(__VA_ARGS__)) +#define _UNITY_DFT_2(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET || _UNITY_DFT_1(__VA_ARGS__)) +#define _UNITY_DFT_1(TARGET, ...) (CONFIG_IDF_TARGET_##TARGET)