Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/69872 )
Change subject: tests: add more wrappers for libusb funcs ......................................................................
tests: add more wrappers for libusb funcs
The patch adds wrappers for libusb functions that are used in the ch341a programmer and have not yet been introduced.
Change-Id: Ic11efb9fd746cb91911dbe87e1c0028759f5bb0b Signed-off-by: Alexander Goncharov chat@joursoir.net Reviewed-on: https://review.coreboot.org/c/flashrom/+/69872 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Anastasia Klimchuk aklm@chromium.org --- M tests/libusb_wraps.c M tests/libusb_wraps.h M tests/meson.build M tests/usb_unittests.h 4 files changed, 82 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Anastasia Klimchuk: Looks good to me, approved
diff --git a/tests/libusb_wraps.c b/tests/libusb_wraps.c index 85bb963..a05cbe9 100644 --- a/tests/libusb_wraps.c +++ b/tests/libusb_wraps.c @@ -34,6 +34,17 @@ return 0; }
+void __wrap_libusb_set_debug(libusb_context *ctx, int level) +{ + LOG_ME; +} + +int __wrap_libusb_set_option(libusb_context *ctx, int option, ...) +{ + LOG_ME; + return 0; +} + int __wrap_libusb_open(libusb_device *dev, libusb_device_handle **devh) { LOG_ME; @@ -58,6 +69,19 @@ return 0; }
+struct libusb_device_handle *__wrap_libusb_open_device_with_vid_pid( + libusb_context *ctx, uint16_t vendor_id, uint16_t product_id) +{ + LOG_ME; + return not_null(); +} + +libusb_device *__wrap_libusb_get_device(libusb_device_handle *dev_handle) +{ + LOG_ME; + return not_null(); +} + ssize_t __wrap_libusb_get_device_list(libusb_context *ctx, libusb_device ***list) { LOG_ME; @@ -161,6 +185,29 @@ LOG_ME; }
+struct libusb_transfer *__wrap_libusb_alloc_transfer(int iso_packets) +{ + LOG_ME; + return not_null(); +} + +int __wrap_libusb_submit_transfer(struct libusb_transfer *transfer) +{ + LOG_ME; + return 0; +} + +void __wrap_libusb_free_transfer(struct libusb_transfer *transfer) +{ + LOG_ME; +} + +int __wrap_libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv) +{ + LOG_ME; + return 0; +} + void __wrap_libusb_exit(libusb_context *ctx) { LOG_ME; diff --git a/tests/libusb_wraps.h b/tests/libusb_wraps.h index f7e4daf..8c3aa40 100644 --- a/tests/libusb_wraps.h +++ b/tests/libusb_wraps.h @@ -21,10 +21,15 @@ void *__wrap_usb_dev_get_by_vid_pid_number( libusb_context *usb_ctx, uint16_t vid, uint16_t pid, unsigned int num); int __wrap_libusb_init(libusb_context **ctx); +void __wrap_libusb_set_debug(libusb_context *ctx, int level); +int __wrap_libusb_set_option(libusb_context *ctx, int option, ...); int __wrap_libusb_open(libusb_device *dev, libusb_device_handle **devh); int __wrap_libusb_set_auto_detach_kernel_driver(libusb_device_handle *devh, int enable); int __wrap_libusb_detach_kernel_driver(libusb_device_handle *dev_handle, int interface_number); int __wrap_libusb_attach_kernel_driver(libusb_device_handle *dev_handle, int interface_number); +struct libusb_device_handle *__wrap_libusb_open_device_with_vid_pid( + libusb_context *ctx, uint16_t vendor_id, uint16_t product_id); +libusb_device *__wrap_libusb_get_device(libusb_device_handle *dev_handle); ssize_t __wrap_libusb_get_device_list(libusb_context *ctx, libusb_device ***list); void __wrap_libusb_free_device_list(libusb_device **list, int unref_devices); uint8_t __wrap_libusb_get_bus_number(libusb_device *dev); @@ -43,6 +48,10 @@ void __wrap_libusb_close(libusb_device_handle *devh); libusb_device *__wrap_libusb_ref_device(libusb_device *dev); void __wrap_libusb_unref_device(libusb_device *dev); +struct libusb_transfer *__wrap_libusb_alloc_transfer(int iso_packets); +int __wrap_libusb_submit_transfer(struct libusb_transfer *transfer); +void __wrap_libusb_free_transfer(struct libusb_transfer *transfer); +int __wrap_libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv); void __wrap_libusb_exit(libusb_context *ctx);
#endif /* LIBUSB_WRAPS_H */ diff --git a/tests/meson.build b/tests/meson.build index 893cca8..e846d91 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -79,10 +79,14 @@ '-Wl,--wrap=INL', '-Wl,--wrap=usb_dev_get_by_vid_pid_number', '-Wl,--wrap=libusb_init', + '-Wl,--wrap=libusb_set_debug', + '-Wl,--wrap=libusb_set_option', '-Wl,--wrap=libusb_open', '-Wl,--wrap=libusb_set_auto_detach_kernel_driver', '-Wl,--wrap=libusb_detach_kernel_driver', '-Wl,--wrap=libusb_attach_kernel_driver', + '-Wl,--wrap=libusb_open_device_with_vid_pid', + '-Wl,--wrap=libusb_get_device', '-Wl,--wrap=libusb_get_device_list', '-Wl,--wrap=libusb_free_device_list', '-Wl,--wrap=libusb_get_bus_number', @@ -98,6 +102,10 @@ '-Wl,--wrap=libusb_ref_device', '-Wl,--wrap=libusb_unref_device', '-Wl,--wrap=libusb_close', + '-Wl,--wrap=libusb_alloc_transfer', + '-Wl,--wrap=libusb_submit_transfer', + '-Wl,--wrap=libusb_free_transfer', + '-Wl,--wrap=libusb_handle_events_timeout', '-Wl,--wrap=libusb_exit', '-Wl,--gc-sections', ] diff --git a/tests/usb_unittests.h b/tests/usb_unittests.h index 29c4b78..f4d83f1 100644 --- a/tests/usb_unittests.h +++ b/tests/usb_unittests.h @@ -55,6 +55,8 @@ struct libusb_endpoint_descriptor; typedef struct libusb_endpoint_descriptor libusb_endpoint_descriptor;
+struct libusb_transfer; + #endif
#endif /* _USB_UNITTESTS_H_ */