Parcourir la source

Merge branch 'feature/unit_test_config_components' into 'master'

unit-test-app: allow building subset of tests for a configuration

See merge request idf/esp-idf!2331
Ivan Grokhotkov il y a 7 ans
Parent
commit
f4d09506ad

+ 14 - 2
.gitlab-ci.yml

@@ -161,11 +161,11 @@ build_esp_idf_tests:
     expire_in: 6 mos
     expire_in: 6 mos
   script:
   script:
     - cd tools/unit-test-app
     - cd tools/unit-test-app
-    - make help # make sure kconfig tools are built in single process
+    - MAKEFLAGS= make help # make sure kconfig tools are built in single process
     - make ut-clean-all-configs
     - make ut-clean-all-configs
     - export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations"
     - export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations"
     - export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
     - export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
-    - make ut-build-all-configs TESTS_ALL=1
+    - make ut-build-all-configs
     - python tools/UnitTestParser.py
     - python tools/UnitTestParser.py
 
 
 .build_examples_template: &build_examples_template
 .build_examples_template: &build_examples_template
@@ -863,6 +863,18 @@ UT_001_27:
     - ESP32_IDF
     - ESP32_IDF
     - UT_T1_1
     - UT_T1_1
 
 
+UT_001_28:
+  <<: *unit_test_template
+  tags:
+    - ESP32_IDF
+    - UT_T1_1
+
+UT_001_29:
+  <<: *unit_test_template
+  tags:
+    - ESP32_IDF
+    - UT_T1_1
+
 UT_002_01:
 UT_002_01:
   <<: *unit_test_template
   <<: *unit_test_template
   tags:
   tags:

+ 2 - 1
components/bootloader/Makefile.projbuild

@@ -32,7 +32,8 @@ BOOTLOADER_MAKE= +\
 	V=$(V) \
 	V=$(V) \
 	BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
 	BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
 	TEST_COMPONENTS= \
 	TEST_COMPONENTS= \
-	TESTS_ALL=
+	TESTS_ALL= \
+	EXCLUDE_COMPONENTS=
 
 
 .PHONY: bootloader-clean bootloader-flash bootloader-list-components bootloader $(BOOTLOADER_BIN)
 .PHONY: bootloader-clean bootloader-flash bootloader-list-components bootloader $(BOOTLOADER_BIN)
 
 

+ 3 - 1
components/libsodium/test/component.mk

@@ -5,7 +5,9 @@
 LS_TESTDIR := ../libsodium/test/default
 LS_TESTDIR := ../libsodium/test/default
 LS_TEST_OBJDIR := libsodium/test/default
 LS_TEST_OBJDIR := libsodium/test/default
 
 
-ifdef TESTS_ALL
+TESTS_ALL ?= 0
+
+ifeq ($(TESTS_ALL),1)
 $(info not linking libsodium tests, use 'TEST_COMPONENTS=libsodium' to test it)
 $(info not linking libsodium tests, use 'TEST_COMPONENTS=libsodium' to test it)
 else
 else
 COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
 COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive

+ 2 - 1
make/project.mk

@@ -153,7 +153,8 @@ COMPONENTS := $(sort $(foreach comp,$(COMPONENTS),$(lastword $(subst /, ,$(comp)
 endif
 endif
 # After a full manifest of component names is determined, subtract the ones explicitly omitted by the project Makefile.
 # After a full manifest of component names is determined, subtract the ones explicitly omitted by the project Makefile.
 ifdef EXCLUDE_COMPONENTS
 ifdef EXCLUDE_COMPONENTS
-COMPONENTS := $(filter-out $(EXCLUDE_COMPONENTS), $(COMPONENTS))
+COMPONENTS := $(filter-out $(subst ",,$(EXCLUDE_COMPONENTS)), $(COMPONENTS)) 
+# to keep syntax highlighters happy: "))
 endif
 endif
 export COMPONENTS
 export COMPONENTS
 
 

+ 31 - 5
tools/unit-test-app/Makefile

@@ -5,10 +5,11 @@
 
 
 PROJECT_NAME := unit-test-app
 PROJECT_NAME := unit-test-app
 
 
-NON_INTERACTIVE_TARGET += ut-apply-config-% ut-clean-%
-
 include $(IDF_PATH)/make/project.mk
 include $(IDF_PATH)/make/project.mk
 
 
+ifeq ($(MAKELEVEL),0)
+# Define helper targets only when not recursing
+
 # List of unit-test-app configurations.
 # List of unit-test-app configurations.
 # Each file in configs/ directory defines a configuration. The format is the
 # Each file in configs/ directory defines a configuration. The format is the
 # same as sdkconfig file. Configuration is applied on top of sdkconfig.defaults
 # same as sdkconfig file. Configuration is applied on top of sdkconfig.defaults
@@ -61,12 +62,22 @@ $(BINARIES_DIR)/%/$(PROJECT_NAME).bin: configs/%
 	cat sdkconfig.defaults > $(BUILDS_DIR)/$*/sdkconfig.defaults
 	cat sdkconfig.defaults > $(BUILDS_DIR)/$*/sdkconfig.defaults
 	echo "" >> $(BUILDS_DIR)/$*/sdkconfig.defaults # in case there is no trailing newline in sdkconfig.defaults
 	echo "" >> $(BUILDS_DIR)/$*/sdkconfig.defaults # in case there is no trailing newline in sdkconfig.defaults
 	cat configs/$* >> $(BUILDS_DIR)/$*/sdkconfig.defaults
 	cat configs/$* >> $(BUILDS_DIR)/$*/sdkconfig.defaults
+
 	# Build, tweaking paths to sdkconfig and sdkconfig.defaults
 	# Build, tweaking paths to sdkconfig and sdkconfig.defaults
 	$(summary) BUILD_CONFIG $(BUILDS_DIR)/$*
 	$(summary) BUILD_CONFIG $(BUILDS_DIR)/$*
-	$(MAKE) defconfig all \
+	# 'TEST_COMPONENTS=names' option can be added to configs/$* to limit the set
+	# of tests to build for given configuration.
+	# Build all tests if this option is not present.
+	test_components=`sed -n 's/^TEST_COMPONENTS=\(.*\)/\1/p' configs/$*`; \
+		tests_all=`test -n "$${test_components}"; echo $${?}`; \
+		exclude_components=`sed -n 's/^EXCLUDE_COMPONENTS=\(.*\)/\1/p' configs/$*`; \
+	$(MAKE) defconfig list-components all \
 		BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
 		BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
 		SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
 		SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
-		SDKCONFIG_DEFAULTS=$(BUILDS_DIR)/$*/sdkconfig.defaults
+		SDKCONFIG_DEFAULTS=$(BUILDS_DIR)/$*/sdkconfig.defaults \
+		TEST_COMPONENTS="$${test_components}" \
+		TESTS_ALL=$${tests_all} \
+		EXCLUDE_COMPONENTS="$${exclude_components}"
 	$(MAKE) print_flash_cmd \
 	$(MAKE) print_flash_cmd \
 		BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
 		BUILD_DIR_BASE=$(BUILDS_DIR)/$* \
 		SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
 		SDKCONFIG=$(BUILDS_DIR)/$*/sdkconfig \
@@ -87,17 +98,32 @@ ut-help:
 	@echo "make ut-build-NAME - Build unit-test-app with configuration provided in configs/NAME."
 	@echo "make ut-build-NAME - Build unit-test-app with configuration provided in configs/NAME."
 	@echo "                  Build directory will be builds/NAME/, output binaries will be"
 	@echo "                  Build directory will be builds/NAME/, output binaries will be"
 	@echo "                  under output/NAME/"
 	@echo "                  under output/NAME/"
-	@echo "make ut-clean-NAME - Remove build and output directories for configuration NAME."
 	@echo ""
 	@echo ""
 	@echo "make ut-build-all-configs - Build all configurations defined in configs/ directory."
 	@echo "make ut-build-all-configs - Build all configurations defined in configs/ directory."
 	@echo ""
 	@echo ""
+	@echo "Above targets determine list of components to be built from configs/NAME files."
+	@echo "To build custom subset of components use 'make ut-apply-config-NAME' and then 'make all'."
+	@echo ""
 	@echo "make ut-apply-config-NAME - Generates configuration based on configs/NAME in sdkconfig"
 	@echo "make ut-apply-config-NAME - Generates configuration based on configs/NAME in sdkconfig"
 	@echo "                         file. After this, normal all/flash targets can be used."
 	@echo "                         file. After this, normal all/flash targets can be used."
 	@echo "                         Useful for development/debugging."
 	@echo "                         Useful for development/debugging."
 	@echo ""
 	@echo ""
+	@echo "make ut-clean-NAME - Remove build and output directories for configuration NAME."
+	@echo ""
 
 
 help: ut-help
 help: ut-help
 
 
 .PHONY: ut-build-all-configs ut-clean-all-configs \
 .PHONY: ut-build-all-configs ut-clean-all-configs \
 		$(CONFIG_BUILD_TARGETS) $(CONFIG_CLEAN_TARGETS) $(CONFIG_APPLY_TARGETS) \
 		$(CONFIG_BUILD_TARGETS) $(CONFIG_CLEAN_TARGETS) $(CONFIG_APPLY_TARGETS) \
 		ut-help
 		ut-help
+
+NON_INTERACTIVE_TARGET += ut-apply-config-% ut-clean-% ut-build-% \
+						  ut-build-all-configs ut-clean-all-configs
+
+else # MAKELEVEL == 0
+
+# If recursing, print the actual list of tests being built
+
+$(info TESTS $(foreach comp,$(TEST_COMPONENT_NAMES),$(patsubst %_test,%,$(comp))))
+
+endif # MAKELEVEL == 0

+ 15 - 0
tools/unit-test-app/components/unity/Kconfig

@@ -0,0 +1,15 @@
+menu "Unity test framework"
+
+config UNITY_FREERTOS_PRIORITY
+	int "Priority of Unity test task"
+	default 5
+
+config UNITY_FREERTOS_CPU
+	int "CPU to run Unity test task on"
+	default 0
+
+config UNITY_FREERTOS_STACK_SIZE
+	int "Stack size of Unity test task, in bytes"
+	default 8192
+
+endmenu

+ 4 - 2
tools/unit-test-app/components/unity/include/unity_config.h

@@ -8,10 +8,12 @@
 // Adapt Unity to our environment, disable FP support
 // Adapt Unity to our environment, disable FP support
 
 
 #include <esp_err.h>
 #include <esp_err.h>
+#include <sdkconfig.h>
 
 
 /* Some definitions applicable to Unity running in FreeRTOS */
 /* Some definitions applicable to Unity running in FreeRTOS */
-#define UNITY_FREERTOS_PRIORITY 5
-#define UNITY_FREERTOS_CPU 0
+#define UNITY_FREERTOS_PRIORITY CONFIG_UNITY_FREERTOS_PRIORITY
+#define UNITY_FREERTOS_CPU CONFIG_UNITY_FREERTOS_CPU
+#define UNITY_FREERTOS_STACK_SIZE CONFIG_UNITY_FREERTOS_STACK_SIZE
 
 
 #define UNITY_EXCLUDE_FLOAT
 #define UNITY_EXCLUDE_FLOAT
 #define UNITY_EXCLUDE_DOUBLE
 #define UNITY_EXCLUDE_DOUBLE

+ 1 - 1
tools/unit-test-app/configs/default

@@ -1 +1 @@
-# default config — nothing to set here
+EXCLUDE_COMPONENTS=libsodium

+ 2 - 0
tools/unit-test-app/configs/libsodium

@@ -0,0 +1,2 @@
+TEST_COMPONENTS=libsodium
+CONFIG_UNITY_FREERTOS_STACK_SIZE=12288

+ 1 - 0
tools/unit-test-app/configs/psram

@@ -1 +1,2 @@
+EXCLUDE_COMPONENTS=libsodium
 CONFIG_SPIRAM_SUPPORT=y
 CONFIG_SPIRAM_SUPPORT=y

+ 1 - 0
tools/unit-test-app/configs/single_core

@@ -1,2 +1,3 @@
+EXCLUDE_COMPONENTS=libsodium
 CONFIG_MEMMAP_SMP=n
 CONFIG_MEMMAP_SMP=n
 CONFIG_FREERTOS_UNICORE=y
 CONFIG_FREERTOS_UNICORE=y

+ 1 - 1
tools/unit-test-app/main/app_main.c

@@ -19,6 +19,6 @@ void app_main()
 
 
     // Note: if unpinning this task, change the way run times are calculated in
     // Note: if unpinning this task, change the way run times are calculated in
     // unity_platform
     // unity_platform
-    xTaskCreatePinnedToCore(unityTask, "unityTask", 8192, NULL,
+    xTaskCreatePinnedToCore(unityTask, "unityTask", UNITY_FREERTOS_STACK_SIZE, NULL,
                             UNITY_FREERTOS_PRIORITY, NULL, UNITY_FREERTOS_CPU);
                             UNITY_FREERTOS_PRIORITY, NULL, UNITY_FREERTOS_CPU);
 }
 }