diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-10-06 14:00:40 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-10-06 14:00:40 +0200 |
commit | 6e9c41a892ed0e0da326e0278b3221ce3f5713b8 (patch) | |
tree | 2e301d871bbeeb44aa57ff9cc070fcf3be484487 /testsuite/sanei |
Initial import of sane-backends version 1.0.24-1.2
Diffstat (limited to 'testsuite/sanei')
-rw-r--r-- | testsuite/sanei/Makefile.am | 43 | ||||
-rw-r--r-- | testsuite/sanei/Makefile.in | 1108 | ||||
-rw-r--r-- | testsuite/sanei/README | 40 | ||||
-rw-r--r-- | testsuite/sanei/data/boolean.conf | 6 | ||||
-rw-r--r-- | testsuite/sanei/data/empty.conf | 1 | ||||
-rw-r--r-- | testsuite/sanei/data/fixed.conf | 6 | ||||
-rw-r--r-- | testsuite/sanei/data/int.conf | 2 | ||||
-rw-r--r-- | testsuite/sanei/data/snapscan.conf | 115 | ||||
-rw-r--r-- | testsuite/sanei/data/string-list.conf | 3 | ||||
-rw-r--r-- | testsuite/sanei/data/string.conf | 3 | ||||
-rw-r--r-- | testsuite/sanei/data/umax_pp.conf | 64 | ||||
-rw-r--r-- | testsuite/sanei/data/word-array.conf | 2 | ||||
-rw-r--r-- | testsuite/sanei/data/wrong-boolean.conf | 4 | ||||
-rw-r--r-- | testsuite/sanei/data/wrong-fixed.conf | 2 | ||||
-rw-r--r-- | testsuite/sanei/data/wrong-range.conf | 2 | ||||
-rw-r--r-- | testsuite/sanei/data/wrong-string-list.conf | 3 | ||||
-rw-r--r-- | testsuite/sanei/sanei_check_test.c | 478 | ||||
-rw-r--r-- | testsuite/sanei/sanei_config_test.c | 904 | ||||
-rw-r--r-- | testsuite/sanei/sanei_constrain_test.c | 795 | ||||
-rw-r--r-- | testsuite/sanei/sanei_usb_test.c | 949 | ||||
-rw-r--r-- | testsuite/sanei/test_wire.c | 236 |
21 files changed, 4766 insertions, 0 deletions
diff --git a/testsuite/sanei/Makefile.am b/testsuite/sanei/Makefile.am new file mode 100644 index 0000000..74cde52 --- /dev/null +++ b/testsuite/sanei/Makefile.am @@ -0,0 +1,43 @@ +## 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. + +EXTRA_DIST = data/boolean.conf data/empty.conf data/fixed.conf data/int.conf \ + data/snapscan.conf data/string.conf data/string-list.conf \ + data/umax_pp.conf data/word-array.conf data/wrong-boolean.conf \ + data/wrong-fixed.conf data/wrong-range.conf \ + data/wrong-string-list.conf + +MATH_LIB = @MATH_LIB@ +USB_LIBS = @USB_LIBS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +TEST_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la ../../lib/libfelib.la $(MATH_LIB) $(USB_LIBS) $(PTHREAD_LIBS) + +check_PROGRAMS = sanei_usb_test test_wire sanei_check_test sanei_config_test sanei_constrain_test +TESTS = $(check_PROGRAMS) + +AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include + +sanei_constrain_test_SOURCES = sanei_constrain_test.c +sanei_constrain_test_LDADD = $(TEST_LDADD) + +sanei_config_test_SOURCES = sanei_config_test.c +sanei_config_test_CPPFLAGS = $(AM_CPPFLAGS) -DTESTSUITE_SANEI_SRCDIR=$(srcdir) +sanei_config_test_LDADD = $(TEST_LDADD) + +sanei_check_test_SOURCES = sanei_check_test.c +sanei_check_test_LDADD = $(TEST_LDADD) + +sanei_usb_test_SOURCES = sanei_usb_test.c +sanei_usb_test_LDADD = $(TEST_LDADD) + +test_wire_SOURCES = test_wire.c +test_wire_LDADD = $(TEST_LDADD) + +clean-local: + rm -f test_wire.out + +all: + @echo "run 'make check' to run tests" diff --git a/testsuite/sanei/Makefile.in b/testsuite/sanei/Makefile.in new file mode 100644 index 0000000..af6761f --- /dev/null +++ b/testsuite/sanei/Makefile.in @@ -0,0 +1,1108 @@ +# Makefile.in generated by automake 1.13.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 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__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +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) test_wire$(EXEEXT) \ + sanei_check_test$(EXEEXT) sanei_config_test$(EXEEXT) \ + sanei_constrain_test$(EXEEXT) +subdir = testsuite/sanei +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/mkinstalldirs $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver README +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(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_check_test_OBJECTS = sanei_check_test.$(OBJEXT) +sanei_check_test_OBJECTS = $(am_sanei_check_test_OBJECTS) +am__DEPENDENCIES_1 = +am__DEPENDENCIES_2 = ../../sanei/libsanei.la ../../lib/liblib.la \ + ../../lib/libfelib.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +sanei_check_test_DEPENDENCIES = $(am__DEPENDENCIES_2) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +am_sanei_config_test_OBJECTS = \ + sanei_config_test-sanei_config_test.$(OBJEXT) +sanei_config_test_OBJECTS = $(am_sanei_config_test_OBJECTS) +sanei_config_test_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_sanei_constrain_test_OBJECTS = sanei_constrain_test.$(OBJEXT) +sanei_constrain_test_OBJECTS = $(am_sanei_constrain_test_OBJECTS) +sanei_constrain_test_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_sanei_usb_test_OBJECTS = sanei_usb_test.$(OBJEXT) +sanei_usb_test_OBJECTS = $(am_sanei_usb_test_OBJECTS) +sanei_usb_test_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_test_wire_OBJECTS = test_wire.$(OBJEXT) +test_wire_OBJECTS = $(am_test_wire_OBJECTS) +test_wire_DEPENDENCIES = $(am__DEPENDENCIES_2) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_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) $(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_CC_1 = +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_CCLD_1 = +SOURCES = $(sanei_check_test_SOURCES) $(sanei_config_test_SOURCES) \ + $(sanei_constrain_test_SOURCES) $(sanei_usb_test_SOURCES) \ + $(test_wire_SOURCES) +DIST_SOURCES = $(sanei_check_test_SOURCES) \ + $(sanei_config_test_SOURCES) $(sanei_constrain_test_SOURCES) \ + $(sanei_usb_test_SOURCES) $(test_wire_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +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@ +EXTRA_DIST = data/boolean.conf data/empty.conf data/fixed.conf data/int.conf \ + data/snapscan.conf data/string.conf data/string-list.conf \ + data/umax_pp.conf data/word-array.conf data/wrong-boolean.conf \ + data/wrong-fixed.conf data/wrong-range.conf \ + data/wrong-string-list.conf + +TEST_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la ../../lib/libfelib.la $(MATH_LIB) $(USB_LIBS) $(PTHREAD_LIBS) +TESTS = $(check_PROGRAMS) +AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include +sanei_constrain_test_SOURCES = sanei_constrain_test.c +sanei_constrain_test_LDADD = $(TEST_LDADD) +sanei_config_test_SOURCES = sanei_config_test.c +sanei_config_test_CPPFLAGS = $(AM_CPPFLAGS) -DTESTSUITE_SANEI_SRCDIR=$(srcdir) +sanei_config_test_LDADD = $(TEST_LDADD) +sanei_check_test_SOURCES = sanei_check_test.c +sanei_check_test_LDADD = $(TEST_LDADD) +sanei_usb_test_SOURCES = sanei_usb_test.c +sanei_usb_test_LDADD = $(TEST_LDADD) +test_wire_SOURCES = test_wire.c +test_wire_LDADD = $(TEST_LDADD) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs +$(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_check_test$(EXEEXT): $(sanei_check_test_OBJECTS) $(sanei_check_test_DEPENDENCIES) $(EXTRA_sanei_check_test_DEPENDENCIES) + @rm -f sanei_check_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(sanei_check_test_OBJECTS) $(sanei_check_test_LDADD) $(LIBS) + +sanei_config_test$(EXEEXT): $(sanei_config_test_OBJECTS) $(sanei_config_test_DEPENDENCIES) $(EXTRA_sanei_config_test_DEPENDENCIES) + @rm -f sanei_config_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(sanei_config_test_OBJECTS) $(sanei_config_test_LDADD) $(LIBS) + +sanei_constrain_test$(EXEEXT): $(sanei_constrain_test_OBJECTS) $(sanei_constrain_test_DEPENDENCIES) $(EXTRA_sanei_constrain_test_DEPENDENCIES) + @rm -f sanei_constrain_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(sanei_constrain_test_OBJECTS) $(sanei_constrain_test_LDADD) $(LIBS) + +sanei_usb_test$(EXEEXT): $(sanei_usb_test_OBJECTS) $(sanei_usb_test_DEPENDENCIES) $(EXTRA_sanei_usb_test_DEPENDENCIES) + @rm -f sanei_usb_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(sanei_usb_test_OBJECTS) $(sanei_usb_test_LDADD) $(LIBS) + +test_wire$(EXEEXT): $(test_wire_OBJECTS) $(test_wire_DEPENDENCIES) $(EXTRA_test_wire_DEPENDENCIES) + @rm -f test_wire$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_wire_OBJECTS) $(test_wire_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_check_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_config_test-sanei_config_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_constrain_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_usb_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wire.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 $@ $< + +sanei_config_test-sanei_config_test.o: sanei_config_test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sanei_config_test-sanei_config_test.o -MD -MP -MF $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo -c -o sanei_config_test-sanei_config_test.o `test -f 'sanei_config_test.c' || echo '$(srcdir)/'`sanei_config_test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo $(DEPDIR)/sanei_config_test-sanei_config_test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sanei_config_test.c' object='sanei_config_test-sanei_config_test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sanei_config_test-sanei_config_test.o `test -f 'sanei_config_test.c' || echo '$(srcdir)/'`sanei_config_test.c + +sanei_config_test-sanei_config_test.obj: sanei_config_test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sanei_config_test-sanei_config_test.obj -MD -MP -MF $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo -c -o sanei_config_test-sanei_config_test.obj `if test -f 'sanei_config_test.c'; then $(CYGPATH_W) 'sanei_config_test.c'; else $(CYGPATH_W) '$(srcdir)/sanei_config_test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo $(DEPDIR)/sanei_config_test-sanei_config_test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sanei_config_test.c' object='sanei_config_test-sanei_config_test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sanei_config_test-sanei_config_test.obj `if test -f 'sanei_config_test.c'; then $(CYGPATH_W) 'sanei_config_test.c'; else $(CYGPATH_W) '$(srcdir)/sanei_config_test.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + 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-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + 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" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +sanei_usb_test.log: sanei_usb_test$(EXEEXT) + @p='sanei_usb_test$(EXEEXT)'; \ + b='sanei_usb_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +test_wire.log: test_wire$(EXEEXT) + @p='test_wire$(EXEEXT)'; \ + b='test_wire'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +sanei_check_test.log: sanei_check_test$(EXEEXT) + @p='sanei_check_test$(EXEEXT)'; \ + b='sanei_check_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +sanei_config_test.log: sanei_config_test$(EXEEXT) + @p='sanei_config_test$(EXEEXT)'; \ + b='sanei_config_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +sanei_constrain_test.log: sanei_constrain_test$(EXEEXT) + @p='sanei_constrain_test$(EXEEXT)'; \ + b='sanei_constrain_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +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: + 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: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +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 clean-local \ + 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 TAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool clean-local \ + cscopelist-am ctags ctags-am 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 \ + recheck tags tags-am uninstall uninstall-am + + +clean-local: + rm -f test_wire.out + +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: diff --git a/testsuite/sanei/README b/testsuite/sanei/README new file mode 100644 index 0000000..247d191 --- /dev/null +++ b/testsuite/sanei/README @@ -0,0 +1,40 @@ +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() + + +sanei_constrain_test +-------------------- + Tests for sanei_constrain_* functions +Function currently tested are: + - sanei_constrain_value() + + +sanei_check_test +---------------- + Tests for sanei_check_* functions +Function currently tested are: + - sanei_check_value() + + +sanei_config_test +----------------- + Tests for sanei_configure_* functions +Function currently tested are: + - sanei_configure_attach() diff --git a/testsuite/sanei/data/boolean.conf b/testsuite/sanei/data/boolean.conf new file mode 100644 index 0000000..f71c0be --- /dev/null +++ b/testsuite/sanei/data/boolean.conf @@ -0,0 +1,6 @@ +# true boolean value +option booltrue true +# false boolean value +boolfalse false +# boolean array +option boolarray false true false diff --git a/testsuite/sanei/data/empty.conf b/testsuite/sanei/data/empty.conf new file mode 100644 index 0000000..f26ad08 --- /dev/null +++ b/testsuite/sanei/data/empty.conf @@ -0,0 +1 @@ +attach devname diff --git a/testsuite/sanei/data/fixed.conf b/testsuite/sanei/data/fixed.conf new file mode 100644 index 0000000..db8dc01 --- /dev/null +++ b/testsuite/sanei/data/fixed.conf @@ -0,0 +1,6 @@ +# FIXED type options +option height 29.7 +some device +option array-of-fixed 2.0 2.1 2.2 2.3 2.4 2.5 2.6 +another device +option width 21.0 diff --git a/testsuite/sanei/data/int.conf b/testsuite/sanei/data/int.conf new file mode 100644 index 0000000..da6738c --- /dev/null +++ b/testsuite/sanei/data/int.conf @@ -0,0 +1,2 @@ +option modelnumber 1234 +attach devname diff --git a/testsuite/sanei/data/snapscan.conf b/testsuite/sanei/data/snapscan.conf new file mode 100644 index 0000000..b244e3a --- /dev/null +++ b/testsuite/sanei/data/snapscan.conf @@ -0,0 +1,115 @@ +#------------------------------ General ----------------------------------- + +# Change to the fully qualified filename of your firmware file, if +# firmware upload is needed by the scanner +firmware /usr/share/sane/snapscan/your-firmwarefile.bin + +# If not automatically found you may manually specify a device name. + +# For USB scanners also specify bus=usb, e.g. +# /dev/usb/scanner0 bus=usb + +# For SCSI scanners specify the generic device, e.g. /dev/sg0 on Linux. +# /dev/sg0 + +#--------------------------------------------------------------------------- +# No changes should be necessary below this line +#--------------------------------------------------------------------------- + +#-------------------------- SCSI scanners ---------------------------------- +# These SCSI devices will be probed automatically +scsi AGFA * Scanner +scsi COLOR * Scanner +scsi Color * Scanner +scsi ACERPERI * Scanner + +#--------------------------- USB scanners ----------------------------------- +# These USB devices will be probed automatically +# (This will currently work only on Linux) + +# Benq/Acer/Vuego 310U +usb 0x04a5 0x1a20 +usb 0x04a5 0x1a26 + +# Benq/Acer/Vuego 320U +usb 0x04a5 0x2022 + +# Benq/Acer/Vuego 620U / 620UT +usb 0x04a5 0x1a2a +usb 0x04a5 0x2040 + +# Benq/Acer/Vuego 640U +usb 0x04a5 0x2060 + +# Benq/Acer/Vuego 640BU +usb 0x04a5 0x207e + +# Benq/Acer/Vuego 640BT +usb 0x04a5 0x20be + +# Benq/Acer/Vuego 1240U +usb 0x04a5 0x20c0 + +# Benq/Acer/Vuego 3300 / 4300 +usb 0x04a5 0x20b0 + +# Benq/Acer/Vuego 4300 +usb 0x04a5 0x20de + +# Benq 5000E / 5000U +usb 0x04a5 0x20f8 + +# Benq 5000 +usb 0x04a5 0x20fc + +# Benq/Acer 5300 +usb 0x04a5 0x20fe + +# Benq 5250C +usb 0x04a5 0x2137 + +# Agfa 1236U +usb 0x06bd 0x0002 + +# Agfa 1212U +usb 0x06bd 0x0001 +usb 0x06bd 0x2061 + +# Agfa Snapscan e10 +usb 0x06bd 0x2093 + +# Agfa Snapscan e20 +usb 0x06bd 0x2091 + +# Agfa Snapscan e25 +usb 0x06bd 0x2095 + +# Agfa Snapscan e26 +usb 0x06bd 0x2097 + +# Agfa Snapscan e40 +usb 0x06bd 0x208d + +# Agfa Snapscan e42 +usb 0x06bd 0x20ff + +# Agfa Snapscan e50 +usb 0x06bd 0x208f + +# Agfa Snapscan e52 +usb 0x06bd 0x20fd + +# Epson Perfection 660 +usb 0x04b8 0x0114 + +# Epson Perfection 1670 +usb 0x04b8 0x011f + +# Epson Perfection 2480 +usb 0x04b8 0x0121 + +# Epson Perfection 3490 +usb 0x04b8 0x0122 + +# Epson Stylus CX-1500 +usb 0x04b8 0x080c diff --git a/testsuite/sanei/data/string-list.conf b/testsuite/sanei/data/string-list.conf new file mode 100644 index 0000000..ffd9b57 --- /dev/null +++ b/testsuite/sanei/data/string-list.conf @@ -0,0 +1,3 @@ +# one choice from string1, string2, string3 and string4 +option string-choice "string3" +attach devname diff --git a/testsuite/sanei/data/string.conf b/testsuite/sanei/data/string.conf new file mode 100644 index 0000000..eb3a1cb --- /dev/null +++ b/testsuite/sanei/data/string.conf @@ -0,0 +1,3 @@ +option modelname "my model" +vendor "my vendor" +attach devname diff --git a/testsuite/sanei/data/umax_pp.conf b/testsuite/sanei/data/umax_pp.conf new file mode 100644 index 0000000..69cc47d --- /dev/null +++ b/testsuite/sanei/data/umax_pp.conf @@ -0,0 +1,64 @@ +# For documentation see sane-umax_pp(5) + +# GLOBAL # + +# size (in bytes) of scan buffer (default: 2 megabyte) +option buffer 1048576 + + +# DEVICES # + +# specify the port your scanner is connected to. +# +# the value 'auto' will make the backend find the correct value +# by itself, it will scan ppdev, ppi device, then hardware address +# 'safe-auto' will do the same but won't do direct hardware access +# on linux systems, you may provide the device name of the ppdev character +# device : /dev/parport0, /dev/parport1, ...... +# +# on *BSD, you may provide the device name of the ppi device: /dev/ppi0, +# /dev/ppi1, ... +# +# Possible hardware addresses are 0x378 (lp0) +# 0x278 (lp2) and 0x3c8 (lp1) +# + +port safe-auto + +# the following options are local to this scanner +# gain for red channel, if not given, will be automatically computed +# must be between 0 and 15 +option red-gain 1 + +# gain for green channel, if not given, will be automatically computed +# must be between 0 and 15 +option green-gain 2 + +# gain for blue channel, if not given, will be automatically computed +# must be between 0 and 15 +option blue-gain 3 + +# offset for red channel, if not given, will default to 0 +# must be between 0 and 15 +option red-offset 4 + +# offset for green channel, if not given, will default to 0 +# must be between 0 and 15 +option green-offset 5 + +# offset for blue channel, if not given, will default to 0 +# must be between 0 and 15 +option blue-offset 6 + + +# +# +# model number +# +# valid values are 610, 1220, 1600 and 2000 +# +# by default, no model, we rely on autodetection +# in case you have black or 'inverted' scans, +# you may override detection by providing the +# model number +option astra 1600 diff --git a/testsuite/sanei/data/word-array.conf b/testsuite/sanei/data/word-array.conf new file mode 100644 index 0000000..4a8a58a --- /dev/null +++ b/testsuite/sanei/data/word-array.conf @@ -0,0 +1,2 @@ +option numbers 1000 1100 1200 1300 1400 1500 1600 +attach devname diff --git a/testsuite/sanei/data/wrong-boolean.conf b/testsuite/sanei/data/wrong-boolean.conf new file mode 100644 index 0000000..c8b64fe --- /dev/null +++ b/testsuite/sanei/data/wrong-boolean.conf @@ -0,0 +1,4 @@ +# true boolean value +option booltrue true +# false boolean value +boolfalse buggy diff --git a/testsuite/sanei/data/wrong-fixed.conf b/testsuite/sanei/data/wrong-fixed.conf new file mode 100644 index 0000000..846c91c --- /dev/null +++ b/testsuite/sanei/data/wrong-fixed.conf @@ -0,0 +1,2 @@ +# value out of range +option height 59.7 diff --git a/testsuite/sanei/data/wrong-range.conf b/testsuite/sanei/data/wrong-range.conf new file mode 100644 index 0000000..00d005c --- /dev/null +++ b/testsuite/sanei/data/wrong-range.conf @@ -0,0 +1,2 @@ +option modelnumber 234 +attach devname diff --git a/testsuite/sanei/data/wrong-string-list.conf b/testsuite/sanei/data/wrong-string-list.conf new file mode 100644 index 0000000..7d8c82e --- /dev/null +++ b/testsuite/sanei/data/wrong-string-list.conf @@ -0,0 +1,3 @@ +# one choice from string1, string2, string3 and string4 +option string-choice "wrong" +attach devname diff --git a/testsuite/sanei/sanei_check_test.c b/testsuite/sanei/sanei_check_test.c new file mode 100644 index 0000000..a149b7e --- /dev/null +++ b/testsuite/sanei/sanei_check_test.c @@ -0,0 +1,478 @@ +#include "../../include/sane/config.h" + +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <assert.h> + +/* sane includes for the sanei functions called */ +#include "../../include/sane/sane.h" +#include "../../include/sane/saneopts.h" +#include "../../include/sane/sanei.h" + +/* range for constraint */ +static const SANE_Range int_range = { + 3, /* minimum */ + 18, /* maximum */ + 3 /* quantization */ +}; + +static SANE_Option_Descriptor int_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_FIXED, + SANE_UNIT_MM, + sizeof (SANE_Word), + 0, + SANE_CONSTRAINT_RANGE, + {NULL} +}; + +#define ARRAY_SIZE 7 + +static SANE_Option_Descriptor array_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_FIXED, + SANE_UNIT_MM, + sizeof (SANE_Word) * ARRAY_SIZE, + 0, + SANE_CONSTRAINT_RANGE, + {NULL} +}; + +static SANE_Option_Descriptor bool_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_BOOL, + SANE_UNIT_MM, + sizeof (SANE_Bool), + 0, + SANE_CONSTRAINT_NONE, + {NULL} +}; + +static SANE_Option_Descriptor bool_array_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_BOOL, + SANE_UNIT_MM, + sizeof (SANE_Bool) * ARRAY_SIZE, + 0, + SANE_CONSTRAINT_NONE, + {NULL} +}; + + +#define WORD_SIZE 9 +static const SANE_Int dpi_list[] = + { WORD_SIZE - 1, 100, 200, 300, 400, 500, 600, 700, 800 }; + +static SANE_Option_Descriptor word_array_opt = { + SANE_NAME_SCAN_RESOLUTION, + SANE_TITLE_SCAN_RESOLUTION, + SANE_DESC_SCAN_RESOLUTION, + SANE_TYPE_INT, + SANE_UNIT_DPI, + sizeof (SANE_Word) * WORD_SIZE, + 100, + SANE_CONSTRAINT_WORD_LIST, + {NULL} +}; + +/******************************/ +/* start of tests definitions */ +/******************************/ + +/* + * constrained int + */ +static void +min_int_value (void) +{ + SANE_Int value = int_range.min; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (value == int_range.min); +} + + +static void +max_int_value (void) +{ + SANE_Int value = int_range.max; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (value == int_range.max); +} + + +static void +below_min_int_value (void) +{ + SANE_Int value = int_range.min - 1; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +/* rounded to lower value */ +static void +quant1_int_value (void) +{ + SANE_Int value = int_range.min + 1; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +/* close to higher value */ +static void +quant2_int_value (void) +{ + SANE_Int value = int_range.min + int_range.quant - 1; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +static void +in_range_int_value (void) +{ + SANE_Int value = int_range.min + int_range.quant; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (value == int_range.min + int_range.quant); +} + + +static void +above_max_int_value (void) +{ + SANE_Int value = int_range.max + 1; + SANE_Status status; + + status = sanei_check_value (&int_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +/* + * constrained int array + */ +static void +min_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min; + } + status = sanei_check_value (&array_opt, value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min); + } +} + + +static void +max_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.max; + } + + status = sanei_check_value (&array_opt, value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.max); + } +} + + +static void +below_min_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min - 1; + } + + status = sanei_check_value (&array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +/* rounded to lower value */ +static void +quant1_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min + 1; + } + status = sanei_check_value (&array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +/* rounded to higher value */ +static void +quant2_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min + int_range.quant - 1; + } + status = sanei_check_value (&array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +static void +in_range_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min + int_range.quant; + } + + status = sanei_check_value (&array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min + int_range.quant); + } +} + + +static void +above_max_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.max + 1; + } + status = sanei_check_value (&array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +static void +bool_true (void) +{ + SANE_Bool value = SANE_TRUE; + SANE_Status status; + status = sanei_check_value (&bool_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +static void +bool_false (void) +{ + SANE_Bool value = SANE_FALSE; + SANE_Status status; + status = sanei_check_value (&bool_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +static void +wrong_bool (void) +{ + SANE_Bool value = 2; + SANE_Status status; + status = sanei_check_value (&bool_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +static void +bool_array (void) +{ + SANE_Bool value[ARRAY_SIZE]; + SANE_Status status; + int i; + for (i = 0; i < ARRAY_SIZE; i++) + value[i] = i % 2; + status = sanei_check_value (&bool_array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +static void +word_array_ok (void) +{ + SANE_Word value = 400; + SANE_Status status; + status = sanei_check_value (&word_array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +static void +word_array_nok (void) +{ + SANE_Word value = 444; + SANE_Status status; + status = sanei_check_value (&word_array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + +static void +wrong_bool_array (void) +{ + SANE_Bool value[ARRAY_SIZE]; + SANE_Status status; + int i; + for (i = 0; i < ARRAY_SIZE; i++) + value[i] = i % 2; + value[3] = 4; + status = sanei_check_value (&bool_array_opt, &value); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +/** + * run the test suite for sanei_check_value related tests + */ +static void +sanei_check_suite (void) +{ + /* to be compatible with pre-C99 compilers */ + int_opt.constraint.range = &int_range; + array_opt.constraint.range = &int_range; + word_array_opt.constraint.word_list = dpi_list; + + /* tests for constrained int value */ + min_int_value (); + max_int_value (); + below_min_int_value (); + above_max_int_value (); + quant1_int_value (); + quant2_int_value (); + in_range_int_value (); + + /* tests for constrained int array */ + min_int_array (); + max_int_array (); + below_min_int_array (); + above_max_int_array (); + quant1_int_array (); + quant2_int_array (); + in_range_int_array (); + + /* tests for boolean value */ + bool_true (); + bool_false (); + wrong_bool (); + bool_array (); + wrong_bool_array (); + + /* word array test */ + word_array_ok (); + word_array_nok (); +} + + +int +main (void) +{ + sanei_check_suite (); + return 0; +} + +/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ diff --git a/testsuite/sanei/sanei_config_test.c b/testsuite/sanei/sanei_config_test.c new file mode 100644 index 0000000..9a07f2b --- /dev/null +++ b/testsuite/sanei/sanei_config_test.c @@ -0,0 +1,904 @@ +#include "../../include/sane/config.h" + +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <assert.h> + +/* sane includes for the sanei functions called */ +#include "../include/sane/sane.h" +#include "../include/sane/saneopts.h" +#include "../include/sane/sanei.h" +#include "../include/sane/sanei_config.h" + +#define XSTR(s) STR(s) +#define STR(s) #s +#define CONFIG_PATH XSTR(TESTSUITE_SANEI_SRCDIR) + +/* + * variables and functions used by the tests below + */ + + +/* range for constraint */ +static const SANE_Range model_range = { + 1000, /* minimum */ + 2000, /* maximum */ + 2 /* quantization */ +}; + +/* range for memory buffer size constraint */ +static const SANE_Range buffer_range = { + 1024, /* minimum bytes */ + 2048 * 1024, /* maximum bytes */ + 1024 /* quantization */ +}; + +/* range for int value in [0-15] */ +static const SANE_Range value16_range = { + 0, /* minimum */ + 15, /* maximum */ + 1 /* quantization */ +}; + +/* range for fixed height value */ +static const SANE_Range height_range = { + SANE_FIX (0), /* minimum */ + SANE_FIX (29.7), /* maximum */ + 0 /* no quantization : hard to do for float values ... */ +}; + +/* list of astra models */ +static const SANE_String_Const astra_models[] = + { "610", "1220", "1600", "2000", NULL }; + +/* string list */ +static const SANE_String_Const string_list[] = + { "string1", "string2", "string3", "string4", NULL }; + +/* last device name used for attach callback */ +static char *lastdevname = NULL; + +static SANE_Status +check_config_attach (SANEI_Config * config, const char *devname) +{ + /* silence compiler warning for now */ + if (config == NULL) + { + return SANE_STATUS_INVAL; + } + + fprintf (stdout, "attaching with devname '%s'\n", devname); + if (lastdevname != NULL) + { + free (lastdevname); + } + lastdevname = strdup (devname); + return SANE_STATUS_GOOD; +} + +/******************************/ +/* start of tests definitions */ +/******************************/ + +/* + * non-existent config file + */ +static void +inexistent_config (void) +{ + SANE_Status status; + SANEI_Config config; + + config.count = 0; + config.descriptors = NULL; + config.values = NULL; + status = sanei_configure_attach (CONFIG_PATH + "/data/inexistent.conf", &config, NULL); + + /* check results */ + assert (status != SANE_STATUS_GOOD); +} + + +/* + * no config struct + */ +static void +null_config (void) +{ + SANE_Status status; + + status = + sanei_configure_attach (CONFIG_PATH "/data/umax_pp.conf", NULL, + check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +/* + * no attach function + */ +static void +null_attach (void) +{ + SANE_Status status; + + status = sanei_configure_attach (CONFIG_PATH + "/data/umax_pp.conf", NULL, NULL); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +/* + * empty config : backend has no configuration option + */ +static void +empty_config (void) +{ + SANE_Status status; + SANEI_Config config; + + config.count = 0; + config.descriptors = NULL; + config.values = NULL; + status = + sanei_configure_attach (CONFIG_PATH "/data/empty.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); +} + + +/* + * string option + */ +static void +string_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Char modelname[128]; + SANE_Char vendor[128]; + SANE_Option_Descriptor *options[2]; + void *values[2]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "modelname"; + options[i]->title = "model name"; + options[i]->desc = "user provided scanner's model name"; + options[i]->type = SANE_TYPE_STRING; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = 128; + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = modelname; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "vendor"; + options[i]->title = "vendor name"; + options[i]->desc = "user provided scanner's vendor name"; + options[i]->type = SANE_TYPE_STRING; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = 128; + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = vendor; + i++; + + config.count = i; + config.descriptors = options; + config.values = values; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/string.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (strcmp (modelname, "my model") == 0); + assert (strcmp (vendor, "my vendor") == 0); +} + + +/* + * int option + */ +static void +int_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Word modelnumber; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "modelnumber"; + options[i]->title = "model number"; + options[i]->desc = "user provided scanner's model number"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &model_range; + values[i] = &modelnumber; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/int.conf", &config, + check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (modelnumber == 1234); +} + + +/* + * int option out of range + */ +static void +wrong_range_int_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Word modelnumber = -1; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "modelnumber"; + options[i]->title = "model number"; + options[i]->desc = "user provided scanner's model number"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &model_range; + values[i] = &modelnumber; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/wrong-range.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_INVAL); + assert (modelnumber == -1); +} + + +/* + * word array + */ +static void +word_array_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Word numbers[7]; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "numbers"; + options[i]->title = "some numbers"; + options[i]->desc = "an array of numbers"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word) * 7; + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &model_range; + values[i] = numbers; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/word-array.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + for (i = 0; i < 7; i++) + { + assert (numbers[i] == 1000 + 100 * i); + } +} + + +/* + * string option with string list constraint + */ +static void +string_list_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Char choice[128]; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "string-choice"; + options[i]->title = "string choice"; + options[i]->desc = "one string among a fixed list"; + options[i]->type = SANE_TYPE_STRING; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = 128; + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_STRING_LIST; + options[i]->constraint.string_list = string_list; + values[i] = choice; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/string-list.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (strcmp (choice, "string3") == 0); +} + + +/* + * string option with string list constraint + */ +static void +wrong_string_list_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Char choice[128]; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "string-choice"; + options[i]->title = "string choice"; + options[i]->desc = "one string among a fixed list"; + options[i]->type = SANE_TYPE_STRING; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = 128; + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_STRING_LIST; + options[i]->constraint.string_list = string_list; + values[i] = choice; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + choice[0] = 0; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH + "/data/wrong-string-list.conf", &config, + check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_INVAL); + assert (strcmp (choice, "") == 0); +} + + +/* + * real umax_pp confiugration file parsing + */ +static void +umax_pp (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Option_Descriptor *options[9]; + void *values[9]; + int i = 0; + /* placeholders for options */ + SANE_Word buffersize = -1; + SANE_Word redgain = -1; + SANE_Word greengain = -1; + SANE_Word bluegain = -1; + SANE_Word redoffset = -1; + SANE_Word greenoffset = -1; + SANE_Word blueoffset = -1; + SANE_Char model[128]; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "buffer"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &buffer_range; + values[i] = &buffersize; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "red-gain"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &value16_range; + values[i] = &redgain; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "green-gain"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &value16_range; + values[i] = &greengain; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "blue-gain"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &value16_range; + values[i] = &bluegain; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "red-offset"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &value16_range; + values[i] = &redoffset; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "green-offset"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &value16_range; + values[i] = &greenoffset; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "blue-offset"; + options[i]->type = SANE_TYPE_INT; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &value16_range; + values[i] = &blueoffset; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "astra"; + options[i]->type = SANE_TYPE_STRING; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = 128; + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_STRING_LIST; + options[i]->constraint.string_list = astra_models; + values[i] = &model; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + model[0] = 0; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/umax_pp.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (buffersize == 1048576); + assert (redgain == 1); + assert (greengain == 2); + assert (bluegain == 3); + assert (redoffset == 4); + assert (greenoffset == 5); + assert (blueoffset == 6); + assert (strcmp (model, "1600") == 0); + assert (strcmp (lastdevname, "port safe-auto") == 0); + + /* free memory */ + while (i > 0) + { + i--; + free (options[i]); + } +} + + +/* + * boolean option + */ +static void +wrong_bool_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Option_Descriptor *options[2]; + void *values[2]; + SANE_Bool booltrue, boolfalse; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "booltrue"; + options[i]->title = "boolean true"; + options[i]->type = SANE_TYPE_BOOL; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Bool); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = &booltrue; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "boolfalse"; + options[i]->title = "boolean false"; + options[i]->type = SANE_TYPE_BOOL; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Bool); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = &boolfalse; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/wrong-boolean.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_INVAL); + assert (booltrue == SANE_TRUE); +} + + +/* + * boolean option + */ +static void +bool_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Option_Descriptor *options[3]; + void *values[3]; + SANE_Bool booltrue, boolfalse, boolarray[3]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "booltrue"; + options[i]->title = "boolean true"; + options[i]->type = SANE_TYPE_BOOL; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Bool); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = &booltrue; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "boolfalse"; + options[i]->title = "boolean false"; + options[i]->type = SANE_TYPE_BOOL; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Bool); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = &boolfalse; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "boolarray"; + options[i]->title = "boolean array"; + options[i]->type = SANE_TYPE_BOOL; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (boolarray); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = boolarray; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/boolean.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (booltrue == SANE_TRUE); + assert (boolfalse == SANE_FALSE); + for (i = 0; i < 3; i++) + { + assert (boolarray[i] == (SANE_Bool) i % 2); + } +} + + +/* + * fixed option + */ +static void +fixed_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Word width, height, fixedarray[7]; + SANE_Option_Descriptor *options[3]; + void *values[3]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "width"; + options[i]->title = "width"; + options[i]->type = SANE_TYPE_FIXED; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = &width; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "height"; + options[i]->title = "height"; + options[i]->type = SANE_TYPE_FIXED; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = &height; + i++; + + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "array-of-fixed"; + options[i]->title = "array of fixed"; + options[i]->type = SANE_TYPE_FIXED; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (fixedarray); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &height_range; + values[i] = fixedarray; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/fixed.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (width == SANE_FIX (21.0)); + assert (height == SANE_FIX (29.7)); + for (i = 0; i < 7; i++) + { + assert (fixedarray[i] == SANE_FIX (2.0 + 0.1 * ((float) i))); + } +} + + +/* + * fixed option with value out of range + */ +static void +wrong_fixed_option (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Word height; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "height"; + options[i]->title = "height"; + options[i]->type = SANE_TYPE_FIXED; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (SANE_Word); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_RANGE; + options[i]->constraint.range = &height_range; + values[i] = &height; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/wrong-fixed.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_INVAL); +} + + +static void +snapscan (void) +{ + SANE_Status status; + SANEI_Config config; + SANE_Char firmware[128]; + SANE_Option_Descriptor *options[1]; + void *values[1]; + int i; + + i = 0; + options[i] = + (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); + options[i]->name = "firmware"; + options[i]->title = "scanner's firmware path"; + options[i]->desc = "user provided scanner's full path"; + options[i]->type = SANE_TYPE_STRING; + options[i]->unit = SANE_UNIT_NONE; + options[i]->size = sizeof (firmware); + options[i]->cap = SANE_CAP_SOFT_SELECT; + options[i]->constraint_type = SANE_CONSTRAINT_NONE; + values[i] = firmware; + i++; + + config.descriptors = options; + config.values = values; + config.count = i; + + /* configure and attach */ + status = + sanei_configure_attach (CONFIG_PATH "/data/snapscan.conf", + &config, check_config_attach); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (strcmp (firmware, "/usr/share/sane/snapscan/your-firmwarefile.bin") + == 0); + /* TODO must test attach() done */ +} + + +/** + * create the test suite for sanei config related tests + */ +static void +sanei_config_suite (void) +{ + /* tests */ + inexistent_config (); + empty_config (); + null_config (); + null_attach (); + string_option (); + int_option (); + string_list_option (); + word_array_option (); + bool_option (); + fixed_option (); + wrong_range_int_option (); + wrong_string_list_option (); + wrong_bool_option (); + wrong_fixed_option (); + + /* backend real conf inspired cases */ + umax_pp (); + snapscan (); +} + +/** + * main function to run the test suites + */ +int +main (void) +{ + /* run suites */ + sanei_config_suite (); + + return 0; +} + +/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ diff --git a/testsuite/sanei/sanei_constrain_test.c b/testsuite/sanei/sanei_constrain_test.c new file mode 100644 index 0000000..0f66bbb --- /dev/null +++ b/testsuite/sanei/sanei_constrain_test.c @@ -0,0 +1,795 @@ +#include "../../include/sane/config.h" + +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <assert.h> + +/* sane includes for the sanei functions called */ +#include "../include/sane/sane.h" +#include "../include/sane/saneopts.h" +#include "../include/sane/sanei.h" + +static SANE_Option_Descriptor none_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_INT, + SANE_UNIT_NONE, + sizeof (SANE_Word), + 0, + SANE_CONSTRAINT_NONE, + {NULL} +}; + + +static SANE_Option_Descriptor none_bool_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_BOOL, + SANE_UNIT_NONE, + sizeof (SANE_Word), + 0, + SANE_CONSTRAINT_NONE, + {NULL} +}; + +/* range for int constraint */ +static const SANE_Range int_range = { + 3, /* minimum */ + 18, /* maximum */ + 3 /* quantization */ +}; + +/* range for sane fixed constraint */ +static const SANE_Range fixed_range = { + SANE_FIX(1.0), /* minimum */ + SANE_FIX(431.8), /* maximum */ + SANE_FIX(0.01) /* quantization */ +}; + +static SANE_Option_Descriptor int_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_FIXED, + SANE_UNIT_MM, + sizeof (SANE_Word), + 0, + SANE_CONSTRAINT_RANGE, + {NULL} +}; + +static SANE_Option_Descriptor fixed_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_FIXED, + SANE_UNIT_MM, + sizeof (SANE_Word), + 0, + SANE_CONSTRAINT_RANGE, + {NULL} +}; + +#define ARRAY_SIZE 7 + +static SANE_Option_Descriptor array_opt = { + SANE_NAME_SCAN_TL_X, + SANE_TITLE_SCAN_TL_X, + SANE_DESC_SCAN_TL_X, + SANE_TYPE_FIXED, + SANE_UNIT_MM, + sizeof (SANE_Word) * ARRAY_SIZE, + 0, + SANE_CONSTRAINT_RANGE, + {NULL} +}; + +#define WORD_SIZE 9 +static const SANE_Int dpi_list[] = + { WORD_SIZE - 1, 100, 200, 300, 400, 500, 600, 700, 800 }; + +static SANE_Option_Descriptor word_array_opt = { + SANE_NAME_SCAN_RESOLUTION, + SANE_TITLE_SCAN_RESOLUTION, + SANE_DESC_SCAN_RESOLUTION, + SANE_TYPE_INT, + SANE_UNIT_DPI, + sizeof (SANE_Word) * WORD_SIZE, + 100, + SANE_CONSTRAINT_WORD_LIST, + {NULL} +}; + +static const SANE_String_Const string_list[] = { + SANE_VALUE_SCAN_MODE_LINEART, + SANE_VALUE_SCAN_MODE_HALFTONE, + SANE_VALUE_SCAN_MODE_GRAY, + "linelength", + 0 +}; + +static SANE_Option_Descriptor string_array_opt = { + SANE_NAME_SCAN_MODE, + SANE_TITLE_SCAN_MODE, + SANE_DESC_SCAN_MODE, + SANE_TYPE_STRING, + SANE_UNIT_NONE, + 8, + 0, + SANE_CONSTRAINT_STRING_LIST, + {NULL} +}; + + +/******************************/ +/* start of tests definitions */ +/******************************/ + +/* + * constrained int + */ +static void +min_int_value (void) +{ + SANE_Int value = int_range.min; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == int_range.min); +} + +static void +max_int_value (void) +{ + SANE_Int value = int_range.max; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == int_range.max); +} + +static void +below_min_int_value (void) +{ + SANE_Int value = int_range.min - 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == int_range.min); +} + +/* rounded to lower value */ +static void +quant1_int_value (void) +{ + SANE_Int value = int_range.min + 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == int_range.min); +} + +/* rounded to higher value */ +static void +quant2_int_value (void) +{ + SANE_Int value = int_range.min + int_range.quant - 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == int_range.min + int_range.quant); +} + +static void +in_range_int_value (void) +{ + SANE_Int value = int_range.min + int_range.quant; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == int_range.min + int_range.quant); +} + +static void +above_max_int_value (void) +{ + SANE_Int value = int_range.max + 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&int_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == int_range.max); +} + +/* + * constrained fixed value + */ +static void +min_fixed_value (void) +{ + SANE_Int value = fixed_range.min; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == fixed_range.min); +} + +static void +max_fixed_value (void) +{ + SANE_Int value = fixed_range.max; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == fixed_range.max); +} + +static void +below_min_fixed_value (void) +{ + SANE_Int value = fixed_range.min - 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == fixed_range.min); +} + +/* rounded to lower value */ +static void +quant1_fixed_value (void) +{ + SANE_Int value = fixed_range.min + fixed_range.quant/3; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == fixed_range.min); +} + +/* rounded to higher value */ +static void +quant2_fixed_value (void) +{ + SANE_Int value = fixed_range.min + fixed_range.quant - fixed_range.quant/3; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == fixed_range.min + fixed_range.quant); +} + +static void +in_range_fixed_value (void) +{ + SANE_Int value = fixed_range.min + fixed_range.quant; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == fixed_range.min + fixed_range.quant); +} + +static void +above_max_fixed_value (void) +{ + SANE_Int value = fixed_range.max + 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&fixed_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == fixed_range.max); +} + + +static void +above_max_word (void) +{ + SANE_Word value = 25000; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&word_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == 800); +} + + +static void +below_max_word (void) +{ + SANE_Word value = 1; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&word_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == 100); +} + +static void +closest_200_word (void) +{ + SANE_Word value = 249; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&word_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == 200); +} + + +static void +closest_300_word (void) +{ + SANE_Word value = 251; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&word_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + assert (value == 300); +} + + +static void +exact_400_word (void) +{ + SANE_Word value = 400; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&word_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + assert (value == 400); +} + +/* + * constrained int array + */ +static void +min_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min; + } + status = sanei_constrain_value (&array_opt, value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min); + } +} + +static void +max_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.max; + } + + status = sanei_constrain_value (&array_opt, value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.max); + } +} + +static void +below_min_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min - 1; + } + + status = sanei_constrain_value (&array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min); + } +} + +/* rounded to lower value */ +static void +quant1_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min + 1; + } + status = sanei_constrain_value (&array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min); + } +} + +/* rounded to higher value */ +static void +quant2_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min + int_range.quant - 1; + } + status = sanei_constrain_value (&array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min + int_range.quant); + } +} + +static void +in_range_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.min + int_range.quant; + } + + status = sanei_constrain_value (&array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.min + int_range.quant); + } +} + +static void +above_max_int_array (void) +{ + SANE_Int value[ARRAY_SIZE]; + SANE_Word info = 0; + SANE_Status status; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) + { + value[i] = int_range.max + 1; + } + status = sanei_constrain_value (&array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == SANE_INFO_INEXACT); + for (i = 0; i < ARRAY_SIZE; i++) + { + assert (value[i] == int_range.max); + } +} + +static void +wrong_string_array (void) +{ + SANE_Char value[9] = "wrong"; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&string_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_INVAL); + assert (info == 0); +} + + +static void +none_int (void) +{ + SANE_Int value = 555; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&none_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); +} + + +static void +none_bool_nok (void) +{ + SANE_Bool value = 555; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&none_bool_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_INVAL); + assert (info == 0); +} + + +static void +none_bool_ok (void) +{ + SANE_Bool value = SANE_FALSE; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&none_bool_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); +} + +/** + * several partial match + */ +static void +string_array_several (void) +{ + SANE_Char value[9] = "Line"; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&string_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_INVAL); + assert (info == 0); +} + +/** + * unique partial match + */ +static void +partial_string_array (void) +{ + SANE_Char value[9] = "Linea"; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&string_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); +} + +static void +string_array_ignorecase (void) +{ + SANE_Char value[9] = "lineart"; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&string_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); +} + +static void +string_array_ok (void) +{ + SANE_Char value[9] = "Lineart"; + SANE_Word info = 0; + SANE_Status status; + + status = sanei_constrain_value (&string_array_opt, &value, &info); + + /* check results */ + assert (status == SANE_STATUS_GOOD); + assert (info == 0); +} + +/** + * run the test suite for sanei constrain related tests + */ +static void +sanei_constrain_suite (void) +{ + /* to be compatible with pre-C99 compilers */ + int_opt.constraint.range = &int_range; + fixed_opt.constraint.range = &fixed_range; + array_opt.constraint.range = &int_range; + word_array_opt.constraint.word_list = dpi_list; + string_array_opt.constraint.string_list = string_list; + + /* tests for constrained int value */ + min_int_value (); + max_int_value (); + below_min_int_value (); + above_max_int_value (); + quant1_int_value (); + quant2_int_value (); + in_range_int_value (); + + /* tests for sane fixed constrained value */ + min_fixed_value (); + max_fixed_value (); + below_min_fixed_value (); + above_max_fixed_value (); + quant1_fixed_value (); + quant2_fixed_value (); + in_range_fixed_value (); + + /* tests for constrained int array */ + min_int_array (); + max_int_array (); + below_min_int_array (); + above_max_int_array (); + quant1_int_array (); + quant2_int_array (); + in_range_int_array (); + + /* tests for word lists */ + above_max_word (); + below_max_word (); + closest_200_word (); + closest_300_word (); + exact_400_word (); + + /* tests for string lists */ + wrong_string_array (); + partial_string_array (); + string_array_ok (); + string_array_ignorecase (); + string_array_several (); + + /* constraint none tests */ + none_int (); + none_bool_nok (); + none_bool_ok (); +} + +/** + * main function to run the test suites + */ +int +main (void) +{ + /* run suites */ + sanei_constrain_suite (); + + return 0; +} + +/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ diff --git a/testsuite/sanei/sanei_usb_test.c b/testsuite/sanei/sanei_usb_test.c new file mode 100644 index 0000000..4c5240e --- /dev/null +++ b/testsuite/sanei/sanei_usb_test.c @@ -0,0 +1,949 @@ +#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; + /* give unused devices a name so strcmp() won't crash. */ + for (i = current_number; i < MAX_DEVICES; i++) + devices[i].devname = ""; + + 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; + /* reset unused devnames to NULL */ + for (i = current_number; i < MAX_DEVICES; i++) + devices[i].devname = NULL; + 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; +} + +/** return count of opened devices + * @return count of opened devices + */ +static int +get_opened (void) +{ + 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++; + } + } + return num; +} + +/** 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 = get_opened(); + + 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 + { + if (status == SANE_STATUS_ACCESS_DENIED || + status == SANE_STATUS_DEVICE_BUSY) + { + expected--; + } + 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, opened, 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)); + + opened = get_opened(); + + /* rescan devices : detected and opened count shouldn't change */ + assert (test_scan_devices (detected, opened)); + + /* 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 */ + assert (count_opened (opened)); + + assert (test_exit (1)); + + /* there should be still as many opened devices */ + assert (count_opened (opened)); + + /* 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, opened)); + + /* then release them all */ + assert (test_release_all (dn, opened)); + + /* close all opened devices */ + assert (test_close_all (dn, opened)); + + /* 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: */ diff --git a/testsuite/sanei/test_wire.c b/testsuite/sanei/test_wire.c new file mode 100644 index 0000000..e8388c4 --- /dev/null +++ b/testsuite/sanei/test_wire.c @@ -0,0 +1,236 @@ +#include "../include/sane/config.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <sys/fcntl.h> + +#include "../include/sane/sane.h" +#include "../include/sane/sanei.h" +#include "../include/sane/sanei_wire.h" +#include "../include/sane/sanei_codec_ascii.h" +#include "../include/sane/sanei_codec_bin.h" + +static Wire w; + +static SANE_Word dpi_word_list[] = { + 4, /* # of elements */ + 3, 30, 300, -600 +}; + +static SANE_String_Const mode_list[] = { + "Lineart", "Grayscale", "Color", 0 +}; + +static char *program_name; +static char *default_codec = "bin"; +static char *default_outfile = "test_wire.out"; + +static int +usage (int code) +{ + if (code == 0) + { + printf ("Usage: %s [OPTION]...\n\ +\n\ +Test the SANE wire manipulation library.\n\ +\n\ + --codec=CODEC set the codec [default=%s]\n\ + --help display this message and exit\n\ +-o, --output=FILE set the output file [default=%s]\n\ + --readonly do not create FILE, just read it\n\ + --version print version information\n\ +\n\ +Valid CODECs are: `ascii' `bin'\n", program_name, default_codec, default_outfile); + } + else + { + fprintf (stderr, "Type ``%s --help'' for more information.\n", + program_name); + } + exit (code); +} + + +int +main (int argc, char **argv) +{ + SANE_Option_Descriptor desc[2], *desc_ptr; + SANE_Word len; + char *codec = default_codec; + char *outfile = default_outfile; + int readonly = 0; + + program_name = argv[0]; + argv++; + while (*argv != 0) + { + if (!strcmp (*argv, "--codec")) + { + if (argv[1] == 0) + { + fprintf (stderr, "%s: option `%s' requires an argument\n", + program_name, *argv); + usage (1); + } + + argv++; + codec = *argv; + } + else if (!strncmp (*argv, "--codec=", 8)) + { + codec = *argv + 8; + } + else if (!strcmp (*argv, "--help")) + { + usage (0); + } + else if (!strcmp (*argv, "-o") || !strcmp (*argv, "--output")) + { + if (argv[1] == 0) + { + fprintf (stderr, "%s: option `%s' requires an argument\n", + program_name, *argv); + usage (1); + } + + argv++; + outfile = *argv; + } + else if (!strncmp (*argv, "--output=", 9)) + { + outfile = *argv + 9; + } + else if (!strcmp (*argv, "--readonly")) + { + readonly = 1; + } + else if (!strcmp (*argv, "--version")) + { + printf ("test_wire (%s) %s\n", PACKAGE, VERSION); + exit (0); + } + else if (**argv == '-') + { + fprintf (stderr, "%s: unrecognized option `%s'\n", + program_name, *argv); + usage (1); + } + else + { + fprintf (stderr, "%s: too many arguments\n", program_name); + } + + argv++; + } + + + if (!strcmp (codec, "bin")) + sanei_w_init (&w, sanei_codec_bin_init); + else if (!strcmp (codec, "ascii")) + sanei_w_init (&w, sanei_codec_ascii_init); + else + { + fprintf (stderr, "%s: unknown codec type `%s'\n", program_name, codec); + usage (1); + } + + desc[0].name = "resolution"; + desc[0].title = 0; + desc[0].desc = "Determines scan resolution in dots/inch (\"DPI\")."; + desc[0].type = SANE_TYPE_FIXED; + desc[0].unit = SANE_UNIT_DPI; + desc[0].size = sizeof (SANE_Word); + desc[0].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; + desc[0].constraint_type = SANE_CONSTRAINT_WORD_LIST; + desc[0].constraint.word_list = dpi_word_list; + + desc[1].name = "mode"; + desc[1].title = "Scan Mode"; + desc[1].desc = "Determines scan mode."; + desc[1].type = SANE_TYPE_STRING; + desc[1].unit = SANE_UNIT_NONE; + desc[1].size = 10; + desc[1].cap = (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT + | SANE_CAP_AUTOMATIC); + desc[1].constraint_type = SANE_CONSTRAINT_STRING_LIST; + desc[1].constraint.string_list = mode_list; + + { + int flags; + if (readonly) + { + printf ("reading %s output from %s\n", codec, outfile); + flags = O_RDONLY; + } + else + { + printf ("creating %s\n", outfile); + flags = O_RDWR | O_CREAT | O_TRUNC; + } + + w.io.fd = open (outfile, flags, 0666); + + if (w.io.fd < 0) + { + perror (outfile); + return -1; + } + } + w.io.read = read; + w.io.write = readonly ? 0 : write; + + if (!readonly) + { + sanei_w_set_dir (&w, WIRE_ENCODE); + w.status = 0; + + len = NELEMS (desc); + desc_ptr = desc; + sanei_w_array (&w, &len, (void **) &desc_ptr, + (WireCodecFunc) sanei_w_option_descriptor, + sizeof (desc[0])); + + if (w.status == 0) + printf ("%s encode successful\n", codec); + else + fprintf (stderr, "%s: %s encode error %d: %s\n", + codec, program_name, w.status, strerror (w.status)); + + printf ("%s output written to %s\n", codec, outfile); + } + + sanei_w_set_dir (&w, WIRE_DECODE); + w.status = 0; + + if (!readonly) + { + printf ("reading %s output from %s\n", codec, outfile); + lseek (w.io.fd, 0, SEEK_SET); + } + + sanei_w_array (&w, &len, (void **) &desc_ptr, + (WireCodecFunc) sanei_w_option_descriptor, sizeof (desc[0])); + + if (w.status == 0) + printf ("%s decode successful\n", codec); + else + fprintf (stderr, "%s: %s decode error %d: %s\n", + program_name, codec, w.status, strerror (w.status)); + + sanei_w_set_dir (&w, WIRE_FREE); + w.status = 0; + sanei_w_array (&w, &len, (void **) &desc_ptr, + (WireCodecFunc) sanei_w_option_descriptor, sizeof (desc[0])); + + if (w.status == 0) + printf ("free successful\n"); + else + fprintf (stderr, "%s: free error %d: %s\n", + program_name, w.status, strerror (w.status)); + + close (w.io.fd); + + return 0; +} |