tests: record coordinator's coverage #966
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Recording the coordinator's coverage is useful to determine, which parts of the component are executed during tests.
crossbar runs labgrid's coordinator component as a guest worker. Guest workers are spawned as subprocesses by crossbar. Therefore recording coverage of the coordinator component does not work out of the box.
To allow recording coordinator coverage, set the coverage command line tool as the
excutablein the crossbar configuration, whose 'run' subcommand works as a drop-in replacement for 'python'. This way the coverage of the guest worker is recorded separately. The--parallel-modeswitch makes coverage add a unique suffix to the coverage data file. Set the location of the coverage data via--data-fileto the root directory. pytest-cov automatically combines the coverage data in this directory.Since the crossbar process is forcefully terminated during the tests, the coverage data can not be written. Since the coverage tool registers an atexit SIGTERM handler to write its data, send crossbar SIGTERM, wait for any remaining output and the process to exit.
Now the coverage data contains labgrid's coordinator component.
Checklist