diff --git a/tests/Makefile.am b/tests/Makefile.am index bb75c97be..7cbf9e8e6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,76 +1,76 @@ # Makefile.am -tests makefile for libxtime # Copyright (C) 2002 Free Software Foundation, Inc. # # This file is part of GnuPG. # # GnuPG 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 3 of the License, or # (at your option) any later version. # # GnuPG 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 . ## Process this file with automake to produce Makefile.in -SUBDIRS = gpgscm openpgp migrations gpgsm gpgme pkits . +SUBDIRS = gpgscm openpgp migrations gpgsm gpgme . GPGSM = ../sm/gpgsm # Note that we need to use /bin/pwd so that we don't get into trouble # if the shell used for inittests would uses an internal version of # pwd which handles symlinks differently. TESTS_ENVIRONMENT = GNUPGHOME=`/bin/pwd` GPG_AGENT_INFO= LC_ALL=C \ GPGSM=$(GPGSM) $(srcdir)/runtest testscripts = sm-sign+verify sm-verify EXTRA_DIST = runtest inittests $(testscripts) ChangeLog-2011 \ text-1.txt text-2.txt text-3.txt \ text-1.osig.pem text-1.dsig.pem text-1.osig-bad.pem \ text-2.osig.pem text-2.osig-bad.pem \ fake-pinentries/README.txt \ fake-pinentries/fake-pinentry.php \ fake-pinentries/fake-pinentry.pl \ fake-pinentries/fake-pinentry.py \ fake-pinentries/fake-pinentry.sh \ samplekeys/steed-self-signing-nonthority.pem \ samplekeys/68A638998DFABAC510EA645CE34F9686B2EDF7EA.key \ samplekeys/32100C27173EF6E9C4E9A25D3D69F86D37A4F939.key \ samplekeys/cert_g10code_pete1.pem \ samplekeys/cert_g10code_test1.pem \ samplekeys/cert_g10code_theo1.pem # We used to run $(testscripts) here but these asschk scripts are not # completely reliable in all environments and thus we better disable # them. The tests are anyway way too minimal. We will eventually # write new tests based on gpg-connect-agent which has a full fledged # script language and thus makes it far easier to write tests than to # use that low-level asschk stuff. TESTS = CLEANFILES = inittests.stamp x y y z out err \ *.lock .\#lk* DISTCLEANFILES = pubring.kbx~ random_seed if !HAVE_W32_SYSTEM noinst_PROGRAMS = asschk endif asschk_SOURCES = asschk.c all-local: inittests.stamp clean-local: srcdir=$(srcdir) $(TESTS_ENVIRONMENT) $(srcdir)/inittests --clean inittests.stamp: inittests srcdir=$(srcdir) $(TESTS_ENVIRONMENT) $(srcdir)/inittests echo timestamp >./inittests.stamp diff --git a/tests/pkits/common.sh b/tests/pkits/common.sh index ca18b9501..697f28f67 100644 --- a/tests/pkits/common.sh +++ b/tests/pkits/common.sh @@ -1,275 +1,275 @@ # common.sh - common defs for all tests -*- sh -*- # Copyright (C) 2004, 2008 Free Software Foundation, Inc. # # This file is part of GnuPG. # # GnuPG 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 3 of the License, or # (at your option) any later version. # # GnuPG 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 . # reset some environment variables because we do not want to test locals LANG=C LANGUAGE=C LC_ALL=C export LANG LANGUAGE LC_ALL pgmname=`basename $0` if [ "$1" = "--debug" ]; then debug=yes set -x else debug= fi [ -z "$srcdir" ] && srcdir="." [ -z "$top_srcdir" ] && top_srcdir=".." [ -z "$GPGSM" ] && GPGSM="../../sm/gpgsm" [ -z "$silent" ] && silent=no AWK=awk SCRATCH="scratch.$$.tmp" # We use this as the faked system time for certain tests. MYTIME="20080508T120000" if [ "$GNUPGHOME" != "`/bin/pwd`" ]; then echo "inittests: please set GNUPGHOME to the tests/pkits directory" >&2 exit 1 fi if [ -n "$GPG_AGENT_INFO" ]; then echo "inittests: please unset GPG_AGENT_INFO" >&2 exit 1 fi -if [ -f PKITS_data.tar.bz2 ]; then +if [ -f "$srcdir/PKITS_data.tar.bz2" ]; then : else if [ "$pgmname" = "import-all-certs" ]; then if [ "$silent" = "yes" ]; then tmp1="Note: "; tmp2=' ' else tmp1="- ____ "; tmp2="$tmp1" fi echo "${tmp1}PKITS_data.tar.bz2 is not installed" echo "${tmp2}All tests will be skipped (this is not an error)" fi # Exit code 77 is used by the Makefile for skipping a tests. exit 77 fi #-------------------------------- #------ utility functions ------- #-------------------------------- echo_n_init=no echo_n () { if test "$echo_n_init" = "no"; then if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then echo_n_n= echo_n_c=' ' else echo_n_n='-n' echo_n_c= fi else echo_n_n= echo_n_c='\c' fi echo_n_init=yes fi echo $echo_n_n "${1}$echo_n_c" } setup_output () { if [ -z "$first_section_set" ]; then first_section_set=$section fi section_out="$(echo $section)" if [ -z "$section_out" ]; then section_out="-" fi } fatal () { echo "$pgmname: fatal:" $* >&2 if [ "$silent" != "yes" ]; then echo "$section_out ERROR: $* (fatal)" fi exit 1; } error () { echo "$pgmname:" $* >&2 if [ "$silent" != "yes" ]; then echo "$section_out ERROR: $*" fi exit 1 } info () { setup_output echo "$pgmname:" $* >&2 if [ "$silent" != "yes" ]; then echo "$section_out ____ $*" fi } info_n () { setup_output echo_n "$pgmname:" $* >&2 } pass () { setup_output echo "PASS: " $* >&2 pass_count=`expr ${pass_count} + 1` if [ "$silent" != "yes" ]; then echo_n "$section_out PASS" if [ -n "$1" ]; then echo_n " $1" elif [ -n "$description" ]; then echo_n " ($description)" fi echo fi } fail () { setup_output echo "FAIL: " $* >&2 fail_count=`expr ${fail_count} + 1` if [ "$silent" != "yes" ]; then echo_n "$section_out FAIL" if [ -n "$1" ]; then echo_n " $1" elif [ -n "$description" ]; then echo_n " ($description)" fi echo fi } skip () { setup_output echo "SKIP: " $* >&2 skip_count=`expr ${skip_count} + 1` if [ "$silent" != "yes" ]; then echo_n "$section_out SKIP" if [ -n "$1" ]; then echo_n " $1" elif [ -n "$description" ]; then echo_n " ($description)" fi echo fi } unresolved () { setup_output echo "UNRESOLVED: " $* >&2 unresolved_count=`expr ${unresolved_count} + 1` if [ "$silent" != "yes" ]; then echo_n "$section_out UNRESOLVED" if [ -n "$1" ]; then echo_n " $1" elif [ -n "$description" ]; then echo_n " ($description)" fi echo fi } final_result () { section=$first_section_set [ $pass_count = 0 ] || info "$pass_count tests passed" [ $fail_count = 0 ] || info "$fail_count tests failed" [ $skip_count = 0 ] || info "$unsupported_count tests skipped" [ $unresolved_count = 0 ] || info "$unresolved_count tests unresolved" [ -z "$debug" -a -f "$SCRATCH" ] && rm "$SCRATCH" if [ $fail_count = 0 ]; then info "all tests passed" else exit 1 fi } clean_homedir () { [ -f pubring.kbx ] && rm pubring.kbx if [ -d private-keys-v1.d ]; then rm private-keys-v1.d/* 2>/dev/null || true rmdir private-keys-v1.d fi } start_test () { section="$1" description="$2" test_status=none echo "BEGIN TEST $section ($description)" >&2 } end_test () { case "$test_status" in none) skip "($description) - test not implemented";; pass) pass "($description)";; fail) fail "($description)";; setup) fail "($description) - setup failed";; ns) skip "($description) - not supported";; nys) skip "($description) - not yet supported";; *) unresolved "$(description)";; esac echo "END TEST $section" >&2 } set_status () { if [ "$test_status" = "none" ]; then test_status=$1 fi } need_cert () { if [ "$2" = "--import-anyway" ]; then if ! ${GPGSM} -q --debug-no-chain-validation --import certs/$1.crt then set_status setup fi else if ! ${GPGSM} -q --import certs/$1.crt; then set_status setup fi fi } need_crl () { # CRL are not yet implemented #set_status setup : } set -e pass_count=0 fail_count=0 skip_count=0 unresolved_count=0 first_section_set="" section_out="" test_status=none # User settable variables section="" description="" #trap cleanup SIGHUP SIGINT SIGQUIT [ -z "$debug" ] && exec 2> ${pgmname}.log : # end diff --git a/tests/pkits/inittests b/tests/pkits/inittests index 5c29bdc49..4bff0a8b8 100755 --- a/tests/pkits/inittests +++ b/tests/pkits/inittests @@ -1,108 +1,108 @@ #!/bin/sh # Copyright (C) 2004 Free Software Foundation, Inc. -*- sh -*- # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This file 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 -e clean_files=' ReadMe.txt pkits.ldif pkits.schema gpgsm.conf gpg-agent.conf trustlist.txt policies.txt pubring.kbx msg msg.sig msg.unsig ' [ -z "$srcdir" ] && srcdir=. [ -z "$GPGSM" ] && GPGSM=../../sm/gpgsm #if [ -f $srcdir/README ] \ # && grep tests/pkits/README README >/dev/null 2>&1; then # : #else # # During make distclean the Makefile has already been removed, # # so we need this extra test. # if ! grep gnupg-test-pkits-directory testdir.stamp >/dev/null 2>&1; then # echo "inittests: please cd to the tests/pkits directory first" >&2 # exit 1 # fi #fi if [ "$1" = "--clean" ]; then if [ -d private-keys-v1.d ]; then rm private-keys-v1.d/* 2>/dev/null || true rmdir private-keys-v1.d fi rm ${clean_files} testdir.stamp 2>/dev/null || true for i in certs certpairs crls pkcs12 smime; do if [ -d $i ]; then rm $i/* 2>/dev/null || true rmdir $i fi done exit 0 fi if [ "$GNUPGHOME" != "`/bin/pwd`" ]; then echo "inittests: please set GNUPGHOME to the tests/pkits directory" >&2 exit 1 fi if [ -n "$GPG_AGENT_INFO" ]; then echo "inittests: please unset GPG_AGENT_INFO" >&2 exit 1 fi -if test -f PKITS_data.tar.bz2; then - if ! bunzip2 -c PKITS_data.tar.bz2 | tar xf - ; then +if test -f "$srcdir/PKITS_data.tar.bz2"; then + if ! bunzip2 -c "$srcdir/PKITS_data.tar.bz2" | tar xf - ; then echo "inittests: failed to untar the test data" >&2 exit 1 fi fi # A stamp file used with --clean echo gnupg-test-pkits-directory > testdir.stamp # Create the configuration scripts cat > gpgsm.conf < policies.txt < gpg-agent.conf < trustlist.txt <policies.txt <