summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-09-12 15:26:33 +0200
committerKay Sievers <kay.sievers@suse.de>2005-09-12 15:26:33 +0200
commita8b38f1c44c8a925bef467c7fbca7812dfbf86f8 (patch)
treedb18eab90df9a6d5bc2c31f19c3cd03b8dacb212
parent852cc0f58dba9d101abf86880aaea4880222de47 (diff)
fic gcov use and move it into the Makefile
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
-rw-r--r--Makefile37
-rw-r--r--docs/README-gcov_for_udev (renamed from README-gcov_for_udev)42
-rw-r--r--make_gcov.sh53
-rw-r--r--run_gcov.sh40
4 files changed, 49 insertions, 123 deletions
diff --git a/Makefile b/Makefile
index 773041b02f..2017e7be3b 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,10 @@ USE_LOG = true
# to print the debug messages to syslog)
DEBUG = false
+# compile with gcc's code coverage option
+# (use it with DEBUG, works only with glibc)
+USE_GCOV = false
+
# include Security-Enhanced Linux support
USE_SELINUX = false
@@ -186,6 +190,11 @@ else
STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
endif
+ifeq ($(strip $(USE_GCOV)),true)
+ CFLAGS += -fprofile-arcs -ftest-coverage
+ LDFLAGS = -fprofile-arcs
+endif
+
# if our own version of klibc is used, we need to build it
ifeq ($(strip $(USE_KLIBC)),true)
KLIBC_INSTALL = $(PWD)/klibc/.install
@@ -291,6 +300,10 @@ ccdv: ccdv.c
clean:
- find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print0 | xargs -0rt rm -f
+ - find -name "*.gcno" -print0 | xargs -0rt rm -f
+ - find -name "*.gcda" -print0 | xargs -0rt rm -f
+ - find -name "*.gcov" -print0 | xargs -0rt rm -f
+ - rm -f udev_gcov.txt
- rm -f core $(PROGRAMS) $(GEN_HEADERS) $(GEN_CONFIGS)
$(MAKE) -C klibc SUBDIRS=klibc clean
@extras="$(EXTRAS)"; for target in $$extras; do \
@@ -397,4 +410,28 @@ test tests: all
buildtest:
./test/simple-build-check.sh
+.PHONY: buildtest
+
+gcov-all:
+ $(MAKE) clean all DEBUG=true USE_GCOV=true
+ @echo
+ @echo "binaries built with gcov support."
+ @echo "run the tests and analyze with 'make udev_gcov.txt'"
+.PHONY: gcov-all
+
+# see docs/README-gcov_for_udev
+udev_gcov.txt: $(wildcard *.gcda) $(wildcard *.gcno)
+ for file in `find -maxdepth 1 -name "*.gcno"`; do \
+ name=`basename $$file .gcno`; \
+ echo "################" >> $@; \
+ echo "$$name.c" >> $@; \
+ echo "################" >> $@; \
+ if [ -e "$$name.gcda" ]; then \
+ gcov -l "$$name.c" >> $@ 2>&1; \
+ else \
+ echo "code for $$name.c was never executed" >> $@ 2>&1; \
+ fi; \
+ echo >> $@; \
+ done; \
+ echo "view $@ for the result"
diff --git a/README-gcov_for_udev b/docs/README-gcov_for_udev
index ca832803a2..c223dc38e8 100644
--- a/README-gcov_for_udev
+++ b/docs/README-gcov_for_udev
@@ -2,6 +2,8 @@
Using GCC's code coverage tool, gcov, with udev
+Leann Ogasawara <ogasawara@osdl.org>, April 2004
+
################################################
For more information on using gcov please see:
@@ -13,14 +15,11 @@ Note that this was developed with udev version 024.
- Make sure you've installed udev and that it is working properly.
If you are having problems, refer to the README and HOWTO-udev_for_dev
- documents in udev tarball. I've also compiled a udev_for_dev
- toubleshooting document for Red Hat which can be found in:
-
- docs/rh_udev_for_dev.txt
+ documents in udev tarball.
- execute make_gcov.sh from udev top level directory
- ./make_gcov.sh
+ make gcov-all
This will compile udev with gcov support. Basically make_gcov.sh will
run make but override the CFLAGS. It strips any optimization from
@@ -28,21 +27,9 @@ Note that this was developed with udev version 024.
also add the -fprofile-arcs and -ftest-coverage options which are the
necessary flags needed to use gcov.
- make_gcov.sh will assume the same default parameters as the regular
- make but also accepts the same parameters. For example if you want
- to get code coverage analysis for udev with the DEBUG flag turned
- on, you would just execute:
-
- ./make_gcov.sh DEBUG=true
-
- There is one exception, gcov will not work with klibc as it does not
- compile cleanly with the -fprofile-arcs and -ftest-coverage flags.
- With this said it is pretty much useless to set the KERNEL_DIR flag
- when using make_gcov.sh as well.
-
- Don't be alarmed if you look into your udev directory and see that it
- has been polluted with a bunch of *.bb, *.bbg, *.da, and *.gcov files.
- gcov creates and uses these files to extract the code coverage info.
+ If you look into your udev directory and see that it has been polluted with
+ a bunch of *.gcno, *.gcda and *.gcov files. gcov creates and uses these files
+ to extract the code coverage info.
- After running make_gcov.sh you need to install udev again. So basically,
@@ -58,7 +45,7 @@ Note that this was developed with udev version 024.
level directory. You need to be root to do this.
su to root
- ./run_gcov.sh
+ make udev_gcov.txt
- This creates udev_gcov.txt in the udev top level directory which holds all
the code coverage information. To see an example of the code coverage info
@@ -95,14 +82,9 @@ Note that this was developed with udev version 024.
was never hit during execution.
- Once you are done with using gcov for udev and want to return to your
- normal use of udev. Simply,
-
- ./make_gcov.sh clean
+ normal use of udev, run a regular 'make clean' on your udev directory.
+ Then just run a regular make and make install and you are back to normal:
- This will clean out all the *.bb, *.bbg, *.da, *.gcov files produced by gcov.
- It will also run a regular make clean on your udev directory. Then just run
- a regular make and make install and you are back to normal:
-
- make
+ make clean all
su to root
- make isntall
+ make install
diff --git a/make_gcov.sh b/make_gcov.sh
deleted file mode 100644
index e3ceb96d07..0000000000
--- a/make_gcov.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh
-#
-# gcov capability for udev
-#
-# Provides code coverage analysis for udev.
-#
-# make_gcov.sh assumes the same same default parameters as make, but also
-# accepts the same parameters as make (see README file in udev/ for
-# parameter info). There is one exception, klibc can not be used with
-# gcov as it will not compile cleanly.
-#
-# make_gcov.sh then overrides CFLAGS to strip out optimization in order
-# for gcov to get correct code coverage analysis.
-#
-# Leann Ogasawara <ogasawara@osdl.org>, April 2004
-
-# clean up udev dir
-clean_udev () {
- find -name "*.gcno" -exec rm -f "{}" \;
- find -name "*.gcda" -exec rm -f "{}" \;
- find -name "*.gcov" -exec rm -f "{}" \;
- rm -f udev_gcov.txt
- make clean
-}
-
-PWD=`pwd`
-GCCINCDIR=`gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"`
-LIBSYSFS="-I$PWD/libsysfs/sysfs -I$PWD/libsysfs"
-WARNINGS="-Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
-GCC="-I$GCCINCDIR"
-USE_LOG="-DUSE_LOG"
-DEBUG="-D_GNU_SOURCE"
-GCOV_FLAGS="-pipe -fprofile-arcs -ftest-coverage"
-
-for i in $*; do
- pre=`echo $i | sed 's/=.*//g'`
- post=`echo $i | sed 's/.*=//g'`
- if [ $pre = "USE_KLIBC" ] && [ $post = "true" ]; then
- echo "cannot use gcov with klibc, will not compile"
- exit
- elif [ $pre = "USE_LOG" ] && [ $post = "false" ]; then
- USE_LOG=""
- elif [ $pre = "DEBUG" ] && [ $post = "true" ]; then
- DEBUG="-g -DDEBUG -D_GNU_SOURCE"
- elif [ $pre = "clean" ]; then
- clean_udev
- exit
- fi
-done
-
-clean_udev
-
-make $* CFLAGS="$WARNINGS $GCOV_FLAGS $USE_LOG $DEBUG $GCC $LIBSYSFS" LDFLAGS="-Wl,-warn-common -fprofile-arcs"
diff --git a/run_gcov.sh b/run_gcov.sh
deleted file mode 100644
index ad6a62b130..0000000000
--- a/run_gcov.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-#
-# run gcov on udev
-#
-# Generate code coverage analysis for udev files
-#
-# This requires that you compiled udev with gcov flags i.e.
-# you should have compiled udev with the make_gcov.sh script.
-#
-# Leann Ogasawara <ogasawara@osdl.org>, April 2004
-
-PWD=`pwd`
-
-# check if root else may not have access to *.da files
-# and gcov analysis will fail.
-if [ $(id -u) -ne 0 ]; then
- echo "please become root before executing run_gcov.sh"
- exit 1
-fi
-
-echo > udev_gcov.txt
-echo "CODE COVERAGE ANALYSIS FOR UDEV" >> udev_gcov.txt
-echo >> udev_gcov.txt
-
-for file in `find -maxdepth 1 -name "*.gcno"`; do
- name=`basename $file .gcno`
- echo "################" >> udev_gcov.txt
- echo "$name.c" >> udev_gcov.txt
- echo "################" >> udev_gcov.txt
- if [ -e "$name.gcda" ]; then
- gcov -l "$name.c" >> udev_gcov.txt 2>&1
- else
- echo "code for $name.c was never executed" >> udev_gcov.txt 2>&1
- echo "no code coverage analysis to be done" >> udev_gcov.txt 2>&1
- fi
- echo >> udev_gcov.txt
-done
-
-echo "udev gcov analysis done. View udev_gcov.txt for results."