1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

tests: Make migration test more robust and silent.

* tests/migrations/from-classic.test: Fix in-tree build, silence test.

Fixes-commit: defbc70b
Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-04-21 14:36:21 +02:00
parent d81de224ec
commit 0c35e09278

View File

@ -13,6 +13,7 @@ if [ -z "$srcdir" ]; then
exit 1 exit 1
fi fi
unset GNUPGHOME
set -e set -e
# (We may not use a relative name for gpg-agent.) # (We may not use a relative name for gpg-agent.)
@ -20,22 +21,28 @@ GPG_AGENT="$(cd ../../agent && /bin/pwd)/gpg-agent"
GPG="../../g10/gpg --no-permission-warning --no-greeting --no-secmem-warning GPG="../../g10/gpg --no-permission-warning --no-greeting --no-secmem-warning
--batch --agent-program=${GPG_AGENT}|--debug-quick-random" --batch --agent-program=${GPG_AGENT}|--debug-quick-random"
export GNUPGHOME="from-classic.gpghome" TEST="from-classic"
setup_home() setup_home()
{ {
rm -rf -- "$GNUPGHOME" XGNUPGHOME="`mktemp -d`"
mkdir "$GNUPGHOME" rm -rf -- scratch
for F in $srcdir/$GNUPGHOME/*.asc mkdir -p "$XGNUPGHOME"
do for F in $srcdir/$TEST.gpghome/*.asc; do
$GPG --dearmor <"$F" >"$GNUPGHOME/`echo $F | sed -e 's/....$//'`" $GPG --dearmor <"$F" >"$XGNUPGHOME/`basename $F .asc`"
done done
chmod go-rwx $GNUPGHOME/* chmod go-rwx $XGNUPGHOME/*
export GNUPGHOME="$XGNUPGHOME"
}
cleanup_home()
{
rm -rf -- "$XGNUPGHOME"
} }
trigger_migration() trigger_migration()
{ {
$GPG --list-secret-keys >/dev/null $GPG --list-secret-keys >/dev/null 2>&1
} }
assert_migrated() assert_migrated()
@ -50,12 +57,14 @@ assert_migrated()
setup_home setup_home
trigger_migration trigger_migration
assert_migrated assert_migrated
cleanup_home
# Test with an existing private-keys-v1.d. # Test with an existing private-keys-v1.d.
setup_home setup_home
mkdir "$GNUPGHOME/private-keys-v1.d" mkdir "$GNUPGHOME/private-keys-v1.d"
trigger_migration trigger_migration
assert_migrated assert_migrated
cleanup_home
# Test with an existing private-keys-v1.d with weird permissions. # Test with an existing private-keys-v1.d with weird permissions.
setup_home setup_home
@ -63,5 +72,6 @@ mkdir "$GNUPGHOME/private-keys-v1.d"
chmod 0 "$GNUPGHOME/private-keys-v1.d" chmod 0 "$GNUPGHOME/private-keys-v1.d"
trigger_migration trigger_migration
assert_migrated assert_migrated
cleanup_home
# XXX Check a case where the migration fails. # XXX Check a case where the migration fails.