testsuite: coveerage: support counters reset
Ability to reset gcov counters allows better isolation of tests coverage. Specifically it allows to: 1. Not include counters for any code that was executed prior running the test, which includes all the code executed during the board boot. 2. Run multiple tests without firmware reload by resetting counters between each. Signed-off-by: Roman Studenikin <srv@meta.com>
This commit is contained in:
parent
ed8c99977f
commit
179585e54b
2 changed files with 31 additions and 3 deletions
|
|
@ -132,12 +132,12 @@ size_t gcov_calculate_buff_size(struct gcov_info *info)
|
|||
}
|
||||
|
||||
/**
|
||||
* gcov_to_gcda - convert from gcov data set (info) to
|
||||
* gcov_populate_buffer - convert from gcov data set (info) to
|
||||
* .gcda file format.
|
||||
* This buffer will now have info similar to a regular gcda
|
||||
* format.
|
||||
*/
|
||||
size_t gcov_to_gcda(uint8_t *buffer, struct gcov_info *info)
|
||||
size_t gcov_populate_buffer(uint8_t *buffer, struct gcov_info *info)
|
||||
{
|
||||
struct gcov_fn_info *functions;
|
||||
struct gcov_ctr_info *counters_per_func;
|
||||
|
|
@ -232,6 +232,33 @@ size_t gcov_to_gcda(uint8_t *buffer, struct gcov_info *info)
|
|||
return buffer_write_position;
|
||||
}
|
||||
|
||||
void gcov_reset_counts(struct gcov_info *info)
|
||||
{
|
||||
struct gcov_fn_info *functions;
|
||||
struct gcov_ctr_info *counters_per_func;
|
||||
uint32_t iter_functions;
|
||||
uint32_t iter_counts;
|
||||
uint32_t iter_counter_values;
|
||||
|
||||
for (iter_functions = 0U;
|
||||
iter_functions < info->n_functions;
|
||||
iter_functions++) {
|
||||
|
||||
functions = info->functions[iter_functions];
|
||||
counters_per_func = functions->ctrs;
|
||||
|
||||
for (iter_counts = 0U;
|
||||
iter_counts < GCOV_COUNTERS;
|
||||
iter_counts++) {
|
||||
for (iter_counter_values = 0U;
|
||||
iter_counter_values < counters_per_func->num;
|
||||
iter_counter_values++) {
|
||||
counters_per_func->values[iter_counter_values] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dump_on_console_start(const char *filename)
|
||||
{
|
||||
printk("\n%c", FILE_START_INDICATOR);
|
||||
|
|
@ -274,7 +301,7 @@ void gcov_coverage_dump(void)
|
|||
goto coverage_dump_end;
|
||||
}
|
||||
|
||||
written_size = gcov_to_gcda(buffer, gcov_list);
|
||||
written_size = gcov_populate_buffer(buffer, gcov_list);
|
||||
if (written_size != size) {
|
||||
printk("Write Error on buff\n");
|
||||
goto coverage_dump_end;
|
||||
|
|
|
|||
|
|
@ -124,5 +124,6 @@ struct gcov_info {
|
|||
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);
|
||||
void gcov_reset_counts(struct gcov_info *info);
|
||||
|
||||
#endif /* _COVERAGE_H_ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue