Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unstable test/unit/tcti-spi-ftdi #2639

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile-test.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
33 changes: 33 additions & 0 deletions test/unit/tcti-spi-ftdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
33 changes: 33 additions & 0 deletions test/unit/tcti-spi-lt2go.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down