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>
This commit is contained in:
Allen Webb 2018-08-17 11:31:39 -07:00 committed by chrome-bot
parent 26708ffa05
commit 625acc6b7c
10 changed files with 56 additions and 11 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 \

View File

@ -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)

11
fuzz/build.mk Normal file
View File

@ -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

29
fuzz/fuzz_config.h Normal file
View File

@ -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 */

View File

@ -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"
/*

View File

@ -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