Skip to content

Commit

Permalink
testsuite: coverage: allow access to gcov internals
Browse files Browse the repository at this point in the history
This allows external applications wishing to report coverage data over
different interfaces the ability to do so by exposing the gcov list.

Signed-off-by: Joshua Lilly <[email protected]>
  • Loading branch information
jgl-meta committed Nov 29, 2023
1 parent b35cd5f commit b3cba84
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions subsys/testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ if(CONFIG_TEST)
zephyr_include_directories(${ZEPHYR_BASE}/subsys/testsuite/include)
endif()
add_subdirectory_ifdef(CONFIG_COVERAGE_GCOV coverage)
zephyr_include_directories_ifdef(CONFIG_COVERAGE_GCOV ${zephyr_BASE}/subsys/testsuite/coverage)

zephyr_library_sources_ifdef(CONFIG_TEST_BUSY_SIM busy_sim/busy_sim.c)
9 changes: 7 additions & 2 deletions subsys/testsuite/coverage/coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static inline void write_u32(void *buffer, size_t *off, uint32_t v)
*off = *off + sizeof(uint32_t);
}

size_t calculate_buff_size(struct gcov_info *info)
size_t gcov_calculate_buff_size(struct gcov_info *info)
{
uint32_t iter;
uint32_t iter_1;
Expand Down Expand Up @@ -266,7 +266,7 @@ void gcov_coverage_dump(void)
while (gcov_list) {

dump_on_console_start(gcov_list->filename);
size = calculate_buff_size(gcov_list);
size = gcov_calculate_buff_size(gcov_list);

buffer = k_heap_alloc(&gcov_heap, size, K_NO_WAIT);
if (CONFIG_COVERAGE_GCOV_HEAP_SIZE > 0 && !buffer) {
Expand Down Expand Up @@ -294,6 +294,11 @@ void gcov_coverage_dump(void)
return;
}

struct gcov_info *gcov_get_list_head(void)
{
/* Locking someway before getting this is recommended. */
return gcov_info_head;
}

/* Initialize the gcov by calling the required constructors */
void gcov_static_init(void)
Expand Down
8 changes: 8 additions & 0 deletions subsys/testsuite/coverage/coverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,12 @@ struct gcov_info {

};

/*
* These functions are in the header for easy access for external interface
* reporting since they aren't useful without the structs in this header.
*/
struct gcov_info *gcov_get_list_head(void);
size_t gcov_populate_buffer(uint8_t *buffer, struct gcov_info *info);
size_t gcov_calculate_buff_size(struct gcov_info *info);

#endif /* _COVERAGE_H_ */

0 comments on commit b3cba84

Please sign in to comment.