[#692] Add ngfuzz installation to makefile

Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
Marina Biryukova 2025-04-16 15:55:52 +03:00 committed by Alexey Vanin
parent e373f7c601
commit 4f0f2ca7bd

View file

@ -26,9 +26,10 @@ LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT
TMP_DIR := .cache TMP_DIR := .cache
# Variables for fuzzing # Variables for fuzzing
FUZZ_NGFUZZ_DIR ?= "" FUZZING_DIR = $(shell pwd)/tests/fuzzing/files
NGFUZZ_REPO = https://gitflic.ru/project/yadro/ngfuzz.git
FUZZ_TIMEOUT ?= 30 FUZZ_TIMEOUT ?= 30
FUZZ_FUNCTIONS ?= "all" FUZZ_FUNCTIONS ?= ""
FUZZ_AUX ?= "" FUZZ_AUX ?= ""
.PHONY: all $(BINS) $(BINDIR) dep docker/ test cover format image image-push dirty-image lint docker/lint pre-commit unpre-commit version clean protoc .PHONY: all $(BINS) $(BINDIR) dep docker/ test cover format image image-push dirty-image lint docker/lint pre-commit unpre-commit version clean protoc
@ -94,24 +95,22 @@ ifeq ($(CLANG),)
@exit 1 @exit 1
endif endif
.PHONY: check-ngfuzz all .PHONY: install-ngfuzz
check-ngfuzz: install-ngfuzz:
@if [ -z "$(FUZZ_NGFUZZ_DIR)" ]; then \ ifeq (,$(wildcard $(FUZZING_DIR)/ngfuzz))
echo "Please set a variable FUZZ_NGFUZZ_DIR to specify path to the ngfuzz"; \ @rm -rf $(FUZZING_DIR)/ngfuzz
exit 1; \ @git clone $(NGFUZZ_REPO) $(FUZZING_DIR)/ngfuzz
fi @cd $(FUZZING_DIR)/ngfuzz && make
endif
.PHONY: install-fuzzing-deps
install-fuzzing-deps: check-clang check-ngfuzz
.PHONY: fuzz .PHONY: fuzz
fuzz: install-fuzzing-deps fuzz: check-clang install-ngfuzz
@START_PATH=$$(pwd); \ @START_PATH=$$(pwd); \
ROOT_PATH=$$(realpath --relative-to=$(FUZZ_NGFUZZ_DIR) $$START_PATH) ; \ ROOT_PATH=$$(realpath --relative-to=$(FUZZING_DIR)/ngfuzz $$START_PATH) ; \
cd $(FUZZ_NGFUZZ_DIR) && \ cd $(FUZZING_DIR)/ngfuzz && \
./ngfuzz -clean && \ ./bin/ngfuzz clean && \
./ngfuzz -fuzz $(FUZZ_FUNCTIONS) -rootdir $$ROOT_PATH -timeout $(FUZZ_TIMEOUT) $(FUZZ_AUX) && \ env CGO_ENABLED=1 ./bin/ngfuzz fuzz --funcs $(FUZZ_FUNCTIONS) --rootdir $$ROOT_PATH --timeout $(FUZZ_TIMEOUT) $(FUZZ_AUX) && \
./ngfuzz -report ./bin/ngfuzz coverage --rootdir $$ROOT_PATH
# Reformat code # Reformat code
format: format: