aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2022-08-08 10:36:06 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2022-08-10 23:53:00 +0000
commit4adfd99d782ab825042f9225df05d360476f8e19 (patch)
treee80cf5dc699bc0d3b5b74c886b8a2246c451c7a4
parent02f43e89bae6bcdd7505af0ccd361e6eb3d3c74c (diff)
downloadflashrom-4adfd99d782ab825042f9225df05d360476f8e19.tar.gz
flashrom-4adfd99d782ab825042f9225df05d360476f8e19.tar.bz2
flashrom-4adfd99d782ab825042f9225df05d360476f8e19.zip
tests: Add function to test programmer init error paths
New function tests an error path for programmer initialisation, and expects programmer init to fail with given error code. BUG=b:181803212 TEST=ninja test Change-Id: Icc59396e604d74442852b4bbd575440df3347c3f Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66507 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Thomas Heijligen <src@posteo.de>
-rw-r--r--tests/lifecycle.c19
-rw-r--r--tests/lifecycle.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/lifecycle.c b/tests/lifecycle.c
index 2b08b89c..11884f88 100644
--- a/tests/lifecycle.c
+++ b/tests/lifecycle.c
@@ -72,3 +72,22 @@ void run_probe_lifecycle(void **state, const struct io_mock *io,
clear_spi_id_cache();
run_lifecycle(state, io, prog, param, chip_name, &probe_chip);
}
+
+void run_init_error_path(void **state, const struct io_mock *io, const struct programmer_entry *prog,
+ const char *param, const int error_code)
+{
+ (void) state; /* unused */
+
+ io_mock_register(io);
+
+ struct flashrom_programmer *flashprog;
+ char *param_dup = strdup(param);
+
+ printf("Testing init error path for programmer=%s with params: %s ...\n", prog->name, param_dup);
+ assert_int_equal(error_code, flashrom_programmer_init(&flashprog, prog->name, param_dup));
+ printf("... init failed with error code %i as expected\n", error_code);
+
+ free(param_dup);
+
+ io_mock_register(NULL);
+}
diff --git a/tests/lifecycle.h b/tests/lifecycle.h
index 1d82e694..1379f7d7 100644
--- a/tests/lifecycle.h
+++ b/tests/lifecycle.h
@@ -35,4 +35,6 @@ void run_basic_lifecycle(void **state, const struct io_mock *io,
void run_probe_lifecycle(void **state, const struct io_mock *io,
const struct programmer_entry *prog, const char *param, const char *const chip_name);
+void run_init_error_path(void **state, const struct io_mock *io,
+ const struct programmer_entry *prog, const char *param, const int error_code);
#endif /* __LIFECYCLE_H__ */