<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9557">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CI: Add support for coverage processing.<br><br>Enable coverage with `./tests/CI/buildAsterisk.sh --coverage`. This<br>will cause Asterisk to be compiled with coverage support. It also<br>initializes 'before' coverage data for all sources.<br><br>./tests/CI/processCoverage.sh is used to process the coverage and<br>generate HTML reports.<br><br>Fix utils/check_expr2 which failed to compiled with coverage enabled.<br><br>Change-Id: I890f7d5665087426ad7d3e363187691b9afc2222<br>---<br>M tests/CI/buildAsterisk.sh<br>M tests/CI/ci.functions<br>A tests/CI/processCoverage.sh<br>M utils/Makefile<br>4 files changed, 63 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/57/9557/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/CI/buildAsterisk.sh b/tests/CI/buildAsterisk.sh</span><br><span>index 9840d85..5262c8f 100755</span><br><span>--- a/tests/CI/buildAsterisk.sh</span><br><span>+++ b/tests/CI/buildAsterisk.sh</span><br><span>@@ -28,6 +28,10 @@</span><br><span> </span><br><span> [ x"$OUTPUT_DIR" != x ] && mkdir -p "$OUTPUT_DIR" 2&> /dev/null</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+if [ -z $LCOV_DIR ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+ LCOV_DIR="${OUTPUT_DIR:+${OUTPUT_DIR}/}lcov"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if [ x"$CACHE_DIR" != x ] ; then</span><br><span> mkdir -p "$CACHE_DIR/sounds $CACHE_DIR/externals" 2&> /dev/null</span><br><span> fi</span><br><span>@@ -63,6 +67,9 @@</span><br><span> common_config_args="--prefix=/usr ${_libdir:+--libdir=${_libdir}} --sysconfdir=/etc --with-pjproject-bundled"</span><br><span> common_config_args+=" ${CACHE_DIR:+--with-sounds-cache=${CACHE_DIR}/sounds --with-externals-cache=${CACHE_DIR}/externals}"</span><br><span> common_config_args+=" --enable-dev-mode"</span><br><span style="color: hsl(120, 100%, 40%);">+if [ $COVERAGE -eq 1 ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ common_config_args+=" --enable-coverage"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span> export WGET_EXTRA_ARGS="--quiet"</span><br><span> </span><br><span> runner ./configure ${common_config_args} > ${OUTPUT_DIR:+${OUTPUT_DIR}/}configure.txt</span><br><span>@@ -91,6 +98,21 @@</span><br><span> </span><br><span> runner ${MAKE} -j8 || runner ${MAKE} -j1 NOISY_BUILD=yes</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+runner rm -f ${LCOV_DIR}/*.info</span><br><span style="color: hsl(120, 100%, 40%);">+if [ $COVERAGE -eq 1 ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ runner mkdir -p ${LCOV_DIR}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ # Zero counter data</span><br><span style="color: hsl(120, 100%, 40%);">+ runner lcov --quiet --directory . --zerocounters</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ # Branch coverage is not supported by --initial. Disable to suppresses a notice</span><br><span style="color: hsl(120, 100%, 40%);">+ # printed if it was enabled in lcovrc.</span><br><span style="color: hsl(120, 100%, 40%);">+ # This initial capture ensures any module which was built but never loaded is</span><br><span style="color: hsl(120, 100%, 40%);">+ # reported with 0% coverage for all sources.</span><br><span style="color: hsl(120, 100%, 40%);">+ runner lcov --quiet --directory . --no-external --capture --initial --rc lcov_branch_coverage=0 \</span><br><span style="color: hsl(120, 100%, 40%);">+ --output-file ${LCOV_DIR}/initial.info</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ALEMBIC=$(which alembic 2>/dev/null || : )</span><br><span> if [ x"$ALEMBIC" = x ] ; then</span><br><span> echo "Alembic not installed"</span><br><span>diff --git a/tests/CI/ci.functions b/tests/CI/ci.functions</span><br><span>index 67616c2..662acb0 100644</span><br><span>--- a/tests/CI/ci.functions</span><br><span>+++ b/tests/CI/ci.functions</span><br><span>@@ -25,6 +25,6 @@</span><br><span> done</span><br><span> </span><br><span> runner() {</span><br><span style="color: hsl(0, 100%, 40%);">- ( set -x ; ${@} )</span><br><span style="color: hsl(120, 100%, 40%);">+ ( set -x ; "${@}" )</span><br><span> }</span><br><span> </span><br><span>diff --git a/tests/CI/processCoverage.sh b/tests/CI/processCoverage.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..a0953e5</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/processCoverage.sh</span><br><span>@@ -0,0 +1,39 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/usr/bin/env bash</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+CIDIR=$(dirname $(readlink -fn $0))</span><br><span style="color: hsl(120, 100%, 40%);">+source $CIDIR/ci.functions</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if [ -z $LCOV_DIR ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+ LCOV_DIR="${OUTPUT_DIR:+${OUTPUT_DIR}/}lcov"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if [ -z $COVERAGE_DIR ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+ COVERAGE_DIR="${OUTPUT_DIR:+${OUTPUT_DIR}/}coverage"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if [ -z $ASTERISK_VERSION ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+ ASTERISK_VERSION=$(./build_tools/make_version .)</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Capture counter data from testing</span><br><span style="color: hsl(120, 100%, 40%);">+runner lcov --no-external --capture --directory . --output-file ${LCOV_DIR}/tested.info > /dev/null</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Combine initial and tested data.</span><br><span style="color: hsl(120, 100%, 40%);">+runner lcov \</span><br><span style="color: hsl(120, 100%, 40%);">+ --add-tracefile ${LCOV_DIR}/initial.info \</span><br><span style="color: hsl(120, 100%, 40%);">+ --add-tracefile ${LCOV_DIR}/tested.info \</span><br><span style="color: hsl(120, 100%, 40%);">+ --output-file ${LCOV_DIR}/combined.info > /dev/null</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# We don't care about coverage reporting for tests, utils or third-party.</span><br><span style="color: hsl(120, 100%, 40%);">+runner lcov --remove ${LCOV_DIR}/combined.info \</span><br><span style="color: hsl(120, 100%, 40%);">+ "${PWD}/main/dns_test.*" \</span><br><span style="color: hsl(120, 100%, 40%);">+ "${PWD}/main/test.*" \</span><br><span style="color: hsl(120, 100%, 40%);">+ "${PWD}/tests/*" \</span><br><span style="color: hsl(120, 100%, 40%);">+ "${PWD}/utils/*" \</span><br><span style="color: hsl(120, 100%, 40%);">+ "${PWD}/third-party/*" \</span><br><span style="color: hsl(120, 100%, 40%);">+ --output-file ${LCOV_DIR}/filtered.info > /dev/null</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Generate HTML coverage report.</span><br><span style="color: hsl(120, 100%, 40%);">+runner mkdir -p ${COVERAGE_DIR}</span><br><span style="color: hsl(120, 100%, 40%);">+runner genhtml --prefix ${PWD} --ignore-errors source ${LCOV_DIR}/filtered.info \</span><br><span style="color: hsl(120, 100%, 40%);">+ --legend --title "Asterisk ${ASTERISK_VERSION}" --output-directory=${COVERAGE_DIR} > /dev/null</span><br><span>diff --git a/utils/Makefile b/utils/Makefile</span><br><span>index 6bd33da..2ec1b91 100644</span><br><span>--- a/utils/Makefile</span><br><span>+++ b/utils/Makefile</span><br><span>@@ -183,7 +183,7 @@</span><br><span> $(ECHO_PREFIX) echo " [CC] ast_expr2.c -> ast_expr2z.o"</span><br><span> $(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE2 $(ASTTOPDIR)/main/ast_expr2.c -o ast_expr2z.o</span><br><span> $(ECHO_PREFIX) echo " [LD] ast_expr2fz.o ast_expr2z.o -> check_expr2"</span><br><span style="color: hsl(0, 100%, 40%);">- $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o astmm.o -lm</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o astmm.o -lm $(_ASTLDFLAGS)</span><br><span> $(ECHO_PREFIX) echo " [RM] ast_expr2fz.o ast_expr2z.o"</span><br><span> rm ast_expr2z.o ast_expr2fz.o</span><br><span> ./check_expr2 expr2.testinput</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9557">change 9557</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9557"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I890f7d5665087426ad7d3e363187691b9afc2222 </div>
<div style="display:none"> Gerrit-Change-Number: 9557 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>