Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/62311 )
Change subject: tests/: Allow realtek_mst test to check multiple paths ......................................................................
tests/: Allow realtek_mst test to check multiple paths
[WIP]
Change-Id: I80d5e1fc26ad9caf49a98a7671d069bbd8428045 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M tests/init_shutdown.c 1 file changed, 18 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/11/62311/1
diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c index 2a8d6f5..c0e404c 100644 --- a/tests/init_shutdown.c +++ b/tests/init_shutdown.c @@ -299,9 +299,21 @@
#define REALTEK_MST_MOCK_FD 0x10ec
+struct realtek_mst_io_mock_state { + unsigned int noc; + const char *paths[2]; // no. of subsequent paths to check. +}; +static const char * get_realtek_mst_path(struct realtek_mst_io_mock_state * state) +{ + const char *path = state->paths[state->noc]; + state->noc++; // proceed to the next path upon next call. + return path; +} + static int realtek_mst_open(void *state, const char *pathname, int flags) { - assert_string_equal(pathname, "/dev/i2c-254"); + const char *path = get_realtek_mst_path(state); + assert_string_equal(pathname, path); assert_int_equal(flags & O_RDWR, O_RDWR); return REALTEK_MST_MOCK_FD; } @@ -335,11 +347,16 @@ void realtek_mst_init_and_shutdown_test_success(void **state) { #if CONFIG_REALTEK_MST_I2C_SPI == 1 + static struct realtek_mst_io_mock_state data = { + .paths = {"/run/lock/flashrom_lock", "/dev/i2c-254"}, + .noc = 0, + }; const struct io_mock realtek_mst_io = { .open = realtek_mst_open, .ioctl = realtek_mst_ioctl, .read = realtek_mst_read, .write = realtek_mst_write, + .state = &data, }; io_mock_register(&realtek_mst_io);