Commit 1a14eb4e authored by Rui Chang's avatar Rui Chang Committed by Tomasz Zawadzki
Browse files

test/unit: fix "git clean" failure



In autorun.sh it executes autotest.sh as root. But in autotest.sh and
test/unit/unittest.sh, when run git clean -f'*.gcda', it may show errors like:

 08:03:54	-- unit/unittest.sh@277 -- # cd /home/jenkins/spdk_repo/spdk
 08:03:54	-- unit/unittest.sh@277 -- # git clean -f '*.gcda'
fatal: unsafe repository ('/home/jenkins/spdk_repo/spdk' is owned by someone else)

The reason is the spdk source folder owner may not be root but we run the git
clean command as root. Fix it by using the folder owner's id to do
the git clean operation.

Signed-off-by: default avatarRui Chang <rui.chang@arm.com>
Change-Id: Ifbd3098d4c32ffef5dcca738625302f63572e0c6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12693


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 13b6c53d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -347,6 +347,7 @@ if hash lcov && ! [[ "$CC_TYPE" == *"clang"* ]]; then
	$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
	git clean -f "*.gcda"
	owner=$(stat -c "%U" .)
	sudo -u $owner git clean -f "*.gcda"
	rm -f cov_base.info cov_test.info OLD_STDOUT OLD_STDERR
fi
+3 −1
Original line number Diff line number Diff line
@@ -274,7 +274,9 @@ if [ "$cov_avail" = "yes" ] && ! [[ "$CC_TYPE" == *"clang"* ]]; then
	rm -f $UT_COVERAGE/ut_cov_base.info $UT_COVERAGE/ut_cov_test.info
	genhtml $UT_COVERAGE/ut_cov_unit.info --output-directory $UT_COVERAGE
	# git -C option not used for compatibility reasons
	(cd $rootdir && git clean -f "*.gcda")
	owner=$(stat -c "%U" $rootdir)
	cd $rootdir
	sudo -u $owner git clean -f "*.gcda"
fi

set +x