From 55944e5e40b1be2afc4855d8d2baf4b73d1876b5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:49:52 +0200 Subject: Adding upstream version 255.4. Signed-off-by: Daniel Baumann --- test/testsuite-80.units/fdstore-pin.sh | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 test/testsuite-80.units/fdstore-pin.sh (limited to 'test/testsuite-80.units/fdstore-pin.sh') diff --git a/test/testsuite-80.units/fdstore-pin.sh b/test/testsuite-80.units/fdstore-pin.sh new file mode 100755 index 0000000..4cb041a --- /dev/null +++ b/test/testsuite-80.units/fdstore-pin.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +PINNED="$1" +COUNTER="/tmp/fdstore-invoked.$PINNED" +FILE="/tmp/fdstore-data.$PINNED" + +# This script is called six times: thrice from a service unit where the fdstore +# is pinned, and thrice where it isn't. The second iteration of each series is +# a restart, the third a stop followed by a start + +if [ -e "$COUNTER" ] ; then + read -r N < "$COUNTER" +else + N=0 +fi + +echo "Invocation #$N with PINNED=$PINNED." + +if [ "$N" -eq 0 ] ; then + # First iteration + test "${LISTEN_FDS:-0}" -eq 0 + test ! -e "$FILE" + echo waldi > "$FILE" + systemd-notify --fd=3 --fdname="fd-$N-$PINNED" 3< "$FILE" +elif [ "$N" -eq 1 ] || { [ "$N" -eq 2 ] && [ "$PINNED" -eq 1 ]; } ; then + # Second iteration, or iteration with pinning on + test "${LISTEN_FDS:-0}" -eq 1 + # We reopen fd #3 here, so that the read offset is at zero each time (hence no <&3 hereā€¦) + read -r word < /proc/self/fd/3 + test "$word" = "waldi" +else + test "${LISTEN_FDS:-0}" -eq 0 + test -e "$FILE" +fi + +if [ "$N" -ge 2 ] ; then + rm "$COUNTER" "$FILE" +else + echo $((N + 1)) > "$COUNTER" +fi + +systemd-notify --ready --status="Ready" + +exec sleep infinity -- cgit v1.2.3