gpgme/tests/start-stop-agent
Werner Koch a5b040cc57
Fix test suite for GnuPG 2.1 which uses pubring.kbx.
* tests/gpgsm/final.test: New.
* tests/gpgsm/initial.test: New.
* tests/gpg/start-stop-agent: Move to ../.
* tests/gpgsm/Makefile.am (TESTS_ENVIRONMENT): Export top_srcdir.
(TESTS): Add intial.test and final.test.
(AM_LDFLAGS): Add -no-install.
(clean-local): Use start-stop-agent
(initial.test): Add dependency.
* tests/gpg/Makefile.am (top_srcdir): Export top_srcdir.
(AM_LDFLAGS): Add -no-install.
(check-local): Depend on pubring-stamp instead of pubring.gpg.
(initial.test): Depend on check-local.
(./pubring-gpg): Replace by rule for ./pubring-stamp.
--

There are also a couple of other changes which should make the tests a
bit more robust and the gpg and gpgsm tests more similar.

The -no-install avoids creating wrappers for test programs, which make
debugging easier.

The dependency on check-local guarantees that its rules are run before
the first test.  This is important because conf files are setup by
this rule.  Earlier automake versions seem to have run check-local
always before the tests but today the order of execution is not
defined.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-06-08 10:43:29 +02:00

46 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Copyright (C) 2013 g10 Code GmbH
#
# 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.
if [ -z "$(command -v gpg-connect-agent)" ]; then
echo "gpg-agent not installed and thus not started" >&2
exit 0;
fi
GPG_AGENT_INFO=
export GPG_AGENT_INFO
token=$(echo "gpgme-$(pwd)" | tr ' ' '_')
if [ "$1" = "--stop" ]; then
if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
!= "D set" ]; then
echo "gpg-agent not running" >&2
exit 0
fi
echo "stopping gpg-agent " >&2
gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1
exit 0
fi
if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
= "D set" ]; then
echo "gpg-agent already running" >&2
exit 0
fi
echo "starting gpg-agent " >&2
gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1
if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
!= "D set" ]; then
echo "error starting gpg-agent" >&2
exit 1
fi
exit 0