diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-01-07 11:35:34 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-01-07 16:18:53 +0000 |
commit | 640602b53ec3a387aef776d6a727118e1784f6d7 (patch) | |
tree | c9ce7688135f51158c35f0676d5402673aacfbc2 /tests/tstunt | |
parent | edbc2fc23a2df787cc7c0d998df9724dcaceaaf7 (diff) |
test suite: gnupg: Run with a lock held
This is also an attempt to reduce the impact of the gnupg races.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'tests/tstunt')
-rwxr-xr-x | tests/tstunt/gpg | 32 | ||||
-rwxr-xr-x | tests/tstunt/gpg-locked | 32 |
2 files changed, 35 insertions, 29 deletions
diff --git a/tests/tstunt/gpg b/tests/tstunt/gpg index 892b9c8..679a6b8 100755 --- a/tests/tstunt/gpg +++ b/tests/tstunt/gpg @@ -1,32 +1,6 @@ #!/bin/sh set -e -for attempt in '' ' ' exec; do - -set +e -$attempt \ -$DGIT_TEST_REAL_GPG \ - --agent-program=$DGIT_STUNT_AGENT \ - "$@" -rc=$? -set -e - -if [ $rc != 2 ]; then exit $rc; fi - -echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $*" - -sh -ec ' - if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then - exec >"$DGIT_GNUPG_STUNT_ERRLOG" - else - exec 2>/dev/null - fi - exec >/dev/tty - printf "%s\n" "$*" -' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $*" - -sleep 10 - -done - -exit 127 +exec \ +with-lock-ex -w "$DGIT_TEST_GNUPG_GLOBAL_LOCK" \ + $tmp "$DGIT_TEST_TROOT"/tstunt/gpg-locked "$@" diff --git a/tests/tstunt/gpg-locked b/tests/tstunt/gpg-locked new file mode 100755 index 0000000..892b9c8 --- /dev/null +++ b/tests/tstunt/gpg-locked @@ -0,0 +1,32 @@ +#!/bin/sh +set -e + +for attempt in '' ' ' exec; do + +set +e +$attempt \ +$DGIT_TEST_REAL_GPG \ + --agent-program=$DGIT_STUNT_AGENT \ + "$@" +rc=$? +set -e + +if [ $rc != 2 ]; then exit $rc; fi + +echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $*" + +sh -ec ' + if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then + exec >"$DGIT_GNUPG_STUNT_ERRLOG" + else + exec 2>/dev/null + fi + exec >/dev/tty + printf "%s\n" "$*" +' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $*" + +sleep 10 + +done + +exit 127 |