<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9844">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><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. Accept<br>--tested-only to disable modules which are not run by any test.<br>Enabling coverage also sets tested-only true by default. To build<br>everything with coverage enabled use `--coverage --tested-only=0`.<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>Add status output 5 times per stage of astobj2_test_perf to ensure<br>remote CLI does not timeout when compiled with coverage. Remote CLI<br>disconnects if no output is received for 60 seconds. When coverage is<br>enabled it takes about 70 seconds for my laptop to run the stages of<br>this test, so with the change a message is printed every 14 seconds.<br><br>Change-Id: I890f7d5665087426ad7d3e363187691b9afc2222<br>---<br>M tests/CI/buildAsterisk.sh<br>A tests/CI/processCoverage.sh<br>M tests/test_astobj2.c<br>M utils/Makefile<br>4 files changed, 98 insertions(+), 1 deletion(-)<br><br></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 71c390f..683b4bb 100755</span><br><span>--- a/tests/CI/buildAsterisk.sh</span><br><span>+++ b/tests/CI/buildAsterisk.sh</span><br><span>@@ -1,6 +1,7 @@</span><br><span> #!/usr/bin/env bash</span><br><span> </span><br><span> CIDIR=$(dirname $(readlink -fn $0))</span><br><span style="color: hsl(120, 100%, 40%);">+COVERAGE=0</span><br><span> REF_DEBUG=0</span><br><span> source $CIDIR/ci.functions</span><br><span> </span><br><span>@@ -28,6 +29,15 @@</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 $TESTED_ONLY ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # Skip building untested modules by default if coverage is enabled.</span><br><span style="color: hsl(120, 100%, 40%);">+ TESTED_ONLY=$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 $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 +73,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>@@ -81,6 +94,25 @@</span><br><span> runner menuselect/menuselect `gen_cats enable $cat_enables` menuselect.makeopts</span><br><span> </span><br><span> mod_disables="res_digium_phone chan_vpb"</span><br><span style="color: hsl(120, 100%, 40%);">+if [ $TESTED_ONLY -eq 1 ] ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # These modules are not tested at all. They are loaded but nothing is ever done</span><br><span style="color: hsl(120, 100%, 40%);">+ # with them, no testsuite tests depend on them.</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" app_adsiprog app_alarmreceiver app_celgenuserevent app_db app_dictate"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" app_dumpchan app_externalivr app_festival app_getcpeid app_ices app_image"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" app_jack app_milliwatt app_minivm app_morsecode app_mp3 app_nbscat app_privacy"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" app_readexten app_sms app_speech_utils app_test app_url app_waitforring"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" app_waitforsilence app_waituntil app_zapateller"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" cdr_adaptive_odbc cdr_custom cdr_manager cdr_odbc cdr_pgsql cdr_radius"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" cdr_syslog cdr_tds"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" cel_odbc cel_pgsql cel_radius cel_sqlite3_custom cel_tds"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" chan_alsa chan_console chan_mgcp chan_motif chan_oss chan_rtp chan_skinny chan_unistim"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" func_frame_trace func_pitchshift func_speex func_volume func_dialgroup"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" func_periodic_hook func_sprintf func_enum func_extstate func_sysinfo func_iconv"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" func_callcompletion func_version func_rand func_sha1 func_module func_md5"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" pbx_dundi pbx_loopback"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" res_ael_share res_calendar res_config_ldap res_config_pgsql res_corosync"</span><br><span style="color: hsl(120, 100%, 40%);">+ mod_disables+=" res_http_post res_pktccops res_rtp_multicast res_snmp res_xmpp"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span> [ "$BRANCH_NAME" == "master" ] && mod_disables+=" codec_opus codec_silk codec_g729a codec_siren7 codec_siren14"</span><br><span> runner menuselect/menuselect `gen_mods disable $mod_disables` menuselect.makeopts</span><br><span> </span><br><span>@@ -91,6 +123,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/processCoverage.sh b/tests/CI/processCoverage.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..b34ebee</span><br><span>--- /dev/null</span><br><span>+++ b/tests/CI/processCoverage.sh</span><br><span>@@ -0,0 +1,45 @@</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 [ ! -r main/asterisk.gcno ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # Coverage is not enabled.</span><br><span style="color: hsl(120, 100%, 40%);">+ exit 0</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 $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%);">+set -x</span><br><span style="color: hsl(120, 100%, 40%);">+# Capture counter data from testing</span><br><span style="color: hsl(120, 100%, 40%);">+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%);">+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%);">+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%);">+mkdir -p ${COVERAGE_DIR}</span><br><span style="color: hsl(120, 100%, 40%);">+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/tests/test_astobj2.c b/tests/test_astobj2.c</span><br><span>index 827ebb5..3158a66 100644</span><br><span>--- a/tests/test_astobj2.c</span><br><span>+++ b/tests/test_astobj2.c</span><br><span>@@ -1994,10 +1994,15 @@</span><br><span> {</span><br><span> int res = AST_TEST_PASS;</span><br><span> int i;</span><br><span style="color: hsl(120, 100%, 40%);">+ int reportcount = iterations / 5;</span><br><span> struct timeval start;</span><br><span> </span><br><span> start = ast_tvnow();</span><br><span> for (i = 1 ; i <= iterations && res == AST_TEST_PASS ; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (i % reportcount == 0 && i != iterations) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_test_status_update(test, "%5.2fK traversals, %9s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ i / 1000.0, test_container2str(type));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> res = test_performance(test, type, copt);</span><br><span> }</span><br><span> ast_test_status_update(test, "%5.2fK traversals, %9s : %5lu ms\n",</span><br><span>diff --git a/utils/Makefile b/utils/Makefile</span><br><span>index 9e7b08b..62e7551 100644</span><br><span>--- a/utils/Makefile</span><br><span>+++ b/utils/Makefile</span><br><span>@@ -180,7 +180,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 -lm</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.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/9844">change 9844</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/9844"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I890f7d5665087426ad7d3e363187691b9afc2222 </div>
<div style="display:none"> Gerrit-Change-Number: 9844 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>