Test coverage for Python C modules

It's actually pretty easy to get some coverage statistics of C code, even with Python. You've just gotta grip it.

First, you shouldn't write half a script duplicating Tools/freeze/freeze.py in the Python distribution. Freezing for C libraries equals statically compiling! It's true.

Here's what I did, rougly:

  1. Copy my C extension's C file and header to Modules/;
  2. edit Modules/Setup.local, include a line saying foo foomodule.c -lblah;
  3. make clean
  4. ./config.status --recheck
  5. make coverage
  6. ./python.exe ~/path/to/tests.py
  7. gcov -o foomodule

So by the way, I have about 65% test coverage in pylibmc.


Comments

Comment the entry:

Name: (required, possibly pseudonym)
Remember me (cookie)

E-mail: (not required, never published, solely for me to reply to you in person)

URL:

Comment:

RSS 2.0