From 92989f2496e3b138e784d10ef4b2536a757c0953 Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Fri, 24 Sep 2021 16:05:35 +1000 Subject: tests: Add wrap for libusb_init and use it in dediprog test Missing wrap for libusb_init has been discovered while working on the test for raiden_debug_spi. Both dediprog (existing test) and raiden_debug_spi (new test, see later in this chain) are using libusb_init, so it definitely needs to be wrapped and added to io_mock. Why tests worked before, without the wrap: my understanding is that real libusb_init was called for dediprog test? Given that tests definitely should not call any real libusb functions, wrap is needed. BUG=b:181803212 TEST=builds and ninja test Change-Id: I51c9cb96db1afb3298f4d098df96509d3cb3c046 Signed-off-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/57917 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- tests/init_shutdown.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/init_shutdown.c') diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c index 03e888fd..e64e58cb 100644 --- a/tests/init_shutdown.c +++ b/tests/init_shutdown.c @@ -54,6 +54,13 @@ void nicrealtek_init_and_shutdown_test_success(void **state) #endif } + +int dediprog_libusb_init(void *state, libusb_context **ctx) +{ + *ctx = not_null(); + return 0; +} + int dediprog_libusb_control_transfer(void *state, libusb_device_handle *devh, uint8_t bmRequestType, @@ -75,6 +82,7 @@ void dediprog_init_and_shutdown_test_success(void **state) { #if CONFIG_DEDIPROG == 1 const struct io_mock dediprog_io = { + .libusb_init = dediprog_libusb_init, .libusb_control_transfer = dediprog_libusb_control_transfer, }; -- cgit v1.2.3