liboqs icon indicating copy to clipboard operation
liboqs copied to clipboard

Code coverage

Open tlepoint opened this issue 8 years ago • 1 comments

Add code coverage using coveralls

tlepoint avatar Aug 14 '17 01:08 tlepoint

In all honesty, I don't have a tonne of experience with setting up code coverage in non-Golang environments.

I think that https://coveralls.io looks very nice and has a good interface. That said, I'm always a little bit wary to adopt SaaS when there could be a more "long lived" solution. (for example, choosing astyle over clang-format despite astyle existing on Sourceforge)

I was recommended gcov as well. I'm probably going to read the manual for gcov and then give it a go. If anyone has firm opinions and/or recommendations, I would be very interested to hear them.

Seems like a lot of C test coverage tools are proprietary.

aidenfoxivey avatar Oct 02 '24 23:10 aidenfoxivey

Well, this is a bit later...

Image

(included image is of lcov being run to generate code coverage)

Turns out it wasn't actually that hard. I was just being kind of daft.

aidenfoxivey avatar Apr 17 '25 04:04 aidenfoxivey

I'm not 100% sure this actually makes 100% sense, so please do check me if something this diagnostic is showing seems inaccurate.

It seems like coveralls has a nice interface, but it's also just using gcov underneath.

So much for a diverse ecosystem of C code coverage tools! :)

aidenfoxivey avatar Apr 17 '25 04:04 aidenfoxivey

Thanks for revisiting this. Is this output for a single execution of test_kem for a BIKE algorithm? Is it able to aggregate coverage across multiple runs?

dstebila avatar Apr 17 '25 14:04 dstebila

Image

Yeah it appears to be able to do a decent job of aggregating across multiple tests being run. I just need to figure out how to run all the tests haha.

aidenfoxivey avatar Apr 18 '25 01:04 aidenfoxivey

Image

also works for AES.

aidenfoxivey avatar Apr 18 '25 01:04 aidenfoxivey

Seems to use pytest if I'm not wrong.

aidenfoxivey avatar Apr 18 '25 02:04 aidenfoxivey

Image

aidenfoxivey avatar Apr 18 '25 02:04 aidenfoxivey

Alright, looks like this is the approximate flow:

# build with --coverage flag
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="--coverage" -DCMAKE_CXX_FLAGS="--coverage" ..

# run files
<trying to sort this bit out>

# use lcov to automate running gcov for us
lcov --capture --directory . --output-file coverage.info

# generate an HTML report
genhtml coverage.info --output-directory coverage_html

aidenfoxivey avatar Apr 18 '25 02:04 aidenfoxivey

Hi @aidenfoxivey! I took a stab at this a couple of months ago but haven't had time to properly see it through. Maybe my branch would be helpful to you?

SWilson4 avatar Apr 21 '25 14:04 SWilson4

That's awesome. Thanks @SWilson4. I'll give that a look.

aidenfoxivey avatar Apr 21 '25 23:04 aidenfoxivey