thanks, added ----- Original Message ----- > The .db files are missing from EXTRA_DIST causing make distcheck failure > > diff --git a/Makefile.am b/Makefile.am > index b29f56b..afa7d7a 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -87,6 +87,9 @@ EXTRA_DIST += \ > build-aux/tap-driver.sh \ > build-aux/tap-test \ > build-aux/test-driver \ > + tests/db/cert8.db \ > + tests/db/key3.db \ > + tests/db/secmod.db \ > $(NULL) > > > Christophe > > > On Thu, Oct 08, 2015 at 05:40:39PM +0200, marcandre.lureau@xxxxxxxxxx wrote: > > From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> > > --- > > Makefile.am | 28 ++- > > build-aux/glib-tap.mk | 150 +++++++++++ > > build-aux/tap-driver.sh | 652 > > ++++++++++++++++++++++++++++++++++++++++++++++++ > > build-aux/tap-test | 5 + > > configure.ac | 4 +- > > m4/glibtests.m4 | 28 +++ > > tests/db/cert8.db | Bin 0 -> 65536 bytes > > tests/db/key3.db | Bin 0 -> 16384 bytes > > tests/db/secmod.db | Bin 0 -> 16384 bytes > > tests/libcacard.c | 239 ++++++++++++++++++ > > 10 files changed, 1100 insertions(+), 6 deletions(-) > > create mode 100644 build-aux/glib-tap.mk > > create mode 100755 build-aux/tap-driver.sh > > create mode 100755 build-aux/tap-test > > create mode 100644 m4/glibtests.m4 > > create mode 100644 tests/db/cert8.db > > create mode 100644 tests/db/key3.db > > create mode 100644 tests/db/secmod.db > > create mode 100644 tests/libcacard.c > > > > diff --git a/Makefile.am b/Makefile.am > > index f8ee424..b8e8a90 100644 > > --- a/Makefile.am > > +++ b/Makefile.am > > @@ -43,7 +43,7 @@ libcacard_la_LDFLAGS = \ > > -export-symbols $(srcdir)/src/libcacard.syms \ > > -no-undefined \ > > -version-info 0:0:0 \ > > - $(WARN_LDFLAGS) > > + $(AM_LDFLAGS) \ > > $(NULL) > > > > if OS_WIN32 > > @@ -62,15 +62,33 @@ if OS_WIN32 > > vscclient_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 > > endif > > > > -AM_CPPFLAGS = $(CACARD_CFLAGS) $(PCSC_CFLAGS) $(WARN_CFLAGS) > > -EXTRA_DIST = \ > > +include $(srcdir)/build-aux/glib-tap.mk > > + > > +test_programs = tests/libcacard > > +tests_libcacard_LDADD = libcacard.la > > + > > +@CODE_COVERAGE_RULES@ > > + > > +AM_CPPFLAGS = \ > > + $(CACARD_CFLAGS) \ > > + $(CODE_COVERAGE_CFLAGS) \ > > + $(PCSC_CFLAGS) \ > > + $(WARN_CFLAGS) \ > > + -I$(srcdir)/src \ > > + $(NULL) > > +AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) $(WARN_LDFLAGS) > > + > > +EXTRA_DIST += \ > > NEWS \ > > README.md \ > > docs/libcacard.txt \ > > src/libcacard.syms \ > > + build-aux/tap-driver.sh \ > > + build-aux/tap-test \ > > + build-aux/test-driver \ > > $(NULL) > > > > -MAINTAINERCLEANFILES = \ > > +MAINTAINERCLEANFILES += \ > > $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \ > > $(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN) \ > > $(GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL) > > @@ -82,7 +100,7 @@ dist-hook: gen-ChangeLog > > $(top_srcdir)/.version: > > echo $(VERSION) > $@-t && mv $@-t $@ > > > > -BUILT_SOURCES = $(top_srcdir)/.version > > +BUILT_SOURCES += $(top_srcdir)/.version > > EXTRA_DIST += $(top_srcdir)/.version > > gen-ChangeLog: > > @if test -d "$(srcdir)/.git"; then \ > > diff --git a/build-aux/glib-tap.mk b/build-aux/glib-tap.mk > > new file mode 100644 > > index 0000000..b63d6c9 > > --- /dev/null > > +++ b/build-aux/glib-tap.mk > > @@ -0,0 +1,150 @@ > > +# GLIB - Library of useful C routines > > + > > +AM_TESTS_ENVIRONMENT= \ > > + G_TEST_SRCDIR="$(abs_srcdir)/tests" \ > > + G_TEST_BUILDDIR="$(abs_builddir)/tests" \ > > + G_DEBUG="gc-friendly cleanup" \ > > + MALLOC_CHECK_=2 \ > > + MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) > > +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) > > $(top_srcdir)/build-aux/tap-driver.sh > > +LOG_COMPILER = $(top_srcdir)/build-aux/tap-test > > + > > +NULL = > > + > > +# initialize variables for unconditional += appending > > +BUILT_SOURCES = > > +BUILT_EXTRA_DIST = > > +CLEANFILES = *.log *.trs > > +DISTCLEANFILES = > > +MAINTAINERCLEANFILES = > > +EXTRA_DIST = > > +TESTS = > > + > > +installed_test_LTLIBRARIES = > > +installed_test_PROGRAMS = > > +installed_test_SCRIPTS = > > +nobase_installed_test_DATA = > > + > > +noinst_LTLIBRARIES = > > +noinst_PROGRAMS = > > +noinst_SCRIPTS = > > +noinst_DATA = > > + > > +check_LTLIBRARIES = > > +check_PROGRAMS = > > +check_SCRIPTS = > > +check_DATA = > > + > > +# We support a fairly large range of possible variables. It is expected > > that all types of files in a test suite > > +# will belong in exactly one of the following variables. > > +# > > +# First, we support the usual automake suffixes, but in lowercase, with > > the customary meaning: > > +# > > +# test_programs, test_scripts, test_data, test_ltlibraries > > +# > > +# The above are used to list files that are involved in both uninstalled > > and installed testing. The > > +# test_programs and test_scripts are taken to be actual testcases and will > > be run as part of the test suite. > > +# Note that _data is always used with the nobase_ automake variable name > > to ensure that installed test data is > > +# installed in the same way as it appears in the package layout. > > +# > > +# In order to mark a particular file as being only for one type of > > testing, use 'installed' or 'uninstalled', > > +# like so: > > +# > > +# installed_test_programs, uninstalled_test_programs > > +# installed_test_scripts, uninstalled_test_scripts > > +# installed_test_data, uninstalled_test_data > > +# installed_test_ltlibraries, uninstalled_test_ltlibraries > > +# > > +# Additionally, we support 'extra' infixes for programs and scripts. This > > is used for support programs/scripts > > +# that should not themselves be run as testcases (but exist to be used > > from other testcases): > > +# > > +# test_extra_programs, installed_test_extra_programs, > > uninstalled_test_extra_programs > > +# test_extra_scripts, installed_test_extra_scripts, > > uninstalled_test_extra_scripts > > +# > > +# Additionally, for _scripts and _data, we support the customary dist_ > > prefix so that the named script or data > > +# file automatically end up in the tarball. > > +# > > +# dist_test_scripts, dist_test_data, dist_test_extra_scripts > > +# dist_installed_test_scripts, dist_installed_test_data, > > dist_installed_test_extra_scripts > > +# dist_uninstalled_test_scripts, dist_uninstalled_test_data, > > dist_uninstalled_test_extra_scripts > > +# > > +# Note that no file is automatically disted unless it appears in one of > > the dist_ variables. This follows the > > +# standard automake convention of not disting programs scripts or data by > > default. > > +# > > +# test_programs, test_scripts, uninstalled_test_programs and > > uninstalled_test_scripts (as well as their disted > > +# variants) will be run as part of the in-tree 'make check'. These are > > all assumed to be runnable under > > +# gtester. That's a bit strange for scripts, but it's possible. > > + > > +TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) > > $(uninstalled_test_scripts) \ > > + $(dist_test_scripts) $(dist_uninstalled_test_scripts) > > + > > +# Note: build even the installed-only targets during 'make check' to > > ensure that they still work. > > +# We need to do a bit of trickery here and manage disting via EXTRA_DIST > > instead of using dist_ prefixes to > > +# prevent automake from mistreating gmake functions like $(wildcard ...) > > and $(addprefix ...) as if they were > > +# filenames, including removing duplicate instances of the opening part > > before the space, eg. '$(addprefix'. > > +all_test_programs = $(test_programs) $(uninstalled_test_programs) > > $(installed_test_programs) \ > > + $(test_extra_programs) > > $(uninstalled_test_extra_programs) $(installed_test_extra_programs) > > +all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) > > $(installed_test_scripts) \ > > + $(test_extra_scripts) > > $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts) > > +all_dist_test_scripts = $(dist_test_scripts) > > $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \ > > + $(dist_test_extra_scripts) > > $(dist_uninstalled_test_extra_scripts) > > $(dist_installed_test_extra_scripts) > > +all_test_scripts += $(all_dist_test_scripts) > > +EXTRA_DIST += $(all_dist_test_scripts) > > +all_test_data = $(test_data) $(uninstalled_test_data) > > $(installed_test_data) > > +all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) > > $(dist_installed_test_data) > > +all_test_data += $(all_dist_test_data) > > +EXTRA_DIST += $(all_dist_test_data) > > +all_test_ltlibs = $(test_ltlibraries) > > $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries) > > + > > +if ENABLE_ALWAYS_BUILD_TESTS > > +noinst_LTLIBRARIES += $(all_test_ltlibs) > > +noinst_PROGRAMS += $(all_test_programs) > > +noinst_SCRIPTS += $(all_test_scripts) > > +noinst_DATA += $(all_test_data) > > +else > > +check_LTLIBRARIES += $(all_test_ltlibs) > > +check_PROGRAMS += $(all_test_programs) > > +check_SCRIPTS += $(all_test_scripts) > > +check_DATA += $(all_test_data) > > +endif > > + > > +if ENABLE_INSTALLED_TESTS > > +installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \ > > + $(test_extra_programs) > > $(installed_test_extra_programs) > > +installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \ > > + $(test_extra_scripts) > > $(test_installed_extra_scripts) > > +installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) > > \ > > + $(dist_installed_test_scripts) > > $(dist_installed_test_extra_scripts) > > +nobase_installed_test_DATA += $(test_data) $(installed_test_data) > > +nobase_installed_test_DATA += $(dist_test_data) > > $(dist_installed_test_data) > > +installed_test_LTLIBRARIES += $(test_ltlibraries) > > $(installed_test_ltlibraries) > > +installed_testcases = $(test_programs) $(installed_test_programs) \ > > + $(test_scripts) $(installed_test_scripts) \ > > + $(dist_test_scripts) $(dist_installed_test_scripts) > > + > > +installed_test_meta_DATA = $(installed_testcases:=.test) > > + > > +%.test: %$(EXEEXT) Makefile > > + $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ > > + echo 'Type=session' >> $@.tmp; \ > > + echo 'Exec=$(installed_testdir)/$(notdir $<) --tap' >> $@.tmp; \ > > + echo 'Output=TAP' >> $@.tmp; \ > > + mv $@.tmp $@) > > + > > +CLEANFILES += $(installed_test_meta_DATA) > > + > > +endif > > + > > +VALGRIND_ARGS = \ > > + --leak-check=full \ > > + --show-leak-kinds=all \ > > + --child-silent-after-fork=yes \ > > + --suppressions=$(abs_top_srcdir)/build-aux/glib.supp \ > > + --num-callers=18 \ > > + $(NULL) > > + > > +memcheck-local: $(all_test_programs) > > + $(MAKE) check-am TESTS="$(all_test_programs)" \ > > + TESTS_ENVIRONMENT="G_DEBUG='gc-friendly cleanup'" \ > > + LOG_FLAGS="libtool --mode=execute valgrind $(VALGRIND_ARGS) --quiet > > --log-fd=7" \ > > + AM_TESTS_FD_REDIRECT="7>&2" > > diff --git a/build-aux/tap-driver.sh b/build-aux/tap-driver.sh > > new file mode 100755 > > index 0000000..19aa531 > > --- /dev/null > > +++ b/build-aux/tap-driver.sh > > @@ -0,0 +1,652 @@ > > +#! /bin/sh > > +# Copyright (C) 2011-2013 Free Software Foundation, Inc. > > +# > > +# This program is free software; you can redistribute it and/or modify > > +# it under the terms of the GNU General Public License as published by > > +# the Free Software Foundation; either version 2, or (at your option) > > +# any later version. > > +# > > +# This program is distributed in the hope that it will be useful, > > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > +# GNU General Public License for more details. > > +# > > +# You should have received a copy of the GNU General Public License > > +# along with this program. If not, see <http://www.gnu.org/licenses/>. > > + > > +# As a special exception to the GNU General Public License, if you > > +# distribute this file as part of a program that contains a > > +# configuration script generated by Autoconf, you may include it under > > +# the same distribution terms that you use for the rest of that program. > > + > > +# This file is maintained in Automake, please report > > +# bugs to <bug-automake@xxxxxxx> or send patches to > > +# <automake-patches@xxxxxxx>. > > + > > +scriptversion=2011-12-27.17; # UTC > > + > > +# Make unconditional expansion of undefined variables an error. This > > +# helps a lot in preventing typo-related bugs. > > +set -u > > + > > +me=tap-driver.sh > > + > > +fatal () > > +{ > > + echo "$me: fatal: $*" >&2 > > + exit 1 > > +} > > + > > +usage_error () > > +{ > > + echo "$me: $*" >&2 > > + print_usage >&2 > > + exit 2 > > +} > > + > > +print_usage () > > +{ > > + cat <<END > > +Usage: > > + tap-driver.sh --test-name=NAME --log-file=PATH --trs-file=PATH > > + [--expect-failure={yes|no}] [--color-tests={yes|no}] > > + [--enable-hard-errors={yes|no}] [--ignore-exit] > > + [--diagnostic-string=STRING] [--merge|--no-merge] > > + [--comments|--no-comments] [--] TEST-COMMAND > > +The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory. > > +END > > +} > > + > > +# TODO: better error handling in option parsing (in particular, ensure > > +# TODO: $log_file, $trs_file and $test_name are defined). > > +test_name= # Used for reporting. > > +log_file= # Where to save the result and output of the test script. > > +trs_file= # Where to save the metadata of the test run. > > +expect_failure=0 > > +color_tests=0 > > +merge=0 > > +ignore_exit=0 > > +comments=0 > > +diag_string='#' > > +while test $# -gt 0; do > > + case $1 in > > + --help) print_usage; exit $?;; > > + --version) echo "$me $scriptversion"; exit $?;; > > + --test-name) test_name=$2; shift;; > > + --log-file) log_file=$2; shift;; > > + --trs-file) trs_file=$2; shift;; > > + --color-tests) color_tests=$2; shift;; > > + --expect-failure) expect_failure=$2; shift;; > > + --enable-hard-errors) shift;; # No-op. > > + --merge) merge=1;; > > + --no-merge) merge=0;; > > + --ignore-exit) ignore_exit=1;; > > + --comments) comments=1;; > > + --no-comments) comments=0;; > > + --diagnostic-string) diag_string=$2; shift;; > > + --) shift; break;; > > + -*) usage_error "invalid option: '$1'";; > > + esac > > + shift > > +done > > + > > +test $# -gt 0 || usage_error "missing test command" > > + > > +case $expect_failure in > > + yes) expect_failure=1;; > > + *) expect_failure=0;; > > +esac > > + > > +if test $color_tests = yes; then > > + init_colors=' > > + color_map["red"]="[0;31m" # Red. > > + color_map["grn"]="[0;32m" # Green. > > + color_map["lgn"]="[1;32m" # Light green. > > + color_map["blu"]="[1;34m" # Blue. > > + color_map["mgn"]="[0;35m" # Magenta. > > + color_map["std"]="[m" # No color. > > + color_for_result["ERROR"] = "mgn" > > + color_for_result["PASS"] = "grn" > > + color_for_result["XPASS"] = "red" > > + color_for_result["FAIL"] = "red" > > + color_for_result["XFAIL"] = "lgn" > > + color_for_result["SKIP"] = "blu"' > > +else > > + init_colors='' > > +fi > > + > > +# :; is there to work around a bug in bash 3.2 (and earlier) which > > +# does not always set '$?' properly on redirection failure. > > +# See the Autoconf manual for more details. > > +:;{ > > + ( > > + # Ignore common signals (in this subshell only!), to avoid potential > > + # problems with Korn shells. Some Korn shells are known to propagate > > + # to themselves signals that have killed a child process they were > > + # waiting for; this is done at least for SIGINT (and usually only for > > + # it, in truth). Without the `trap' below, such a behaviour could > > + # cause a premature exit in the current subshell, e.g., in case the > > + # test command it runs gets terminated by a SIGINT. Thus, the awk > > + # script we are piping into would never seen the exit status it > > + # expects on its last input line (which is displayed below by the > > + # last `echo $?' statement), and would thus die reporting an internal > > + # error. > > + # For more information, see the Autoconf manual and the threads: > > + # > > <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html> > > + # > > <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html> > > + trap : 1 3 2 13 15 > > + if test $merge -gt 0; then > > + exec 2>&1 > > + else > > + exec 2>&3 > > + fi > > + "$@" > > + echo $? > > + ) | LC_ALL=C ${AM_TAP_AWK-awk} \ > > + -v me="$me" \ > > + -v test_script_name="$test_name" \ > > + -v log_file="$log_file" \ > > + -v trs_file="$trs_file" \ > > + -v expect_failure="$expect_failure" \ > > + -v merge="$merge" \ > > + -v ignore_exit="$ignore_exit" \ > > + -v comments="$comments" \ > > + -v diag_string="$diag_string" \ > > +' > > +# FIXME: the usages of "cat >&3" below could be optimized when using > > +# FIXME: GNU awk, and/on on systems that supports /dev/fd/. > > + > > +# Implementation note: in what follows, `result_obj` will be an > > +# associative array that (partly) simulates a TAP result object > > +# from the `TAP::Parser` perl module. > > + > > +## ----------- ## > > +## FUNCTIONS ## > > +## ----------- ## > > + > > +function fatal(msg) > > +{ > > + print me ": " msg | "cat >&2" > > + exit 1 > > +} > > + > > +function abort(where) > > +{ > > + fatal("internal error " where) > > +} > > + > > +# Convert a boolean to a "yes"/"no" string. > > +function yn(bool) > > +{ > > + return bool ? "yes" : "no"; > > +} > > + > > +function add_test_result(result) > > +{ > > + if (!test_results_index) > > + test_results_index = 0 > > + test_results_list[test_results_index] = result > > + test_results_index += 1 > > + test_results_seen[result] = 1; > > +} > > + > > +# Whether the test script should be re-run by "make recheck". > > +function must_recheck() > > +{ > > + for (k in test_results_seen) > > + if (k != "XFAIL" && k != "PASS" && k != "SKIP") > > + return 1 > > + return 0 > > +} > > + > > +# Whether the content of the log file associated to this test should > > +# be copied into the "global" test-suite.log. > > +function copy_in_global_log() > > +{ > > + for (k in test_results_seen) > > + if (k != "PASS") > > + return 1 > > + return 0 > > +} > > + > > +# FIXME: this can certainly be improved ... > > +function get_global_test_result() > > +{ > > + if ("ERROR" in test_results_seen) > > + return "ERROR" > > + if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) > > + return "FAIL" > > + all_skipped = 1 > > + for (k in test_results_seen) > > + if (k != "SKIP") > > + all_skipped = 0 > > + if (all_skipped) > > + return "SKIP" > > + return "PASS"; > > +} > > + > > +function stringify_result_obj(result_obj) > > +{ > > + if (result_obj["is_unplanned"] || result_obj["number"] != testno) > > + return "ERROR" > > + > > + if (plan_seen == LATE_PLAN) > > + return "ERROR" > > + > > + if (result_obj["directive"] == "TODO") > > + return result_obj["is_ok"] ? "XPASS" : "XFAIL" > > + > > + if (result_obj["directive"] == "SKIP") > > + return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; > > + > > + if (length(result_obj["directive"])) > > + abort("in function stringify_result_obj()") > > + > > + return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL > > +} > > + > > +function decorate_result(result) > > +{ > > + color_name = color_for_result[result] > > + if (color_name) > > + return color_map[color_name] "" result "" color_map["std"] > > + # If we are not using colorized output, or if we do not know how > > + # to colorize the given result, we should return it unchanged. > > + return result > > +} > > + > > +function report(result, details) > > +{ > > + if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/) > > + { > > + msg = ": " test_script_name > > + add_test_result(result) > > + } > > + else if (result == "#") > > + { > > + msg = " " test_script_name ":" > > + } > > + else > > + { > > + abort("in function report()") > > + } > > + if (length(details)) > > + msg = msg " " details > > + # Output on console might be colorized. > > + print decorate_result(result) msg > > + # Log the result in the log file too, to help debugging (this is > > + # especially true when said result is a TAP error or "Bail out!"). > > + print result msg | "cat >&3"; > > +} > > + > > +function testsuite_error(error_message) > > +{ > > + report("ERROR", "- " error_message) > > +} > > + > > +function handle_tap_result() > > +{ > > + details = result_obj["number"]; > > + if (length(result_obj["description"])) > > + details = details " " result_obj["description"] > > + > > + if (plan_seen == LATE_PLAN) > > + { > > + details = details " # AFTER LATE PLAN"; > > + } > > + else if (result_obj["is_unplanned"]) > > + { > > + details = details " # UNPLANNED"; > > + } > > + else if (result_obj["number"] != testno) > > + { > > + details = sprintf("%s # OUT-OF-ORDER (expecting %d)", > > + details, testno); > > + } > > + else if (result_obj["directive"]) > > + { > > + details = details " # " result_obj["directive"]; > > + if (length(result_obj["explanation"])) > > + details = details " " result_obj["explanation"] > > + } > > + > > + report(stringify_result_obj(result_obj), details) > > +} > > + > > +# `skip_reason` should be empty whenever planned > 0. > > +function handle_tap_plan(planned, skip_reason) > > +{ > > + planned += 0 # Avoid getting confused if, say, `planned` is "00" > > + if (length(skip_reason) && planned > 0) > > + abort("in function handle_tap_plan()") > > + if (plan_seen) > > + { > > + # Error, only one plan per stream is acceptable. > > + testsuite_error("multiple test plans") > > + return; > > + } > > + planned_tests = planned > > + # The TAP plan can come before or after *all* the TAP results; we speak > > + # respectively of an "early" or a "late" plan. If we see the plan line > > + # after at least one TAP result has been seen, assume we have a late > > + # plan; in this case, any further test result seen after the plan will > > + # be flagged as an error. > > + plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN) > > + # If testno > 0, we have an error ("too many tests run") that will be > > + # automatically dealt with later, so do not worry about it here. If > > + # $plan_seen is true, we have an error due to a repeated plan, and that > > + # has already been dealt with above. Otherwise, we have a valid "plan > > + # with SKIP" specification, and should report it as a particular kind > > + # of SKIP result. > > + if (planned == 0 && testno == 0) > > + { > > + if (length(skip_reason)) > > + skip_reason = "- " skip_reason; > > + report("SKIP", skip_reason); > > + } > > +} > > + > > +function extract_tap_comment(line) > > +{ > > + if (index(line, diag_string) == 1) > > + { > > + # Strip leading `diag_string` from `line`. > > + line = substr(line, length(diag_string) + 1) > > + # And strip any leading and trailing whitespace left. > > + sub("^[ \t]*", "", line) > > + sub("[ \t]*$", "", line) > > + # Return what is left (if any). > > + return line; > > + } > > + return ""; > > +} > > + > > +# When this function is called, we know that line is a TAP result line, > > +# so that it matches the (perl) RE "^(not )?ok\b". > > +function setup_result_obj(line) > > +{ > > + # Get the result, and remove it from the line. > > + result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0) > > + sub("^(not )?ok[ \t]*", "", line) > > + > > + # If the result has an explicit number, get it and strip it; otherwise, > > + # automatically assing the next progresive number to it. > > + if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/) > > + { > > + match(line, "^[0-9]+") > > + # The final `+ 0` is to normalize numbers with leading zeros. > > + result_obj["number"] = substr(line, 1, RLENGTH) + 0 > > + line = substr(line, RLENGTH + 1) > > + } > > + else > > + { > > + result_obj["number"] = testno > > + } > > + > > + if (plan_seen == LATE_PLAN) > > + # No further test results are acceptable after a "late" TAP plan > > + # has been seen. > > + result_obj["is_unplanned"] = 1 > > + else if (plan_seen && testno > planned_tests) > > + result_obj["is_unplanned"] = 1 > > + else > > + result_obj["is_unplanned"] = 0 > > + > > + # Strip trailing and leading whitespace. > > + sub("^[ \t]*", "", line) > > + sub("[ \t]*$", "", line) > > + > > + # This will have to be corrected if we have a "TODO"/"SKIP" directive. > > + result_obj["description"] = line > > + result_obj["directive"] = "" > > + result_obj["explanation"] = "" > > + > > + if (index(line, "#") == 0) > > + return # No possible directive, nothing more to do. > > + > > + # Directives are case-insensitive. > > + rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*" > > + > > + # See whether we have the directive, and if yes, where. > > + pos = match(line, rx "$") > > + if (!pos) > > + pos = match(line, rx "[^a-zA-Z0-9_]") > > + > > + # If there was no TAP directive, we have nothing more to do. > > + if (!pos) > > + return > > + > > + # Let`s now see if the TAP directive has been escaped. For example: > > + # escaped: ok \# SKIP > > + # not escaped: ok \\# SKIP > > + # escaped: ok \\\\\# SKIP > > + # not escaped: ok \ # SKIP > > + if (substr(line, pos, 1) == "#") > > + { > > + bslash_count = 0 > > + for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--) > > + bslash_count += 1 > > + if (bslash_count % 2) > > + return # Directive was escaped. > > + } > > + > > + # Strip the directive and its explanation (if any) from the test > > + # description. > > + result_obj["description"] = substr(line, 1, pos - 1) > > + # Now remove the test description from the line, that has been dealt > > + # with already. > > + line = substr(line, pos) > > + # Strip the directive, and save its value (normalized to upper case). > > + sub("^[ \t]*#[ \t]*", "", line) > > + result_obj["directive"] = toupper(substr(line, 1, 4)) > > + line = substr(line, 5) > > + # Now get the explanation for the directive (if any), with leading > > + # and trailing whitespace removed. > > + sub("^[ \t]*", "", line) > > + sub("[ \t]*$", "", line) > > + result_obj["explanation"] = line > > +} > > + > > +function get_test_exit_message(status) > > +{ > > + if (status == 0) > > + return "" > > + if (status !~ /^[1-9][0-9]*$/) > > + abort("getting exit status") > > + if (status < 127) > > + exit_details = "" > > + else if (status == 127) > > + exit_details = " (command not found?)" > > + else if (status >= 128 && status <= 255) > > + exit_details = sprintf(" (terminated by signal %d?)", status - 128) > > + else if (status > 256 && status <= 384) > > + # We used to report an "abnormal termination" here, but some Korn > > + # shells, when a child process die due to signal number n, can leave > > + # in $? an exit status of 256+n instead of the more standard 128+n. > > + # Apparently, both behaviours are allowed by POSIX (2008), so be > > + # prepared to handle them both. See also Austing Group report ID > > + # 0000051 <http://www.austingroupbugs.net/view.php?id=51> > > + exit_details = sprintf(" (terminated by signal %d?)", status - 256) > > + else > > + # Never seen in practice. > > + exit_details = " (abnormal termination)" > > + return sprintf("exited with status %d%s", status, exit_details) > > +} > > + > > +function write_test_results() > > +{ > > + print ":global-test-result: " get_global_test_result() > trs_file > > + print ":recheck: " yn(must_recheck()) > trs_file > > + print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file > > + for (i = 0; i < test_results_index; i += 1) > > + print ":test-result: " test_results_list[i] > trs_file > > + close(trs_file); > > +} > > + > > +BEGIN { > > + > > +## ------- ## > > +## SETUP ## > > +## ------- ## > > + > > +'"$init_colors"' > > + > > +# Properly initialized once the TAP plan is seen. > > +planned_tests = 0 > > + > > +COOKED_PASS = expect_failure ? "XPASS": "PASS"; > > +COOKED_FAIL = expect_failure ? "XFAIL": "FAIL"; > > + > > +# Enumeration-like constants to remember which kind of plan (if any) > > +# has been seen. It is important that NO_PLAN evaluates "false" as > > +# a boolean. > > +NO_PLAN = 0 > > +EARLY_PLAN = 1 > > +LATE_PLAN = 2 > > + > > +testno = 0 # Number of test results seen so far. > > +bailed_out = 0 # Whether a "Bail out!" directive has been seen. > > + > > +# Whether the TAP plan has been seen or not, and if yes, which kind > > +# it is ("early" is seen before any test result, "late" otherwise). > > +plan_seen = NO_PLAN > > + > > +## --------- ## > > +## PARSING ## > > +## --------- ## > > + > > +is_first_read = 1 > > + > > +while (1) > > + { > > + # Involutions required so that we are able to read the exit status > > + # from the last input line. > > + st = getline > > + if (st < 0) # I/O error. > > + fatal("I/O error while reading from input stream") > > + else if (st == 0) # End-of-input > > + { > > + if (is_first_read) > > + abort("in input loop: only one input line") > > + break > > + } > > + if (is_first_read) > > + { > > + is_first_read = 0 > > + nextline = $0 > > + continue > > + } > > + else > > + { > > + curline = nextline > > + nextline = $0 > > + $0 = curline > > + } > > + # Copy any input line verbatim into the log file. > > + print | "cat >&3" > > + # Parsing of TAP input should stop after a "Bail out!" directive. > > + if (bailed_out) > > + continue > > + > > + # TAP test result. > > + if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) > > + { > > + testno += 1 > > + setup_result_obj($0) > > + handle_tap_result() > > + } > > + # TAP plan (normal or "SKIP" without explanation). > > + else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/) > > + { > > + # The next two lines will put the number of planned tests in $0. > > + sub("^1\\.\\.", "") > > + sub("[^0-9]*$", "") > > + handle_tap_plan($0, "") > > + continue > > + } > > + # TAP "SKIP" plan, with an explanation. > > + else if ($0 ~ /^1\.\.0+[ \t]*#/) > > + { > > + # The next lines will put the skip explanation in $0, stripping > > + # any leading and trailing whitespace. This is a little more > > + # tricky in truth, since we want to also strip a potential leading > > + # "SKIP" string from the message. > > + sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "") > > + sub("[ \t]*$", ""); > > + handle_tap_plan(0, $0) > > + } > > + # "Bail out!" magic. > > + # Older versions of prove and TAP::Harness (e.g., 3.17) did not > > + # recognize a "Bail out!" directive when preceded by leading > > + # whitespace, but more modern versions (e.g., 3.23) do. So we > > + # emulate the latter, "more modern" behaviour. > > + else if ($0 ~ /^[ \t]*Bail out!/) > > + { > > + bailed_out = 1 > > + # Get the bailout message (if any), with leading and trailing > > + # whitespace stripped. The message remains stored in `$0`. > > + sub("^[ \t]*Bail out![ \t]*", ""); > > + sub("[ \t]*$", ""); > > + # Format the error message for the > > + bailout_message = "Bail out!" > > + if (length($0)) > > + bailout_message = bailout_message " " $0 > > + testsuite_error(bailout_message) > > + } > > + # Maybe we have too look for dianogtic comments too. > > + else if (comments != 0) > > + { > > + comment = extract_tap_comment($0); > > + if (length(comment)) > > + report("#", comment); > > + } > > + } > > + > > +## -------- ## > > +## FINISH ## > > +## -------- ## > > + > > +# A "Bail out!" directive should cause us to ignore any following TAP > > +# error, as well as a non-zero exit status from the TAP producer. > > +if (!bailed_out) > > + { > > + if (!plan_seen) > > + { > > + testsuite_error("missing test plan") > > + } > > + else if (planned_tests != testno) > > + { > > + bad_amount = testno > planned_tests ? "many" : "few" > > + testsuite_error(sprintf("too %s tests run (expected %d, got %d)", > > + bad_amount, planned_tests, testno)) > > + } > > + if (!ignore_exit) > > + { > > + # Fetch exit status from the last line. > > + exit_message = get_test_exit_message(nextline) > > + if (exit_message) > > + testsuite_error(exit_message) > > + } > > + } > > + > > +write_test_results() > > + > > +exit 0 > > + > > +} # End of "BEGIN" block. > > +' > > + > > +# TODO: document that we consume the file descriptor 3 :-( > > +} 3>"$log_file" > > + > > +test $? -eq 0 || fatal "I/O or internal error" > > + > > +# Local Variables: > > +# mode: shell-script > > +# sh-indentation: 2 > > +# eval: (add-hook 'write-file-hooks 'time-stamp) > > +# time-stamp-start: "scriptversion=" > > +# time-stamp-format: "%:y-%02m-%02d.%02H" > > +# time-stamp-time-zone: "UTC" > > +# time-stamp-end: "; # UTC" > > +# End: > > diff --git a/build-aux/tap-test b/build-aux/tap-test > > new file mode 100755 > > index 0000000..f96d795 > > --- /dev/null > > +++ b/build-aux/tap-test > > @@ -0,0 +1,5 @@ > > +#! /bin/sh > > + > > +# run a GTest in tap mode. The test binary is passed as $1 > > + > > +$@ -k --tap > > diff --git a/configure.ac b/configure.ac > > index 6a0a73d..137cd45 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -54,6 +54,8 @@ if test "x$enable_pcsc" != "xno"; then > > fi > > AM_CONDITIONAL(ENABLE_PCSC, test "x$enable_pcsc" = "xyes") > > > > +GLIB_TESTS > > + > > AC_CONFIG_FILES([ > > Makefile > > src/Makefile > > @@ -67,5 +69,5 @@ libcacard - $VERSION > > > > • Prefix: $prefix > > • PCSC enabled: $enable_pcsc > > - > > +• Code coverage: $enable_code_coverage > > ]) > > diff --git a/m4/glibtests.m4 b/m4/glibtests.m4 > > new file mode 100644 > > index 0000000..7d5920a > > --- /dev/null > > +++ b/m4/glibtests.m4 > > @@ -0,0 +1,28 @@ > > +dnl GLIB_TESTS > > +dnl > > + > > +AC_DEFUN([GLIB_TESTS], > > +[ > > + AC_ARG_ENABLE(installed-tests, > > + AS_HELP_STRING([--enable-installed-tests], > > + [Enable installation of some test cases]), > > + [case ${enableval} in > > + yes) ENABLE_INSTALLED_TESTS="1" ;; > > + no) ENABLE_INSTALLED_TESTS="" ;; > > + *) AC_MSG_ERROR([bad value ${enableval} for > > --enable-installed-tests]) ;; > > + esac]) > > + AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test "$ENABLE_INSTALLED_TESTS" > > = "1") > > + AC_ARG_ENABLE(always-build-tests, > > + AS_HELP_STRING([--enable-always-build-tests], > > + [Enable always building tests during 'make > > all']), > > + [case ${enableval} in > > + yes) ENABLE_ALWAYS_BUILD_TESTS="1" ;; > > + no) ENABLE_ALWAYS_BUILD_TESTS="" ;; > > + *) AC_MSG_ERROR([bad value ${enableval} for > > --enable-always-build-tests]) ;; > > + esac]) > > + AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test > > "$ENABLE_ALWAYS_BUILD_TESTS" = "1") > > + if test "$ENABLE_INSTALLED_TESTS" = "1"; then > > + AC_SUBST(installed_test_metadir, > > [${datadir}/installed-tests/]AC_PACKAGE_NAME) > > + AC_SUBST(installed_testdir, > > [${libexecdir}/installed-tests/]AC_PACKAGE_NAME) > > + fi > > +]) > > diff --git a/tests/db/cert8.db b/tests/db/cert8.db > > new file mode 100644 > > index > > 0000000000000000000000000000000000000000..a1f4c9243281b7d9ccb21d7c90e598510528877f > > GIT binary patch > > literal 65536 > > zcmeI)do)yQ9|!O~GiY)xozjIa9FkjRB$sHS(&e~Cs8E;)70NUy8MzgulT(V)K^Ntk > > zLLyRh6)BD=l1Az%*N7-NL+@%GFTMTKI%~aWefL_=+WXo2+0V20XZ@b%zu!X$OtdEm > > zf=m#6<pi;acS(p61c`SVEClsG7rf^~Hz-5rp+|(^;B}<i?grj@@EB|}SpM;Y`sI86 > > z@o_OA1Rwwb2tWV=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2n;WI_)`di=<^8kQkV|C%8^O3RTM()905 > > zgni$e2(;l7fu=TWBJipsKA6T^+W+^GpByw`Y?R%b;Bcl^QR3#REgzb5ng04OG|DEA > > z>yUmR*&2D#$2!O6tdw|0zRB7KyIu=}aK34kmhnqsT`km=YkQrH9?DqwaQLXo)^e+h > > zLh`fLmz+HwOfOsW*)!D4w5^M+@_u~tIi)3ggSvW><(g7tY{RUUTKjcb<zzWH+Ql&S > > zh1w)cmZi;Q{vIi{+owLXIO9Mx(?l___?@GeeWX|8^O*(>f;G=;nr(6=rctl&j_5S4 > > zoXz~*E`Kg<6ZcWw?Y@Q%w(Qhks;QH@$)&<S8t-5531S`>+iH@KoqHi`_RpsK`+m#V > > zR(eX^ZO4Jjw;a}S6=+&MPbJ5S8cG?y+bON~&55vGGNnDRC+UnBE2||h&gPvHA+^a- > > zR+epV8oj#Z66YqX_^$OX>#VDNowDB9@lSmtb0*QM%EyS%2V5<;J~=UIm7&2hk316( > > zvn^M0$Q7Cbs~_LqFH-YfN6Ew9i)E>-UK-Y5@Irl7uH(H-{bwh+Cg<Elv+t?9yPl76 > > zWz{NKQM}$q?4Liw+`8tS%f@;She+?l?AZ#g9p?p(GPb03RJ45bGSv+);^d~%b&AsC > > z#_9!_D#m3@Z}pkb{Y#9XS&&WZbhG;(B&sP&GVk>de)78#Epe~3>Y=<{b4^7?O8ClD > > zN~^1LF1z64-BKOHJ<ftvQ>QmrDm9ZM6;5n3bd_i_8k`6;-cAF&y#+?u0ATbbpEk7Q > > z(}@0m&29_$5ePs40uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa > > w0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz!2hqnUv=+~^Z)<= > > > > literal 0 > > HcmV?d00001 > > > > diff --git a/tests/db/key3.db b/tests/db/key3.db > > new file mode 100644 > > index > > 0000000000000000000000000000000000000000..b7b8e8beb7b54ee406371e1169bc30ae0bab96d3 > > GIT binary patch > >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-25`uEhjK!{zW%Y3fPaD1+ > > z(CY`qz*gCt3X8!-re6#qo})Ong2EVW#E-x_UPM!*lbi@5k1%F^+mu~37i;U8lH)$} > > z(wA<oM)q387A_utSShxGu<{;dd^9kLGbBzlJott=M_+u1KHfgH*KExYWlLsBi0{`- > > z#cs~kaLhSf40H=lmlfQ7C>BqYiue8gOE*w8)$n!rb1kBbZP~tIAD~L56njEm_WFwA > > p@jv&z39k$nfD6C{-~w;~xBy%LE&vyR3%~{70&oGiz`sf0e*nBYgfajC > > > > literal 0 > > HcmV?d00001 > > > > diff --git a/tests/db/secmod.db b/tests/db/secmod.db > > new file mode 100644 > > index > > 0000000000000000000000000000000000000000..b6e81ca751dff9ba46a094715f7b4f507fbc7a6c > > GIT binary patch > > literal 16384 > > zcmeI&u}Z^07{Kw*R!RqnE^Z<R4!0Hh0Ga9{MJdD=h{?5t#-yYv=-^{G3O<vYlS6zB > > zsh3=f7Qw-x6#0K}+}(GV?=HXjq;njKNK0h@MdZj1<v?W5c6F2PYGBu!M7!ymCAaA@ > > zd#G%#j(ShswjNz~pRJ$Efe0Xg00IagfB*srAb<b@2q1s}0tg_000IagfB*srAb<b@ > > z2<(bLOWqGF@71fkUAYnWKmY**5I_I{1Q0*~0R#|0;BNvQQS!F&Mto=s#kRTR$yE@j > > zi>x$77N%-690cmD-&dD;yhx4R^%UjVIGMyr;p?7OktxbiVaCawueF+*`>)B|M7MeD > > zYuESU8?DA^IGOuuF^j{}G$r(EGT5l&HVnU4bE(AETYqw$Pfd1i=24N%$|TR~755JR > > nxxMu5RZngE5x@Q3$C5w*0R#|0009ILKmY**5I_Kd|1R(eN?b*1 > > > > literal 0 > > HcmV?d00001 > > > > diff --git a/tests/libcacard.c b/tests/libcacard.c > > new file mode 100644 > > index 0000000..a6ff49b > > --- /dev/null > > +++ b/tests/libcacard.c > > @@ -0,0 +1,239 @@ > > +#include <glib.h> > > +#include "libcacard.h" > > + > > +#define ARGS "db=\"sql:%s\" use_hw=no soft=(,Test,CAC,,cert1,cert2,cert3)" > > + > > +static GMainLoop *loop; > > +static GThread *thread; > > +static guint nreaders; > > +static GMutex mutex; > > +static GCond cond; > > + > > +static gpointer > > +events_thread(gpointer arg) > > +{ > > + unsigned int reader_id; > > + VEvent *event; > > + > > + while (1) { > > + event = vevent_wait_next_vevent(); > > + if (event == NULL) { > > + break; > > + } > > + reader_id = vreader_get_id(event->reader); > > + if (reader_id == VSCARD_UNDEFINED_READER_ID) { > > + g_mutex_lock(&mutex); > > + vreader_set_id(event->reader, nreaders++); > > + g_cond_signal(&cond); > > + g_mutex_unlock(&mutex); > > + reader_id = vreader_get_id(event->reader); > > + } > > + switch (event->type) { > > + case VEVENT_READER_INSERT: > > + case VEVENT_READER_REMOVE: > > + case VEVENT_CARD_INSERT: > > + case VEVENT_CARD_REMOVE: > > + break; > > + case VEVENT_LAST: > > + default: > > + g_warn_if_reached(); > > + break; > > + } > > + vevent_delete(event); > > + } > > + > > + return NULL; > > +} > > + > > +static void libcacard_init(void) > > +{ > > + VCardEmulOptions *command_line_options = NULL; > > + gchar *dbdir = g_test_build_filename(G_TEST_DIST, "db", NULL); > > + gchar *args = g_strdup_printf(ARGS, dbdir); > > + VReader *r; > > + VCardEmulError ret; > > + > > + thread = g_thread_new("test/events", events_thread, NULL); > > + > > + command_line_options = vcard_emul_options(args); > > + ret = vcard_emul_init(command_line_options); > > + g_assert_cmpint(ret, ==, VCARD_EMUL_OK); > > + > > + r = vreader_get_reader_by_name("Test"); > > + g_assert_nonnull(r); > > + vreader_free(r); /* get by name ref */ > > + > > + g_mutex_lock(&mutex); > > + while (nreaders == 0) > > + g_cond_wait(&cond, &mutex); > > + g_mutex_unlock(&mutex); > > + > > + g_free(args); > > + g_free(dbdir); > > +} > > + > > +static void test_list(void) > > +{ > > + VReaderList *list = vreader_get_reader_list(); > > + VReaderListEntry *reader_entry; > > + int cards = 0; > > + > > + for (reader_entry = vreader_list_get_first(list); reader_entry; > > + reader_entry = vreader_list_get_next(reader_entry)) { > > + VReader *r = vreader_list_get_reader(reader_entry); > > + vreader_id_t id; > > + id = vreader_get_id(r); > > + g_assert_cmpstr(vreader_get_name(r), ==, "Test"); > > + g_assert_cmpint(id, !=, VSCARD_UNDEFINED_READER_ID); > > + if (vreader_card_is_present(r) == VREADER_OK) { > > + cards++; > > + } > > + } > > + g_assert_cmpint(cards, ==, 1); > > + vreader_list_delete(list); > > +} > > + > > +static void test_card_remove_insert(void) > > +{ > > + VReader *reader = vreader_get_reader_by_id(0); > > + VCardEmulError error; > > + > > + g_assert_nonnull(reader); > > + > > + error = vcard_emul_force_card_remove(reader); > > + g_assert_cmpint(error, ==, VCARD_EMUL_OK); > > + g_assert_cmpint(vreader_card_is_present(reader), ==, VREADER_NO_CARD); > > + > > + error = vcard_emul_force_card_remove(reader); > > + g_assert_cmpint(error, ==, VCARD_EMUL_FAIL); > > + g_assert_cmpint(vreader_card_is_present(reader), ==, VREADER_NO_CARD); > > + > > + error = vcard_emul_force_card_insert(reader); > > + g_assert_cmpint(error, ==, VCARD_EMUL_OK); > > + g_assert_cmpint(vreader_card_is_present(reader), ==, VREADER_OK); > > + > > + error = vcard_emul_force_card_insert(reader); > > + g_assert_cmpint(error, ==, VCARD_EMUL_FAIL); > > + g_assert_cmpint(vreader_card_is_present(reader), ==, VREADER_OK); > > + > > + vreader_free(reader); /* get by id ref */ > > +} > > + > > +#define APDUBufSize 270 > > + > > +static void test_xfer(void) > > +{ > > + VReader *reader = vreader_get_reader_by_id(0); > > + VReaderStatus status; > > + int dwRecvLength = APDUBufSize; > > + uint8_t pbRecvBuffer[APDUBufSize]; > > + uint8_t pbSendBuffer[] = { > > + 0x00, 0xa4, 0x04, 0x00, 0x07, 0x62, 0x76, 0x01, 0xff, 0x00, 0x00, > > 0x00, > > + }; > > + > > + g_assert_nonnull(reader); > > + status = vreader_xfr_bytes(reader, > > + pbSendBuffer, sizeof(pbSendBuffer), > > + pbRecvBuffer, &dwRecvLength); > > + g_assert_cmpint(status, ==, VREADER_OK); > > + vreader_free(reader); /* get by id ref */ > > +} > > + > > +static void test_cac(void) > > +{ > > + VReader *reader = vreader_get_reader_by_id(0); > > + VReaderStatus status; > > + int dwRecvLength = APDUBufSize, len; > > + uint8_t pbRecvBuffer[APDUBufSize]; > > + uint8_t selfile0[] = { > > + 0x00, 0xa4, 0x04, 0x00, 0x07, 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, > > 0x00 > > + }; > > + uint8_t getresp[] = { > > + 0x00, 0xc0, 0x00, 0x00, 0x07 > > + }; > > + uint8_t getcert[] = { > > + 0x00, 0x36, 0x00, 0x00, 0x00 > > + }; > > + > > + g_assert_nonnull(reader); > > + status = vreader_xfr_bytes(reader, > > + selfile0, sizeof(selfile0), > > + pbRecvBuffer, &dwRecvLength); > > + g_assert_cmpint(status, ==, VREADER_OK); > > + g_assert_cmphex(pbRecvBuffer[0], ==, VCARD7816_SW1_RESPONSE_BYTES); > > + g_assert_cmphex(pbRecvBuffer[1], ==, 0x7); > > + > > + dwRecvLength = APDUBufSize; > > + status = vreader_xfr_bytes(reader, > > + getresp, sizeof(getresp), > > + pbRecvBuffer, &dwRecvLength); > > + g_assert_cmpint(status, ==, VREADER_OK); > > + g_assert_cmpint(dwRecvLength, ==, 9); > > + g_assert_cmphex(pbRecvBuffer[7], ==, VCARD7816_SW1_SUCCESS); > > + g_assert_cmphex(pbRecvBuffer[8], ==, 0x0); > > + > > + len = 0xff; > > + do { > > + dwRecvLength = APDUBufSize; > > + getcert[4] = len; > > + status = vreader_xfr_bytes(reader, > > + getcert, sizeof(getcert), > > + pbRecvBuffer, &dwRecvLength); > > + g_assert_cmpint(status, ==, VREADER_OK); > > + g_assert_cmpint(dwRecvLength, ==, len + 2); > > + switch (pbRecvBuffer[len]) { > > + case VCARD7816_SW1_WARNING_CHANGE: > > + len = pbRecvBuffer[len+1]; > > + break; > > + case VCARD7816_SW1_SUCCESS: > > + len = 0; > > + break; > > + default: > > + g_assert_not_reached(); > > + } > > + } while (len != 0); > > + > > + vreader_free(reader); /* get by id ref */ > > +} > > + > > +static void test_remove(void) > > +{ > > + VReader *reader = vreader_get_reader_by_id(0); > > + VReaderStatus status; > > + > > + g_assert_nonnull(reader); > > + > > + status = vreader_remove_reader(reader); > > + g_assert_cmpint(status, ==, VREADER_OK); > > + vreader_free(reader); /* get by id ref */ > > + vreader_free(reader); > > + > > + reader = vreader_get_reader_by_id(0); > > + g_assert_null(reader); > > +} > > + > > +int main(int argc, char *argv[]) > > +{ > > + int ret; > > + > > + g_test_init(&argc, &argv, NULL); > > + > > + loop = g_main_loop_new(NULL, TRUE); > > + > > + libcacard_init(); > > + > > + g_test_add_func("/libcacard/list", test_list); > > + g_test_add_func("/libcacard/card-remove-insert", > > test_card_remove_insert); > > + g_test_add_func("/libcacard/xfer", test_xfer); > > + g_test_add_func("/libcacard/cac", test_cac); > > + g_test_add_func("/libcacard/remove", test_remove); > > + > > + ret = g_test_run(); > > + > > + g_main_loop_unref(loop); > > + > > + /* FIXME: no wait to queue a NULL event */ > > + /* g_thread_join(thread); */ > > + > > + return ret; > > +} > > -- > > 2.4.3 > > > > _______________________________________________ > > Spice-devel mailing list > > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > > http://lists.freedesktop.org/mailman/listinfo/spice-devel > _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel