summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-cli-json-hooks
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2021-04-23 15:15:56 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2021-04-23 15:20:45 +0200
commit329f0cc3654f8d13bbaff71cc400cb9c4154ad53 (patch)
treef3e58ec267a33df60f375ce0ca3ae2d7de3d16ec /test/integration/test-apt-cli-json-hooks
parent94cf53979640ff8a29d445a2b056a6b17c7b3e49 (diff)
test/json: Make the test hook more reliable
Ugh, this was super flaky under -j 16 and -j 4, each behaving in slightly different ways. This seems to be stable now. No real bug though, all behaviors were OK.
Diffstat (limited to 'test/integration/test-apt-cli-json-hooks')
-rwxr-xr-xtest/integration/test-apt-cli-json-hooks15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/integration/test-apt-cli-json-hooks b/test/integration/test-apt-cli-json-hooks
index 3ec470284..a3bcf3fdb 100755
--- a/test/integration/test-apt-cli-json-hooks
+++ b/test/integration/test-apt-cli-json-hooks
@@ -28,14 +28,12 @@ export TEST_HOOK_VERSION=0.2
cat >> json-hook.sh << EOF
#!/bin/bash
-set -e
+trap '' SIGPIPE
while true; do
- read request <&\$APT_HOOK_SOCKET
- read empty <&\$APT_HOOK_SOCKET
+ read request <&\$APT_HOOK_SOCKET || exit 1
if echo "\$request" | grep -q ".hello"; then
echo "HOOK: HELLO"
- printf '{"jsonrpc": "2.0", "result": {"version": "'\$TEST_HOOK_VERSION'"}, "id": 0}\n\n' >&\$APT_HOOK_SOCKET
fi
if echo "\$request" | grep -q ".bye"; then
@@ -44,7 +42,16 @@ while true; do
fi
echo HOOK: request \$request
+
+ read empty <&\$APT_HOOK_SOCKET || exit 1
+
echo HOOK: empty \$empty
+
+ if echo "\$request" | grep -q ".hello"; then
+ printf '{"jsonrpc": "2.0", "result": {"version": "'\$TEST_HOOK_VERSION'"}, "id": 0}\n\n' >&\$APT_HOOK_SOCKET 2>/dev/null || exit 1
+ fi
+
+
done
EOF