@@ -37,6 +37,10 @@ BUILD_DIR := $(REPOSITORY_ROOT)/build
3737# Other dependency versions
3838ENVTEST_BIN_VERSION ?= 1.19.2
3939
40+ # FUZZ_TIME defines the max amount of time, in Go Duration,
41+ # each fuzzer should run for.
42+ FUZZ_TIME ?= 1m
43+
4044# Caches libgit2 versions per tag, "forcing" rebuild only when needed.
4145LIBGIT2_PATH := $(BUILD_DIR ) /libgit2/$(LIBGIT2_TAG )
4246LIBGIT2_LIB_PATH := $(LIBGIT2_PATH ) /lib
@@ -219,7 +223,7 @@ ENVTEST = $(GOBIN)/setup-envtest
219223setup-envtest : # # Download envtest-setup locally if necessary.
220224 $(call go-install-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
221225
222- # Build fuzzers
226+ # Build fuzzers used by oss-fuzz.
223227fuzz-build : $(LIBGIT2 )
224228 rm -rf $(shell pwd) /build/fuzz/
225229 mkdir -p $(shell pwd) /build/fuzz/out/
@@ -231,13 +235,20 @@ fuzz-build: $(LIBGIT2)
231235 -v "$(shell pwd)/build/fuzz/out":/out \
232236 local-fuzzing:latest
233237
238+ # Run each fuzzer once to ensure they will work when executed by oss-fuzz.
234239fuzz-smoketest : fuzz-build
235240 docker run --rm \
236241 -v " $( shell pwd) /build/fuzz/out" :/out \
237242 -v " $( shell pwd) /tests/fuzz/oss_fuzz_run.sh" :/runner.sh \
238243 local-fuzzing:latest \
239244 bash -c " /runner.sh"
240245
246+ # Run fuzz tests for the duration set in FUZZ_TIME.
247+ fuzz-native :
248+ KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
249+ FUZZ_TIME=$(FUZZ_TIME ) \
250+ ./tests/fuzz/native_go_run.sh
251+
241252# go-install-tool will 'go install' any package $2 and install it to $1.
242253define go-install-tool
243254@[ -f $(1 ) ] || { \
0 commit comments