test/blob: Use CFLAGS when checking CUnit version

If the CUnit include files are located through CFLAGS rather being
in one of the system include directories, then the version test will
fail and blob.c unit tests will be skipped. Specify CFLAGS as part of
the CC command.

If the version check fails, clean won't be run to remove any left over
artifacts. This can occur if CUnit is being built externally and gets
cleaned before SPDK. Add an extra definition (ALL_DIRS) to control
compilation, so that clean will always be run.

Signed-off-by: Nick Connolly <nick.connolly@mayadata.io>
Change-Id: I6099fceb14cfc6473a6b8feed746d2b44b8d291a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6054
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
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>
This commit is contained in:
Nick Connolly 2021-01-22 17:21:14 +00:00 committed by Tomasz Zawadzki
parent 2a0c2a2dcc
commit 9e422bd76a

View File

@ -34,17 +34,24 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..) SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
HASH = \# # Make targets are based on the current value of $(CUNIT_VERSION),
CUNIT_VERSION = $(shell echo "$(HASH)include <CUnit/CUnit.h>" | $(CC) -E -dM - | sed -n -e 's/\#define CU_VERSION "\([0-9\.\-]*\).*/\1/p') # rather than on configuration values. All sub-directories are
ifeq ($(CUNIT_VERSION),2.1-3) # added to $(DIRS-y) so that they are included in 'make clean'.
# $(ALL_DIRS) contains the list of sub-directories to compile.
DIRS-y = blob.c DIRS-y = blob.c
ALL_DIRS =
HASH = \#
CUNIT_VERSION = $(shell echo "$(HASH)include <CUnit/CUnit.h>" | $(CC) $(CFLAGS) -E -dM - | sed -n -e 's/\#define CU_VERSION "\([0-9\.\-]*\).*/\1/p')
ifeq ($(CUNIT_VERSION),2.1-3)
ALL_DIRS = blob.c
else else
$(warning "blob_ut.c compilation skipped, only CUnit version 2.1-3 is supported") $(warning "blob_ut.c compilation skipped, only CUnit version 2.1-3 is supported")
endif endif
.PHONY: all clean $(DIRS-y) .PHONY: all clean $(DIRS-y)
all: $(DIRS-y) all: $(ALL_DIRS)
clean: $(DIRS-y) clean: $(DIRS-y)
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk