From a1f9fa9628907a650f00f27ad1669d5ad69028d3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 7 Jan 2018 14:34:08 +0000 Subject: [PATCH] test suite: gnupg: Save stdin on apt-key's import invocations Recognise these with an ad-hoc pattern on the command line arguments. When they occur, save stdin to a temporary file. We can't do this generally, because stdin might be some thing that gpg's caller doesn't expect gpg to eat. When we do this saving, print the size in bytes of the input file. Signed-off-by: Ian Jackson --- tests/tstunt/gpg-locked | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/tstunt/gpg-locked b/tests/tstunt/gpg-locked index 892b9c8c..ddb880f6 100755 --- a/tests/tstunt/gpg-locked +++ b/tests/tstunt/gpg-locked @@ -3,6 +3,20 @@ set -e for attempt in '' ' ' exec; do +case "$*" in +*" +--batch +--import") + # ^ apt-key's invocation + if [ "x$stdin_tmp" = x ]; then + stdin_tmp="$GNUPGHOME"/dgit-stdin-tmp + cat >$stdin_tmp + stdin_tmp_bytes=$(wc -c <$stdin_tmp) + fi + exec <$stdin_tmp + ;; +esac + set +e $attempt \ $DGIT_TEST_REAL_GPG \ @@ -13,7 +27,7 @@ set -e if [ $rc != 2 ]; then exit $rc; fi -echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $*" +echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $stdin_tmp_bytes $*" sh -ec ' if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then @@ -23,7 +37,7 @@ sh -ec ' fi exec >/dev/tty printf "%s\n" "$*" -' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $*" +' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $stdin_tmp_bytes $*" sleep 10 -- 2.30.2