Skip to contentSkip to conversation

binman: Switch to 'python-coverage'

RFC In review Tom Rini 2 participants 4 messages May 26, 2018 – Jun 7, 2018

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

RFC 1/1 binman: Switch to 'python-coverage'

The most portable way to get access to coverage is to invoke it as 'python-coverage'.

---
So, here's the set of problems I have. First, running 'pip install coverage' doesn't get me a 'coverage' binary, so I've just never made good use of 'make tests' and so never have these run. It also means they aren't strictly in travis-ci, so they're never run automatically. With this patch, make tests executes for me, and now fails noting that a lot of things don't have coverage. I'm honestly not sure what the best path forward here is.

---
 tools/binman/README    | 3 +--
 tools/binman/binman.py | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
tools/binman/README +1 -2
index b20098177ee9..5d55ed68e3da 100644
@@ -506,8 +506,7 @@ implementations target 100% test coverage. Run 'binman -T' to check this.
 
 To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
 
-   $ sudo apt-get install python-pip python-pytest
-   $ sudo pip install coverage
+   $ sudo apt-get install python-coverage python-pytest
 
 
 Advanced Features / Technical docs
tools/binman/binman.py +2 -2
index fa2f551f5542..447062dca167 100755
@@ -71,11 +71,11 @@ def RunTests(debug):
 def RunTestCoverage():
     """Run the tests and check that we get 100% coverage"""
     # This uses the build output from sandbox_spl to get _libfdt.so
-    cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools coverage run '
+    cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools python-coverage run '
             '--include "tools/binman/*.py" --omit "*test*,*binman.py" '
             'tools/binman/binman.py -t' % options.build_dir)
     os.system(cmd)
-    stdout = command.Output('coverage', 'report')
+    stdout = command.Output('python-coverage', 'report')
     lines = stdout.splitlines()
 
     test_set= set([os.path.basename(line.split()[0])
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw

Hi Tom,

Quoted 13 lines · Tom Rini

The most portable way to get access to coverage is to invoke it as 'python-coverage'.

---
So, here's the set of problems I have. First, running 'pip install coverage' doesn't get me a 'coverage' binary, so I've just never made good use of 'make tests' and so never have these run. It also means they aren't strictly in travis-ci, so they're never run automatically. With this patch, make tests executes for me, and now fails noting that a lot of things don't have coverage. I'm honestly not sure what the best path forward here is.

Quoted 5 lines
---
 tools/binman/README    | 3 +--
 tools/binman/binman.py | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

For me this patch works fine. The -T option works correctly.

Typing 'python-coverage html' produces this report:

https://pste.eu/p/NI7q.html

Note that your patch needs to update this line too:

print "Type 'coverage html' to get a report in htmlcov/index.html"

Can you send me the output you see?

Regards,
Simon

author
#2 lore raw
Quoted 28 lines · Simon Glass

Hi Tom,

Quoted 13 lines · Tom Rini

The most portable way to get access to coverage is to invoke it as 'python-coverage'.

---
So, here's the set of problems I have. First, running 'pip install coverage' doesn't get me a 'coverage' binary, so I've just never made good use of 'make tests' and so never have these run. It also means they aren't strictly in travis-ci, so they're never run automatically. With this patch, make tests executes for me, and now fails noting that a lot of things don't have coverage. I'm honestly not sure what the best path forward here is.

Quoted 5 lines
---
 tools/binman/README    | 3 +--
 tools/binman/binman.py | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

For me this patch works fine. The -T option works correctly.

Typing 'python-coverage html' produces this report:

Quoted 7 lines

https://pste.eu/p/NI7q.html

Note that your patch needs to update this line too:

print "Type 'coverage html' to get a report in htmlcov/index.html"

Can you send me the output you see?

So, I need to amend this a bit. On my Docker-based ubuntu 16.04 setup, I see as non-fatal (and not coverage related, but binman test):
<unittest.result.TestResult run=79 errors=0 failures=0> <unittest.result.TestResult run=11 errors=0 failures=4>
Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 218, in testGood
self.assertEqual(result.ok, True)
AssertionError: False != True

Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 252, in testIndent
self.assertEqual(len(result.problems), 1)
AssertionError: 2 != 1

Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 230, in testNoSignoff
self.assertEqual(len(result.problems), 1)
AssertionError: 2 != 1

Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 241, in testSpaces
self.assertEqual(len(result.problems), 3)
AssertionError: 4 != 3

Checking: https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/
<unittest.result.TestResult run=35 errors=0 failures=1>
Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/buildman/test.py", line 426, in testToolchainDownload
self.toolchains.LocateArchUrl('arm'))
AssertionError: 'https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.9.0/x86_64-gcc-4.9.0-nolibc_arm-unknown-linux-gnueabi.tar.xz' != 'https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/x86_64-gcc-7.3.0-nolibc_arm-linux-gnueabi.tar.xz'

<unittest.result.TestResult run=12 errors=0 failures=0> <unittest.result.TestResult run=79 errors=0 failures=0>

And then the coverage part works fine. With the changes in this RFC
patch so that my desktop itself could run coverage stuff I also see:
Missing tests for u_boot_with_ucode_ptr.py, u_boot_spl_bss_pad.py, entry.py, u_boot_spl.py, u_boot_spl_with_ucode_ptr.py, u_boot_spl_dtb.py, u_boot_img.py, intel_vbt.py, u_boot_dtb.py, intel_vga.py, intel_descriptor.py, u_boot_dtb_with_ucode.py, intel_cmc.py, x86_start16.py, u_boot_nodtb.py, u_boot.py, intel_fsp.py, blob.py, intel_mrc.py, u_boot_spl_nodtb.py, u_boot_ucode.py, x86_start16_spl.py, intel_me.py
ValueError: Test coverage failure
Tests FAILED
Makefile:1710: recipe for target 'tests' failed
make: *** [tests] Error 1

So I guess there's something wrong with trying to use coverage this way, rather than via pip.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180601/062c09c2/attachment.sig>
#3 lore raw

Hi Tom,

Quoted 57 lines · Tom Rini
Quoted 28 lines · Simon Glass

Hi Tom,

Quoted 13 lines · Tom Rini

The most portable way to get access to coverage is to invoke it as 'python-coverage'.

---
So, here's the set of problems I have. First, running 'pip install coverage' doesn't get me a 'coverage' binary, so I've just never made good use of 'make tests' and so never have these run. It also means they aren't strictly in travis-ci, so they're never run automatically. With this patch, make tests executes for me, and now fails noting that a lot of things don't have coverage. I'm honestly not sure what the best path forward here is.

Quoted 5 lines
---
 tools/binman/README    | 3 +--
 tools/binman/binman.py | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

For me this patch works fine. The -T option works correctly.

Typing 'python-coverage html' produces this report:

Quoted 7 lines

https://pste.eu/p/NI7q.html

Note that your patch needs to update this line too:

print "Type 'coverage html' to get a report in htmlcov/index.html"

Can you send me the output you see?

So, I need to amend this a bit. On my Docker-based ubuntu 16.04 setup, I see as non-fatal (and not coverage related, but binman test):
<unittest.result.TestResult run=79 errors=0 failures=0> <unittest.result.TestResult run=11 errors=0 failures=4>
Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 218, in testGood
self.assertEqual(result.ok, True)
AssertionError: False != True

Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 252, in testIndent
self.assertEqual(len(result.problems), 1)
AssertionError: 2 != 1

Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 230, in testNoSignoff
self.assertEqual(len(result.problems), 1)
AssertionError: 2 != 1

Quoted 5 lines

Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/patman/test.py", line 241, in testSpaces
self.assertEqual(len(result.problems), 3)
AssertionError: 4 != 3

This is new to the SPDX change in checkpatch. I'll send a pull request with a fix for this soon.

Quoted 6 lines

Checking: https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/
<unittest.result.TestResult run=35 errors=0 failures=1>
Traceback (most recent call last):
File "/home/trini/work/u-boot/u-boot/tools/buildman/test.py", line 426, in testToolchainDownload
self.toolchains.LocateArchUrl('arm'))
AssertionError: 'https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.9.0/x86_64-gcc-4.9.0-nolibc_arm-unknown-linux-gnueabi.tar.xz' != 'https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/7.3.0/x86_64-gcc-7.3.0-nolibc_arm-linux-gnueabi.tar.xz'

This is due to the version number changes. It needs a fix to the test.

Quoted 11 lines

<unittest.result.TestResult run=12 errors=0 failures=0> <unittest.result.TestResult run=79 errors=0 failures=0>

And then the coverage part works fine. With the changes in this RFC
patch so that my desktop itself could run coverage stuff I also see:
Missing tests for u_boot_with_ucode_ptr.py, u_boot_spl_bss_pad.py, entry.py, u_boot_spl.py, u_boot_spl_with_ucode_ptr.py, u_boot_spl_dtb.py, u_boot_img.py, intel_vbt.py, u_boot_dtb.py, intel_vga.py, intel_descriptor.py, u_boot_dtb_with_ucode.py, intel_cmc.py, x86_start16.py, u_boot_nodtb.py, u_boot.py, intel_fsp.py, blob.py, intel_mrc.py, u_boot_spl_nodtb.py, u_boot_ucode.py, x86_start16_spl.py, intel_me.py
ValueError: Test coverage failure
Tests FAILED
Makefile:1710: recipe for target 'tests' failed
make: *** [tests] Error 1

This looks like it is not getting any coverage info at all. Perhaps there is a complete test failure? Can you try:

binman -t

and see what tests fail?

Quoted 3 lines

So I guess there's something wrong with trying to use coverage this way, rather than via pip.

Maybe, but it works OK for me. Given that it works fine on travis (right?) I think we should apply your patch, with the additional change I mentioned in my previous email.

Regards,
Simon