Skip to content

Conversation

@Bastian-Krause
Copy link
Member

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 excutable in 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-mode switch makes coverage add a unique suffix to the coverage data file. Set the location of the coverage data via --data-file to 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

  • PR has been tested

Python allows running a module via 'python -mmodule' (single argument).
To be able to record the coordinator's coverage in a future commit,
'coverage run' is used instead of 'python'. The coverage tool is a
little pickier than python and requires '-m' and the actual module name
to be separate arguments.

Since it will not hurt to have the arguments separated generally, split
them.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
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 excutable in 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-mode' switch makes coverage add a unique suffix to the
coverage data file. Set the location of the coverage data via
'--data-file' to 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.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
@codecov
Copy link

codecov bot commented Aug 11, 2022

Codecov Report

Merging #966 (33fa0dd) into master (d0fc794) will increase coverage by 4.7%.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           master    #966     +/-   ##
========================================
+ Coverage    57.1%   61.8%   +4.7%     
========================================
  Files         150     150             
  Lines       11203   11203             
========================================
+ Hits         6402    6930    +528     
+ Misses       4801    4273    -528     
Impacted Files Coverage Δ
labgrid/remote/common.py 92.7% <0.0%> (+4.6%) ⬆️
labgrid/util/atomic.py 100.0% <0.0%> (+76.9%) ⬆️
labgrid/remote/coordinator.py 79.6% <0.0%> (+79.6%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jluebbe jluebbe merged commit 6ad1d66 into labgrid-project:master Aug 11, 2022
@Bastian-Krause Bastian-Krause deleted the bst/coordinator-coverage branch August 18, 2022 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants