aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/init_shutdown.c8
-rw-r--r--tests/io_mock.h1
-rw-r--r--tests/libusb_wraps.c8
-rw-r--r--tests/meson.build1
4 files changed, 18 insertions, 0 deletions
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,
};
diff --git a/tests/io_mock.h b/tests/io_mock.h
index 7c235d82..0bee6cab 100644
--- a/tests/io_mock.h
+++ b/tests/io_mock.h
@@ -70,6 +70,7 @@ struct io_mock {
unsigned int (*inl)(void *state, unsigned short port);
/* USB I/O */
+ int (*libusb_init)(void *state, libusb_context **ctx);
int (*libusb_control_transfer)(void *state,
libusb_device_handle *devh,
uint8_t bmRequestType,
diff --git a/tests/libusb_wraps.c b/tests/libusb_wraps.c
index 94ef652f..978108e6 100644
--- a/tests/libusb_wraps.c
+++ b/tests/libusb_wraps.c
@@ -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;
diff --git a/tests/meson.build b/tests/meson.build
index c55c5d20..30b1e782 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -64,6 +64,7 @@ mocks = [
'-Wl,--wrap=test_outl',
'-Wl,--wrap=test_inl',
'-Wl,--wrap=usb_dev_get_by_vid_pid_number',
+ '-Wl,--wrap=libusb_init',
'-Wl,--wrap=libusb_set_configuration',
'-Wl,--wrap=libusb_claim_interface',
'-Wl,--wrap=libusb_control_transfer',