mirror of https://github.com/nirenjan/libx52.git
Add stub routines for mocking libusb
This is to be used for running automated tests on libx52 and associated libraries and/or programspull/13/head
parent
59652c0aff
commit
dc7300db26
|
@ -1,6 +1,6 @@
|
|||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = libx52 test cli util
|
||||
SUBDIRS = libx52 cli util libusbx52 test
|
||||
|
||||
# Extra files that need to be in the distribution
|
||||
EXTRA_DIST = README.md LICENSE
|
||||
|
|
|
@ -30,8 +30,9 @@ AC_SUBST([X52_CORE_LIB], [../libx52/libx52.la])
|
|||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
libx52/Makefile
|
||||
test/Makefile
|
||||
libusbx52/Makefile
|
||||
cli/Makefile
|
||||
util/Makefile
|
||||
test/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# libusb stub library for use by test programs
|
||||
check_LTLIBRARIES = libusbx52.la
|
||||
|
||||
libusbx52_la_SOURCES = usb_x52_stub.c
|
||||
|
||||
EXTRA_DIST = README.md
|
|
@ -0,0 +1,15 @@
|
|||
LibUSB mocker library
|
||||
=====================
|
||||
|
||||
This folder contains a convenience library to mock the API of libusb. This is
|
||||
intended to be used as an LD_PRELOAD library when used by automated tests to
|
||||
verify the library without needing actual hardware to verify the tests.
|
||||
|
||||
While a manual test using real hardware is valuable, running some automated
|
||||
tests in an environment where the hardware is not available is equally valuable,
|
||||
especially if the source code is changing frequently.
|
||||
|
||||
Note that the API exported by the mocker is limited to the API used by libx52,
|
||||
as writing a complete USB simulator stack in software is not an easy job, nor is
|
||||
it necessary for the purposes of this project.
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* LibUSB stub driver for testing the Saitek X52/X52 Pro
|
||||
*
|
||||
* Copyright (C) 2017 Nirenjan Krishnan (nirenjan@nirenjan.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation, version 2.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
|
||||
int libusb_init(libusb_context **ctx)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libusb_exit(libusb_context *ctx)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void libusb_set_debug(libusb_context *ctx, int level)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
ssize_t libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libusb_free_device_list(libusb_device **list, int unref_devices)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int libusb_get_device_descriptor(libusb_device *dev,
|
||||
struct libusb_device_descriptor *desc)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libusb_open(libusb_device *dev, libusb_device_handle **handle)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libusb_close(libusb_device_handle *dev_handle)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int libusb_control_transfer(libusb_device_handle *dev_handle,
|
||||
uint8_t request_type,
|
||||
uint8_t bRequest,
|
||||
uint16_t wValue,
|
||||
uint16_t wIndex,
|
||||
unsigned char *data,
|
||||
uint16_t wLength,
|
||||
unsigned int timeout)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue