]> granicus.if.org Git - python/commitdiff
GHOP #217: add support for compiling Python with coverage checking enabled.
authorGeorg Brandl <georg@python.org>
Sun, 18 May 2008 11:46:51 +0000 (11:46 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 18 May 2008 11:46:51 +0000 (11:46 +0000)
Makefile.pre.in
README

index 80043c24ad8944beb70b223b5a030035c51c3910..b692a4661e4b82f5df95e4b8b2172d19ec9013e3 100644 (file)
@@ -375,6 +375,12 @@ run_profile_task:
 build_all_use_profile:
        $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
 
+coverage:
+       @echo "Building with support for coverage checking:"
+       $(MAKE) clean
+       $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
+
+
 # Build the interpreter
 $(BUILDPYTHON):        Modules/python.o $(LIBRARY) $(LDLIBRARY)
                $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
diff --git a/README b/README
index e97bb17b93cdcf2b0e2880e6aabd1e7767e9983b..8f53ca43e42dc060fdc0d1062a08008a35911c18 100644 (file)
--- a/README
+++ b/README
@@ -917,6 +917,26 @@ libraries.  The Makefile/Setup mechanism can be used to compile and
 link most extension modules statically.
 
 
+Coverage checking
+-----------------
+
+For C coverage checking using gcov, run "make coverage".  This will
+build a Python binary with profiling activated, and a ".gcno" and
+".gcda" file for every source file compiled with that option.  With
+the built binary, now run the code whose coverage you want to check.
+Then, you can see coverage statistics for each individual source file
+by running gcov, e.g.
+
+    gcov -o Modules zlibmodule
+
+This will create a "zlibmodule.c.gcov" file in the current directory
+containing coverage info for that source file.
+
+This works only for source files statically compiled into the
+executable; use the Makefile/Setup mechanism to compile and link
+extension modules you want to coverage-check statically.
+
+
 Testing
 -------