summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Webb <allenwebb@google.com>2018-08-17 11:31:39 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-22 16:02:19 -0700
commit625acc6b7c7455b0f7c6ad49f467737ce64b37eb (patch)
treef9786735eb02c8e448ddcd02718ca4b833b9278a
parent26708ffa05ee1fc88bd754ddb959499acea1c41d (diff)
downloadchrome-ec-625acc6b7c7455b0f7c6ad49f467737ce64b37eb.tar.gz
Move fuzzing tests into a fuzz subfolder.
BRANCH=none CQ-DEPEND=CL:*664115 BUG=chromium:876582 TEST=make -j buildall && make -j buildfuzztests Change-Id: Iade5e5138f495e6b3b99ec16f1a467861ade5537 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1180179 Reviewed-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--Makefile12
-rw-r--r--board/cr50/build.mk1
-rw-r--r--extra/rma_reset/Makefile2
-rw-r--r--extra/usb_updater/Makefile2
-rw-r--r--fuzz/build.mk11
-rw-r--r--fuzz/fuzz_config.h29
-rw-r--r--fuzz/host_command_fuzz.c (renamed from test/host_command_fuzz.c)0
-rw-r--r--fuzz/host_command_fuzz.tasklist (renamed from test/host_command_fuzz.tasklist)0
-rw-r--r--include/config.h6
-rw-r--r--test/build.mk4
10 files changed, 56 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index dcd8944a83..cc3a773e10 100644
--- a/Makefile
+++ b/Makefile
@@ -91,13 +91,14 @@ UC_PROJECT:=$(call uppercase,$(PROJECT))
# Transform the configuration into make variables. This must be done after
# the board/baseboard/project/chip/core variables are defined, since some of
# the configs are dependent on particular configurations.
-includes=include core/$(CORE)/include $(dirs) $(out) test
+includes=include core/$(CORE)/include $(dirs) $(out) fuzz test
ifdef CTS_MODULE
includes+=cts/$(CTS_MODULE) cts
endif
ifeq "$(TEST_BUILD)" "y"
_tsk_lst_file:=ec.tasklist
- _tsk_lst_flags:=-Itest -DTEST_BUILD -imacros $(PROJECT).tasklist
+ _tsk_lst_flags:=$(if $(TEST_FUZZ),-Ifuzz,-Itest) -DTEST_BUILD -imacros \
+ $(PROJECT).tasklist
else ifdef CTS_MODULE
_tsk_lst_file:=ec.tasklist
_tsk_lst_flags:=-I cts/$(CTS_MODULE) -Icts -DCTS_MODULE=$(CTS_MODULE) \
@@ -195,6 +196,7 @@ include chip/$(CHIP)/build.mk
include core/$(CORE)/build.mk
include common/build.mk
include driver/build.mk
+include fuzz/build.mk
include power/build.mk
-include private/build.mk
ifneq ($(PDIR),)
@@ -226,14 +228,18 @@ all-obj-$(1)+=$(call objs_from_dir_p,power,power,$(1))
ifdef CTS_MODULE
all-obj-$(1)+=$(call objs_from_dir_p,cts,cts,$(1))
endif
+ifeq ($(TEST_FUZZ),y)
+all-obj-$(1)+=$(call objs_from_dir_p,fuzz,$(PROJECT),$(1))
+else
all-obj-$(1)+=$(call objs_from_dir_p,test,$(PROJECT),$(1))
+endif
endef
# Get all sources to build
$(eval $(call get_sources,y))
$(eval $(call get_sources,ro))
-dirs=core/$(CORE) chip/$(CHIP) $(BASEDIR) $(BDIR) common power test \
+dirs=core/$(CORE) chip/$(CHIP) $(BASEDIR) $(BDIR) common fuzz power test \
cts/common cts/$(CTS_MODULE)
dirs+= private $(PDIR)
dirs+=$(shell find common -type d)
diff --git a/board/cr50/build.mk b/board/cr50/build.mk
index d607fbe41c..86e6e1f2c4 100644
--- a/board/cr50/build.mk
+++ b/board/cr50/build.mk
@@ -72,6 +72,7 @@ CPPFLAGS += -I$(abspath ./chip/$(CHIP))
# For core includes
CPPFLAGS += -I$(abspath .)
CPPFLAGS += -I$(abspath $(BDIR))
+CPPFLAGS += -I$(abspath ./fuzz)
CPPFLAGS += -I$(abspath ./test)
ifeq ($(CONFIG_UPTO_SHA512),y)
CPPFLAGS += -DSHA512_SUPPORT
diff --git a/extra/rma_reset/Makefile b/extra/rma_reset/Makefile
index d693f6427c..4a640c5b4c 100644
--- a/extra/rma_reset/Makefile
+++ b/extra/rma_reset/Makefile
@@ -27,7 +27,7 @@ endif
#
# Add libusb-1.0 required flags
#
-INCLUDE=-I. -I../../ -I../../test -I../../include -I../../chip/host
+INCLUDE=-I. -I../../ -I../../fuzz -I../../test -I../../include -I../../chip/host
LIBS += -lcrypto -lssl
CFLAGS += ${INCLUDE}
STANDALONE_FLAGS=${INCLUDE} -ffreestanding -fno-builtin \
diff --git a/extra/usb_updater/Makefile b/extra/usb_updater/Makefile
index e56331f110..01608ae1ea 100644
--- a/extra/usb_updater/Makefile
+++ b/extra/usb_updater/Makefile
@@ -30,7 +30,7 @@ endif
#
LIBS += $(shell $(PKG_CONFIG) --libs libusb-1.0)
CFLAGS += $(shell $(PKG_CONFIG) --cflags libusb-1.0)
-CFLAGS += -I../../include -I../../util -I../../test
+CFLAGS += -I../../include -I../../util -I../../fuzz -I../../test
BOARD := cr50
LIBS_g = $(shell $(PKG_CONFIG) --libs libcrypto)
diff --git a/fuzz/build.mk b/fuzz/build.mk
new file mode 100644
index 0000000000..dc3fb8eb29
--- /dev/null
+++ b/fuzz/build.mk
@@ -0,0 +1,11 @@
+# -*- makefile -*-
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# fuzzer binaries
+#
+
+fuzz-test-list-host = host_command_fuzz
+
+host_command_fuzz-y = host_command_fuzz.o
diff --git a/fuzz/fuzz_config.h b/fuzz/fuzz_config.h
new file mode 100644
index 0000000000..6244340c7e
--- /dev/null
+++ b/fuzz/fuzz_config.h
@@ -0,0 +1,29 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Fuzzer target config flags */
+
+#ifndef __FUZZ_FUZZ_CONFIG_H
+#define __FUZZ_FUZZ_CONFIG_H
+#ifdef TEST_FUZZ
+
+/* Disable hibernate: We never want to exit while fuzzing. */
+#undef CONFIG_HIBERNATE
+
+#ifdef TEST_HOST_COMMAND_FUZZ
+#undef CONFIG_HOSTCMD_DEBUG_MODE
+
+/* Defining this makes fuzzing slower, but exercises additional code paths. */
+#define FUZZ_HOSTCMD_VERBOSE
+
+#ifdef FUZZ_HOSTCMD_VERBOSE
+#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_PARAMS
+#else
+#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
+#endif /* ! FUZZ_HOSTCMD_VERBOSE */
+#endif /* TEST_HOST_COMMAND_FUZZ */
+
+#endif /* TEST_FUZZ */
+#endif /* __TEST_TEST_CONFIG_H */
diff --git a/test/host_command_fuzz.c b/fuzz/host_command_fuzz.c
index 7f0bfad7a5..7f0bfad7a5 100644
--- a/test/host_command_fuzz.c
+++ b/fuzz/host_command_fuzz.c
diff --git a/test/host_command_fuzz.tasklist b/fuzz/host_command_fuzz.tasklist
index de4df33e13..de4df33e13 100644
--- a/test/host_command_fuzz.tasklist
+++ b/fuzz/host_command_fuzz.tasklist
diff --git a/include/config.h b/include/config.h
index c5a79901c4..a16b37b43e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3936,9 +3936,11 @@
#endif
/*
- * Apply test config overrides last, since tests need to override some of the
- * config flags in non-standard ways to mock only parts of the system.
+ * Apply fuzzer and test config overrides last, since fuzzers and tests need to
+ * override some of the config flags in non-standard ways to mock only parts of
+ * the system.
*/
+#include "fuzz_config.h"
#include "test_config.h"
/*
diff --git a/test/build.mk b/test/build.mk
index 4fffada544..f03b614469 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -66,9 +66,6 @@ test-list-host += vboot
test-list-host += x25519
endif
-# Fuzzing tests
-fuzz-test-list-host = host_command_fuzz
-
base32-y=base32.o
battery_get_params_smart-y=battery_get_params_smart.o
bklight_lid-y=bklight_lid.o
@@ -86,7 +83,6 @@ fan-y=fan.o
flash-y=flash.o
hooks-y=hooks.o
host_command-y=host_command.o
-host_command_fuzz-y=host_command_fuzz.o
inductive_charging-y=inductive_charging.o
interrupt-scale=10
interrupt-y=interrupt.o