1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00
gnupg/tests/openpgp/gpgtar.test
Werner Koch 96bcd4220f
Now build "gpg" binary but install as "gpg2"
* configure.ac (USE_GPG2_HACK): New ac_define am_conditional.
* common/homedir.c (gnupg_module_name): Replace use of macro
NAME_OF_INSTALLED_GPG.
* g10/keygen.c (generate_keypair): Ditto.
* g10/Makefile.am (bin_PROGRAMS): Remove.
(noinst_PROGRAMS): Add gpg or gpg2 and gpgv or gpg2.
(gpg2_hack_list): New.
(use_gpg2_hack): New.
(gpg2_SOURCES): Rename to gpg_SOURCES.
(gpgv2_SOURCES): Rename to gpgv_SOURCES.
(gpg2_LDADD): Rename to gpg_LDADD.
(gpgv2_LDADD): Rename to gpgv_LDADD.
(gpg2_LDFLAGS): Rename to gpg_LDFLAGS.
(gpgv2_LDFLAGS): Rename to gpgv2_LDFLAGS.
(install-exec-hook): Remove WinCE specific rules and add new rules.
(uninstall-local): Uninstall gpg/gpg2 and gpgv/gpgv2.
* tests/openpgp/Makefile.am (required_pgms): s/gpg2/gpg/.
* tests/openpgp/defs.inc: Ditto.
* tests/openpgp/gpgtar.test: Ditto.
* tests/openpgp/mkdemodirs: Ditto.
* tests/openpgp/signdemokey: Ditto.

* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Remove obsolete
--enable-mailto, add --enable-gpg2-is-gpg.
--

Although we need to duplicate some automake generated code this method
allows to easily switch the name of the installed target using the
configure option "--enable-gpg2-is-gpg".

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-04 18:40:25 +02:00

127 lines
2.7 KiB
Bash
Executable File

#!/bin/sh
#set -x
# Make sure $srcdir is set.
if test "x$srcdir" = x
then
echo srcdir environment variable not set!
exit 1
fi
. $srcdir/defs.inc || exit 3
set -e
# Make sure $GNUPGHOME is set.
if test "x$GNUPGHOME" = x
then
echo "GNUPGHOME not set."
exit 1
fi
TESTFILES="$plain_files $data_files"
TESTDIR=gpgtar.d
FILELIST="${TESTDIR}/filelist"
PPFILE="${TESTDIR}/passphrase"
PPFLAGS="--gpg-args --passphrase-file=$PPFILE"
GPG=../../g10/gpg
GPGARGS="$opt_always --no-permission-warning"
GPGTAR="../../tools/gpgtar"
GPGZIP="sh ../../tools/gpg-zip"
# Skip test if gpgtar has not been built.
if ! test -x "$GPGTAR"
then
exit 77
fi
# Create, inspect, and extract an archive with the given options.
#
# $1 the tool to test
# $2 options used to create the archive
# $3 options used to inspect the archive
# $4 options used to extract the archive
do_test()
{
(
TOOL="$1"
CREATE_FLAGS="$2"
INSPECT_FLAGS="$3"
EXTRACT_FLAGS="$4"
rm -rf -- "${TESTDIR}"
mkdir "${TESTDIR}"
echo frob >"$PPFILE"
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $CREATE_FLAGS \
--output "${TESTDIR}/test.tar.pgp" $TESTFILES
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $INSPECT_FLAGS \
"${TESTDIR}/test.tar.pgp" \
>"$FILELIST"
for F in $TESTFILES
do
awk '{print $NF}' "$FILELIST" | grep "^${F}$" >/dev/null
done
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $EXTRACT_FLAGS \
--tar-args --directory="${TESTDIR}" \
"${TESTDIR}/test.tar.pgp"
for F in $TESTFILES
do
cmp "$F" "${TESTDIR}/$F"
done
)
}
for TOOL in "$GPGTAR" "$GPGZIP"
#for TOOL in "$GPGZIP"
do
# Asymmetric encryption.
do_test "$TOOL" \
"--encrypt --recipient $usrname2" \
"--list-archive" \
"--decrypt"
# Asymmetric encryption and signing.
do_test "$TOOL" \
"--encrypt --recipient $usrname2 --sign --local-user $usrname3" \
"--list-archive" \
"--decrypt"
# Signing only.
do_test "$TOOL" \
"--sign --local-user $usrname3" \
"--list-archive" \
"--decrypt"
# Symmetric encryption.
do_test "$TOOL" \
"${PPFLAGS} --symmetric" \
"${PPFLAGS} --list-archive" \
"${PPFLAGS} --decrypt"
# Symmetric encryption, explicitly choose cipher.
for a in `all_cipher_algos`; do
do_test "$TOOL" \
"${PPFLAGS} --gpg-args --cipher=$a --symmetric" \
"${PPFLAGS} --list-archive" \
"${PPFLAGS} --decrypt"
break
done
# Asymmetric and symmetric encryption, and signing.
do_test "$TOOL" \
"${PPFLAGS} --encrypt --symmetric --recipient $usrname2 --sign --local-user $usrname3" \
"${PPFLAGS} --list-archive" \
"${PPFLAGS} --decrypt"
done
# Success!
exit 0