-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subsys: testsuite: coverage: support resetting counters #73034
base: main
Are you sure you want to change the base?
Conversation
Hello @srv-meta, and thank you very much for your first pull request to the Zephyr project! |
cc @nordic-piks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the indentation issue, commit needs a Signed-off-by: ..
, otherwise LGTM
A test would be nice to see. |
uint32_t iter_counts; | ||
uint32_t iter_counter_values; | ||
|
||
for (iter_functions = 0U; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this traversal code is copy paste? Maybe extract it into it's own function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it will make the code more readable. And I don't see any other place where it could be reused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this same file does the traversal of the gcov nodes a couple of times at least.
Last time I talked to @cfriedt we had discussed a function for traversal that took a function pointer to operate of the nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be kind of useful, even in terms of public API. The major benefit I think would be that external code could iterate over coverage data while keeping it in a single, private, location. This would enable coverage backends. Reduces code duplication.
Can be reused by (most?) existing function calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 3 nested loops here and there are actions that are needed to be done on each level. Do you propose to define a traversal method that contains these 3 loops and accepts 3 callback functions? And each function will receive a context consisting of multiple variables?
I really don't see how to make it in a simple way that would improve things. Please suggest the exact api you are proposing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is kind of an interesting proposal. I hadn't thought about it with three callbacks, each one being applied to each level.
What I was thinking is that mostly the "outer" two for loops are just finding out how to walk the counters. I was more thinking about a single function to operate on the specific counters themselves, which are really what the point of the code is in all of the places it is called. So the idea is, to provide something like a for each functionality for each counter.
@srv-meta Thanks for fixing gcov_populate_buffer to gcvo_to_gcda. I have one question, when (at which conditions)
has downside, especially for testing at HW, as during the board boot there are eg. drivers and peripherals initialized |
@nordic-piks |
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 <[email protected]>
This continues the work started by Joshua in #65842
Ability to reset gcov counters allows better isolation of tests
coverage. Specifically it allows to:
test, which includes all the code executed during the board boot.
between each.
I also undo renaming of gcov_populate_buffer to gcvo_to_gcda from bc8b7dd as it was actually a bug. The function was only renamed in .c, but not in the corresponding .h. I opted for returning it to original name to avoid breaking the public contract from the header.