Salome HOME
52887a4b2921f05be4599c1155b1730eeeec93e1
[modules/shaper.git] / src / XAO / tests / coverage_report.sh
1 #!/bin/bash
2
3 # Copyright (C) 2013-2023  CEA, EDF
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 # This script can be used to generate the code coverage report.
23 # Important: the library needs to be compiled in debug mode and with coverage option
24 #            add to configure options:
25 #                CXXFLAGS="-fprofile-arcs -ftest-coverage"
26 #                CFLAGS="-fprofile-arcs -ftest-coverage"
27
28 # to run the script:
29 # > cd BUILD/GEOM/src/XAO
30 # > make
31 # > cd tests
32 # > make
33 # > cp ../.libs/*.gcno .
34 # > ./TestXAO
35 # > cp ../.libs/*.gcda .
36 # > ./coverage_report XAO
37
38 QUIET=--quiet
39 # report directory
40 REPORT_PATH=report
41 # browser to open the report
42 BROWSER=firefox
43 # name for the info file
44 TITLE=$1
45
46 # initialize
47 if [[ $TITLE == "--reset" ]]
48 then
49     lcov --base-directory . --directory . --zerocounters -q
50     echo "Reset counters"
51     exit 0
52 fi
53
54
55 if [ -z $TITLE ]
56 then
57     echo $TITLE "name is required"
58     exit 1
59 fi
60
61 INFO_FILE=${TITLE}.info
62 if [ -f $INFO_FILE ]
63 then
64     rm -f $INFO_FILE
65 fi
66
67 # collecte des données
68 lcov --directory . --capture --output-file $INFO_FILE
69
70 # suppression des symboles externes
71 lcov --remove $INFO_FILE "/usr*" -o $INFO_FILE $QUIET
72 # prerequisites
73 lcov --remove $INFO_FILE "/home2/*" -o $INFO_FILE $QUIET
74
75 # suppression des tests
76 lcov --remove $INFO_FILE "*/tests/*" -o $INFO_FILE $QUIET
77
78 # génération du rapport
79 genhtml --output-directory $REPORT_PATH --title $TITLE --num-spaces 4 $INFO_FILE
80
81 if [ ! -z $BROWSER ]
82 then
83     $BROWSER $REPORT_PATH/index.html &
84 fi