From ea47496f7dd4feac94f2a3a7f51fe1e07e012ee4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 27 Jun 2018 23:44:15 +0100 Subject: New gnupg agent thing 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 --- tests/tstunt/gpg | 2 +- tests/tstunt/gpg-withagent | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 tests/tstunt/gpg-withagent (limited to 'tests/tstunt') diff --git a/tests/tstunt/gpg b/tests/tstunt/gpg index 679a6b8..74152bd 100755 --- a/tests/tstunt/gpg +++ b/tests/tstunt/gpg @@ -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 index 0000000..4cb5d4e --- /dev/null +++ b/tests/tstunt/gpg-withagent @@ -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 &1 \ + | grep dgit-gpg-agent-ok >&2 +} + + +$DGIT_STUNT_AGENT --daemon &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 &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 -- cgit v1.2.3