1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-02 06:23:18 +02:00

tests: add init_shutdown test for realtek_mst_i2c_spi

This can catch regressions like the earlier one in this programmer that
caused initialization to always fail. Requires support for mocking POSIX
file I/O functions because the programmer does ioctls on the opened
file.

TEST=ninja test

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56911
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Peter Marheine
2021-08-10 15:38:47 +10:00
committed by Edward O'Callaghan
parent b261bec1ee
commit 47f4c18260
5 changed files with 100 additions and 0 deletions

View File

@ -42,6 +42,14 @@ struct pci_dev {
unsigned int device_id;
};
/* POSIX open() flags, avoiding dependency on fcntl.h */
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
/* Linux I2C interface constants, avoiding linux/i2c-dev.h */
#define I2C_SLAVE 0x0703
struct io_mock {
void *state;
@ -65,6 +73,12 @@ struct io_mock {
unsigned char *data,
uint16_t wLength,
unsigned int timeout);
/* POSIX File I/O */
int (*open)(void *state, const char *pathname, int flags);
int (*ioctl)(void *state, int fd, unsigned long request, va_list args);
int (*read)(void *state, int fd, void *buf, size_t sz);
int (*write)(void *state, int fd, const void *buf, size_t sz);
};
void io_mock_register(const struct io_mock *io);