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') 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 From 641b95390e9ff7fea44a0c4ec4181b10be0b78c1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 29 Jun 2018 00:49:47 +0100 Subject: test suite: Add bc to appropriate test Depends. Signed-off-by: Ian Jackson --- tests/enumerate-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/enumerate-tests b/tests/enumerate-tests index 0599b69..0f37c96 100755 --- a/tests/enumerate-tests +++ b/tests/enumerate-tests @@ -42,7 +42,7 @@ finish- () { test-begin-gencontrol () { restrictions='' - dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin' + dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc' } restriction-gencontrol () { -- cgit v1.2.3 From 7d0d834d7b41b5f3cafffc37b9a9d94966c68e0f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 29 Jun 2018 12:11:56 +0100 Subject: test suite: gpg-agent workaround: Add more debugging output. Signed-off-by: Ian Jackson --- tests/tstunt/gpg-withagent | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent index 4cb5d4e..d7fe793 100755 --- a/tests/tstunt/gpg-withagent +++ b/tests/tstunt/gpg-withagent @@ -1,9 +1,18 @@ #!/bin/sh set -ex +d () { + date --iso-8601=ns >&2 + ps -ef | grep gpg-agent >&2 +} + +d + retry_until_ok () { sleeptime=0 + d while ! "$@"; do + d case $sleeptime in ??.*) echo >&2 "$0: GPG AGENT STARTP $@ TIMED OUT" @@ -29,12 +38,16 @@ retry_until_ok agent_is_running echo >&2 'GPG-WITHAGENT... RUNNING' +d + set +e $DGIT_TEST_REAL_GPG \ --agent-program=$DGIT_STUNT_AGENT "$@" rc=$? set -e +d + echo >&2 'GPG-WITHAGENT... STOPPING' kill_agent_not_running () { @@ -48,4 +61,6 @@ retry_until_ok kill_agent_not_running echo >&2 'GPG-WITHAGENT... DONE' +d + exit $rc -- cgit v1.2.3 From 395e13bd154a9d00ffb25cff3f45e3afa8222d13 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 29 Jun 2018 12:13:59 +0100 Subject: test suite: gpg-agent workaround: Kill unexpected leftover agents. Signed-off-by: Ian Jackson --- tests/tstunt/gpg-withagent | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent index d7fe793..4318cce 100755 --- a/tests/tstunt/gpg-withagent +++ b/tests/tstunt/gpg-withagent @@ -24,7 +24,16 @@ retry_until_ok () { done } -echo >&2 'GPG-WITHAGENT...' +kill_agent_not_running () { + LC_MESSAGES=C gpg-connect-agent --no-autostart &1 \ + | tee -a /dev/stderr \ + | grep 'no gpg-agent running' >&2 +} + +echo >&2 'GPG-WITHAGENT... PRE-STOPPING' + +retry_until_ok kill_agent_not_running agent_is_running () { gpg-connect-agent --no-autostart &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' -- cgit v1.2.3 From 3ae4d20d8146c3ea111b3f622bf00adbd4e6442f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 29 Jun 2018 13:02:36 +0100 Subject: test suite: gpg-agent workaround: Cope if ps not found. Signed-off-by: Ian Jackson --- tests/tstunt/gpg-withagent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent index 4318cce..3f56d08 100755 --- a/tests/tstunt/gpg-withagent +++ b/tests/tstunt/gpg-withagent @@ -3,7 +3,7 @@ set -ex d () { date --iso-8601=ns >&2 - ps -ef | grep gpg-agent >&2 + ps -ef | grep gpg-agent ||: >&2 } d -- cgit v1.2.3 From 0a9d7c678c2ef3a3dbe40c012f3a1b86a8ca3c2a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 29 Jun 2018 17:05:06 +0100 Subject: test suite: gpg-agent workaround: Send ps output to stderr (oops) Signed-off-by: Ian Jackson --- tests/tstunt/gpg-withagent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent index 3f56d08..4b2ee1a 100755 --- a/tests/tstunt/gpg-withagent +++ b/tests/tstunt/gpg-withagent @@ -3,7 +3,7 @@ set -ex d () { date --iso-8601=ns >&2 - ps -ef | grep gpg-agent ||: >&2 + ps -ef | grep gpg-agent >&2 ||: } d -- cgit v1.2.3 From 53cdf2a1ad851c4747711877d304c647eaf83f41 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 30 Jun 2018 09:55:26 +0100 Subject: test suite: gnupg workaround: Remove a sprurious $tmp This is not set here, which is just as well because it would have been quite wrong. Signed-off-by: Ian Jackson --- tests/tstunt/gpg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tstunt/gpg b/tests/tstunt/gpg index 74152bd..79d8319 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-withagent "$@" + "$DGIT_TEST_TROOT"/tstunt/gpg-withagent "$@" -- cgit v1.2.3 From 38eae0db7f393311667bec9dfe0aa7a514b893bd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 30 Jun 2018 10:20:57 +0100 Subject: test suite: Provide DGIT_TEST_BYHAND if appropriate Signed-off-by: Ian Jackson --- tests/lib | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/lib b/tests/lib index f3fb0da..bad47c9 100644 --- a/tests/lib +++ b/tests/lib @@ -41,6 +41,7 @@ export DGIT_TEST_TROOT=$troot tmp=$ADTTMP if [ x"$tmp" = x ]; then + export DGIT_TEST_BYHAND=1 mkdir -p tests/tmp tmpbase=$troot/tmp tmp=tests/tmp/$testname -- cgit v1.2.3 From 690272dfb77eefa9277970dafe4bbb47de3b35e1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 30 Jun 2018 10:21:32 +0100 Subject: test suite: gpg agent workaround: Neaten the logging. Signed-off-by: Ian Jackson --- tests/setup/gnupg | 6 ++++-- tests/tstunt/gpg | 14 ++++++++++++++ tests/tstunt/gpg-withagent | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/setup/gnupg b/tests/setup/gnupg index c88d40b..7a164ef 100755 --- a/tests/setup/gnupg +++ b/tests/setup/gnupg @@ -7,10 +7,11 @@ cp $troot/gnupg/* $tmp/gnupg chmod go-rw $tmp/gnupg/* export DGIT_TEST_GNUPG_GLOBAL_LOCK=$tmp/gnupg/dgit-test-global-lock +export DGIT_TEST_GNUPG_LOG=$tmp/gnupg-workarounds.log setup=' export GNUPGHOME=$tmp/gnupg - export DGIT_TEST_GNUPG_GLOBAL_LOCK + export DGIT_TEST_GNUPG_GLOBAL_LOCK DGIT_TEST_GNUPG_LOG cat >$tmp/gnupg/gpg-agent.conf <&2 2>>"$DGIT_TEST_GNUPG_LOG" + rc=$? + if [ rc = 0 ]; then exit 0; fi + if [ "x$DGIT_TEST_BYHAND" != x ]; then + echo >&2 "BYHAND, not catting $DGIT_TEST_GNUPG_LOG" + else + echo >&2 "########################################" + echo >&2 "$DGIT_TEST_GNUPG_LOG" + cat >&2 "$DGIT_TEST_GNUPG_LOG" + echo >&2 "end of $DGIT_TEST_GNUPG_LOG" + fi + exit $rc + ' x \ "$DGIT_TEST_TROOT"/tstunt/gpg-withagent "$@" diff --git a/tests/tstunt/gpg-withagent b/tests/tstunt/gpg-withagent index 4b2ee1a..b7b8bfd 100755 --- a/tests/tstunt/gpg-withagent +++ b/tests/tstunt/gpg-withagent @@ -51,7 +51,7 @@ d set +e $DGIT_TEST_REAL_GPG \ - --agent-program=$DGIT_STUNT_AGENT "$@" + --agent-program=$DGIT_STUNT_AGENT "$@" 2>&9 rc=$? set -e -- cgit v1.2.3 From 8916ea3e2ca88820e6ad1d0c8823a37221f8ed88 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 30 Jun 2018 19:03:10 +0100 Subject: test suite: gpg agent workaround: Fix bugs in log neatening. Signed-off-by: Ian Jackson --- tests/tstunt/gpg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/tstunt/gpg b/tests/tstunt/gpg index 7e12846..4214b4a 100755 --- a/tests/tstunt/gpg +++ b/tests/tstunt/gpg @@ -6,14 +6,16 @@ with-lock-ex -w "$DGIT_TEST_GNUPG_GLOBAL_LOCK" \ sh -c ' "$@" 9>&2 2>>"$DGIT_TEST_GNUPG_LOG" rc=$? - if [ rc = 0 ]; then exit 0; fi + if [ $rc = 0 ]; then exit 0; fi if [ "x$DGIT_TEST_BYHAND" != x ]; then - echo >&2 "BYHAND, not catting $DGIT_TEST_GNUPG_LOG" + echo >&2 "BYHAND, not dumping $DGIT_TEST_GNUPG_LOG" else echo >&2 "########################################" echo >&2 "$DGIT_TEST_GNUPG_LOG" - cat >&2 "$DGIT_TEST_GNUPG_LOG" + sed '\''s/^/\[gnupg-workarounds] /'\'' >&2 \ + "$DGIT_TEST_GNUPG_LOG" echo >&2 "end of $DGIT_TEST_GNUPG_LOG" + echo >&2 "########################################" fi exit $rc ' x \ -- cgit v1.2.3