#
ifneq "$(findstring fuzzer,${CFLAGS})" ""
+#
+# Put the output artifacts into the build directory, but only if the
+# variable is not already set by the environment or make filesx
+#
+FUZZER_ARTIFACTS ?= ${BUILD_DIR}/fuzzer
+
+#
+# Time out "test.fuzzer.foo" after this number of seconds
+#
+FUZZER_TIMEOUT ?= 10
+
#
# Define a function to do all of the same thing.
#
tar -xf $(PROTOCOL).tar; \
fi
-$(TEST_BIN_DIR)/fuzzer_$(PROTOCOL): $(BUILD_DIR)/lib/local/libfreeradius-$(PROTOCOL).la
+.PHONY: $(FUZZER_ARTIFACTS)/$(PROTOCOL)
+$(FUZZER_ARTIFACTS)/$(PROTOCOL):
+ @mkdir -p $@
+
+$(TEST_BIN_DIR)/fuzzer_$(PROTOCOL): $(BUILD_DIR)/lib/local/libfreeradius-$(PROTOCOL).la | $(FUZZER_ARTIFACTS)/$(PROTOCOL)
#
# Run the fuzzer binary against the fuzzer corpus data files.
# increase the size of the corpus by several times.
#
fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL)
- ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) -max_len=512 -D share/dictionary src/tests/fuzzer-corpus/$(PROTOCOL)
+ ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \
+ -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)" \
+ -max_len=512 $(FUZZER_ARGUMENTS) \
+ -D share/dictionary \
+ src/tests/fuzzer-corpus/$(PROTOCOL)
#
# tests add a 10s timeout. This is so that we can see if the fuzzers run _at all_.
#
test.fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL)
- ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) -max_len=512 -timeout=10 -D share/dictionary src/tests/fuzzer-corpus/$(PROTOCOL)
+ @echo TEST-FUZZER $(PROTOCOL) for $(FUZZER_TIMEOUT)s
+ ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \
+ -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)" \
+ -max_len=512 $(FUZZER_ARGUMENTS) \
+ -max_total_time=$(FUZZER_TIMEOUT) \
+ -D share/dictionary \
+ src/tests/fuzzer-corpus/$(PROTOCOL)