Commit 6f2b8056 authored by Michal Berger's avatar Michal Berger Committed by Konrad Sztyber
Browse files

autotest: Stop rejecting coverage collection under clang



78d5bfe5 claimed that collecting coverage from a clang build
takes signficant amount of time, hence not being collected by
the autotest nor unittest.

However, currently this doesn't seem to be the case anymore.
To align coverage and make sure there are no any odd exceptions
let's have it always collected.

This also merges llvm coverage into the one collected by the
autotest instance as there's no point now to keep it separately.

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


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

# lcov takes considerable time to process clang coverage.
# Disabling lcov allow us to do this.
# More information: https://github.com/spdk/spdk/issues/1693
CC_TYPE=$(grep CC_TYPE mk/cc.mk)
if hash lcov && ! [[ "$CC_TYPE" == *"clang"* ]]; then
if hash lcov; then
	export LCOV_OPTS="
		--rc lcov_branch_coverage=1
		--rc lcov_function_coverage=1
@@ -77,6 +73,7 @@ if hash lcov && ! [[ "$CC_TYPE" == *"clang"* ]]; then
		--rc genhtml_function_coverage=1
		--rc genhtml_legend=1
		--rc geninfo_all_blocks=1
		$lcov_opt
		"
	export LCOV="lcov $LCOV_OPTS --no-external"
	# Print lcov version to log
@@ -399,7 +396,7 @@ chmod a+r $output_dir/timing.txt

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

if hash lcov && ! [[ "$CC_TYPE" == *"clang"* ]]; then
if hash lcov; 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
+10 −0
Original line number Diff line number Diff line
@@ -262,6 +262,16 @@ export AR_TOOL=$rootdir/scripts/ar-xnvme-fixer
# For testing nvmes which are attached to some sort of a fanout switch in the CI pool
export UNBIND_ENTIRE_IOMMU_GROUP=${UNBIND_ENTIRE_IOMMU_GROUP:-no}

_LCOV_MAIN=0
_LCOV_LLVM=1
_LCOV=$LCOV_MAIN
[[ $CC == *clang* || $SPDK_TEST_FUZZER -eq 1 ]] && _LCOV=$_LCOV_LLVM

_lcov_opt[_LCOV_LLVM]="--gcov-tool $rootdir/test/fuzz/llvm/llvm-gcov.sh"
_lcov_opt[_LCOV_MAIN]=""

lcov_opt=${_lcov_opt[_LCOV]}

# pass our valgrind desire on to unittest.sh
if [ $SPDK_RUN_VALGRIND -eq 0 ]; then
	export valgrind=''
+0 −50
Original line number Diff line number Diff line
@@ -14,59 +14,9 @@ llvm_out=$output_dir/llvm

mkdir -p $rootdir/../corpus/ $llvm_out

function lcov_start() {
	local out=$llvm_out/coverage
	local src=$rootdir

	mkdir -p $out

	if hash lcov; then
		export LCOV_OPTS="
			--rc lcov_branch_coverage=1
			--rc lcov_function_coverage=1
			--rc genhtml_branch_coverage=1
			--rc genhtml_function_coverage=1
			--rc genhtml_legend=1
			--rc geninfo_all_blocks=1
			--gcov-tool $rootdir/test/fuzz/llvm/llvm-gcov.sh
			"
		export LCOV="lcov $LCOV_OPTS --no-external"

		# Print lcov version to log
		$LCOV -v
		# zero out coverage data
		$LCOV -q -c -i -t "Baseline" -d $src -o $out/cov_base.info
	fi
}

function lcov_stop() {
	local out=$llvm_out/coverage
	local src=$rootdir

	if hash lcov; 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
		$LCOV -q -r $out/cov_total.info '*/dpdk/*' -o $out/cov_total.info
		$LCOV -q -r $out/cov_total.info '/usr/*' -o $out/cov_total.info
		rm -f cov_base.info cov_test.info OLD_STDOUT OLD_STDERR
	fi
}

# Collect coverage data when run fuzzers for longer period of time
# this allow to check coverage progression between runs, and grow of corpus files
if [[ $SPDK_TEST_FUZZER_SHORT -eq 0 ]]; then
	lcov_start
fi

for fuzzer in "${fuzzers[@]}"; do
	case "$fuzzer" in
		nvmf) run_test "nvmf_llvm_fuzz" "$testdir/llvm/$fuzzer/run.sh" ;;
		vfio) run_test "vfio_llvm_fuzz" "$testdir/llvm/$fuzzer/run.sh" ;;
	esac
done

if [[ $SPDK_TEST_FUZZER_SHORT -eq 0 ]]; then
	lcov_stop
	genhtml $llvm_out/coverage/cov_total.info --output-directory $llvm_out/coverage
fi
+6 −13
Original line number Diff line number Diff line
@@ -178,23 +178,15 @@ if [ $SPDK_RUN_VALGRIND -eq 1 ]; then
fi

# setup local unit test coverage if cov is available
# lcov takes considerable time to process clang coverage.
# Disabling lcov allow us to do this.
# More information: https://github.com/spdk/spdk/issues/1693
CC_TYPE=$(grep CC_TYPE $rootdir/mk/cc.mk)
if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' $rootdir/include/spdk/config.h && ! [[ "$CC_TYPE" == *"clang"* ]]; then
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
	# set unit test output dir if not specified in env var
	if [[ -z $output_dir ]]; then
		UT_COVERAGE="ut_coverage"
	else
	UT_COVERAGE=$output_dir/ut_coverage
	fi
	mkdir -p $UT_COVERAGE
	mkdir -p "$UT_COVERAGE"
	export LCOV_OPTS="
		--rc lcov_branch_coverage=1
		--rc lcov_function_coverage=1
@@ -202,6 +194,7 @@ if [ "$cov_avail" = "yes" ]; then
		--rc genhtml_function_coverage=1
		--rc genhtml_legend=1
		--rc geninfo_all_blocks=1
		$lcov_opt
		"
	export LCOV="lcov $LCOV_OPTS --no-external"
	# zero out coverage data
@@ -296,7 +289,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" ] && ! [[ "$CC_TYPE" == *"clang"* ]]; then
if [ "$cov_avail" = "yes" ]; 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