2

Using SWIG 2.0 to execute C code from python testing framework, pytest in my case.

Is there a way to configure SWIG to generate code coverage reports of the executed C code? some integration with bullseye, gcov or other similar tools?

Tried to look on the web and in SWIG documentation. Didn't find any useful resources. If there are any, please point me.

alexpov
  • 1,158
  • 2
  • 16
  • 29
  • I think that you should test C layer in isolation if this is your C code. If is third party them they should have tested their code. I'm not aware of any integration between gcov and pytest :/ – geckos Mar 21 '19 at 11:28
  • Related if not the same: https://stackoverflow.com/questions/39086957/test-coverage-from-swig-compiled-c-python-code – pmav99 Apr 18 '19 at 13:23

1 Answers1

1

Eventually compiled the code with gcov instrumentation and used gcovr to generate the coverage report. All worked fine.

To make this work, compile the code with the following flags (enables gcov instrumentation)

CFLAGS_VAL += -O0 --coverage

Then, execute the test, .gcno and .gcda files should be generated.

To create the report, run

gcovr -r . --filter="<src path>" --html --html-details -o coverage/coverage.html

GCOV docs, here

Same can create with lcov, follow an example in this wiki page

alexpov
  • 1,158
  • 2
  • 16
  • 29