Commit a988124d authored by Seth Howell's avatar Seth Howell Committed by Ben Walker
Browse files

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: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466816


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 2f2ffd98
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+9 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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"