diff --git a/Makefile-test.am b/Makefile-test.am index 2d36185ac..494e8581f 100644 --- a/Makefile-test.am +++ b/Makefile-test.am @@ -557,7 +557,9 @@ test_unit_tcti_spi_lt2go_LDFLAGS = -Wl,--wrap=libusb_bulk_transfer \ -Wl,--wrap=libusb_open_device_with_vid_pid \ -Wl,--wrap=libusb_release_interface \ -Wl,--wrap=libusb_set_auto_detach_kernel_driver \ - -Wl,--wrap=libusb_strerror + -Wl,--wrap=libusb_strerror \ + -Wl,--wrap=select \ + -Wl,--wrap=gettimeofday test_unit_tcti_spi_lt2go_SOURCES = test/unit/tcti-spi-lt2go.c \ src/tss2-tcti/tcti-spi-lt2go.c endif @@ -571,7 +573,9 @@ test_unit_tcti_spi_ftdi_LDFLAGS = -Wl,--wrap=Close \ -Wl,--wrap=PinLow \ -Wl,--wrap=Start \ -Wl,--wrap=Stop \ - -Wl,--wrap=Transfer + -Wl,--wrap=Transfer \ + -Wl,--wrap=select \ + -Wl,--wrap=gettimeofday test_unit_tcti_spi_ftdi_SOURCES = test/unit/tcti-spi-ftdi.c \ src/tss2-tcti/tcti-spi-ftdi.c endif diff --git a/test/unit/tcti-spi-ftdi.c b/test/unit/tcti-spi-ftdi.c index 0f90dbc5f..e1758cd32 100644 --- a/test/unit/tcti-spi-ftdi.c +++ b/test/unit/tcti-spi-ftdi.c @@ -42,6 +42,39 @@ static const unsigned char TPM_RID_0[] = {0x80, 0xd4, 0x0f, 0x04, 0x00}; static struct mpsse_context *_mpsse; +/* + * Mock function select + */ +int __wrap_select (int nfds, fd_set *readfds, + fd_set *writefds, + fd_set *exceptfds, + struct timeval *timeout) +{ + + assert_int_equal (nfds, 0); + assert_null (readfds); + assert_null (writefds); + assert_null (exceptfds); + assert_non_null (timeout); + + return 0; +} + +/* + * Mock function gettimeofday + */ +int __wrap_gettimeofday (struct timeval *tv, + struct timezone *tz) +{ + assert_null (tz); + assert_non_null (tv); + + tv->tv_sec = 0; + tv->tv_usec = 0; + + return 0; +} + /* * Mock function MPSSE */ diff --git a/test/unit/tcti-spi-lt2go.c b/test/unit/tcti-spi-lt2go.c index 474626882..71ca91737 100644 --- a/test/unit/tcti-spi-lt2go.c +++ b/test/unit/tcti-spi-lt2go.c @@ -59,6 +59,39 @@ static unsigned char *device_mem_alloc; static size_t device_mem_alloc_length; static uint16_t transfer_length; +/* + * Mock function select + */ +int __wrap_select (int nfds, fd_set *readfds, + fd_set *writefds, + fd_set *exceptfds, + struct timeval *timeout) +{ + + assert_int_equal (nfds, 0); + assert_null (readfds); + assert_null (writefds); + assert_null (exceptfds); + assert_non_null (timeout); + + return 0; +} + +/* + * Mock function gettimeofday + */ +int __wrap_gettimeofday (struct timeval *tv, + struct timezone *tz) +{ + assert_null (tz); + assert_non_null (tv); + + tv->tv_sec = 0; + tv->tv_usec = 0; + + return 0; +} + /* * Mock function libusb_get_device. */