Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions subsys/testsuite/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ config COVERAGE_DUMP

endchoice

config COVERAGE_DUMP_PATH_EXCLUDE
string "Exclude files matching this pattern from the coverage data"
default ""
help
Filenames are matched against the pattern using the POSIX fnmatch
function. Filenames are based on their path in the build folder, not the
original source tree. The empty string "" disables the pattern
matching.

endif # COVERAGE_GCOV

config FORCE_COVERAGE
Expand Down
7 changes: 7 additions & 0 deletions subsys/testsuite/coverage/coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <fnmatch.h>
#include "coverage.h"

K_HEAP_DEFINE(gcov_heap, CONFIG_COVERAGE_GCOV_HEAP_SIZE);
Expand Down Expand Up @@ -315,6 +316,11 @@ void gcov_coverage_dump(void)
}
printk("\nGCOV_COVERAGE_DUMP_START");
while (gcov_list) {
if ((strlen(CONFIG_COVERAGE_DUMP_PATH_EXCLUDE) > 0) &&
(fnmatch(CONFIG_COVERAGE_DUMP_PATH_EXCLUDE, gcov_list->filename, 0) == 0)) {
/* Don't print a note here, it would be interpreted as dump data */
goto file_dump_end;
}

dump_on_console_start(gcov_list->filename);
size = gcov_calculate_buff_size(gcov_list);
Expand All @@ -334,6 +340,7 @@ void gcov_coverage_dump(void)
dump_on_console_data(buffer, size);

k_heap_free(&gcov_heap, buffer);
file_dump_end:
gcov_list = gcov_list->next;
if (gcov_list_first == gcov_list) {
goto coverage_dump_end;
Expand Down
Loading