hs-test: always build when running 'make build'

- running 'make build' will now always build docker images,
  'make test' will try to skip building them unless FORCE_BUILD=true
- now also checking ubuntu version

Type: make

Change-Id: Ie16e8dc4712963de19e2450e058b867c1cede7ee
Signed-off-by: Adrian Villin <avillin@cisco.com>
This commit is contained in:
Adrian Villin 2024-12-13 09:12:07 +01:00
parent ea360b570b
commit f5b832e729
2 changed files with 16 additions and 10 deletions

View File

@ -57,6 +57,8 @@ ifeq ($(ARCH),)
ARCH=$(shell dpkg --print-architecture) ARCH=$(shell dpkg --print-architecture)
endif endif
FORCE_BUILD?=true
.PHONY: help .PHONY: help
help: help:
@echo "Make targets:" @echo "Make targets:"
@ -74,6 +76,7 @@ help:
@echo @echo
@echo "'make build' and 'make test' arguments:" @echo "'make build' and 'make test' arguments:"
@echo " UBUNTU_VERSION - ubuntu version for docker image" @echo " UBUNTU_VERSION - ubuntu version for docker image"
@echo " FORCE_BUILD=[true|false] - force docker image building"
@echo @echo
@echo "'make test' specific arguments:" @echo "'make test' specific arguments:"
@echo " PERSIST=[true|false] - whether clean up topology and dockers after test" @echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
@ -115,6 +118,7 @@ build-vpp-gcov:
@touch .build.ok @touch .build.ok
.PHONY: test .PHONY: test
test: FORCE_BUILD=false
test: .deps.ok .build.ok test: .deps.ok .build.ok
@bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
--unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
@ -122,8 +126,8 @@ test: .deps.ok .build.ok
--dryrun=$(DRYRUN); \ --dryrun=$(DRYRUN); \
./script/compress.sh $$? ./script/compress.sh $$?
.PHONY: test-debug .PHONY: test-debug
test-debug: FORCE_BUILD=false
test-debug: .deps.ok .build_debug.ok test-debug: .deps.ok .build_debug.ok
@bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
--unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \
@ -132,6 +136,7 @@ test-debug: .deps.ok .build_debug.ok
./script/compress.sh $$? ./script/compress.sh $$?
.PHONY: test-cov .PHONY: test-cov
test-leak: FORCE_BUILD=false
test-cov: .deps.ok .build.cov.ok test-cov: .deps.ok .build.cov.ok
@bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
--unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \
@ -149,19 +154,19 @@ build-go:
.PHONY: build .PHONY: build
build: .deps.ok build-vpp-release build-go build: .deps.ok build-vpp-release build-go
@rm -f .build.ok @rm -f .build.ok
bash ./script/build_hst.sh release bash ./script/build_hst.sh release $(FORCE_BUILD)
@touch .build.ok @touch .build.ok
.PHONY: build-cov .PHONY: build-cov
build-cov: .deps.ok build-vpp-gcov build-go build-cov: .deps.ok build-vpp-gcov build-go
@rm -f .build.cov.ok @rm -f .build.cov.ok
bash ./script/build_hst.sh gcov bash ./script/build_hst.sh gcov $(FORCE_BUILD)
@touch .build.cov.ok @touch .build.cov.ok
.PHONY: build-debug .PHONY: build-debug
build-debug: .deps.ok build-vpp-debug build-go build-debug: .deps.ok build-vpp-debug build-go
@rm -f .build.ok @rm -f .build.ok
bash ./script/build_hst.sh debug bash ./script/build_hst.sh debug $(FORCE_BUILD)
@touch .build.ok @touch .build.ok
.deps.ok: .deps.ok:

View File

@ -5,10 +5,14 @@ if [ "$(lsb_release -is)" != Ubuntu ]; then
exit 1 exit 1
fi fi
export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"}
echo "Ubuntu version is set to ${UBUNTU_VERSION}"
LAST_STATE_FILE=".last_state_hash" LAST_STATE_FILE=".last_state_hash"
# get current state hash # get current state hash and ubuntu version
current_state_hash=$(git status --porcelain | grep -vE '(/\.|/10|\.go$|\.sum$|\.mod$|\.txt$|\.test$)' | sha1sum | awk '{print $1}') current_state_hash=$(git status --porcelain | grep -vE '(/\.|/10|\.go$|\.sum$|\.mod$|\.txt$|\.test$)' | sha1sum | awk '{print $1}')
current_state_hash=$current_state_hash$UBUNTU_VERSION
if [ -f "$LAST_STATE_FILE" ]; then if [ -f "$LAST_STATE_FILE" ]; then
last_state_hash=$(cat "$LAST_STATE_FILE") last_state_hash=$(cat "$LAST_STATE_FILE")
@ -16,8 +20,8 @@ else
last_state_hash="" last_state_hash=""
fi fi
# compare current state with last state # compare current state with last state and check FORCE_BUILD
if [ "$current_state_hash" = "$last_state_hash" ]; then if [ "$current_state_hash" = "$last_state_hash" ] && [ "$2" = "false" ]; then
echo "*** Skipping docker build - no new changes \ echo "*** Skipping docker build - no new changes \
(excluding .go, .txt, .sum, .mod, dotfiles, IP address files) ***" (excluding .go, .txt, .sum, .mod, dotfiles, IP address files) ***"
exit 0 exit 0
@ -48,9 +52,6 @@ else
fi fi
echo "Taking build objects from ${VPP_BUILD_ROOT}" echo "Taking build objects from ${VPP_BUILD_ROOT}"
export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"}
echo "Ubuntu version is set to ${UBUNTU_VERSION}"
export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/${OS_ARCH}-linux-gnu/libvcl_ldpreload.so export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/${OS_ARCH}-linux-gnu/libvcl_ldpreload.so
echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}" echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}"