chiark / gitweb /
fix dbg() callers
[elogind.git] / docs / README-gcov_for_udev
1 ################################################
2
3 Using GCC's code coverage tool, gcov, with udev
4
5 Leann Ogasawara <ogasawara@osdl.org>, April 2004
6
7 ################################################
8
9 For more information on using gcov please see:
10
11 http://gcc.gnu.org/onlinedocs/gcc/Gcov.html
12
13 With that said, here is how to get code coverage analysis for udev files.
14 Note that this was developed with udev version 024.
15
16 - Make sure you've installed udev and that it is working properly.
17
18 - Build udev with:
19     make gcov-all
20   This will compile udev with gcov support. If you look into your udev directory
21   and see that it has been polluted with a bunch of *.gcno, *.gcda and *.gcov files.
22   gcov creates and uses these files to extract the code coverage info.
23
24 - Then execute some udev tasks.  You can run some udev tests, reboot, or
25   do anything your little udev heart desires.  Once you are satisfied, you
26   can now see how much udev code was covered.  I personally recommend just
27   running test/udev-test.pl for starters.
28
29 - To get the udev code coverage analysis:
30     make udev_gcov.txt
31
32 - This creates udev_gcov.txt in the udev top level directory which holds all
33   the code coverage information. To see an example of the code coverage info
34   after executing the udev-test.pl test, please see:
35
36   http://developer.osdl.org/ogasawara/gcov_for_udev/udev_gcov.txt
37
38 - Also, after having executed gcov on udev (ie executing run_gcov.sh) a
39   *.gcov file is created for every file which contained code that was
40   used.  Looking at the *.gcov files, one will see what lines of code
41   were hit, and what lines were missed.  For, example if code in udev-add.c
42   were executed, gcov then created a file called udev-add.c.gcov.  And a
43   portion of udev-add.c.gov might look like:
44
45   static int get_major_minor(struct sysfs_class_device *class_dev, struct udevice *udev)
46           95    {
47           95            struct sysfs_attribute *attr = NULL;
48                 
49           95            attr = sysfs_get_classdev_attr(class_dev, "dev");
50           95            if (attr == NULL)
51       ######                    goto error;
52                         dbg("dev='%s'", attr->value);
53                 
54           95            if (sscanf(attr->value, "%u:%u", &udev->major, &udev->minor) != 2)
55       ######                    goto error;
56                         dbg("found major=%d, minor=%d", udev->major, udev->minor);
57                 
58           95            return 0;
59                 error:
60       ######            return -1;
61                 }
62
63   Any line of code that is preceded by a "######" implies that the code
64   was never hit during execution.
65
66 - Once you are done with using gcov for udev and want to return to your
67   normal use of udev, run a regular 'make clean' on your udev directory.
68   Then just run a regular make and make install and you are back to normal.