diff options
-rw-r--r-- | tests/ChangeLog | 9 | ||||
-rw-r--r-- | tests/Makefile.am | 31 | ||||
-rw-r--r-- | tests/asschk.c | 22 | ||||
-rwxr-xr-x | tests/inittests | 23 | ||||
-rwxr-xr-x | tests/runtest | 2 | ||||
-rw-r--r-- | tests/samplekeys/distfiles | 4 | ||||
-rw-r--r-- | tests/sm-sign+verify | 3 | ||||
-rw-r--r-- | tests/sm-verify | 16 |
8 files changed, 67 insertions, 43 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 1711e9529..627d02274 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,12 @@ +2002-08-09 Werner Koch <wk@gnupg.org> + + * asschk.c (cmd_getenv): New. + (expand_line): Allow / as variable name delimiter. + * sm-sign+verify, sm-verify: Use $srcdir so that a VPATH build works. + + * Makefile.am: Fixes for make dist. + * samplekets/Makefile.am: New. + 2002-08-08 Werner Koch <wk@gnupg.org> * asschk.c: Added some new features. diff --git a/tests/Makefile.am b/tests/Makefile.am index ac0e6cb8c..442d86435 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,17 +24,23 @@ GPGSM = ../sm/gpgsm # We can't unset a variable here so we unset GPG_AGENT_INFO in runtest TESTS_ENVIRONMENT = GNUPGHOME=`pwd` LC_ALL=C GPGSM=$(GPGSM) $(srcdir)/runtest -EXTRA_DIST = runtest inittests \ +testscripts = sm-sign+verify sm-verify + +EXTRA_DIST = runtest inittests $(testscripts) \ 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 + text-2.osig.pem text-2.osig-bad.pem \ + samplekeys/32100C27173EF6E9C4E9A25D3D69F86D37A4F939.key \ + samplekeys/cert_g10code_pete1.pem \ + samplekeys/cert_g10code_test1.pem \ + samplekeys/cert_g10code_theo1.pem -TESTS = sm-sign+verify sm-verify +TESTS = $(testscripts) CLEANFILES = inittests.stamp x y y z out err *.lock .\#lk* -DISTCLEANFILES = keyring.kbx~ random_seed +DISTCLEANFILES = pubring.kbx~ random_seed noinst_PROGRAMS = asschk @@ -44,22 +50,9 @@ asschk_SOURCES = asschk.c all-local: inittests.stamp clean-local: - $(TESTS_ENVIRONMENT) $(srcdir)/inittests --clean + srcdir=$(srcdir) $(TESTS_ENVIRONMENT) $(srcdir)/inittests --clean inittests.stamp: inittests - $(TESTS_ENVIRONMENT) $(srcdir)/inittests + srcdir=$(srcdir) $(TESTS_ENVIRONMENT) $(srcdir)/inittests echo timestamp >./inittests.stamp -# Include all files listed in the samplekeys/distfiles -dist-hook: - @set -e; \ - dir=$(srcdir)/samplekeys ; \ - $(mkinstalldirs) $(distdir)/$$dir ; \ - for i in distfiles `cat $$dir/distfiles` ; do \ - ln $(srcdir)/$$dir/$$i $(distdir)/$$dir/$$i 2> /dev/null \ - || cp -p $(srcdir)/$$dir/$$i $(distdir)/$$dir/$$i; \ - done - - - - diff --git a/tests/asschk.c b/tests/asschk.c index 7b7321675..829c86273 100644 --- a/tests/asschk.c +++ b/tests/asschk.c @@ -30,8 +30,8 @@ a line is processed but after comment processing. Macros are only expanded once and non existing macros expand to the empty string. A macro is dereferenced by prefixing its name with a dollar sign; - the end of the name is currently indicated by a white space. To - use a dollor sign verbatim, double it. + the end of the name is currently indicated by a white space, a + dollar sign or a slash. To use a dollor sign verbatim, double it. A macro is assigned by prefixing a statement with the macro name and an equal sign. The value is assigned verbatim if it does not @@ -96,6 +96,9 @@ cmpfiles <first> <second> Returns true when the content of the files FIRST and SECOND match. + getenv <name> + Return the value of the environment variable NAME. + */ #include <stdio.h> @@ -571,7 +574,8 @@ expand_line (char *buffer) line = p + 1; continue; } - for (pend=p+1; *pend && !spacep (pend) && *pend != '$'; pend++) + for (pend=p+1; *pend && !spacep (pend) + && *pend != '$' && *pend != '/'; pend++) ; if (*pend) { @@ -854,6 +858,17 @@ cmd_cmpfiles (const char *assign_to, char *arg) fclose (fp2); } +static void +cmd_getenv (const char *assign_to, char *arg) +{ + const char *s; + s = *arg? getenv (arg):""; + set_var (assign_to, s? s:""); +} + + + + /* Process the current script line LINE. */ static int interpreter (char *line) @@ -875,6 +890,7 @@ interpreter (char *line) { "quit-if" , cmd_quit_if }, { "fail-if" , cmd_fail_if }, { "cmpfiles" , cmd_cmpfiles }, + { "getenv" , cmd_getenv }, { NULL } }; char *p, *save_p; diff --git a/tests/inittests b/tests/inittests index 1de903e57..b1860f5fd 100755 --- a/tests/inittests +++ b/tests/inittests @@ -11,7 +11,7 @@ set -e -sample_cert=' +sample_certs=' cert_g10code_test1.pem cert_g10code_pete1.pem cert_g10code_theo1.pem @@ -22,7 +22,7 @@ private_keys=' ' clean_files=' -gpgsm.conf gpg-agent.conf trustlist.txt keyring.kbx +gpgsm.conf gpg-agent.conf trustlist.txt pubring.kbx msg msg.sig msg.unsig ' @@ -34,8 +34,12 @@ if [ -d $srcdir/samplekeys ] \ && grep TESTS_ENVIRONMENT Makefile >/dev/null 2>&1; then : else - echo "inittests: please cd to the tests directory first" >&2 - exit 1 + # During make distclean the Makefile has already been removed, + # so we need this extra test. + if ! grep gnupg-test-directory testdir.stamp >/dev/null 2>&1; then + echo "inittests: please cd to the tests directory first" >&2 + exit 1 + fi fi if [ "$1" = "--clean" ]; then @@ -43,7 +47,7 @@ if [ "$1" = "--clean" ]; then rm private-keys-v1.d/* 2>/dev/null || true rmdir private-keys-v1.d fi - rm ${clean_files} 2>/dev/null || true + rm ${clean_files} testdir.stamp 2>/dev/null || true exit 0 fi @@ -57,13 +61,15 @@ if [ -n "$GPG_AGENT_INFO" ]; then exit 1 fi +# A stamp file used with --clean +echo gnupg-test-directory > testdir.stamp # Create the private key directy if it does not exists and copy # the sample keys. [ -d private-keys-v1.d ] || mkdir private-keys-v1.d for i in ${private_keys}; do - cp ${srcdir}/samplekeys/$i.key private-keys-v1.d/$i.key + cat ${srcdir}/samplekeys/$i.key >private-keys-v1.d/$i.key done # Create the configuration scripts @@ -83,7 +89,8 @@ cat > trustlist.txt <<EOF 3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S EOF -# Make sure that the sample certs are available +# Make sure that the sample certs are available but ignore errors here +# because we are not a test script. for i in ${sample_certs}; do - $GPGSM --import ${srcdir}/samplekeys/$i.pem + $GPGSM --import ${srcdir}/samplekeys/$i || true done diff --git a/tests/runtest b/tests/runtest index 6284179ef..71385fb46 100755 --- a/tests/runtest +++ b/tests/runtest @@ -1,5 +1,5 @@ #!/bin/sh unset GPG_AGENT_INFO -[ -x "$1" ] && exec "$1" +[ -x "$1" ] && exec $1 $2 exec ./asschk --no-echo -DGPGSM=${GPGSM} <"$1" diff --git a/tests/samplekeys/distfiles b/tests/samplekeys/distfiles deleted file mode 100644 index 75f7fd181..000000000 --- a/tests/samplekeys/distfiles +++ /dev/null @@ -1,4 +0,0 @@ -32100C27173EF6E9C4E9A25D3D69F86D37A4F939.key -cert_g10code_pete1.pem -cert_g10code_test1.pem -cert_g10code_theo1.pem diff --git a/tests/sm-sign+verify b/tests/sm-sign+verify index 014126f11..1c3ae7dbd 100644 --- a/tests/sm-sign+verify +++ b/tests/sm-sign+verify @@ -3,7 +3,8 @@ # Creating a signature and verifying it # Requirements: a plain file "text-1.txt" -plaintext = text-1.txt +srcdir = getenv srcdir +plaintext = let $srcdir/text-1.txt in = openfile $plaintext out = createfile msg.sig diff --git a/tests/sm-verify b/tests/sm-verify index 6abc81b5a..b06dc16a4 100644 --- a/tests/sm-verify +++ b/tests/sm-verify @@ -4,8 +4,10 @@ # Requirements: # +srcdir = getenv srcdir + # Check an opaque signature -sig = openfile text-1.osig.pem +sig = openfile $srcdir/text-1.osig.pem out = createfile msg.unsig pipeserver $GPGSM send INPUT FD=$sig @@ -26,12 +28,12 @@ expect-ok sig = out = -cmpfiles text-1.txt msg.unsig +cmpfiles $srcdir/text-1.txt msg.unsig fail-if !$? # Check a detached signature. -sig = openfile text-1.dsig.pem -plain = openfile text-1.txt +sig = openfile $srcdir/text-1.dsig.pem +plain = openfile $srcdir/text-1.txt pipeserver $GPGSM send INPUT FD=$sig expect-ok @@ -50,7 +52,7 @@ send BYE expect-ok # Check a tampered opaque message -sig = openfile text-1.osig-bad.pem +sig = openfile $srcdir/text-1.osig-bad.pem out = createfile msg.unsig pipeserver $GPGSM @@ -71,7 +73,7 @@ send BYE expect-ok # Check another opaque signature but without asking for the output. -sig = openfile text-2.osig.pem +sig = openfile $srcdir/text-2.osig.pem pipeserver $GPGSM send INPUT FD=$sig @@ -89,7 +91,7 @@ send BYE expect-ok # We als have tampered version. -sig = openfile text-2.osig-bad.pem +sig = openfile $srcdir/text-2.osig-bad.pem pipeserver $GPGSM send INPUT FD=$sig |