Skip to content

Commit 61f2c68

Browse files
committed
Build: Fix coverage builds
1 parent ebf71a0 commit 61f2c68

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

configure.ac

+18-17
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,13 @@ AC_ARG_WITH(initdir,
295295
SUPPORT_PROFILING=0
296296
AC_ARG_WITH(profiling,
297297
[ --with-profiling
298-
Support gprof profiling ],
298+
Disable optimizations for effective profiling ],
299299
[ SUPPORT_PROFILING=$withval ])
300300

301-
SUPPORT_GCOV=0
302-
AC_ARG_WITH(gcov,
303-
[ --with-gcov
304-
Support gcov coverage testing ],
305-
[ SUPPORT_GCOV=$withval ])
301+
AC_ARG_WITH(coverage,
302+
[ --with-coverage
303+
Disable optimizations for effective profiling ],
304+
[ SUPPORT_COVERAGE=$withval ])
306305

307306
PUBLICAN_BRAND="common"
308307
AC_ARG_WITH(brand,
@@ -957,36 +956,38 @@ dnl ========================================================================
957956
dnl Profiling and GProf
958957
dnl ========================================================================
959958

960-
case $SUPPORT_GCOV in
959+
AC_MSG_NOTICE(Old CFLAGS: $CFLAGS)
960+
case $SUPPORT_COVERAGE in
961961
1|yes|true)
962962
SUPPORT_PROFILING=1
963+
PCMK_FEATURES="$PCMK_FEATURES coverage"
964+
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
965+
dnl During linking, make sure to specify -lgcov or -coverage
966+
967+
dnl Enable gprof
968+
#LIBS="$LIBS -pg"
969+
#CFLAGS="$CFLAGS -pg"
963970
;;
964971
esac
965972

966973
case $SUPPORT_PROFILING in
967974
1|yes|true)
968975
SUPPORT_PROFILING=1
969976

970-
dnl Enable gprof
971-
#LIBS="$LIBS -pg"
972-
#CFLAGS="$CFLAGS -pg"
973-
974977
dnl Disable various compiler optimizations
975-
CFLAGS="$CFLAGS -fno-omit-frame-pointer -fprofile-arcs -ftest-coverage -fno-inline"
976-
#CFLAGS="$CFLAGS -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls"
977-
dnl CFLAGS="$CFLAGS -fno-default-inline -fno-inline"
978+
CFLAGS="$CFLAGS -fno-omit-frame-pointer -fno-inline"
979+
dnl CFLAGS="$CFLAGS -fno-inline-functions -fno-default-inline -fno-inline-functions-called-once -fno-optimize-sibling-calls"
978980

979-
dnl Turn off optimization so code coverage tool can get accurate line numbers
980-
AC_MSG_NOTICE(Old CFLAGS: $CFLAGS)
981+
dnl Turn off optimization so tools can get accurate line numbers
981982
CFLAGS=`echo $CFLAGS | sed -e 's/-O.\ //g' -e 's/-Wp,-D_FORTIFY_SOURCE=.\ //g' -e 's/-D_FORTIFY_SOURCE=.\ //g'`
982983
CFLAGS="$CFLAGS -O0"
983-
AC_MSG_NOTICE(New CFLAGS: $CFLAGS)
984984

985985
dnl Update features
986986
PCMK_FEATURES="$PCMK_FEATURES profile"
987987
;;
988988
*) SUPPORT_PROFILING=0;;
989989
esac
990+
AC_MSG_NOTICE(New CFLAGS: $CFLAGS)
990991
AC_DEFINE_UNQUOTED(SUPPORT_PROFILING, $SUPPORT_PROFILING, Support for profiling)
991992

992993
dnl ========================================================================

coverage.sh.in

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
start=$PWD
34
test_home=`dirname $0`
45
sanitydir=@datadir@/@PACKAGE@/tests
56

@@ -27,7 +28,15 @@ else
2728
export GCOV_PREFIX_STRIP=4
2829
export GCOV_PREFIX=$GCOV_BASE
2930

30-
cd `rpm -ql pacemaker-debuginfo | grep include | head -n 1`/..
31+
top=`find / -name crm_internal.h 2>/dev/null | grep debug | head -n 1`
32+
if [ "x$top" = x ]; then
33+
echo "Could not locate the pacemaker headers"
34+
exit 1
35+
fi
36+
37+
cd `dirname $top`
38+
cd ..
39+
3140
echo "Creating the directory structure in $GCOV_BASE from $PWD"
3241
# The .gcno files will already be there for sources,
3342
# but we still need to create the include/ subtree
@@ -39,7 +48,7 @@ else
3948
find . -type f -name "*.debug" -exec ln -s $PWD/\{\} $GCOV_BASE\{\} \;
4049
fi
4150

42-
cd -
51+
cd $start
4352
lcov -d $GCOV_BASE -z
4453

4554
# Run all active regression tests
@@ -50,3 +59,4 @@ lcov -d $GCOV_BASE -c -o pacemaker.info
5059
rm -rf html
5160
mkdir html
5261
genhtml -o html pacemaker.info
62+

pacemaker.spec.in

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# Build with/without support for profiling tools
2525
%bcond_with profiling
2626

27+
# Include Build with/without support for performing coverage analysis
28+
%bcond_with coverage
29+
2730
# We generate docs using Publican, Asciidoc and Inkscape, but they're not available everywhere
2831
%bcond_without doc
2932

@@ -92,19 +95,19 @@ BuildRequires: bison byacc flex help2man gnutls-devel
9295
BuildRequires: systemd-devel
9396
%endif
9497

95-
%if "%{?_vendor}" == "redhat"
96-
9798
# If you want to build for unofficial installs of corosync-2 on RHEL < 7
9899
# or fedora < 17, remove all references to clusterlib-devel below
99100

101+
%if 0%{?fedora} > 0
100102
%if 0%{?fedora} < 17
101103
BuildRequires: clusterlib-devel
102104
%endif
105+
%endif
103106

107+
%if 0%{?rhel} > 0
104108
%if 0%{?rhel} < 7
105109
BuildRequires: clusterlib-devel
106110
%endif
107-
108111
%endif
109112

110113
Requires: corosync
@@ -137,7 +140,7 @@ when related resources fail and can be configured to periodically check
137140
resource health.
138141

139142
Available rpmbuild rebuild options:
140-
--with(out) : stonithd doc profiling pre_release upstart_job
143+
--with(out) : stonithd doc coverage profiling pre_release upstart_job
141144

142145
%package cli
143146
License: GPLv2+ and LGPLv2+
@@ -254,6 +257,7 @@ find . -exec touch \{\} \;
254257
# RHEL <= 5 does not support --docdir
255258
docdir=%{pcmk_docdir} %{configure} \
256259
%{?with_profiling: --with-profiling} \
260+
%{?with_coverage: --with-coverage} \
257261
--with-initdir=%{_initrddir} \
258262
--localstatedir=%{_var} \
259263
--with-version=%{version}-%{release}
@@ -301,7 +305,7 @@ rm -f %{buildroot}/%{_initrddir}/pacemaker
301305
rm -f %{buildroot}/%{_initrddir}/pacemaker_remote
302306
%endif
303307

304-
%if %{with profiling}
308+
%if %{with coverage}
305309
GCOV_BASE=%{buildroot}/%{_var}/lib/pacemaker/gcov
306310
mkdir -p $GCOV_BASE
307311
find . -name '*.gcno' -type f | while read F ; do
@@ -520,7 +524,7 @@ exit 0
520524
%{_datadir}/pacemaker/tests
521525
%{_includedir}/pacemaker
522526
%{_libdir}/*.so
523-
%if %{with profiling}
527+
%if %{with coverage}
524528
%{_var}/lib/pacemaker
525529
%endif
526530
%{_libdir}/pkgconfig/*.pc

0 commit comments

Comments
 (0)