Add some docs about using gpg-agent with pwmd.
[pwmd.git] / tests / common.sh
blobc20493c42c03c3c0c0d9eb0a581b2156cf00d65a
1 PWMD="../src/pwmd"
2 WDIR="`/bin/pwd`"
3 PWMC_ARGS="--url $WDIR/socket --no-status"
4 PID=
6 set -e
7 trap on_exit EXIT
9 cp -f `pwd`/.gnupg/trustdb.gpg.orig `pwd`/.gnupg/trustdb.gpg
10 cp -f `pwd`/.gnupg/pubring.kbx.orig `pwd`/.gnupg/pubring.kbx
12 on_exit() {
13 set +o errexit
15 if [ $PID ]; then
16 kill $PID
19 if [ -S "$WDIR/.gnupg/S.gpg-agent" ]; then
20 agent_pid="`echo GETINFO pid | gpg-connect-agent -S $WDIR/.gnupg/S.gpg-agent | awk '{print $2}' | sed -ne '1p'`"
21 if [ $agent_pid ]; then
22 kill $agent_pid 2>/dev/null
24 unset agent_pid
27 rm -f config
30 wait_for_socket() {
31 local pid="$1"
32 local socket="$2"
34 until [ -e $socket ]; do
35 echo "waiting for socket '$socket' ..."
36 if [ $pid != 0 ]; then
37 kill -0 $PID || break;
39 sleep 1
40 done
42 unset pid
43 unset socket
46 launch_pwmd () {
47 $PWMD --homedir $WDIR -n $@ > /dev/null &
48 PID=$!
49 wait_for_socket $PID socket
52 test_success() {
53 echo "All tests in $0 succeeded."
56 begin_test() {
57 echo ""
58 echo "Starting test $0 ..."
59 echo ""