Commit 11abc273 authored by Michal Berger's avatar Michal Berger Committed by Konrad Sztyber
Browse files

test: Gather coverage when it's enabled in the build



This makes sure we always gather coverage when it's requested without
depending on lcov presence - if it's not available, we should just
fail hard.

Change-Id: Ifd5230e07edc013bb370ad13b2b964238e9d54a1
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24769


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 26f88ce7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ cd $src
freebsd_update_contigmem_mod
freebsd_set_maxsock_buf

if hash lcov; then
if [[ $CONFIG_COVERAGE == y ]]; then
	export LCOV_OPTS="
		--rc lcov_branch_coverage=1
		--rc lcov_function_coverage=1
@@ -396,7 +396,7 @@ chmod a+r $output_dir/timing.txt

[[ -f "$output_dir/udev.log" ]] && rm -f "$output_dir/udev.log"

if hash lcov; then
if [[ $CONFIG_COVERAGE == y ]]; then
	# generate coverage data and combine with baseline
	$LCOV -q -c -d $src -t "$(hostname)" -o $out/cov_test.info
	$LCOV -q -a $out/cov_base.info -a $out/cov_test.info -o $out/cov_total.info
+2 −9
Original line number Diff line number Diff line
@@ -177,14 +177,7 @@ if [ $SPDK_RUN_VALGRIND -eq 1 ]; then
	fi
fi

# setup local unit test coverage if cov is available
if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' $rootdir/include/spdk/config.h; then
	cov_avail="yes"
else
	cov_avail="no"
fi

if [ "$cov_avail" = "yes" ]; then
if [[ $CONFIG_COVERAGE == y ]]; then
	UT_COVERAGE=$output_dir/ut_coverage
	mkdir -p "$UT_COVERAGE"
	export LCOV_OPTS="
@@ -286,7 +279,7 @@ run_test "unittest_dma" $valgrind $testdir/lib/dma/dma.c/dma_ut
run_test "unittest_init" unittest_init
run_test "unittest_keyring" $valgrind "$testdir/lib/keyring/keyring.c/keyring_ut"

if [ "$cov_avail" = "yes" ]; then
if [[ $CONFIG_COVERAGE == y ]]; then
	$LCOV -q -d . -c -t "$(hostname)" -o $UT_COVERAGE/ut_cov_test.info
	$LCOV -q -a $UT_COVERAGE/ut_cov_base.info -a $UT_COVERAGE/ut_cov_test.info -o $UT_COVERAGE/ut_cov_total.info
	$LCOV -q -a $UT_COVERAGE/ut_cov_total.info -o $UT_COVERAGE/ut_cov_unit.info