Salome HOME
Merge from BR_V7_main_Field branch (02/09/2013)
[modules/geom.git] / src / XAO / tests / coverage_report.sh
1 #!/bin/bash
2
3 # This script can be used to generate the code coverage report.
4 # Important: the library needs to be compiled in debug mode and with coverage option
5 #            add to configure options:
6 #                CXXFLAGS="-fprofile-arcs -ftest-coverage"
7 #                CFLAGS="-fprofile-arcs -ftest-coverage"
8
9 # to run the script:
10 # > cd BUILD/GEOM/src/XAO
11 # > make
12 # > cd tests
13 # > make
14 # > cp ../.libs/*.gcno .
15 # > ./TestXAO
16 # > cp ../.libs/*.gcda .
17 # > ./coverage_report XAO
18
19 QUIET=--quiet
20 # report directory
21 REPORT_PATH=report
22 # browser to open the report
23 BROWSER=firefox
24 # name for the info file
25 TITLE=$1
26
27 # initialize
28 if [[ $TITLE == "--reset" ]]
29 then
30     lcov --base-directory . --directory . --zerocounters -q
31     echo "Reset counters"
32     exit 0
33 fi
34
35
36 if [ -z $TITLE ]
37 then
38     echo $TITLE "name is required"
39     exit 1
40 fi
41
42 INFO_FILE=${TITLE}.info
43 if [ -f $INFO_FILE ]
44 then
45     rm -f $INFO_FILE
46 fi
47
48 # collecte des données
49 lcov --directory . --capture --output-file $INFO_FILE
50
51 # suppression des symboles externes
52 lcov --remove $INFO_FILE "/usr*" -o $INFO_FILE $QUIET
53 # prerequisites
54 lcov --remove $INFO_FILE "/home2/*" -o $INFO_FILE $QUIET
55
56 # suppression des tests
57 lcov --remove $INFO_FILE "*/tests/*" -o $INFO_FILE $QUIET
58
59 # génération du rapport
60 genhtml --output-directory $REPORT_PATH --title $TITLE --num-spaces 4 $INFO_FILE
61
62 if [ ! -z $BROWSER ]
63 then
64     $BROWSER $REPORT_PATH/index.html &
65 fi