2
0
forked from Ivasoft/DSView

Add DSLogic hardware support

This commit is contained in:
DreamSourceLab
2014-04-14 17:46:11 +08:00
parent a76c4b4a5f
commit 264a094168
300 changed files with 305141 additions and 284 deletions

View File

@@ -0,0 +1,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/libusb
LDADD = ../libusb/libusb-1.0.la
noinst_PROGRAMS = stress
stress_SOURCES = stress.c libusbx_testlib.h testlib.c

View File

@@ -0,0 +1,525 @@
# Makefile.in generated by automake 1.11.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
noinst_PROGRAMS = stress$(EXEEXT)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/libusb/version.h \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
PROGRAMS = $(noinst_PROGRAMS)
am_stress_OBJECTS = stress.$(OBJEXT) testlib.$(OBJEXT)
stress_OBJECTS = $(am_stress_OBJECTS)
stress_LDADD = $(LDADD)
stress_DEPENDENCIES = ../libusb/libusb-1.0.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(stress_SOURCES)
DIST_SOURCES = $(stress_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLDFLAGS = @LTLDFLAGS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_DARWIN = @OS_DARWIN@
OS_LINUX = @OS_LINUX@
OS_NETBSD = @OS_NETBSD@
OS_OPENBSD = @OS_OPENBSD@
OS_WINDOWS = @OS_WINDOWS@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
RC = @RC@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_UDEV = @USE_UDEV@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir)/libusb
LDADD = ../libusb/libusb-1.0.la
stress_SOURCES = stress.c libusbx_testlib.h testlib.c
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu tests/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
stress$(EXEEXT): $(stress_OBJECTS) $(stress_DEPENDENCIES) $(EXTRA_stress_DEPENDENCIES)
@rm -f stress$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(stress_OBJECTS) $(stress_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stress.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testlib.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstPROGRAMS ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,107 @@
/*
* libusbx test library helper functions
* Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIBUSBX_TESTLIB_H
#define LIBUSBX_TESTLIB_H
#include <stdio.h>
#if !defined(bool)
#define bool int
#endif
#if !defined(true)
#define true (1 == 1)
#endif
#if !defined(false)
#define false (!true)
#endif
/** Values returned from a test function to indicate test result */
typedef enum {
/** Indicates that the test ran successfully. */
TEST_STATUS_SUCCESS,
/** Indicates that the test failed one or more test. */
TEST_STATUS_FAILURE,
/** Indicates that an unexpected error occurred. */
TEST_STATUS_ERROR,
/** Indicates that the test can't be run. For example this may be
* due to no suitable device being connected to perform the tests.*/
TEST_STATUS_SKIP
} libusbx_testlib_result;
/**
* Context for test library functions
*/
typedef struct {
char ** test_names;
int test_count;
bool list_tests;
bool verbose;
int old_stdout;
int old_stderr;
FILE* output_file;
int null_fd;
} libusbx_testlib_ctx;
/**
* Logs some test information or state
*/
void libusbx_testlib_logf(libusbx_testlib_ctx * ctx,
const char* fmt, ...);
/**
* Function pointer for a libusbx test function.
*
* Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value.
*/
typedef libusbx_testlib_result
(*libusbx_testlib_test_function)(libusbx_testlib_ctx * ctx);
/**
* Structure holding a test description.
*/
typedef struct {
/** Human readable name of the test. */
const char * name;
/** The test library will call this function to run the test. */
libusbx_testlib_test_function function;
} libusbx_testlib_test;
/**
* Value to use at the end of a test array to indicate the last
* element.
*/
#define LIBUSBX_NULL_TEST {NULL, NULL}
/**
* Runs the tests provided.
*
* Before running any tests argc and argv will be processed
* to determine the mode of operation.
*
* \param argc The argc from main
* \param argv The argv from main
* \param tests A NULL_TEST terminated array of tests
* \return 0 on success, non-zero on failure
*/
int libusbx_testlib_run_tests(int argc,
char ** argv,
const libusbx_testlib_test * tests);
#endif //LIBUSBX_TESTLIB_H

View File

@@ -0,0 +1,160 @@
/*
* libusbx stress test program to perform simple stress tests
* Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include "libusb.h"
#include "libusbx_testlib.h"
/** Test that creates and destroys a single concurrent context
* 10000 times. */
static libusbx_testlib_result test_init_and_exit(libusbx_testlib_ctx * tctx)
{
libusb_context * ctx = NULL;
int i;
for (i = 0; i < 10000; ++i) {
int r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
libusbx_testlib_logf(tctx,
"Failed to init libusb on iteration %d: %d",
i, r);
return TEST_STATUS_FAILURE;
}
libusb_exit(ctx);
ctx = NULL;
}
return TEST_STATUS_SUCCESS;
}
/** Tests that devices can be listed 1000 times. */
static libusbx_testlib_result test_get_device_list(libusbx_testlib_ctx * tctx)
{
libusb_context * ctx = NULL;
int r, i;
r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
for (i = 0; i < 1000; ++i) {
libusb_device ** device_list;
ssize_t list_size = libusb_get_device_list(ctx, &device_list);
if (list_size < 0 || device_list == NULL) {
libusbx_testlib_logf(tctx,
"Failed to get device list on iteration %d: %d (%p)",
i, -list_size, device_list);
return TEST_STATUS_FAILURE;
}
libusb_free_device_list(device_list, 1);
}
libusb_exit(ctx);
return TEST_STATUS_SUCCESS;
}
/** Tests that 100 concurrent device lists can be open at a time. */
static libusbx_testlib_result test_many_device_lists(libusbx_testlib_ctx * tctx)
{
#define LIST_COUNT 100
libusb_context * ctx = NULL;
libusb_device ** device_lists[LIST_COUNT];
int r, i;
memset(device_lists, 0, sizeof(device_lists));
r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
/* Create the 100 device lists. */
for (i = 0; i < LIST_COUNT; ++i) {
ssize_t list_size = libusb_get_device_list(ctx, &(device_lists[i]));
if (list_size < 0 || device_lists[i] == NULL) {
libusbx_testlib_logf(tctx,
"Failed to get device list on iteration %d: %d (%p)",
i, -list_size, device_lists[i]);
return TEST_STATUS_FAILURE;
}
}
/* Destroy the 100 device lists. */
for (i = 0; i < LIST_COUNT; ++i) {
if (device_lists[i]) {
libusb_free_device_list(device_lists[i], 1);
device_lists[i] = NULL;
}
}
libusb_exit(ctx);
return TEST_STATUS_SUCCESS;
#undef LIST_COUNT
}
/** Tests that the default context (used for various things including
* logging) works correctly when the first context created in a
* process is destroyed. */
static libusbx_testlib_result test_default_context_change(libusbx_testlib_ctx * tctx)
{
libusb_context * ctx = NULL;
int r, i;
for (i = 0; i < 100; ++i) {
/* First create a new context */
r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
/* Enable debug output, to be sure to use the context */
libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG);
libusb_set_debug(ctx, LIBUSB_LOG_LEVEL_DEBUG);
/* Now create a reference to the default context */
r = libusb_init(NULL);
if (r != LIBUSB_SUCCESS) {
libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
/* Destroy the first context */
libusb_exit(ctx);
/* Destroy the default context */
libusb_exit(NULL);
}
return TEST_STATUS_SUCCESS;
}
/* Fill in the list of tests. */
static const libusbx_testlib_test tests[] = {
{"init_and_exit", &test_init_and_exit},
{"get_device_list", &test_get_device_list},
{"many_device_lists", &test_many_device_lists},
{"default_context_change", &test_default_context_change},
LIBUSBX_NULL_TEST
};
int main (int argc, char ** argv)
{
return libusbx_testlib_run_tests(argc, argv, tests);
}

View File

@@ -0,0 +1,277 @@
/*
* libusbx test library helper functions
* Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libusbx_testlib.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#if !defined(_WIN32_WCE)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
#if defined(_WIN32_WCE)
// No support for selective redirection of STDOUT on WinCE.
#define DISABLE_STDOUT_REDIRECTION
#define STDOUT_FILENO 1
#elif defined(_WIN32)
#include <io.h>
#define dup _dup
#define dup2 _dup2
#define open _open
#define close _close
#define fdopen _fdopen
#define NULL_PATH "nul"
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#else
#include <unistd.h>
#define NULL_PATH "/dev/null"
#endif
#define INVALID_FD -1
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
/**
* Converts a test result code into a human readable string.
*/
static const char* test_result_to_str(libusbx_testlib_result result)
{
switch (result) {
case TEST_STATUS_SUCCESS:
return "Success";
case TEST_STATUS_FAILURE:
return "Failure";
case TEST_STATUS_ERROR:
return "Error";
case TEST_STATUS_SKIP:
return "Skip";
default:
return "Unknown";
}
}
static void print_usage(int argc, char ** argv)
{
printf("Usage: %s [-l] [-v] [<test_name> ...]\n",
argc > 0 ? argv[0] : "test_*");
printf(" -l List available tests\n");
printf(" -v Don't redirect STDERR/STDOUT during tests\n");
}
static void cleanup_test_output(libusbx_testlib_ctx * ctx)
{
#ifndef DISABLE_STDOUT_REDIRECTION
if (!ctx->verbose) {
if (ctx->old_stdout != INVALID_FD) {
IGNORE_RETVAL(dup2(ctx->old_stdout, STDOUT_FILENO));
ctx->old_stdout = INVALID_FD;
}
if (ctx->old_stderr != INVALID_FD) {
IGNORE_RETVAL(dup2(ctx->old_stderr, STDERR_FILENO));
ctx->old_stderr = INVALID_FD;
}
if (ctx->null_fd != INVALID_FD) {
close(ctx->null_fd);
ctx->null_fd = INVALID_FD;
}
if (ctx->output_file != stdout) {
fclose(ctx->output_file);
ctx->output_file = stdout;
}
}
#endif
}
/**
* Setup test output handles
* \return zero on success, non-zero on failure
*/
static int setup_test_output(libusbx_testlib_ctx * ctx)
{
#ifndef DISABLE_STDOUT_REDIRECTION
/* Stop output to stdout and stderr from being displayed if using non-verbose output */
if (!ctx->verbose) {
/* Keep a copy of STDOUT and STDERR */
ctx->old_stdout = dup(STDOUT_FILENO);
if (ctx->old_stdout < 0) {
ctx->old_stdout = INVALID_FD;
printf("Failed to duplicate stdout handle: %d\n", errno);
return 1;
}
ctx->old_stderr = dup(STDERR_FILENO);
if (ctx->old_stderr < 0) {
ctx->old_stderr = INVALID_FD;
cleanup_test_output(ctx);
printf("Failed to duplicate stderr handle: %d\n", errno);
return 1;
}
/* Redirect STDOUT_FILENO and STDERR_FILENO to /dev/null or "nul"*/
ctx->null_fd = open(NULL_PATH, O_WRONLY);
if (ctx->null_fd < 0) {
ctx->null_fd = INVALID_FD;
cleanup_test_output(ctx);
printf("Failed to open null handle: %d\n", errno);
return 1;
}
if ((dup2(ctx->null_fd, STDOUT_FILENO) < 0) ||
(dup2(ctx->null_fd, STDERR_FILENO) < 0)) {
cleanup_test_output(ctx);
return 1;
}
ctx->output_file = fdopen(ctx->old_stdout, "w");
if (!ctx->output_file) {
ctx->output_file = stdout;
cleanup_test_output(ctx);
printf("Failed to open FILE for output handle: %d\n", errno);
return 1;
}
}
#endif
return 0;
}
void libusbx_testlib_logf(libusbx_testlib_ctx * ctx,
const char* fmt, ...)
{
va_list va;
va_start(va, fmt);
vfprintf(ctx->output_file, fmt, va);
va_end(va);
fprintf(ctx->output_file, "\n");
fflush(ctx->output_file);
}
int libusbx_testlib_run_tests(int argc,
char ** argv,
const libusbx_testlib_test * tests)
{
int run_count = 0;
int idx = 0;
int pass_count = 0;
int fail_count = 0;
int error_count = 0;
int skip_count = 0;
int r, j;
size_t arglen;
libusbx_testlib_result test_result;
libusbx_testlib_ctx ctx;
/* Setup default mode of operation */
ctx.test_names = NULL;
ctx.test_count = 0;
ctx.list_tests = false;
ctx.verbose = false;
ctx.old_stdout = INVALID_FD;
ctx.old_stderr = INVALID_FD;
ctx.output_file = stdout;
ctx.null_fd = INVALID_FD;
/* Parse command line options */
if (argc >= 2) {
for (j = 1; j < argc; j++) {
arglen = strlen(argv[j]);
if ( ((argv[j][0] == '-') || (argv[j][0] == '/')) &&
arglen >=2 ) {
switch (argv[j][1]) {
case 'l':
ctx.list_tests = true;
break;
case 'v':
ctx.verbose = true;
break;
default:
printf("Unknown option: '%s'\n", argv[j]);
print_usage(argc, argv);
return 1;
}
} else {
/* End of command line options, remaining must be list of tests to run */
ctx.test_names = argv + j;
ctx.test_count = argc - j;
break;
}
}
}
/* Validate command line options */
if (ctx.test_names && ctx.list_tests) {
printf("List of tests requested but test list provided\n");
print_usage(argc, argv);
return 1;
}
/* Setup test log output */
r = setup_test_output(&ctx);
if (r != 0)
return r;
/* Act on any options not related to running tests */
if (ctx.list_tests) {
while (tests[idx].function != NULL) {
libusbx_testlib_logf(&ctx, tests[idx].name);
++idx;
}
cleanup_test_output(&ctx);
return 0;
}
/* Run any requested tests */
while (tests[idx].function != NULL) {
const libusbx_testlib_test * test = &tests[idx];
++idx;
if (ctx.test_count > 0) {
/* Filtering tests to run, check if this is one of them */
int i;
for (i = 0; i < ctx.test_count; ++i) {
if (strcmp(ctx.test_names[i], test->name) == 0)
/* Matches a requested test name */
break;
}
if (i >= ctx.test_count) {
/* Failed to find a test match, so do the next loop iteration */
continue;
}
}
libusbx_testlib_logf(&ctx,
"Starting test run: %s...", test->name);
test_result = test->function(&ctx);
libusbx_testlib_logf(&ctx,
"%s (%d)",
test_result_to_str(test_result), test_result);
switch (test_result) {
case TEST_STATUS_SUCCESS: pass_count++; break;
case TEST_STATUS_FAILURE: fail_count++; break;
case TEST_STATUS_ERROR: error_count++; break;
case TEST_STATUS_SKIP: skip_count++; break;
}
++run_count;
}
libusbx_testlib_logf(&ctx, "---");
libusbx_testlib_logf(&ctx, "Ran %d tests", run_count);
libusbx_testlib_logf(&ctx, "Passed %d tests", pass_count);
libusbx_testlib_logf(&ctx, "Failed %d tests", fail_count);
libusbx_testlib_logf(&ctx, "Error in %d tests", error_count);
libusbx_testlib_logf(&ctx, "Skipped %d tests", skip_count);
cleanup_test_output(&ctx);
return pass_count != run_count;
}