1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 22:21:16 +02:00

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 <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57917
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Anastasia Klimchuk
2021-09-24 16:05:35 +10:00
committed by Nico Huber
parent a7a59cf0bb
commit 92989f2496
4 changed files with 18 additions and 0 deletions

View File

@ -23,6 +23,14 @@ void *__wrap_usb_dev_get_by_vid_pid_number(
return not_null();
}
int __wrap_libusb_init(libusb_context **ctx)
{
LOG_ME;
if (get_io() && get_io()->libusb_init)
return get_io()->libusb_init(get_io()->state, ctx);
return 0;
}
int __wrap_libusb_set_configuration(libusb_device_handle *devh, int config)
{
LOG_ME;