mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
examples: Collects coverage info in component
This commit is contained in:
@@ -63,10 +63,12 @@ See the Getting Started Guide for full steps to configure and use ESP-IDF to bui
|
|||||||
The example will initially execute two hard-coded dumps. Therefore, when the application outputs `Ready to dump GCOV data...`, users should execute the `esp32 gcov dump` OpenOCD command. The example should output the following:
|
The example will initially execute two hard-coded dumps. Therefore, when the application outputs `Ready to dump GCOV data...`, users should execute the `esp32 gcov dump` OpenOCD command. The example should output the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
Counter = 0
|
blink_dummy_func: Counter = 0
|
||||||
|
some_dummy_func: Counter = 0
|
||||||
Ready to dump GCOV data...
|
Ready to dump GCOV data...
|
||||||
GCOV data have been dumped.
|
GCOV data have been dumped.
|
||||||
Counter = 1
|
blink_dummy_func: Counter = 1
|
||||||
|
some_dummy_func: Counter = 2
|
||||||
Ready to dump GCOV data...
|
Ready to dump GCOV data...
|
||||||
GCOV data have been dumped.
|
GCOV data have been dumped.
|
||||||
```
|
```
|
||||||
@@ -76,15 +78,24 @@ GCOV data have been dumped.
|
|||||||
After the two hard-coded dumps, the example will continue looping through it's main blink function. Users can call `esp32 gcov` OpenOCD command to trigger an instant run-time dump. The output should resemble the following:
|
After the two hard-coded dumps, the example will continue looping through it's main blink function. Users can call `esp32 gcov` OpenOCD command to trigger an instant run-time dump. The output should resemble the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
Counter = 2
|
blink_dummy_func: Counter = 2
|
||||||
Counter = 3
|
some_dummy_func: Counter = 4
|
||||||
Counter = 4
|
blink_dummy_func: Counter = 3
|
||||||
Counter = 5
|
some_dummy_func: Counter = 6
|
||||||
Counter = 6
|
blink_dummy_func: Counter = 4
|
||||||
Counter = 7
|
some_dummy_func: Counter = 8
|
||||||
Counter = 8
|
blink_dummy_func: Counter = 5
|
||||||
Counter = 9
|
some_dummy_func: Counter = 10
|
||||||
Counter = 10
|
blink_dummy_func: Counter = 6
|
||||||
|
some_dummy_func: Counter = 12
|
||||||
|
blink_dummy_func: Counter = 7
|
||||||
|
some_dummy_func: Counter = 14
|
||||||
|
blink_dummy_func: Counter = 8
|
||||||
|
some_dummy_func: Counter = 16
|
||||||
|
blink_dummy_func: Counter = 9
|
||||||
|
some_dummy_func: Counter = 18
|
||||||
|
blink_dummy_func: Counter = 10
|
||||||
|
some_dummy_func: Counter = 20
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -99,26 +110,30 @@ To clean Gcov and report related data from the build directory, call `cmake --bu
|
|||||||
The following log should be output when generating the coverage report:
|
The following log should be output when generating the coverage report:
|
||||||
|
|
||||||
```
|
```
|
||||||
Generating coverage report in: /home/alexey/projects/esp/esp-idf/examples/system/gcov/build/coverage_report
|
[1/1] Generating coverage report in: /home/user/projects/esp/tmp_idf/esp-idf/examples/system/gcov/build/coverage_report
|
||||||
Using gcov: ~/projects/esp/crosstool-NG/builds/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcov
|
Using gcov: xtensa-esp32-elf-gcov
|
||||||
Capturing coverage data from /home/alexey/projects/esp/esp-idf/examples/system/gcov/build
|
Capturing coverage data from /home/user/projects/esp/tmp_idf/esp-idf/examples/system/gcov/build
|
||||||
Found gcov version: 5.2.0
|
Found gcov version: 8.2.0
|
||||||
Scanning /home/alexey/projects/esp/esp-idf/examples/system/gcov/build for .gcda files ...
|
Using intermediate gcov format
|
||||||
Found 2 data files in /home/alexey/projects/esp/esp-idf/examples/system/gcov/build
|
Scanning /home/user/projects/esp/tmp_idf/esp-idf/examples/system/gcov/build for .gcda files ...
|
||||||
Processing main/gcov_example_func.gcda
|
Found 3 data files in /home/user/projects/esp/tmp_idf/esp-idf/examples/system/gcov/build
|
||||||
Processing main/gcov_example.gcda
|
Processing sample/CMakeFiles/__idf_sample.dir/some_funcs.c.gcda
|
||||||
|
Processing main/CMakeFiles/__idf_main.dir/gcov_example_func.c.gcda
|
||||||
|
Processing main/CMakeFiles/__idf_main.dir/gcov_example_main.c.gcda
|
||||||
Finished .info-file creation
|
Finished .info-file creation
|
||||||
Reading data file /home/alexey/projects/esp/esp-idf/examples/system/gcov/build/coverage_report/gcov_example.info
|
Reading data file /home/user/projects/esp/tmp_idf/esp-idf/examples/system/gcov/build/coverage_report/gcov_example.info
|
||||||
Found 2 entries.
|
Found 4 entries.
|
||||||
Found common filename prefix "/home/alexey/projects/esp/esp-idf/examples/system/gcov"
|
Found common filename prefix "/home/user/projects/esp/tmp_idf/esp-idf/examples/system/gcov"
|
||||||
Writing .css and .png files.
|
Writing .css and .png files.
|
||||||
Generating output.
|
Generating output.
|
||||||
Processing file main/gcov_example.c
|
Processing file /home/user/projects/esp/tmp_idf/esp-idf/components/freertos/include/freertos/task.h
|
||||||
|
Processing file components/sample/some_funcs.c
|
||||||
|
Processing file main/gcov_example_main.c
|
||||||
Processing file main/gcov_example_func.c
|
Processing file main/gcov_example_func.c
|
||||||
Writing directory view page.
|
Writing directory view page.
|
||||||
Overall coverage rate:
|
Overall coverage rate:
|
||||||
lines......: 90.0% (18 of 20 lines)
|
lines......: 100.0% (28 of 28 lines)
|
||||||
functions..: 100.0% (3 of 3 functions)
|
functions..: 100.0% (4 of 4 functions)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
6
examples/system/gcov/components/sample/CMakeLists.txt
Normal file
6
examples/system/gcov/components/sample/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
idf_component_register(SRCS "some_funcs.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
|
|
||||||
|
set_source_files_properties(some_funcs.c
|
||||||
|
PROPERTIES COMPILE_FLAGS
|
||||||
|
--coverage)
|
6
examples/system/gcov/components/sample/component.mk
Normal file
6
examples/system/gcov/components/sample/component.mk
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# "main" pseudo-component makefile.
|
||||||
|
#
|
||||||
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
|
|
||||||
|
CFLAGS += --coverage
|
10
examples/system/gcov/components/sample/some_funcs.c
Normal file
10
examples/system/gcov/components/sample/some_funcs.c
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
void some_dummy_func(void)
|
||||||
|
{
|
||||||
|
static int i;
|
||||||
|
printf("some_dummy_func: Counter = %d\n", i++);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
@@ -4,6 +4,6 @@
|
|||||||
void blink_dummy_func(void)
|
void blink_dummy_func(void)
|
||||||
{
|
{
|
||||||
static int i;
|
static int i;
|
||||||
printf("Counter = %d\n", i++);
|
printf("blink_dummy_func: Counter = %d\n", i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#define BLINK_GPIO CONFIG_BLINK_GPIO
|
#define BLINK_GPIO CONFIG_BLINK_GPIO
|
||||||
|
|
||||||
void blink_dummy_func(void);
|
void blink_dummy_func(void);
|
||||||
|
void some_dummy_func(void);
|
||||||
|
|
||||||
static void blink_task(void *pvParameter)
|
static void blink_task(void *pvParameter)
|
||||||
{
|
{
|
||||||
@@ -43,6 +44,7 @@ static void blink_task(void *pvParameter)
|
|||||||
gpio_set_level(BLINK_GPIO, 1);
|
gpio_set_level(BLINK_GPIO, 1);
|
||||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||||
blink_dummy_func();
|
blink_dummy_func();
|
||||||
|
some_dummy_func();
|
||||||
if (dump_gcov_after++ < 0) {
|
if (dump_gcov_after++ < 0) {
|
||||||
// Dump gcov data
|
// Dump gcov data
|
||||||
printf("Ready to dump GCOV data...\n");
|
printf("Ready to dump GCOV data...\n");
|
||||||
|
Reference in New Issue
Block a user