16 agent_socket
="`gpgconf --homedir $OUTDIR/.gnupg --list-dirs | grep '^agent-socket:' | awk -F: '{print $2}'`"
17 if [ -S "$agent_socket" ]; then
18 agent_pid
="`echo GETINFO pid | gpg-connect-agent -S $agent_socket 2>/dev/null`"
19 agent_pid
="`echo $agent_pid | awk '{print $2}' | sed -ne '1p'`"
20 if [ $agent_pid ]; then
21 kill $agent_pid 2>/dev
/null
28 if [ x
"$DEBUG" = "x" ]; then
39 until [ -S $OUTDIR/$socket ]; do
40 kill -0 $pid 2>/dev
/null || bail_out
"Could not launch pwmd"
41 if [ $remaining -eq 0 ]; then
42 bail_out
"Could not connect to pwmd socket"
45 echo "# Waiting for socket. Timeout in ${remaining}s"
46 remaining
=$
((remaining
- 1))
56 args
="--homedir $OUTDIR -n $@"
58 if [ x
"$TESTS" != "x" -o x
"$DEBUG" = "x" ]; then
59 $PWMD $args 2>/dev
/null
>/dev
/null
&
65 wait_for_socket
$PID socket
76 if [ $# -eq 4 -a $e -eq 0 ]; then
77 if [ "$3" = "save" ]; then
78 # The SAVE tests generate dynamic results. The following is needed
79 # for 'make distcheck'.
80 cmp $OUTDIR/${3}.result
${test_n} result
82 cmp $WDIR/${3}.result
${test_n} result
89 test_success
$1 $e "$msg"
103 if [ $# -eq 4 ]; then
109 if [ $2 -eq 0 ]; then
110 echo "# Return code indicated success but should have failed."
111 echo "not ok $2 - $desc"
116 if [ $# -eq 4 -a x
"$TESTS" != "x" -o x
"$DEBUG" != "x" ]; then
117 if [ -s "pwmc.out" ]; then
118 rc
="`grep '^ERR [0-9]*:' < pwmc.out | cut -d ' ' -f 2 | cut -b -9`"
119 if [ "$rc" != "$3" ]; then
129 test_success
$1 $rc "$desc"
134 if [ "$1" = "-h" ]; then
135 echo "Run all or the specified tests from 1 to $MAX_TESTS. Note that" \
136 "some tests depend on"
137 echo "the result of previous tests."
138 echo "Usage: $0 [testN] [...]"
144 if [ $# -eq 0 ]; then
145 for t
in $
(seq 1 $MAX_TESTS); do
152 if [ $t -gt $MAX_TESTS ]; then
153 echo "$0: No such test $t." 1>&2
159 if [ $ret -eq 0 ]; then
167 # Common in some tests.
170 if [ $e -eq 0 ]; then
171 $PWMC $PWMC_ARGS $1 >result
$DEVNULL <<EOF
180 eval "pwmc $PWMC_ARGS $@"
184 OUTDIR
="$AM_BUILDDIR"
187 PWMC_ARGS
="--url $OUTDIR/socket"
191 $PWMC --version >/dev
/null
193 skip_test
"Could not run $PWMC. Please make sure libpwmd is installed."
196 if [ x
"$TESTS" = "x" -a x
"$DEBUG" = "x" ]; then
197 PWMC_ARGS
="$PWMC_ARGS --quiet"
198 DEVNULL
="2>/dev/null"
205 if [ $WDIR != $OUTDIR ]; then
206 cp -Rf $WDIR/.gnupg
$OUTDIR 2>/dev
/null \
207 || bail_out
"Could not copy .gnupg."
208 chmod -R u
+w
$OUTDIR/.gnupg
211 cp -f $WDIR/.gnupg
/trustdb.gpg.dist
$OUTDIR/.gnupg
/trustdb.gpg
2>/dev
/null \
212 || bail_out
"Could not copy trustdb.gpg."
213 cp -f $WDIR/.gnupg
/pubring.kbx.dist
$OUTDIR/.gnupg
/pubring.kbx
2>/dev
/null \
214 || bail_out
"Could not copy pubring.kbx."
216 echo "1..${MAX_TESTS}"