1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-02 22:43:17 +02:00

tests: Add init-shutdown test for raiden_debug_spi

This patch adds a test for raiden_debug_spi and lots of libusb wraps.

libusb.h becomes required for tests to build and run, since new tests
are using libusb structs in depth and opaque symbols not sufficient
anymore.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: I880a8637ab02de179df9169c1898230bce4dc1c7
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57918
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Anastasia Klimchuk
2021-09-24 16:13:25 +10:00
committed by Edward O'Callaghan
parent 421d9133bb
commit f47ff316ec
6 changed files with 208 additions and 5 deletions

View File

@ -34,11 +34,14 @@
/* Required for `FILE *` */
#include <stdio.h>
/* Define libusb symbols to avoid dependency on libusb.h */
struct libusb_device_handle;
typedef struct libusb_device_handle libusb_device_handle;
struct libusb_context;
typedef struct libusb_context libusb_context;
/*
* Explicitly including the header because some tests are using libusb structs
* in depth, opaque symbols are not sufficient.
*/
#include <libusb.h>
/* Address value needs fit into uint8_t. */
#define USB_DEVICE_ADDRESS 19
/* Define struct pci_dev to avoid dependency on pci.h */
struct pci_dev {
@ -80,6 +83,14 @@ struct io_mock {
unsigned char *data,
uint16_t wLength,
unsigned int timeout);
ssize_t (*libusb_get_device_list)(void *state, libusb_context *, libusb_device ***list);
void (*libusb_free_device_list)(void *state, libusb_device **list, int unref_devices);
int (*libusb_get_device_descriptor)(void *state, libusb_device *, struct libusb_device_descriptor *);
int (*libusb_get_config_descriptor)(void *state,
libusb_device *,
uint8_t config_index,
struct libusb_config_descriptor **);
void (*libusb_free_config_descriptor)(void *state, struct libusb_config_descriptor *);
/* POSIX File I/O */
int (*open)(void *state, const char *pathname, int flags);