add testsuite/sanei for sanei test programs

- add sanei_usb_test to test sanei_usb functions
 - update SUBDIRS so the check target is ran on testsuite/sanei
merge-requests/1/head
Stphane Voltz 2013-03-10 11:45:30 +01:00
rodzic 5a1d5a62ee
commit 8b3674a516
10 zmienionych plików z 1835 dodań i 39 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
## This file is part of the "Sane" build infra-structure. See
## included LICENSE file for license information.
SUBDIRS = include lib sanei backend frontend tools doc po
SUBDIRS = include lib sanei backend frontend tools doc po testsuite
DIST_SUBDIRS = include lib sanei backend frontend tools doc po japi testsuite
dist_doc_DATA = AUTHORS ChangeLog COPYING LICENSE NEWS PROBLEMS PROJECTS \

Wyświetl plik

@ -297,7 +297,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = include lib sanei backend frontend tools doc po
SUBDIRS = include lib sanei backend frontend tools doc po testsuite
DIST_SUBDIRS = include lib sanei backend frontend tools doc po japi testsuite
dist_doc_DATA = AUTHORS ChangeLog COPYING LICENSE NEWS PROBLEMS PROJECTS \
README README.aix README.beos README.darwin README.djpeg README.freebsd \

3
configure vendored
Wyświetl plik

@ -18095,7 +18095,7 @@ fi
DISTCLEAN_FILES="*~ .*~ *.log *.bak *.old *.orig *.out *.rej \"\#\"* \".\\#\"*"
ac_config_files="$ac_config_files Makefile lib/Makefile sanei/Makefile frontend/Makefile japi/Makefile backend/Makefile include/Makefile doc/Makefile po/Makefile testsuite/Makefile tools/Makefile doc/doxygen-sanei.conf doc/doxygen-genesys.conf"
ac_config_files="$ac_config_files Makefile lib/Makefile sanei/Makefile frontend/Makefile japi/Makefile backend/Makefile include/Makefile doc/Makefile po/Makefile testsuite/Makefile testsuite/sanei/Makefile tools/Makefile doc/doxygen-sanei.conf doc/doxygen-genesys.conf"
ac_config_files="$ac_config_files tools/sane-config"
@ -19167,6 +19167,7 @@ do
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;;
"testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
"testsuite/sanei/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/sanei/Makefile" ;;
"tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
"doc/doxygen-sanei.conf") CONFIG_FILES="$CONFIG_FILES doc/doxygen-sanei.conf" ;;
"doc/doxygen-genesys.conf") CONFIG_FILES="$CONFIG_FILES doc/doxygen-genesys.conf" ;;

Wyświetl plik

@ -772,7 +772,7 @@ AC_SUBST(DISTCLEAN_FILES)
AC_CONFIG_FILES([Makefile lib/Makefile sanei/Makefile frontend/Makefile \
japi/Makefile backend/Makefile include/Makefile doc/Makefile \
po/Makefile testsuite/Makefile tools/Makefile doc/doxygen-sanei.conf doc/doxygen-genesys.conf])
po/Makefile testsuite/Makefile testsuite/sanei/Makefile tools/Makefile doc/doxygen-sanei.conf doc/doxygen-genesys.conf])
AC_CONFIG_FILES([tools/sane-config], [chmod a+x tools/sane-config])
AC_CONFIG_FILES([tools/sane-backends.pc])
AC_OUTPUT

Wyświetl plik

@ -4,6 +4,8 @@
## This file is part of the "Sane" build infra-structure. See
## included LICENSE file for license information.
SUBDIRS = sanei
SCANIMAGE = ../frontend/scanimage$(EXEEXT)
TESTFILE = $(srcdir)/testfile.pnm
OUTFILE = outfile.pnm

Wyświetl plik

@ -47,7 +47,47 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
distdir
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
@ -218,6 +258,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = sanei
SCANIMAGE = ../frontend/scanimage$(EXEEXT)
TESTFILE = $(srcdir)/testfile.pnm
OUTFILE = outfile.pnm
@ -225,7 +266,7 @@ DEVICE = test
OPTIONS = --mode Color --depth 16 --test-picture "Color pattern" --resolution 50 -y 20 -x 20 > $(OUTFILE)
EXTRA_DIST = README testfile.pnm
CLEANFILES = $(OUTFILE)
all: all-am
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@ -264,12 +305,141 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
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:
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
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:
CTAGS: ctags-recursive $(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'`; \
@ -301,19 +471,48 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
check: check-recursive
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@ -331,84 +530,88 @@ distclean-generic:
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: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi: dvi-recursive
dvi-am:
html: html-am
html: html-recursive
html-am:
info: info-am
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html: install-html-recursive
install-html-am:
install-info: install-info-am
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-am
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf: pdf-recursive
pdf-am:
ps: ps-am
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
install-am install-strip tags-recursive
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool 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 \
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am check check-am clean clean-generic clean-libtool \
ctags ctags-recursive distclean 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 installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am
all: help

Wyświetl plik

@ -0,0 +1,20 @@
## Makefile.am -- an automake template for Makefile.in file
## Copyright (C) 2013 Stéphane Voltz and Sane Developers.
##
## This file is part of the "Sane" build infra-structure. See
## included LICENSE file for license information.
MATH_LIB = @MATH_LIB@
USB_LIBS = @USB_LIBS@
PTHREAD_LIBS = @PTHREAD_LIBS@
check_PROGRAMS = sanei_usb_test
TESTS = $(check_PROGRAMS)
AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
sanei_usb_test_SOURCES = sanei_usb_test.c
sanei_usb_test_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la ../../lib/libfelib.la $(MATH_LIB) $(USB_LIBS) $(PTHREAD_LIBS)
all:
@echo "run 'make check' to run tests"

Wyświetl plik

@ -0,0 +1,630 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@
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@
check_PROGRAMS = sanei_usb_test$(EXEEXT)
subdir = testsuite/sanei
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/byteorder.m4 \
$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/sane/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am_sanei_usb_test_OBJECTS = sanei_usb_test.$(OBJEXT)
sanei_usb_test_OBJECTS = $(am_sanei_usb_test_OBJECTS)
am__DEPENDENCIES_1 =
sanei_usb_test_DEPENDENCIES = ../../sanei/libsanei.la \
../../lib/liblib.la ../../lib/libfelib.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/sane
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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(sanei_usb_test_SOURCES)
DIST_SOURCES = $(sanei_usb_test_SOURCES)
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
red=; grn=; lgn=; blu=; std=
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AVAHI_CFLAGS = @AVAHI_CFLAGS@
AVAHI_LIBS = @AVAHI_LIBS@
AWK = @AWK@
BACKENDS = @BACKENDS@
BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@
BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@
BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DISTCLEAN_FILES = @DISTCLEAN_FILES@
DLLTOOL = @DLLTOOL@
DL_LIBS = @DL_LIBS@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
DVIPS = @DVIPS@
DYNAMIC_FLAG = @DYNAMIC_FLAG@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GPHOTO2_CPPFLAGS = @GPHOTO2_CPPFLAGS@
GPHOTO2_LDFLAGS = @GPHOTO2_LDFLAGS@
GPHOTO2_LIBS = @GPHOTO2_LIBS@
GREP = @GREP@
HAVE_GPHOTO2 = @HAVE_GPHOTO2@
IEEE1284_LIBS = @IEEE1284_LIBS@
INCLUDES = @INCLUDES@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_LOCKPATH = @INSTALL_LOCKPATH@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JPEG_LIBS = @JPEG_LIBS@
LATEX = @LATEX@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBUSB_1_0_CFLAGS = @LIBUSB_1_0_CFLAGS@
LIBUSB_1_0_LIBS = @LIBUSB_1_0_LIBS@
LIBV4L_CFLAGS = @LIBV4L_CFLAGS@
LIBV4L_LIBS = @LIBV4L_LIBS@
LINKER_RPATH = @LINKER_RPATH@
LIPO = @LIPO@
LN_S = @LN_S@
LOCKPATH_GROUP = @LOCKPATH_GROUP@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MATH_LIB = @MATH_LIB@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
NUMBER_VERSION = @NUMBER_VERSION@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
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@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PRELOADABLE_BACKENDS = @PRELOADABLE_BACKENDS@
PRELOADABLE_BACKENDS_ENABLED = @PRELOADABLE_BACKENDS_ENABLED@
PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@
RESMGR_LIBS = @RESMGR_LIBS@
SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@
SANE_CONFIG_PATH = @SANE_CONFIG_PATH@
SCSI_LIBS = @SCSI_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@
SOCKET_LIBS = @SOCKET_LIBS@
STRICT_LDFLAGS = @STRICT_LDFLAGS@
STRIP = @STRIP@
SYSLOG_LIBS = @SYSLOG_LIBS@
SYSTEMD_LIBS = @SYSTEMD_LIBS@
TIFF_LIBS = @TIFF_LIBS@
USB_LIBS = @USB_LIBS@
VERSION = @VERSION@
V_MAJOR = @V_MAJOR@
V_MINOR = @V_MINOR@
V_REV = @V_REV@
XGETTEXT = @XGETTEXT@
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@
configdir = @configdir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
effective_target = @effective_target@
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@
locksanedir = @locksanedir@
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@
TESTS = $(check_PROGRAMS)
AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
sanei_usb_test_SOURCES = sanei_usb_test.c
sanei_usb_test_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la ../../lib/libfelib.la $(MATH_LIB) $(USB_LIBS) $(PTHREAD_LIBS)
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 testsuite/sanei/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu testsuite/sanei/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-checkPROGRAMS:
@list='$(check_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
sanei_usb_test$(EXEEXT): $(sanei_usb_test_OBJECTS) $(sanei_usb_test_DEPENDENCIES)
@rm -f sanei_usb_test$(EXEEXT)
$(LINK) $(sanei_usb_test_OBJECTS) $(sanei_usb_test_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_usb_test.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(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
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
srcdir=$(srcdir); export srcdir; \
list=' $(TESTS) '; \
$(am__tty_colors); \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
elif test -f $$tst; then dir=; \
else dir="$(srcdir)/"; fi; \
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*[\ \ ]$$tst[\ \ ]*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
col=$$red; res=XPASS; \
;; \
*) \
col=$$grn; res=PASS; \
;; \
esac; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*[\ \ ]$$tst[\ \ ]*) \
xfail=`expr $$xfail + 1`; \
col=$$lgn; res=XFAIL; \
;; \
*) \
failed=`expr $$failed + 1`; \
col=$$red; res=FAIL; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
col=$$blu; res=SKIP; \
fi; \
echo "$${col}$$res$${std}: $$tst"; \
done; \
if test "$$all" -eq 1; then \
tests="test"; \
All=""; \
else \
tests="tests"; \
All="All "; \
fi; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
banner="$$All$$all $$tests passed"; \
else \
if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
fi; \
else \
if test "$$xpass" -eq 0; then \
banner="$$failed of $$all $$tests failed"; \
else \
if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
fi; \
fi; \
dashes="$$banner"; \
skipped=""; \
if test "$$skip" -ne 0; then \
if test "$$skip" -eq 1; then \
skipped="($$skip test was not run)"; \
else \
skipped="($$skip tests were not run)"; \
fi; \
test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
dashes="$$skipped"; \
fi; \
report=""; \
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
report="Please report to $(PACKAGE_BUGREPORT)"; \
test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
if test "$$failed" -eq 0; then \
echo "$$grn$$dashes"; \
else \
echo "$$red$$dashes"; \
fi; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
echo "$$dashes$$std"; \
test "$$failed" -eq 0; \
else :; fi
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
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile
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:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
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-checkPROGRAMS clean-generic clean-libtool \
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: check-am install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
clean-checkPROGRAMS clean-generic clean-libtool 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
all:
@echo "run 'make check' to run tests"
# 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:

Wyświetl plik

@ -0,0 +1,19 @@
SANEI test suite
================
This directory contains test programs for sanei functions. They are compiled
and run by 'make check'.
sanei_usb_test
---------------
Tests sanei_usb_* functions. No USB scanner needs to be plugged,
but in this case less code is covered (open/close and claim/release
of real devices).
Function currently tested are:
- sanei_usb_init()
- sanei_usb_open(): valid, invalid devname, already opened
- sanei_usb_get_vendor_product_byname(): valid and invalid devname
- sanei_usb_get_vendor_product(): valid and invalid devname
- sanei_usb_close()
- sanei_usb_exit()
- store_device()

Wyświetl plik

@ -0,0 +1,921 @@
#include "../../include/sane/config.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <stddef.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_MKDIR
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include <assert.h>
#define BACKEND_NAME sanei_usb
#include "../../include/sane/sane.h"
#include "../../include/sane/sanei.h"
#include "../../include/sane/saneopts.h"
#include "../../include/sane/sanei_backend.h"
#include "../../include/sane/sanei_usb.h"
#include "../../include/_stdint.h"
/*
* In order to avoid modifying sanei_usb.c to allow for unit tests
* we include it so we can use its private variables and structures
* and still test the code.
*/
#include "../../sanei/sanei_usb.c"
/** test sanei_usb_init()
* calls sanei_usb_init
* @param expected expected use count
* @return 1 on success, else 0
*/
static int
test_init (int expected)
{
/* initialize USB */
printf ("%s starting ...\n", __FUNCTION__);
sanei_usb_init ();
if (initialized == 0)
{
printf ("ERROR: sanei_usb not initialized!\n");
return 0;
}
if (initialized != expected)
{
printf ("ERROR: incorrect use count, expected %d, got %d!\n", expected,
initialized);
return 0;
}
printf ("sanei_usb initialized, use count is %d ...\n", initialized);
printf ("%s success\n\n", __FUNCTION__);
return 1;
}
/** test sanei_usb_exit()
* calls sanei_usb_exit
* @param expected use count after exit call
* @return 1 on success, else 0
*/
static int
test_exit (int expected)
{
printf ("%s starting ...\n", __FUNCTION__);
/* end of USB use test */
sanei_usb_exit ();
if (initialized != expected)
{
printf ("ERROR: incorrect use count, expected %d, got %d!\n", expected,
initialized);
return 0;
}
printf ("%s success\n\n", __FUNCTION__);
return 1;
}
/** count detected devices
* count all detected devices and check it against expected value
* @param expected detected count
* @return 1 on success, else 0
*/
static int
count_detected (int expected)
{
int num = 0;
int i;
for (i = 0; i < device_number; i++)
{
if (devices[i].missing == 0 && devices[i].devname != NULL)
{
num++;
}
}
if (num != expected)
{
printf ("ERROR: %d detected devices, expected %d!\n", num, expected);
return 0;
}
printf ("%d devices still detected.\n", num);
return 1;
}
/** create mock device
* create a mock device entry
* @param device device pointer to fill with mock data
* @return nothing
*/
static void
create_mock_device (char *devname, device_list_type * device)
{
memset (device, 0, sizeof (device_list_type));
device->devname = strdup (devname);
device->vendor = 0xdead;
device->product = 0xbeef;
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
device->method = sanei_usb_method_libusb;
#endif
#ifdef HAVE_USBCALLS
device->method = sanei_usb_method_usbcalls;
#endif
#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) && !defined(HAVE_USBCALLS)
device->method == sanei_usb_method_scanner_driver;
#endif
}
/** test store_device
* test store_device for corner cases not covered by the
* other regular use by sanei_usb_scan_devices
* the startiing situation is that the mock device has never
* put into device list.
* @return 1 on success, else 0
*/
static int
test_store_device (void)
{
int current_number;
int expected;
int i;
int found;
device_list_type mock;
create_mock_device ("mock", &mock);
/* first test store when there is no more room
* to store device */
current_number = device_number;
device_number = MAX_DEVICES;
store_device (mock);
/* there should be no more devices */
if (device_number > MAX_DEVICES)
{
printf ("ERROR: store past end of device list!\n");
return 0;
}
/* walk device list to be sure mock device hasn't been stored */
for (i = 0; i < MAX_DEVICES; i++)
{
if (devices[i].devname && !strcmp (devices[i].devname, mock.devname))
{
printf
("ERROR: device stored although there were no place for it!\n");
return 0;
}
}
/* restore device_number */
device_number = current_number;
expected = device_number + 1;
/* store mock device */
store_device (mock);
found = 0;
for (i = 0; i < MAX_DEVICES && !found; i++)
{
if (devices[i].devname && !strcmp (devices[i].devname, mock.devname))
{
found = 1;
}
}
if (device_number != expected || !found)
{
printf ("ERROR: mock device not stored !\n");
return 0;
}
/* scan devices should mark it as missing, and device_number should decrease */
sanei_usb_scan_devices ();
found = 0;
for (i = 0; i < MAX_DEVICES && !found; i++)
{
if (devices[i].devname
&& devices[i].missing == 1
&& !strcmp (devices[i].devname, mock.devname))
{
found = 1;
}
}
if (device_number != expected || !found)
{
printf ("ERROR: mock device still present !\n");
return 0;
}
/* second scan devices should mark missing to 2 */
sanei_usb_scan_devices ();
found = 0;
for (i = 0; i < MAX_DEVICES && !found; i++)
{
if (devices[i].devname
&& devices[i].missing == 2
&& !strcmp (devices[i].devname, mock.devname))
{
found = 1;
}
}
if (device_number != expected || !found)
{
printf ("ERROR: mock device slot not reusable !\n");
return 0;
}
/* store mock device again, slot in devices should be reused
* and device_number shouldn't change */
create_mock_device ("mock2", &mock);
store_device (mock);
found = 0;
for (i = 0; i < MAX_DEVICES && !found; i++)
{
if (devices[i].devname && !strcmp (devices[i].devname, mock.devname))
{
found = 1;
}
}
if (device_number != expected || !found)
{
printf ("ERROR: mock device not stored !\n");
return 0;
}
/* last rescan to wipe mock device out */
sanei_usb_scan_devices ();
return 1;
}
/** count opened devices
* count all opended devices and check it against expected value
* @param expected use opened count
* @return 1 on success, else 0
*/
static int
count_opened (int expected)
{
int num = 0;
int i;
for (i = 0; i < device_number; i++)
{
if (devices[i].missing == 0 && devices[i].devname != NULL
&& devices[i].open == SANE_TRUE)
{
num++;
}
}
if (num != expected)
{
printf ("ERROR: %d opened devices, expected %d!\n", num, expected);
return 0;
}
printf ("%d devices still opened.\n", num);
return 1;
}
/** open all devices
* loop on all existing devices and open them
* @param dn array to store opened device number
* @param expected number of devices to be opened
* @return 1 on success, else 0
*/
static int
test_open_all (SANE_Int * dn, int expected)
{
int opened = 0;
int i;
int last;
SANE_Status status;
/* loop on detected devices and open them */
last = -1;
for (i = 0; i < device_number; i++)
{
if (devices[i].missing == 0 && devices[i].devname != NULL)
{
/* open device */
status = sanei_usb_open (devices[i].devname, dn + opened);
if (status == SANE_STATUS_GOOD)
{
opened++;
last = i;
}
else
{
printf ("ERROR: couldn't open device %s!\n",
devices[i].devname);
return 0;
}
}
}
printf ("opened %d devices\n", opened);
/* try to reopen an opened device when there is one */
if (last >= 0)
{
status = sanei_usb_open (devices[last].devname, dn + opened);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: unexpected success when opening %s twice!\n",
devices[last].devname);
return 0;
}
}
/* there should be as many opened devices than detected devices */
return count_opened (expected);
}
/** test opening invalid device
* try to open an non existing device
* @return 1 on success, else 0
*/
static int
test_open_invalid (void)
{
SANE_Status status;
SANE_Int dn;
status = sanei_usb_open ("invalid device", &dn);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: unexpected success opening invalid device!\n");
return 0;
}
return 1;
}
/** close all devices
* loop on all opened devices and close them
* @param dn array of opened device number
* @param expected number of devices to be closed
* @return 1 on success, else 0
*/
static int
test_close_all (SANE_Int * dn, int expected)
{
int closed = 0;
int i;
/* loop on detected devices and open them */
for (i = 0; i < expected; i++)
{
/* close device */
sanei_usb_close (dn[i]);
closed++;
}
printf ("closed %d devices\n", closed);
/* there should be any more opened devices */
return count_opened (0);
}
/** claim all open devices
* loop on all opened devices and claim interface 0
* @param dn array of opened device number
* @param expected number of devices to be claimed
* @return 1 on success, else 0
*/
static int
test_claim_all (SANE_Int * dn, int expected)
{
int claimed = 0;
int i;
SANE_Status status;
device_list_type mock;
claimed = 0;
for (i = 0; i < expected; i++)
{
status = sanei_usb_claim_interface (dn[i], devices[dn[i]].interface_nr);
if (status != SANE_STATUS_GOOD)
{
printf ("ERROR: couldn't claim interface 0 on device %d!\n", dn[i]);
}
else
{
claimed++;
}
}
if (claimed != expected)
{
printf ("ERROR: expected %d claimed interfaces, got %d!\n", expected,
claimed);
return 0;
}
printf ("%d devices claimed...\n\n", claimed);
/* try to claim invalid device entry */
status = sanei_usb_claim_interface (device_number, 0);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: could claim interface 0 on invalid device!\n");
return 0;
}
/* create a mock device and make it missing by rescanning */
create_mock_device ("mock", &mock);
store_device (mock);
sanei_usb_scan_devices ();
/* try to claim interface on missing device */
status = sanei_usb_claim_interface (device_number - 1, 0);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: could claim interface 0 on invalid device!\n");
return 0;
}
/* remove mock device */
device_number--;
free (devices[device_number].devname);
devices[device_number].devname = NULL;
return 1;
}
/** release all claimed devices
* loop on all opened devices and claim interface 0
* @param dn array of opened device number
* @param expected number of devices to be claimed
* @return 1 on success, else 0
*/
static int
test_release_all (SANE_Int * dn, int expected)
{
int released = 0;
int i;
SANE_Status status;
device_list_type mock;
released = 0;
for (i = 0; i < expected; i++)
{
status =
sanei_usb_release_interface (dn[i], devices[dn[i]].interface_nr);
if (status != SANE_STATUS_GOOD)
{
printf ("ERROR: couldn't release interface 0 on device %d!\n",
dn[i]);
}
else
{
released++;
}
}
if (released != expected)
{
printf ("ERROR: expected %d released interfaces, got %d!\n", expected,
released);
return 0;
}
printf ("%d devices released...\n\n", released);
/* try to release invalid device entry */
status = sanei_usb_release_interface (device_number, 0);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: could release interface 0 on invalid device!\n");
return 0;
}
/* create a mock device and make it missing by rescanning */
create_mock_device ("mock", &mock);
store_device (mock);
sanei_usb_scan_devices ();
/* try to claim interface on missing device */
status = sanei_usb_release_interface (device_number - 1, 0);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: could release interface 0 on invalid device!\n");
return 0;
}
/* remove mock device */
device_number--;
free (devices[device_number].devname);
devices[device_number].devname = NULL;
return 1;
}
/** get id for all devices names
* loop on all existing devices and get vendor
* and product id by name.
* @param expected count
* @return 1 on success, else 0
*/
static int
test_vendor_by_devname (void)
{
int i;
SANE_Status status;
SANE_Word vendor, product;
device_list_type mock;
/* loop on detected devices and open them */
for (i = 0; i < device_number; i++)
{
if (devices[i].missing == 0 && devices[i].devname != NULL)
{
/* get device id */
status = sanei_usb_get_vendor_product_byname (devices[i].devname,
&vendor, &product);
if (status != SANE_STATUS_GOOD)
{
printf ("ERROR: couldn't query device %s!\n",
devices[i].devname);
return 0;
}
if (vendor == 0 || product == 0)
{
printf ("ERROR: incomplete device id for %s!\n",
devices[i].devname);
return 0;
}
printf ("%s is %04x:%04x\n", devices[i].devname, vendor, product);
}
}
/* add mock device */
create_mock_device ("mock", &mock);
store_device (mock);
status = sanei_usb_get_vendor_product_byname ("mock", &vendor, &product);
if (status != SANE_STATUS_GOOD)
{
printf ("ERROR: getting vendor for mock devname!\n");
return 0;
}
if (vendor != mock.vendor || product != mock.product)
{
printf ("ERROR: wrong vendor/product for mock devname!\n");
return 0;
}
/* remove mock device */
device_number--;
free (devices[device_number].devname);
devices[device_number].devname = NULL;
/* try go get id for an invalid devname */
status = sanei_usb_get_vendor_product_byname ("invalid devname",
&vendor, &product);
if (status == SANE_STATUS_GOOD)
{
printf ("ERROR: unexpected success getting id for invalid devname!\n");
return 0;
}
printf ("\n");
return 1;
}
/** get vendor for all devices id
* loop on all existing devices and get vendor
* and product id.
* @param expected count
* @return 1 on success, else 0
*/
static int
test_vendor_by_id (void)
{
int i;
SANE_Status status;
SANE_Word vendor, product;
device_list_type mock;
/* loop on detected devices and open them */
for (i = 0; i < device_number; i++)
{
if (devices[i].missing == 0 && devices[i].devname != NULL)
{
/* get device id */
status = sanei_usb_get_vendor_product (i, &vendor, &product);
if (status != SANE_STATUS_GOOD)
{
printf ("ERROR: couldn't query device %d!\n", i);
return 0;
}
if (vendor == 0 || product == 0)
{
printf ("ERROR: incomplete device id for %d!\n", i);
return 0;
}
printf ("%d is %04x:%04x\n", i, vendor, product);
}
}
/* add mock device */
create_mock_device ("mock", &mock);
store_device (mock);
status =
sanei_usb_get_vendor_product (device_number - 1, &vendor, &product);
if (status != SANE_STATUS_GOOD)
{
printf ("ERROR: getting vendor for mock devname!\n");
return 0;
}
if (vendor != mock.vendor || product != mock.product)
{
printf ("ERROR: wrong vendor/product for mock devname!\n");
return 0;
}
/* remove mock device */
device_number--;
free (devices[device_number].devname);
devices[device_number].devname = NULL;
/* try go get id for an invalid id */
status =
sanei_usb_get_vendor_product (device_number + 1, &vendor, &product);
if (status == SANE_STATUS_GOOD)
{
printf
("ERROR: unexpected success getting vendor for invalid devname!\n");
return 0;
}
printf ("\n");
return 1;
}
/** test timeout functions : libusb only
* @return 1 on success, else 0
*/
static int
test_timeout (void)
{
#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
int timeout = libusb_timeout;
sanei_usb_set_timeout (5000);
if (libusb_timeout != 5000)
{
printf ("ERROR: failed to set timeout\n");
return 1;
}
sanei_usb_set_timeout (timeout);
#endif
return 1;
}
/** test device scanning
* call sanei_usb_scan_devices, since it has no return code, no real
* assert can be done, but at least we can test it doesn't break
* other functions or don't leak memory
* @return always 1
*/
static int
test_scan_devices (int detected, int opened)
{
int rc;
printf ("rescanning for devices ...\n");
sanei_usb_scan_devices ();
rc = count_detected (detected);
if (!rc)
{
printf ("ERROR: scanning devices change detected count!\n");
return 0;
}
rc = count_opened (opened);
if (!rc)
{
printf ("ERROR: scanning devices change opened count!\n");
return 0;
}
printf ("\n");
return 1;
}
/**
* flag for dummy attach
*/
static int dummy_flag;
/**
* expected device name during attach
*/
static char *expected_device;
/** dummy attach function
* dummy attach function
* @return resturn SANE_STATUS_GOOD
*/
static SANE_Status
dummy_attach (const char *dev)
{
dummy_flag = (strcmp (expected_device, dev) == 0);
if (dummy_flag)
{
printf ("success attaching to %s...\n", dev);
}
else
{
printf ("failed attaching to %s...\n", dev);
}
return SANE_STATUS_GOOD;
}
/** test attaching usb device
* create a mock device and attach to it, checking
* if it is ok
* @return 1 on success, else 0
*/
static int
test_attach (void)
{
device_list_type mock;
/* add mock device and try ot attach to it */
dummy_flag = 0;
create_mock_device ("mock", &mock);
expected_device = mock.devname;
store_device (mock);
sanei_usb_attach_matching_devices ("usb 0xdead 0xbeef", dummy_attach);
/* flag must be set */
if (dummy_flag != 1)
{
printf ("ERROR: couldn't attach to 'usb xdead 0xbeef' device!\n");
return 0;
}
/* attach by devname */
dummy_flag = 0;
sanei_usb_attach_matching_devices (mock.devname, dummy_attach);
/* flag must be set */
if (dummy_flag != 1)
{
printf ("ERROR: couldn't attach to 'mock' device!\n");
return 0;
}
/* attach to bogus device */
dummy_flag = 0;
sanei_usb_attach_matching_devices ("usb 0x0001 0x0001", dummy_attach);
/* flag must not be set */
if (dummy_flag != 0)
{
printf ("ERROR: shouldn't be attached to bogus device!\n");
return 0;
}
/* attach by bogus devname */
sanei_usb_attach_matching_devices ("bogus", dummy_attach);
/* flag must not be set */
if (dummy_flag != 0)
{
printf ("ERROR: shouldn't be attached to bogus device!\n");
return 0;
}
/* remove mock device */
device_number--;
free (devices[device_number].devname);
devices[device_number].devname = NULL;
dummy_flag = 0;
return 1;
}
int
main (int argc, char **argv)
{
int detected, i;
SANE_Int dn[MAX_DEVICES];
#ifdef HAVE_LIBUSB
printf ("\n%s built with old libusb\n\n", argv[0]);
#endif
#ifdef HAVE_LIBUSB_1_0
printf ("\n%s built with libusb-1.0\n\n", argv[0]);
#endif
#ifdef HAVE_USBCALLS
printf ("\n%s built with usbcalls\n\n", argv[0]);
#endif
#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) && !defined(HAVE_USBCALLS)
printf ("\n%s relying on deprecated scanner kernel module\n", argv[0]);
#endif
/* start sanei_usb */
assert (test_init (1));
/* test timeout function */
assert (test_timeout ());
/* count available devices */
detected = 0;
for (i = 0; i < device_number; i++)
{
if (devices[i].missing == 0 && devices[i].devname != NULL)
{
detected++;
}
}
printf ("%d devices found.\n", detected);
/* rescan devices : detected count shouldn't change */
assert (test_scan_devices (detected, 0));
/* test corner cases with mock device */
assert (test_store_device ());
/* get vendor/product id for all available devices devname */
assert (test_vendor_by_devname ());
/* get vendor/product id for all available devices id */
assert (test_vendor_by_id ());
/* open all available devices */
assert (test_open_all (dn, detected));
/* rescan devices : detected and opened count shouldn't change */
assert (test_scan_devices (detected, detected));
/* try to open an inexisting device */
assert (test_open_invalid ());
/* increase sanei _sub use count */
assert (test_init (2));
/* there should be still as many detected devices */
assert (count_detected (detected));
/* there should be still as many opened devices than detected devices */
assert (count_opened (detected));
assert (test_exit (1));
/* there should be still as many opened devices than detected devices */
assert (count_opened (detected));
/* count devices again , sanei_usb_exit() shouldn't have
* change the count */
assert (count_detected (detected));
/* claim all available devices */
assert (test_claim_all (dn, detected));
/* then release them all */
assert (test_release_all (dn, detected));
/* close all opened devices */
assert (test_close_all (dn, detected));
/* check there is no opened device */
assert (count_opened (0));
/* finally free resources */
assert (test_exit (0));
/* check there is no more devices */
assert (count_detected (0));
/* test attach matching device with a mock */
assert (test_attach ());
/* try to call sanei_usb_exit() when it not initialized */
assert (test_exit (0));
/* scan devices when sanei usb is not initialized */
assert (test_scan_devices (0, 0));
/* we re start use of sanei usb so we check we have left it
* it he correct state after "closing" it. */
printf ("\n============================================================\n");
printf ("restart use of sanei usb after having freed all resources...\n\n");
assert (test_init (1));
/* we should have the same initial count of detected devices */
assert (count_detected (detected));
/* finally free resources */
assert (test_exit (0));
/* all the tests are OK ! */
return 0;
}
/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */