Development

How to use python coverage tool

chbae 2023. 4. 21. 04:07
728x90
반응형

Test Environment: Python3 and Poky (Yocto Reference System)

Installation

$ sudo pip3 install coverage

Run

$ git clone git://git.yoctoproject.org/poky  
$ cd poky  
$ source oe-init-build-env  
$ coverage3 run ../bitbake/bin/bitbake zip-native

Analysis

Result summary

".coverage" file is created in poky/build directory

$ coverage3 report

 

Result analysis in each files

"xxx.cover" files are created in each file's directory.

You can open the xxx,cover file using "vi" tool with "vim syntax"

 

Sometimes you need "sudo" to avoid error.

$ coverage3 annotate
$ vi bitbake,cover

 

Create reports as HTML type

$ coverage3 html

 

The htmlcov directory is created and to run webserver temporarily, you can use "python -m SimpleHTTPServer 9999 or python3 -m http.server 9999" command.

728x90