summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Webb <allenwebb@google.com>2018-12-10 15:10:19 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-19 01:12:52 -0800
commita6f0a7e96c6fe9da398f7db5004d7d2b9c00e3e3 (patch)
tree85d0ed1af00b07b0f412b58cd588e70188c2ed7a
parent4790392940e3b70a843274e1acb952e8f22825f6 (diff)
downloadchrome-ec-a6f0a7e96c6fe9da398f7db5004d7d2b9c00e3e3.tar.gz
Makefile.rules: Add buildfuzztests to buildall.
This incorporates the fuzz targets into buildall and adds a quick sanity check to each fuzz target to make sure it exits successfully for an empty input. This adds roughly 5.88 seconds to "make -j buildall" (This includes an addtionally target that will be enabled in a later CL). time make -j buildall # BEFORE real 1m19.519s user 23m9.220s sys 5m1.690s time make -j buildall # AFTER real 1m25.399s user 23m35.753s sys 5m12.609s BRANCH=None BUG=None TEST=make -j buildall Change-Id: Ib77a57297ee896569c509d0c8c998552d2a3a76c Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1370934 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-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