make: override scan-build for unit tests.

The unit test mock macro function doesn't mesh well with the scan-build
static analysis tool. So we need to reset cc to the user provided value
or default before running the unit tests.

Change-Id: Ib636f6e396b09f9bf1cb8f930e6befa56ce99848
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466816
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Seth Howell 2019-08-29 09:18:37 -07:00 committed by Ben Walker
parent 2f2ffd98b0
commit a988124db9
3 changed files with 11 additions and 1 deletions

2
configure vendored
View File

@ -368,7 +368,7 @@ done
# Detect the compiler toolchain
$rootdir/scripts/detect_cc.sh --cc="$CC" --cxx="$CXX" --lto="${CONFIG[LTO]}" --ld="$LD" --cross-prefix="${CONFIG[CROSS_PREFIX]}" > $rootdir/mk/cc.mk
CC=$(cat $rootdir/mk/cc.mk | grep "CC=" | cut -d "=" -f 2)
CC=$(cat $rootdir/mk/cc.mk | grep "DEFAULT_CC=" | cut -d "=" -f 2)
CC_TYPE=$(cat $rootdir/mk/cc.mk | grep "CC_TYPE=" | cut -d "=" -f 2)
BUILD_CMD=($CC -o /dev/null -x c $CPPFLAGS $CFLAGS $LDFLAGS)

View File

@ -35,6 +35,15 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app_vars.mk
include $(SPDK_ROOT_DIR)/mk/spdk.mock.unittest.mk
# We don't want to run scan-build against the unit tests
# because it can't understand our mock function macros and
# throws false positives because of them.
# Scan-build inserts a phony compiler by overriding the value
# of CC, so we store the original CC under DEFAULT_CC and
# re-assign it here.
override CC=$(DEFAULT_CC)
C_SRCS = $(TEST_FILE)
CFLAGS += -I$(SPDK_ROOT_DIR)/lib

View File

@ -168,6 +168,7 @@ if [ -n "$CROSS_PREFIX" ]; then
fi
function set_default() {
echo "DEFAULT_$1=$2"
echo "ifeq (\$(origin $1),default)"
echo "$1=$2"
echo "endif"