summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--Makefile.rules40
-rw-r--r--fuzz/build.mk6
3 files changed, 36 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index dabe3e9b20..6f9984cf8a 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,14 @@
# Embedded Controller firmware build system
#
+# Allow for masking of some targets based on the build architecture. When
+# building using a portage package (such as chromeos-ec), this variable will
+# already be set. To support the typical developer workflow a default value is
+# provided matching the typical architecture of developer workstations. Note
+# that amd64 represents the entire x84_64 architecture including intel CPUs.
+# This is used to exclude build targets that depend on sanitizers such as
+# fuzzers on architectures that don't support sanitizers yet (e.g. arm).
+ARCH?=amd64
BOARD ?= bds
# Directory where the board is configured (includes /$(BOARD) at the end)
diff --git a/Makefile.rules b/Makefile.rules
index fd13a040ef..1ea22549c8 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -74,6 +74,8 @@ cmd_smap = $(NM) $< | sort > $@
cmd_elf = $(CC) $(objs) $(libsharedobjs_elf-y) $(LDFLAGS) \
-o $@ -Wl,-T,$< -Wl,-Map,$(patsubst %.elf,%.map,$@)
cmd_fuzz_exe = $(CXX) $^ $(HOST_TEST_LDFLAGS) $(LDFLAGS_EXTRA) -o $@
+cmd_run_fuzz = build/host/$*/$*.exe -seed=1 -runs=1 $(silent) \
+ $(silent_err) || (echo "Test $* failed!" && false)
cmd_exe = $(CC) $(ro-objs) $(HOST_TEST_LDFLAGS) -o $@
cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MP -MF $@.d -c $< -o $(@D)/$(@F)
cmd_cxx_to_o = $(CXX) -std=c++11 $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $@.d -c $< \
@@ -163,6 +165,7 @@ build_boards:
.PHONY: buildall
buildall: build_boards
$(MAKE) build_cts
+ $(MAKE) buildfuzztests
$(MAKE) runtests
@touch .tests-passed
@echo "$@ completed successfully!"
@@ -265,9 +268,28 @@ $(host-test-targets): host-%:
$(run-test-targets): run-%: host-%
$(call quiet,run_host_test,TEST )
+# Fuzzing tests
+
+fuzz-test-targets=$(foreach t,$(fuzz-test-list-host),host-$(t))
+run-fuzz-test-targets=$(foreach t,$(fuzz-test-list-host),run-$(t))
+
+.PHONY: $(fuzz-test-targets) $(run-fuzz-test-targets)
+
+$(fuzz-test-targets): host-%:
+ $(call quiet,host_test,BUILD )
+$(run-fuzz-test-targets): run-%: buildfuzztests
+ $(call quiet,run_fuzz,TEST )
+
+.PHONY: buildfuzztests
+buildfuzztests: TEST_FLAG=TEST_FUZZ=y TEST_ASAN=$(TEST_ASAN) \
+ TEST_MSAN=$(TEST_MSAN) TEST_UBSAN=$(TEST_UBSAN) \
+ CROSS_COMPILE=$(shell echo $(HOSTCC) | grep -v ccache | \
+ sed -e 's/[^-]*$$//')
+buildfuzztests: $(fuzz-test-targets)
+
.PHONY: hosttests runtests
hosttests: $(host-test-targets)
-runtests: $(run-test-targets)
+runtests: $(run-test-targets) $(run-fuzz-test-targets)
# Automatically enumerate all suites.
cts_excludes := common
@@ -334,22 +356,6 @@ coverage: TEST_FLAG=TEST_COVERAGE=y
coverage: $(cov-test-targets)
$(call quiet,report_cov,REPORT )
-# Fuzzing tests
-
-fuzz-test-targets=$(foreach t,$(fuzz-test-list-host),host-$(t))
-
-.PHONY: $(fuzz-test-targets)
-
-$(fuzz-test-targets): host-%:
- $(call quiet,host_test,BUILD )
-
-.PHONY: buildfuzztests
-buildfuzztests: TEST_FLAG=TEST_FUZZ=y TEST_ASAN=$(TEST_ASAN) \
- TEST_MSAN=$(TEST_MSAN) TEST_UBSAN=$(TEST_UBSAN) \
- CROSS_COMPILE=$(shell echo $(HOSTCC) | grep -v ccache | \
- sed -e 's/[^-]*$$//')
-buildfuzztests: $(fuzz-test-targets)
-
$(out)/libec.a: $(ro-objs)
$(call quiet,libec,BUILD )
diff --git a/fuzz/build.mk b/fuzz/build.mk
index ff18d1b0c2..08bba75220 100644
--- a/fuzz/build.mk
+++ b/fuzz/build.mk
@@ -6,8 +6,12 @@
# fuzzer binaries
#
+fuzz-test-list-host =
+# Fuzzers should only be built for architectures that support sanitizers.
+ifeq ($(ARCH),amd64)
# TODO(crbug.com/911310) Fix the chromeos-ec build before adding cr50_fuzz back.
-fuzz-test-list-host = host_command_fuzz usb_pd_fuzz
+fuzz-test-list-host += host_command_fuzz usb_pd_fuzz
+endif
# For fuzzing targets libec.a is built from the ro objects and hides functions
# that collide with stdlib. The rw only objects are then linked against libec.a