fuzz_host_cmd: Add fpsensor task + fp host cmds

This CL enables the fpsensor task and adds the following
remaining fingerprint host commands to the fuzzer:

* EC_CMD_FP_PASSTHRU
* EC_CMD_FP_INFO
* EC_CMD_FP_FRAME
* EC_CMD_FP_STATS
* EC_CMD_FP_TEMPLATE

BRANCH=none
BUG=b:116065496
TEST=make buildall -j
TEST=make run-host_command_fuzz
TEST=# Pull in TEST_COVERAGE fix
     git fetch "https://chromium.googlesource.com/chromiumos/platform/ec" \
     refs/changes/86/1725186/1 && git cherry-pick FETCH_HEAD
     make host-host_command_fuzz TEST_COVERAGE=1
     timeout 5m ./build/host/host_command_fuzz/host_command_fuzz.exe
     llvm-profdata merge -sparse default.profraw -o default.profdata
     llvm-cov show build/host/host_command_fuzz/host_command_fuzz.exe \
     --instr-profile=default.profdata --format=html --output-dir=cov
     # Inspect cov/.../common/fpsensor/fpsensor_state.c.html to verify

Change-Id: Icad9493ba41cd4daa61a30246d01afd1dbe16c56
Signed-off-by: Craig Hesling <hesling@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1682945
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Sean Abraham <seanabraham@chromium.org>
This commit is contained in:
Craig Hesling 2019-07-26 09:32:11 -07:00 committed by Commit Bot
parent 5866ec2921
commit 7eded13a72
8 changed files with 31 additions and 7 deletions

View File

@ -44,7 +44,11 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
test_mockable void button_interrupt(enum gpio_signal signal)
{
};
}
test_mockable void fps_event(enum gpio_signal signal)
{
}
#ifdef CONFIG_I2C
/* I2C ports */
@ -62,6 +66,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
#ifdef CONFIG_SPI_MASTER
/* SPI devices */
const struct spi_device_t spi_devices[] = {
/* Fingerprint sensor (SCLK at 4Mhz) */
{ CONFIG_SPI_FP_PORT, 3, GPIO_SPI1_NSS },
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);

View File

@ -73,4 +73,11 @@ enum {
#define PD_MIN_CURRENT_MA 500
#define PD_MIN_POWER_MW 7500
/* Configuration for fake Fingerprint Sensor */
#define CONFIG_SPI_MASTER
#define CONFIG_SPI_FP_PORT 1 /* SPI1: third master config */
#define CONFIG_RNG
void fps_event(enum gpio_signal signal);
#endif /* __CROS_EC_BOARD_H */

View File

@ -14,6 +14,8 @@ GPIO_INT(AC_PRESENT, PIN(0, 2), GPIO_INT_BOTH, extpower_interrupt)
GPIO_INT(VOLUME_DOWN_L, PIN(0, 3), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(VOLUME_UP_L, PIN(0, 4), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(CHARGE_DONE, PIN(0, 5), GPIO_INT_BOTH, inductive_charging_interrupt)
/* Fingerprint */
GPIO_INT(FPS_INT, PIN(0, 14), GPIO_INT_RISING, fps_event)
GPIO(EC_INT_L, PIN(0, 6), 0)
GPIO(WP, PIN(0, 7), 0)
@ -24,3 +26,6 @@ GPIO(ENABLE_BACKLIGHT, PIN(0, 10), 0)
/* Inductive charging */
GPIO(CHARGE_EN, PIN(0, 11), 0)
GPIO(BASE_CHG_VDD_EN, PIN(0, 12), 0)
/* Fingerprint */
GPIO(SPI1_NSS, PIN(0, 13), GPIO_OUT_HIGH)

View File

@ -9,9 +9,8 @@ _fpsensor_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_state.o
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_crypto.o
ifneq ($(CONFIG_SPI_FP_PORT),)
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor.o
endif
ifeq ($(HAS_MOCK_FP_SENSOR),)
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_stubs.o
endif

View File

@ -4,5 +4,6 @@
*/
#define CONFIG_TEST_MOCK_LIST \
MOCK(FP_SENSOR) \
MOCK(ROLLBACK)
MOCK(FP_SENSOR) \
MOCK(MKBP_EVENTS) \
MOCK(ROLLBACK)

View File

@ -7,4 +7,4 @@
* See CONFIG_TASK_LIST in config.h for details.
*/
#define CONFIG_TEST_TASK_LIST \
TASK_TEST(FPSENSOR, fp_task_simulate, NULL, TASK_STACK_SIZE)
TASK_TEST(FPSENSOR, fp_task, NULL, TASK_STACK_SIZE)

View File

@ -25,6 +25,7 @@
#if defined(HAVE_PRIVATE) && !defined(TEST_BUILD)
#define HAVE_FP_PRIVATE_DRIVER
/* Include the device specific header file */
#define PRIV_HEADER(header) STRINGIFY(header)
#include PRIV_HEADER(FP_SENSOR_PRIVATE)
#else
@ -35,6 +36,10 @@
#define FP_ALGORITHM_TEMPLATE_SIZE 0
#define FP_MAX_FINGER_COUNT 5
#endif
#ifdef TEST_BUILD
/* This represents the mock of the private */
#define HAVE_FP_PRIVATE_DRIVER
#endif
#define SBP_ENC_KEY_LEN 16
#define FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE \
(FP_ALGORITHM_TEMPLATE_SIZE + \

View File

@ -4,5 +4,6 @@
*/
#define CONFIG_TEST_MOCK_LIST \
MOCK(FP_SENSOR) \
MOCK(FP_SENSOR) \
MOCK(MKBP_EVENTS) \
MOCK(TIMER)