chiark / gitweb /
New gnupg agent thing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 27 Jun 2018 22:44:15 +0000 (23:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 27 Jun 2018 23:50:30 +0000 (00:50 +0100)
before (5.3)

1044.27user 126.77system 6:26.89elapsed 302%CPU (0avgtext+0avgdata 402420maxresident)k
1778718inputs+5123720outputs (2370major+57693524minor)pagefaults 0swaps

after (5.3 + these changes)

1072.81user 131.38system 6:25.02elapsed 312%CPU (0avgtext+0avgdata 402448maxresident)k
1777558inputs+5124952outputs (2370major+59176578minor)pagefaults 0swaps

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
tests/tstunt/gpg
tests/tstunt/gpg-withagent [new file with mode: 0755]

index 0e4194e..fc26e97 100644 (file)
@@ -1,3 +1,9 @@
+dgit (5.4+exp2) experimental; urgency=medium
+
+  * test suite: Explicit agent starting/stopping
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Thu, 28 Jun 2018 00:42:00 +0100
+
 dgit (5.4+exp1) experimental; urgency=medium
 
   * No-change upload, for testing.
index 679a6b8..74152bd 100755 (executable)
@@ -3,4 +3,4 @@ set -e
 
 exec \
 with-lock-ex -w "$DGIT_TEST_GNUPG_GLOBAL_LOCK" \
-       $tmp "$DGIT_TEST_TROOT"/tstunt/gpg-locked "$@"
+       $tmp "$DGIT_TEST_TROOT"/tstunt/gpg-withagent "$@"
diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent
new file mode 100755 (executable)
index 0000000..4cb5d4e
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+set -ex
+
+retry_until_ok () {
+       sleeptime=0
+       while ! "$@"; do
+               case $sleeptime in
+               ??.*)
+                       echo >&2 "$0: GPG AGENT STARTP $@ TIMED OUT"
+                       exit 127
+                       ;;
+               esac
+               sleep $sleeptime
+               sleeptime=$(echo "($sleeptime + 0.001) * 2" | bc -l)
+       done
+}
+
+echo >&2 'GPG-WITHAGENT...'
+
+agent_is_running () {
+       gpg-connect-agent --no-autostart </dev/null \
+               '/echo dgit-gpg-agent-ok' /bye 2>&1 \
+       | grep dgit-gpg-agent-ok >&2
+}
+
+
+$DGIT_STUNT_AGENT --daemon </dev/null >&2
+retry_until_ok agent_is_running
+
+echo >&2 'GPG-WITHAGENT... RUNNING'
+
+set +e
+$DGIT_TEST_REAL_GPG                                    \
+       --agent-program=$DGIT_STUNT_AGENT "$@"
+rc=$?
+set -e
+
+echo >&2 'GPG-WITHAGENT... STOPPING'
+
+kill_agent_not_running () {
+       LC_MESSAGES=C gpg-connect-agent --no-autostart </dev/null \
+               KILLAGENT /bye 2>&1 \
+       | tee -a /dev/stderr \
+       | grep 'no gpg-agent running' >&2
+}
+
+retry_until_ok kill_agent_not_running
+
+echo >&2 'GPG-WITHAGENT... DONE'
+
+exit $rc