Edward O'Callaghan has uploaded this change for review.

View Change

tests/linux_mtd: Allow for checking open() calls

BUG=b:217629892,b:215255210
TEST=`ninja test`.

Change-Id: I06e54c0bdc4f5320904e2ab6542345721f1ca370
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M tests/init_shutdown.c
1 file changed, 17 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/18/62318/1
diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c
index 2a8d6f5..5221a16 100644
--- a/tests/init_shutdown.c
+++ b/tests/init_shutdown.c
@@ -193,6 +193,8 @@

struct linux_mtd_io_state {
char *fopen_path;
+ unsigned int noc;
+ const char *paths[2]; // no. of subsequent paths to check.
};

FILE *linux_mtd_fopen(void *state, const char *pathname, const char *mode)
@@ -247,15 +249,29 @@
return 0;
}

+static int linux_mtd_open(void *state, const char *pathname, int flags)
+{
+ struct linux_mtd_io_state *io_state = state;
+ const char *path = io_state->paths[io_state->noc];
+ io_state->noc++; // proceed to the next path upon next call.
+ assert_string_equal(pathname, path);
+ return 0x1EA;
+}
+
void linux_mtd_init_and_shutdown_test_success(void **state)
{
#if CONFIG_LINUX_MTD == 1
- struct linux_mtd_io_state linux_mtd_io_state = { NULL };
+ struct linux_mtd_io_state linux_mtd_io_state = {
+ .fopen_path = NULL,
+ .paths = {},
+ .noc = 0,
+ };
const struct io_mock linux_mtd_io = {
.state = &linux_mtd_io_state,
.fopen = linux_mtd_fopen,
.fread = linux_mtd_fread,
.fclose = linux_mtd_fclose,
+ .open = linux_mtd_open,
};

io_mock_register(&linux_mtd_io);

To view, visit change 62318. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I06e54c0bdc4f5320904e2ab6542345721f1ca370
Gerrit-Change-Number: 62318
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange