Skip to content
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

support code coverage in unit tests #28935

Closed
pabigot opened this issue Oct 5, 2020 · 5 comments · Fixed by #28968
Closed

support code coverage in unit tests #28935

pabigot opened this issue Oct 5, 2020 · 5 comments · Fixed by #28968
Assignees
Labels
Enhancement Changes/Updates/Additions to existing features

Comments

@pabigot
Copy link
Collaborator

pabigot commented Oct 5, 2020

Coverage of standard tests can be done with a command like:

sanitycheck --platform native_posix_64 -C -T tests/lib/onoff/

This doesn't seem to work for unit tests:

tirzah[93]$ sanitycheck --platform native_posix_64 -C -T tests/unit/timeutil/
Renaming output directory to /mnt/devel/zp/zephyr/sanity-out.8
INFO    - JOBS: 32
INFO    - Building initial testcase list...
INFO    - 0 test configurations selected, 0 configurations discarded due to filters.
INFO    - Adding tasks to the queue...

INFO    - 0 of 0 tests passed (0.00%), 0 failed, 0 skipped with 0 warnings in 0.31 seconds
INFO    - In total 0 test cases were executed on 0 out of total 289 platforms (0.00%)
INFO    - 0 tests executed on platforms, 0 tests were only built.
INFO    - Generating coverage files...
geninfo: WARNING: no .gcda files found in /mnt/devel/zp/zephyr/sanity-out - skipping!
lcov: ERROR: no valid records found in tracefile /mnt/devel/zp/zephyr/sanity-out/coverage.info
lcov: ERROR: no valid records found in tracefile /mnt/devel/zp/zephyr/sanity-out/coverage.info
lcov: ERROR: no valid records found in tracefile /mnt/devel/zp/zephyr/sanity-out/coverage.info
lcov: ERROR: no valid records found in tracefile /mnt/devel/zp/zephyr/sanity-out/coverage.info
genhtml: ERROR: no valid records found in tracefile /mnt/devel/zp/zephyr/sanity-out/coverage.info
tirzah[94]$

It'd be nice to have coverage for these tests.

@pabigot pabigot added the Enhancement Changes/Updates/Additions to existing features label Oct 5, 2020
@pabigot
Copy link
Collaborator Author

pabigot commented Oct 5, 2020

Not sure who should take this.

@nashif
Copy link
Member

nashif commented Oct 6, 2020

sanitycheck -p unit_testing -T tests/unit/crc --coverage

@nashif
Copy link
Member

nashif commented Oct 6, 2020

unit tests are not run with native_posix, they are built as host binaries, you need to use special board 'unit_testing' for this.

@pabigot
Copy link
Collaborator Author

pabigot commented Oct 6, 2020

OK, confirmed that this works. Seems like this should be documented somewhere, probably in coverage.rst. Do you want to do that @nashif or should I do it?

@nashif
Copy link
Member

nashif commented Oct 6, 2020

Do you want to do that @nashif or should I do it?

be my guest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants