0 votes
28 views

I want to enable the GCOV code coverage for my unit tests. I work in VSCode IDE and I am following their instructions to get the coverage working. But the ESP-IDF does not recognize the app_trace configuration parameters somehow and if I build the test project, I get the following errors:

Loading defaults file /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults...
/disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults:5 CONFIG_ESP_TASK_WDT was replaced with CONFIG_ESP_TASK_WDT_INIT
warning: unknown kconfig symbol 'APPTRACE_DEST_UART' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_DEST_NONE' assigned to 'n' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_ENABLE' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_LOCK_ENABLE' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_ONPANIC_HOST_FLUSH_TMO' assigned to '-1' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_POSTMORTEM_FLUSH_THRESH' assigned to '0' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_PENDING_DATA_SIZE_MAX' assigned to '0' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_GCOV_ENABLE' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults

Here is my sdkconfig.defults file

# Disable task WDT for tests
CONFIG_ESP_TASK_WDT_INIT=n

# Relay Channel Driver Default Configuration for Testing
# Keep this as short as possible for tests
CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS=200
CONFIG_RELAY_CHN_COUNT=2
CONFIG_RELAY_CHN_ENABLE_TILTING=y

# App Trace config
CONFIG_APPTRACE_DEST_JTAG=y
CONFIG_APPTRACE_ENABLE=y
CONFIG_APPTRACE_LOCK_ENABLE=y
CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO=-1
CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH=0
CONFIG_APPTRACE_PENDING_DATA_SIZE_MAX=0
CONFIG_APPTRACE_GCOV_ENABLE=y

And here is my test_apps/main/CMakeLists.txt

# === These files must be included in any case ===
set(srcs "test_common.c"
         "test_app_main.c"
         "test_relay_chn_core.c"
         "test_relay_chn_listener.c")

if(CONFIG_RELAY_CHN_ENABLE_TILTING)
    list(APPEND srcs "test_relay_chn_tilt.c")
endif()

message(STATUS "srcs=${srcs}")

# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(
    SRCS ${srcs}
    INCLUDE_DIRS "."
    REQUIRES unity relay_chn app_trace
    WHOLE_ARCHIVE
)

What am I missing?

in ESP-IDF by (1.4k points) | 28 views

1 Answer

0 votes
Best answer

This problem arises because the ESP-IDF can't find the configuration of the app_trace component. Although this wasn't mentioned in the relevant docs or the gcov example, the component should be declared in the test_app/main/CMakeLists.txt file as a REQUIRED component.

Here is the correct declaration so that you can see the app_trace configs in the SDK config menu:

idf_component_register(
    SRCS ${srcs}
    INCLUDE_DIRS "."
    REQUIRES unity relay_chn app_trace
    WHOLE_ARCHIVE
)

GCOV Enablement Checklist

  1. Make sure the and gcovr is installed by python -m pip install gcovr
  2. Add app_trace as REQUIRED in the relevant CMakeLists.txt file
  3. Add the --coverage compiler option for the relevant files to their specific cmake files. See Compiler Option for Gcov
  4. Configure the App Trace component correctly to be able to collect gcov data. See Project Configuration for Gcov
by (1.4k points)
edited by
Welcome to Kozmotronik Q&A, where you can ask questions and receive answers from other members of the community.